mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-24 19:07:32 -07:00
なんかもうめっちゃ変えた
This commit is contained in:
parent
d9a05e962d
commit
f497ab8a92
77 changed files with 170 additions and 165 deletions
|
@ -52,6 +52,9 @@
|
|||
"@types/ms": "0.7.30",
|
||||
"@types/multer": "1.3.5",
|
||||
"@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/redis": "2.8.1",
|
||||
"@types/request": "2.0.7",
|
||||
|
@ -92,8 +95,8 @@
|
|||
"webpack": "3.8.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@prezzemolo/zip": "0.0.3",
|
||||
"@prezzemolo/rap": "0.1.2",
|
||||
"@prezzemolo/zip": "0.0.3",
|
||||
"accesses": "2.5.0",
|
||||
"animejs": "2.2.0",
|
||||
"autwh": "0.0.1",
|
||||
|
@ -131,6 +134,7 @@
|
|||
"page": "1.7.1",
|
||||
"pictograph": "2.0.4",
|
||||
"prominence": "0.2.0",
|
||||
"proxy-addr": "^2.0.2",
|
||||
"pug": "2.0.0-rc.4",
|
||||
"ratelimiter": "3.0.3",
|
||||
"recaptcha-promise": "0.1.3",
|
||||
|
@ -141,6 +145,7 @@
|
|||
"riot": "3.7.4",
|
||||
"rndstr": "1.0.0",
|
||||
"s-age": "1.1.0",
|
||||
"seedrandom": "^2.4.3",
|
||||
"serve-favicon": "2.4.5",
|
||||
"sortablejs": "1.7.0",
|
||||
"summaly": "2.0.3",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as riot from 'riot';
|
||||
const route = require('page');
|
||||
import * as route from 'page';
|
||||
let page = null;
|
||||
|
||||
export default me => {
|
||||
|
@ -22,7 +22,7 @@ export default me => {
|
|||
}
|
||||
|
||||
// EXEC
|
||||
route();
|
||||
(route as any)();
|
||||
};
|
||||
|
||||
function mount(content) {
|
|
@ -343,7 +343,7 @@
|
|||
};
|
||||
|
||||
this.changeFile = () => {
|
||||
this.refs.file.files.forEach(this.upload);
|
||||
Array.from(this.refs.file.files).forEach(this.upload);
|
||||
};
|
||||
|
||||
this.selectFile = () => {
|
||||
|
@ -367,7 +367,7 @@
|
|||
};
|
||||
|
||||
this.onpaste = e => {
|
||||
e.clipboardData.items.forEach(item => {
|
||||
Array.from(e.clipboardData.items).forEach(item => {
|
||||
if (item.kind == 'file') {
|
||||
this.upload(item.getAsFile());
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import * as riot from 'riot';
|
|||
import api from '../scripts/api';
|
||||
|
||||
export default me => {
|
||||
riot.mixin('api', {
|
||||
(riot as any).mixin('api', {
|
||||
api: api.bind(null, me ? me.token : null)
|
||||
});
|
||||
};
|
|
@ -1,7 +1,7 @@
|
|||
import * as riot from 'riot';
|
||||
|
||||
export default me => {
|
||||
riot.mixin('i', {
|
||||
(riot as any).mixin('i', {
|
||||
init: function() {
|
||||
this.I = me;
|
||||
this.SIGNIN = me != null;
|
|
@ -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 });
|
||||
};
|
14
src/web/app/common/mixins/index.ts
Normal file
14
src/web/app/common/mixins/index.ts
Normal 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() });
|
||||
};
|
|
@ -14,7 +14,7 @@ let pending = 0;
|
|||
* @param {any} [data={}] Data
|
||||
* @return {Promise<any>} Response
|
||||
*/
|
||||
export default (i, endpoint, data = {}) => {
|
||||
export default (i, endpoint, data = {}): Promise<any> => {
|
||||
if (++pending === 1) {
|
||||
spinner = document.createElement('div');
|
||||
spinner.setAttribute('id', 'wait');
|
||||
|
@ -22,7 +22,7 @@ export default (i, endpoint, data = {}) => {
|
|||
}
|
||||
|
||||
// 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) => {
|
||||
// Send request
|
|
@ -1,6 +1,6 @@
|
|||
export default (bytes, digits = 0) => {
|
||||
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
||||
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];
|
||||
};
|
|
@ -1,5 +1,7 @@
|
|||
import CONFIG from './config';
|
||||
|
||||
declare var VERSION: string;
|
||||
|
||||
export default function() {
|
||||
fetch(CONFIG.apiUrl + '/meta', {
|
||||
method: 'POST'
|
||||
|
@ -11,4 +13,4 @@ export default function() {
|
|||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
export default () => [
|
||||
'(=^・・^=)',
|
||||
'v(‘ω’)v',
|
||||
'🐡( '-' 🐡 )フグパンチ!!!!'
|
||||
'🐡( \'-\' 🐡 )フグパンチ!!!!'
|
||||
][Math.floor(Math.random() * 3)];
|
|
@ -17,9 +17,9 @@ class Connection extends Stream {
|
|||
this.send({ type: 'alive' });
|
||||
}, 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%');
|
||||
signout();
|
||||
});
|
|
@ -12,7 +12,7 @@ class Connection extends Stream {
|
|||
otherparty
|
||||
});
|
||||
|
||||
this.on('_connected_', () => {
|
||||
(this as any).on('_connected_', () => {
|
||||
this.send({
|
||||
i: me.token
|
||||
});
|
|
@ -1,14 +1,7 @@
|
|||
import StreamManager from './stream-manager';
|
||||
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() {
|
||||
if (this.connection == null) {
|
||||
this.connection = new Connection();
|
||||
|
@ -16,24 +9,4 @@ export default class ServerStreamManager {
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
33
src/web/app/common/scripts/stream-manager.ts
Normal file
33
src/web/app/common/scripts/stream-manager.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,11 @@ import CONFIG from './config';
|
|||
* Misskey stream connection
|
||||
*/
|
||||
class Connection {
|
||||
constructor(endpoint, params) {
|
||||
private state: string;
|
||||
private buffer: any[];
|
||||
private socket: ReconnectingWebsocket;
|
||||
|
||||
constructor(endpoint, params?) {
|
||||
// BIND -----------------------------------
|
||||
this.onOpen = this.onOpen.bind(this);
|
||||
this.onClose = this.onClose.bind(this);
|
||||
|
@ -37,11 +41,10 @@ class Connection {
|
|||
|
||||
/**
|
||||
* Callback of when open connection
|
||||
* @private
|
||||
*/
|
||||
onOpen() {
|
||||
private onOpen() {
|
||||
this.state = 'connected';
|
||||
this.trigger('_connected_');
|
||||
(this as any).trigger('_connected_');
|
||||
|
||||
// バッファーを処理
|
||||
const _buffer = [].concat(this.buffer); // Shallow copy
|
||||
|
@ -53,45 +56,41 @@ class Connection {
|
|||
|
||||
/**
|
||||
* Callback of when close connection
|
||||
* @private
|
||||
*/
|
||||
onClose() {
|
||||
private onClose() {
|
||||
this.state = 'reconnecting';
|
||||
this.trigger('_closed_');
|
||||
(this as any).trigger('_closed_');
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback of when received a message from connection
|
||||
* @private
|
||||
*/
|
||||
onMessage(message) {
|
||||
private onMessage(message) {
|
||||
try {
|
||||
const msg = JSON.parse(message.data);
|
||||
if (msg.type) this.trigger(msg.type, msg.body);
|
||||
} catch(e) {
|
||||
if (msg.type) (this as any).trigger(msg.type, msg.body);
|
||||
} catch (e) {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to connection
|
||||
* @public
|
||||
*/
|
||||
send(message) {
|
||||
public send(message) {
|
||||
// まだ接続が確立されていなかったらバッファリングして次に接続した時に送信する
|
||||
if (this.state != 'connected') {
|
||||
this.buffer.push(message);
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
this.socket.send(JSON.stringify(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Close this connection
|
||||
* @public
|
||||
*/
|
||||
close() {
|
||||
public close() {
|
||||
this.socket.removeEventListener('open', this.onOpen);
|
||||
this.socket.removeEventListener('message', this.onMessage);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import * as riot from 'riot';
|
||||
const pictograph = require('pictograph');
|
||||
import * as pictograph from 'pictograph';
|
||||
import CONFIG from './config';
|
||||
|
||||
const escape = text =>
|
||||
|
@ -12,7 +12,7 @@ export default (tokens, shouldBreak) => {
|
|||
shouldBreak = true;
|
||||
}
|
||||
|
||||
const me = riot.mixin('i').me;
|
||||
const me = (riot as any).mixin('i').me;
|
||||
|
||||
let text = tokens.map(token => {
|
||||
switch (token.type) {
|
|
@ -219,7 +219,7 @@
|
|||
|
||||
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);
|
||||
});
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ function attach(el) {
|
|||
clearTimeout(showTimer);
|
||||
hideTimer = setTimeout(close, 500);
|
||||
});
|
||||
tag = riot.mount(document.body.appendChild(preview), {
|
||||
tag = (riot as any).mount(document.body.appendChild(preview), {
|
||||
user: user
|
||||
})[0];
|
||||
};
|
|
@ -3,7 +3,7 @@ import * as riot from 'riot';
|
|||
// ミックスインにオプションを渡せないのアレ
|
||||
// SEE: https://github.com/riot/riot/issues/2434
|
||||
|
||||
riot.mixin('widget', {
|
||||
(riot as any).mixin('widget', {
|
||||
init: function() {
|
||||
this.mixin('i');
|
||||
this.mixin('api');
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
|
||||
import * as riot from 'riot';
|
||||
const route = require('page');
|
||||
import * as route from 'page';
|
||||
let page = null;
|
||||
|
||||
export default me => {
|
||||
|
@ -83,12 +83,12 @@ export default me => {
|
|||
mount(document.createElement('mk-not-found'));
|
||||
}
|
||||
|
||||
riot.mixin('page', {
|
||||
(riot as any).mixin('page', {
|
||||
page: route
|
||||
});
|
||||
|
||||
// EXEC
|
||||
route();
|
||||
(route as any)();
|
||||
};
|
||||
|
||||
function mount(content) {
|
|
@ -11,7 +11,7 @@ import * as riot from 'riot';
|
|||
import init from '../init';
|
||||
import route from './router';
|
||||
import fuckAdBlock from './scripts/fuck-ad-block';
|
||||
import getPostSummary from '../../../common/get-post-summary.ts';
|
||||
import getPostSummary from '../../../common/get-post-summary';
|
||||
|
||||
/**
|
||||
* init
|
||||
|
@ -27,11 +27,11 @@ init(async (me, stream) => {
|
|||
*/
|
||||
if ('Notification' in window) {
|
||||
// 許可を得ていなかったらリクエスト
|
||||
if (Notification.permission == 'default') {
|
||||
if ((Notification as any).permission == 'default') {
|
||||
await Notification.requestPermission();
|
||||
}
|
||||
|
||||
if (Notification.permission == 'granted') {
|
||||
if ((Notification as any).permission == 'granted') {
|
||||
registerNotifications(stream);
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ function registerNotifications(stream) {
|
|||
});
|
||||
n.onclick = () => {
|
||||
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
|
||||
});
|
||||
};
|
|
@ -1,10 +1,12 @@
|
|||
const getCaretCoordinates = require('textarea-caret');
|
||||
import getCaretCoordinates = require('textarea-caret');
|
||||
import * as riot from 'riot';
|
||||
|
||||
/**
|
||||
* オートコンプリートを管理するクラス。
|
||||
*/
|
||||
class Autocomplete {
|
||||
private suggestion: any;
|
||||
private textarea: any;
|
||||
|
||||
/**
|
||||
* 対象のテキストエリアを与えてインスタンスを初期化します。
|
||||
|
@ -23,22 +25,22 @@ class Autocomplete {
|
|||
/**
|
||||
* このインスタンスにあるテキストエリアの入力のキャプチャを開始します。
|
||||
*/
|
||||
attach() {
|
||||
public attach() {
|
||||
this.textarea.addEventListener('input', this.onInput);
|
||||
}
|
||||
|
||||
/**
|
||||
* このインスタンスにあるテキストエリアの入力のキャプチャを解除します。
|
||||
*/
|
||||
detach() {
|
||||
public detach() {
|
||||
this.textarea.removeEventListener('input', this.onInput);
|
||||
this.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* [Private] テキスト入力時
|
||||
* テキスト入力時
|
||||
*/
|
||||
onInput() {
|
||||
private onInput() {
|
||||
this.close();
|
||||
|
||||
const caret = this.textarea.selectionStart;
|
||||
|
@ -56,9 +58,9 @@ class Autocomplete {
|
|||
}
|
||||
|
||||
/**
|
||||
* [Private] サジェストを提示します。
|
||||
* サジェストを提示します。
|
||||
*/
|
||||
open(type, q) {
|
||||
private open(type, q) {
|
||||
// 既に開いているサジェストは閉じる
|
||||
this.close();
|
||||
|
||||
|
@ -81,7 +83,7 @@ class Autocomplete {
|
|||
const el = document.body.appendChild(tag);
|
||||
|
||||
// マウント
|
||||
this.suggestion = riot.mount(el, {
|
||||
this.suggestion = (riot as any).mount(el, {
|
||||
textarea: this.textarea,
|
||||
complete: this.complete,
|
||||
close: this.close,
|
||||
|
@ -91,9 +93,9 @@ class Autocomplete {
|
|||
}
|
||||
|
||||
/**
|
||||
* [Private] サジェストを閉じます。
|
||||
* サジェストを閉じます。
|
||||
*/
|
||||
close() {
|
||||
private close() {
|
||||
if (this.suggestion == null) return;
|
||||
|
||||
this.suggestion.unmount();
|
||||
|
@ -103,9 +105,9 @@ class Autocomplete {
|
|||
}
|
||||
|
||||
/**
|
||||
* [Private] オートコンプリートする
|
||||
* オートコンプリートする
|
||||
*/
|
||||
complete(user) {
|
||||
private complete(user) {
|
||||
this.close();
|
||||
|
||||
const value = user.username;
|
|
@ -1,9 +1,9 @@
|
|||
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 controller = riot.observable();
|
||||
riot.mount(dialog, {
|
||||
(riot as any).mount(dialog, {
|
||||
controller: controller,
|
||||
title: title,
|
||||
text: text,
|
|
@ -1,6 +1,8 @@
|
|||
require('fuckadblock');
|
||||
import dialog from './dialog';
|
||||
|
||||
declare var fuckAdBlock: any;
|
||||
|
||||
export default () => {
|
||||
if (fuckAdBlock === undefined) {
|
||||
adBlockDetected();
|
|
@ -2,7 +2,7 @@ import * as riot from 'riot';
|
|||
|
||||
export default (title, placeholder, defaultValue, onOk, onCancel) => {
|
||||
const dialog = document.body.appendChild(document.createElement('mk-input-dialog'));
|
||||
return riot.mount(dialog, {
|
||||
return (riot as any).mount(dialog, {
|
||||
title: title,
|
||||
placeholder: placeholder,
|
||||
'default': defaultValue,
|
|
@ -2,7 +2,7 @@ import * as riot from 'riot';
|
|||
|
||||
export default message => {
|
||||
const notification = document.body.appendChild(document.createElement('mk-ui-notification'));
|
||||
riot.mount(notification, {
|
||||
(riot as any).mount(notification, {
|
||||
message: message
|
||||
});
|
||||
};
|
|
@ -2,7 +2,7 @@ import * as riot from 'riot';
|
|||
|
||||
export default (title, onOk, onCancel) => {
|
||||
const dialog = document.body.appendChild(document.createElement('mk-input-dialog'));
|
||||
return riot.mount(dialog, {
|
||||
return (riot as any).mount(dialog, {
|
||||
title: title,
|
||||
type: 'password',
|
||||
onOk: onOk,
|
|
@ -5,7 +5,7 @@ import api from '../../common/scripts/api';
|
|||
|
||||
export default (I, cb, file = null) => {
|
||||
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,
|
||||
title: 'アバターとして表示する部分を選択',
|
||||
aspectRatio: 1 / 1
|
||||
|
@ -37,7 +37,7 @@ export default (I, cb, file = null) => {
|
|||
};
|
||||
|
||||
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: '新しいアバターをアップロードしています'
|
||||
})[0];
|
||||
|
||||
|
@ -46,7 +46,7 @@ export default (I, cb, file = null) => {
|
|||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', CONFIG.apiUrl + '/drive/files/create', true);
|
||||
xhr.onload = e => {
|
||||
const file = JSON.parse(e.target.response);
|
||||
const file = JSON.parse((e.target as any).response);
|
||||
progress.close();
|
||||
set(file);
|
||||
};
|
||||
|
@ -75,7 +75,7 @@ export default (I, cb, file = null) => {
|
|||
if (file) {
|
||||
fileSelected(file);
|
||||
} 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,
|
||||
title: '<i class="fa fa-picture-o"></i>アバターにする画像を選択'
|
||||
})[0];
|
|
@ -5,7 +5,7 @@ import api from '../../common/scripts/api';
|
|||
|
||||
export default (I, cb, file = null) => {
|
||||
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,
|
||||
title: 'バナーとして表示する部分を選択',
|
||||
aspectRatio: 16 / 9
|
||||
|
@ -37,7 +37,7 @@ export default (I, cb, file = null) => {
|
|||
};
|
||||
|
||||
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: '新しいバナーをアップロードしています'
|
||||
})[0];
|
||||
|
||||
|
@ -46,7 +46,7 @@ export default (I, cb, file = null) => {
|
|||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', CONFIG.apiUrl + '/drive/files/create', true);
|
||||
xhr.onload = e => {
|
||||
const file = JSON.parse(e.target.response);
|
||||
const file = JSON.parse((e.target as any).response);
|
||||
progress.close();
|
||||
set(file);
|
||||
};
|
||||
|
@ -75,7 +75,7 @@ export default (I, cb, file = null) => {
|
|||
if (file) {
|
||||
fileSelected(file);
|
||||
} 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,
|
||||
title: '<i class="fa fa-picture-o"></i>バナーにする画像を選択'
|
||||
})[0];
|
|
@ -177,7 +177,7 @@
|
|||
};
|
||||
|
||||
this.applySelect = () => {
|
||||
this.refs.users.children.forEach(el => {
|
||||
Array.from(this.refs.users.children).forEach(el => {
|
||||
el.removeAttribute('data-selected');
|
||||
});
|
||||
|
||||
|
|
|
@ -408,7 +408,7 @@
|
|||
|
||||
// ドロップされてきたものがファイルだったら
|
||||
if (e.dataTransfer.files.length > 0) {
|
||||
e.dataTransfer.files.forEach(file => {
|
||||
Array.from(e.dataTransfer.files).forEach(file => {
|
||||
this.upload(file, this.folder);
|
||||
});
|
||||
return false;
|
||||
|
@ -510,7 +510,7 @@
|
|||
};
|
||||
|
||||
this.changeFileInput = () => {
|
||||
this.refs.fileInput.files.forEach(file => {
|
||||
Array.from(this.refs.fileInput.files).forEach(file => {
|
||||
this.upload(file, this.folder);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -109,7 +109,7 @@
|
|||
|
||||
// ファイルだったら
|
||||
if (e.dataTransfer.files.length > 0) {
|
||||
e.dataTransfer.files.forEach(file => {
|
||||
Array.from(e.dataTransfer.files).forEach(file => {
|
||||
this.browser.upload(file, this.folder);
|
||||
});
|
||||
return false;
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
|
||||
// ファイルだったら
|
||||
if (e.dataTransfer.files.length > 0) {
|
||||
e.dataTransfer.files.forEach(file => {
|
||||
Array.from(e.dataTransfer.files).forEach(file => {
|
||||
this.browser.upload(file, this.folder);
|
||||
});
|
||||
return false;
|
||||
|
|
|
@ -129,7 +129,7 @@
|
|||
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -273,7 +273,7 @@
|
|||
|
||||
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);
|
||||
});
|
||||
|
||||
|
|
|
@ -405,7 +405,7 @@
|
|||
|
||||
// ファイルだったら
|
||||
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 => {
|
||||
e.clipboardData.items.forEach(item => {
|
||||
Array.from(e.clipboardData.items).forEach(item => {
|
||||
if (item.kind == 'file') {
|
||||
this.upload(item.getAsFile());
|
||||
}
|
||||
|
@ -435,7 +435,7 @@
|
|||
};
|
||||
|
||||
this.changeFile = () => {
|
||||
this.refs.file.files.forEach(this.upload);
|
||||
Array.from(this.refs.file.files).forEach(this.upload);
|
||||
};
|
||||
|
||||
this.upload = file => {
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
const tokens = this.post.ast;
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -498,7 +498,7 @@
|
|||
|
||||
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);
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as riot from 'riot';
|
||||
const route = require('page');
|
||||
import * as route from 'page';
|
||||
let page = null;
|
||||
|
||||
export default me => {
|
||||
|
@ -32,7 +32,7 @@ export default me => {
|
|||
}
|
||||
|
||||
// EXEC
|
||||
route();
|
||||
(route as any)();
|
||||
};
|
||||
|
||||
function mount(content) {
|
|
@ -2,14 +2,13 @@
|
|||
* App initializer
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
declare var VERSION: string;
|
||||
declare var LANG: string;
|
||||
|
||||
import * as riot from 'riot';
|
||||
import api from './common/scripts/api';
|
||||
import signout from './common/scripts/signout';
|
||||
import checkForUpdate from './common/scripts/check-for-update';
|
||||
import Connection from './common/scripts/home-stream';
|
||||
import ServerStreamManager from './common/scripts/server-stream-manager.ts';
|
||||
import Progress from './common/scripts/loading';
|
||||
import mixin from './common/mixins';
|
||||
import CONFIG from './common/scripts/config';
|
||||
|
@ -37,21 +36,7 @@ console.info(`Misskey v${VERSION} (葵 aoi)`);
|
|||
document.domain = CONFIG.host;
|
||||
|
||||
// Set global configuration
|
||||
riot.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;
|
||||
}
|
||||
(riot as any).mixin({ CONFIG });
|
||||
|
||||
// iOSでプライベートモードだとlocalStorageが使えないので既存のメソッドを上書きする
|
||||
try {
|
||||
|
@ -72,7 +57,7 @@ setTimeout(checkForUpdate, 3000);
|
|||
// ユーザーをフェッチしてコールバックする
|
||||
export default callback => {
|
||||
// Get cached account data
|
||||
let cachedMe = JSON.parse(localStorage.getItem('me'));
|
||||
const cachedMe = JSON.parse(localStorage.getItem('me'));
|
||||
|
||||
if (cachedMe) {
|
||||
fetched(cachedMe);
|
||||
|
@ -112,11 +97,8 @@ export default callback => {
|
|||
// Init home stream connection
|
||||
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');
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
|
||||
import * as riot from 'riot';
|
||||
const route = require('page');
|
||||
import * as route from 'page';
|
||||
let page = null;
|
||||
|
||||
export default me => {
|
||||
|
@ -131,12 +131,12 @@ export default me => {
|
|||
mount(document.createElement('mk-not-found'));
|
||||
}
|
||||
|
||||
riot.mixin('page', {
|
||||
(riot as any).mixin('page', {
|
||||
page: route
|
||||
});
|
||||
|
||||
// EXEC
|
||||
route();
|
||||
(route as any)();
|
||||
};
|
||||
|
||||
function mount(content) {
|
|
@ -561,7 +561,7 @@
|
|||
};
|
||||
|
||||
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>
|
||||
</mk-drive>
|
||||
|
|
|
@ -285,7 +285,7 @@
|
|||
|
||||
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);
|
||||
});
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@
|
|||
};
|
||||
|
||||
this.onpaste = e => {
|
||||
e.clipboardData.items.forEach(item => {
|
||||
Array.from(e.clipboardData.items).forEach(item => {
|
||||
if (item.kind == 'file') {
|
||||
this.upload(item.getAsFile());
|
||||
}
|
||||
|
@ -228,7 +228,7 @@
|
|||
};
|
||||
|
||||
this.changeFile = () => {
|
||||
this.refs.file.files.forEach(this.upload);
|
||||
Array.from(this.refs.file.files).forEach(this.upload);
|
||||
};
|
||||
|
||||
this.upload = file => {
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
const tokens = this.post.ast;
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -538,7 +538,7 @@
|
|||
|
||||
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);
|
||||
});
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"object-literal-sort-keys": false,
|
||||
"curly": false,
|
||||
"no-console": [false],
|
||||
"no-empty":false,
|
||||
"ordered-imports": [false],
|
||||
"arrow-parens": false,
|
||||
"object-literal-shorthand": false,
|
||||
|
|
|
@ -14,13 +14,13 @@ module.exports = langs.map(([lang, locale]) => {
|
|||
|
||||
// Entries
|
||||
const entry = {
|
||||
desktop: './src/web/app/desktop/script.js',
|
||||
mobile: './src/web/app/mobile/script.js',
|
||||
ch: './src/web/app/ch/script.js',
|
||||
stats: './src/web/app/stats/script.js',
|
||||
status: './src/web/app/status/script.js',
|
||||
dev: './src/web/app/dev/script.js',
|
||||
auth: './src/web/app/auth/script.js'
|
||||
desktop: './src/web/app/desktop/script.ts',
|
||||
mobile: './src/web/app/mobile/script.ts',
|
||||
ch: './src/web/app/ch/script.ts',
|
||||
stats: './src/web/app/stats/script.ts',
|
||||
status: './src/web/app/status/script.ts',
|
||||
dev: './src/web/app/dev/script.ts',
|
||||
auth: './src/web/app/auth/script.ts'
|
||||
};
|
||||
|
||||
const output = {
|
||||
|
@ -33,6 +33,11 @@ module.exports = langs.map(([lang, locale]) => {
|
|||
entry,
|
||||
module: module_(lang, locale),
|
||||
plugins: plugins(version, lang),
|
||||
output
|
||||
output,
|
||||
resolve: {
|
||||
extensions: [
|
||||
'.js', '.ts'
|
||||
]
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue