Compare commits
25 Commits
develop
...
sim-dev-co
Author | SHA1 | Date | |
---|---|---|---|
475cd49d16 | |||
7cd8f2f1c7 | |||
da6951fab5 | |||
8c7263e166 | |||
aa2b3cf4db | |||
ef8037d94f | |||
02923029b1 | |||
5a27a18fef | |||
2ced35512b | |||
fcec47fe13 | |||
67668849d6 | |||
487555c42f | |||
5a8c4f3ad3 | |||
f88592f72b | |||
9fb25cd860 | |||
7249b11f70 | |||
d793ce8152 | |||
40fd9d7aaf | |||
1babd0ca25 | |||
11fbde947c | |||
fcd035055e | |||
fd5b9aa5d0 | |||
90158790e6 | |||
dcc7ba77b9 | |||
a2e8aac5ca |
@ -220,6 +220,7 @@ currentPassword: "現在のパスワード"
|
|||||||
newPassword: "新しいパスワード"
|
newPassword: "新しいパスワード"
|
||||||
newPasswordRetype: "新しいパスワード(再入力)"
|
newPasswordRetype: "新しいパスワード(再入力)"
|
||||||
attachFile: "ファイルを添付"
|
attachFile: "ファイルを添付"
|
||||||
|
attachVideoFile: "動画ファイルを添付"
|
||||||
more: "もっと!"
|
more: "もっと!"
|
||||||
featured: "ハイライト"
|
featured: "ハイライト"
|
||||||
usernameOrUserId: "ユーザー名かユーザーID"
|
usernameOrUserId: "ユーザー名かユーザーID"
|
||||||
|
@ -221,6 +221,7 @@ currentPassword: "現在のパスワード"
|
|||||||
newPassword: "新しいパスワード"
|
newPassword: "新しいパスワード"
|
||||||
newPasswordRetype: "新しいパスワード(再入力)"
|
newPasswordRetype: "新しいパスワード(再入力)"
|
||||||
attachFile: "ファイルを添付"
|
attachFile: "ファイルを添付"
|
||||||
|
attachVideoFile: "動画ファイルを添付"
|
||||||
more: "もっと!"
|
more: "もっと!"
|
||||||
featured: "ハイライト"
|
featured: "ハイライト"
|
||||||
usernameOrUserId: "ユーザー名かユーザーID"
|
usernameOrUserId: "ユーザー名かユーザーID"
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordapp/twemoji": "13.1.0",
|
"@discordapp/twemoji": "13.1.0",
|
||||||
|
"@ffmpeg/core": "0.10.0",
|
||||||
|
"@ffmpeg/ffmpeg": "0.10.1",
|
||||||
"@syuilo/aiscript": "0.11.1",
|
"@syuilo/aiscript": "0.11.1",
|
||||||
"@types/dateformat": "3.0.1",
|
"@types/dateformat": "3.0.1",
|
||||||
"@types/escape-regexp": "0.0.1",
|
"@types/escape-regexp": "0.0.1",
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
<XNotePreview v-if="showPreview" class="preview" :text="text"/>
|
<XNotePreview v-if="showPreview" class="preview" :text="text"/>
|
||||||
<footer>
|
<footer>
|
||||||
<button v-tooltip="i18n.locale.attachFile" class="_button" @click="chooseFileFrom"><i class="fas fa-photo-video"></i></button>
|
<button v-tooltip="i18n.locale.attachFile" class="_button" @click="chooseFileFrom"><i class="fas fa-photo-video"></i></button>
|
||||||
|
<button v-tooltip="i18n.locale.attachVideoFile" class="_button" @click="chooseFileFromEnc"><i class="far fa-file-video"></i></button>
|
||||||
<button v-tooltip="i18n.locale.poll" class="_button" :class="{ active: poll }" @click="togglePoll"><i class="fas fa-poll-h"></i></button>
|
<button v-tooltip="i18n.locale.poll" class="_button" :class="{ active: poll }" @click="togglePoll"><i class="fas fa-poll-h"></i></button>
|
||||||
<button v-tooltip="i18n.locale.useCw" class="_button" :class="{ active: useCw }" @click="useCw = !useCw"><i class="fas fa-eye-slash"></i></button>
|
<button v-tooltip="i18n.locale.useCw" class="_button" :class="{ active: useCw }" @click="useCw = !useCw"><i class="fas fa-eye-slash"></i></button>
|
||||||
<button v-tooltip="i18n.locale.mention" class="_button" @click="insertMention"><i class="fas fa-at"></i></button>
|
<button v-tooltip="i18n.locale.mention" class="_button" @click="insertMention"><i class="fas fa-at"></i></button>
|
||||||
@ -81,6 +82,7 @@ import { Autocomplete } from '@/scripts/autocomplete';
|
|||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { stream } from '@/stream';
|
import { stream } from '@/stream';
|
||||||
import { selectFiles } from '@/scripts/select-file';
|
import { selectFiles } from '@/scripts/select-file';
|
||||||
|
import { selectFilesEnc } from '@/scripts/select-file-enc';
|
||||||
import { defaultStore, notePostInterruptors, postFormActions } from '@/store';
|
import { defaultStore, notePostInterruptors, postFormActions } from '@/store';
|
||||||
import { throttle } from 'throttle-debounce';
|
import { throttle } from 'throttle-debounce';
|
||||||
import MkInfo from '@/components/ui/info.vue';
|
import MkInfo from '@/components/ui/info.vue';
|
||||||
@ -349,6 +351,14 @@ function chooseFileFrom(ev) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function chooseFileFromEnc(ev) {
|
||||||
|
selectFilesEnc(ev.currentTarget || ev.target, i18n.locale.attachVideoFile).then(files_ => {
|
||||||
|
for (const file of files_) {
|
||||||
|
files.push(file);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function detachFile(id) {
|
function detachFile(id) {
|
||||||
files = files.filter(x => x.id != id);
|
files = files.filter(x => x.id != id);
|
||||||
}
|
}
|
||||||
|
155
packages/client/src/scripts/select-file-enc.ts
Normal file
155
packages/client/src/scripts/select-file-enc.ts
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
import * as os from '@/os';
|
||||||
|
import { stream } from '@/stream';
|
||||||
|
import { i18n } from '@/i18n';
|
||||||
|
import { defaultStore } from '@/store';
|
||||||
|
import { DriveFile } from 'misskey-js/built/entities';
|
||||||
|
import { fs } from 'fs';
|
||||||
|
import { createFFmpeg, fetchFile } from '@ffmpeg/ffmpeg';
|
||||||
|
|
||||||
|
|
||||||
|
function select(src: any, label: string | null, multiple: boolean): Promise<DriveFile | DriveFile[]> {
|
||||||
|
return new Promise((res, rej) => {
|
||||||
|
|
||||||
|
|
||||||
|
const chooseFileFromPc = () => {
|
||||||
|
const input = document.createElement('input');
|
||||||
|
input.type = 'file';
|
||||||
|
input.onchange = () => {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const readFromBlobOrFile = (blob) => (
|
||||||
|
console.log('start readfrombloborfile'),
|
||||||
|
new Promise((resolve, reject) => {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = () => {
|
||||||
|
resolve(reader.result);
|
||||||
|
};
|
||||||
|
reader.onerror = ({ target: { error: { code } } }) => {
|
||||||
|
reject(os.alert({ type: 'error', text: 'file could not be read! ' + code }));
|
||||||
|
};
|
||||||
|
reader.readAsArrayBuffer(blob);
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const ffmpeg = createFFmpeg({ log: true });
|
||||||
|
async function ffmpegconv() {
|
||||||
|
os.toast('Start const ffmpegconv');
|
||||||
|
console.log('Start const ffmpegconv');
|
||||||
|
var infilename = Array.from(input.files[0].name);
|
||||||
|
let video = null;
|
||||||
|
var outfilename = infilename.replace(/\.[^/.]+$/, '') + '.mp4';
|
||||||
|
os.toast('Start await beffile');
|
||||||
|
//ここでストップ
|
||||||
|
console.log('Start await beffile');
|
||||||
|
const befFile = new Uint8Array(await readFromBlobOrFile(input.files[0]));
|
||||||
|
|
||||||
|
os.toast('Loading FFmpeg.wasm');
|
||||||
|
console.log('Loading FFmpeg.wasm');
|
||||||
|
if (!ffmpeg.isLoaded()) {
|
||||||
|
os.toast('Loading FFmpeg.wasm-core');
|
||||||
|
console.log('Loading FFmpeg.wasm-core');
|
||||||
|
await ffmpeg.load();
|
||||||
|
}
|
||||||
|
os.toast('Set ffmpeg files');
|
||||||
|
console.log('Set ffmpeg files');
|
||||||
|
ffmpeg.FS('writeFile', infilename, await fetchFile(befFile));
|
||||||
|
os.toast('Converting')
|
||||||
|
await ffmpeg.run('-i', `video.avi`, '-c:v', 'copy', '-c:a', 'copy', `video.mp4`);
|
||||||
|
os.toast('Converted')
|
||||||
|
const aftFile = ffmpeg.FS('readFile', outfilename);
|
||||||
|
os.toast('Uploading')
|
||||||
|
video.value = URL.createObjectURL(new Blob([aftFile.buffer], { type: 'video/mp4' }));
|
||||||
|
os.upload(video, defaultStore.state.uploadFolder).then(res).catch(e => { os.alert({ type: 'error', text: e }) });
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//const promises = Array.from(input.files).map(file => os.upload(file, defaultStore.state.uploadFolder));
|
||||||
|
|
||||||
|
//Promise.all(promises).then(driveFiles => {
|
||||||
|
// res(multiple ? driveFiles : driveFiles[0]);
|
||||||
|
//}).catch(e => {
|
||||||
|
// os.alert({
|
||||||
|
// type: 'error',
|
||||||
|
// text: e
|
||||||
|
// });
|
||||||
|
//});
|
||||||
|
os.toast('Try use FFmpeg.wasm')
|
||||||
|
ffmpegconv();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 一応廃棄
|
||||||
|
(window as any).__misskey_input_ref__ = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
// https://qiita.com/fukasawah/items/b9dc732d95d99551013d
|
||||||
|
// iOS Safari で正常に動かす為のおまじない
|
||||||
|
(window as any).__misskey_input_ref__ = input;
|
||||||
|
|
||||||
|
input.click();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const chooseFileFromDrive = () => {
|
||||||
|
os.selectDriveFile(multiple).then(files => {
|
||||||
|
res(files);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const chooseFileFromUrl = () => {
|
||||||
|
os.inputText({
|
||||||
|
title: i18n.locale.uploadFromUrl,
|
||||||
|
type: 'url',
|
||||||
|
placeholder: i18n.locale.uploadFromUrlDescription
|
||||||
|
}).then(({ canceled, result: url }) => {
|
||||||
|
if (canceled) return;
|
||||||
|
|
||||||
|
const marker = Math.random().toString(); // TODO: UUIDとか使う
|
||||||
|
|
||||||
|
const connection = stream.useChannel('main');
|
||||||
|
connection.on('urlUploadFinished', data => {
|
||||||
|
if (data.marker === marker) {
|
||||||
|
res(multiple ? [data.file] : data.file);
|
||||||
|
connection.dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
os.api('drive/files/upload-from-url', {
|
||||||
|
url: url,
|
||||||
|
folderId: defaultStore.state.uploadFolder,
|
||||||
|
marker
|
||||||
|
});
|
||||||
|
|
||||||
|
os.alert({
|
||||||
|
title: i18n.locale.uploadFromUrlRequested,
|
||||||
|
text: i18n.locale.uploadFromUrlMayTakeTime
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
os.popupMenu([label ? {
|
||||||
|
text: label,
|
||||||
|
type: 'label'
|
||||||
|
} : undefined, {
|
||||||
|
text: i18n.locale.upload,
|
||||||
|
icon: 'fas fa-upload',
|
||||||
|
action: chooseFileFromPc
|
||||||
|
}], src);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function selectFileEnc(src: any, label: string | null = null): Promise<DriveFile> {
|
||||||
|
return select(src, label, false) as Promise<DriveFile>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function selectFilesEnc(src: any, label: string | null = null): Promise<DriveFile[]> {
|
||||||
|
return select(src, label, true) as Promise<DriveFile[]>;
|
||||||
|
}
|
@ -130,6 +130,21 @@
|
|||||||
minimatch "^3.0.4"
|
minimatch "^3.0.4"
|
||||||
strip-json-comments "^3.1.1"
|
strip-json-comments "^3.1.1"
|
||||||
|
|
||||||
|
"@ffmpeg/core@0.10.0":
|
||||||
|
version "0.10.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@ffmpeg/core/-/core-0.10.0.tgz#f6a58361b22d7c23c6f7071b9fff6d572bc3f499"
|
||||||
|
integrity sha512-qunWJl5PezpXEm31tb8Qu5z37B5KVA1VYZCpXchMhuAb3X9T7PuE3SlhOwphEoRhzaOa3lpofDfzihAUMFaVPQ==
|
||||||
|
|
||||||
|
"@ffmpeg/ffmpeg@0.10.1":
|
||||||
|
version "0.10.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/@ffmpeg/ffmpeg/-/ffmpeg-0.10.1.tgz#3dacf3985de9c83a95fbf79fe709920cc009b00a"
|
||||||
|
integrity sha512-ChQkH7Rh57hmVo1LhfQFibWX/xqneolJKSwItwZdKPcLZuKigtYAYDIvB55pDfP17VtR1R77SxgkB2/UApB+Og==
|
||||||
|
dependencies:
|
||||||
|
is-url "^1.2.4"
|
||||||
|
node-fetch "^2.6.1"
|
||||||
|
regenerator-runtime "^0.13.7"
|
||||||
|
resolve-url "^0.2.1"
|
||||||
|
|
||||||
"@hapi/hoek@^9.0.0":
|
"@hapi/hoek@^9.0.0":
|
||||||
version "9.2.0"
|
version "9.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.2.0.tgz#f3933a44e365864f4dad5db94158106d511e8131"
|
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.2.0.tgz#f3933a44e365864f4dad5db94158106d511e8131"
|
||||||
@ -3630,6 +3645,11 @@ is-unicode-supported@^0.1.0:
|
|||||||
resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7"
|
resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7"
|
||||||
integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==
|
integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==
|
||||||
|
|
||||||
|
is-url@^1.2.4:
|
||||||
|
version "1.2.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/is-url/-/is-url-1.2.4.tgz#04a4df46d28c4cff3d73d01ff06abeb318a1aa52"
|
||||||
|
integrity sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==
|
||||||
|
|
||||||
is-weakref@^1.0.1:
|
is-weakref@^1.0.1:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/is-weakref/-/is-weakref-1.0.1.tgz#842dba4ec17fa9ac9850df2d6efbc1737274f2a2"
|
resolved "https://registry.yarnpkg.com/is-weakref/-/is-weakref-1.0.1.tgz#842dba4ec17fa9ac9850df2d6efbc1737274f2a2"
|
||||||
@ -5165,6 +5185,11 @@ regenerator-runtime@^0.13.4:
|
|||||||
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55"
|
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55"
|
||||||
integrity sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==
|
integrity sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==
|
||||||
|
|
||||||
|
regenerator-runtime@^0.13.7:
|
||||||
|
version "0.13.9"
|
||||||
|
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52"
|
||||||
|
integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==
|
||||||
|
|
||||||
regexpp@^3.2.0:
|
regexpp@^3.2.0:
|
||||||
version "3.2.0"
|
version "3.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2"
|
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2"
|
||||||
@ -5225,6 +5250,11 @@ resolve-from@^5.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69"
|
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69"
|
||||||
integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==
|
integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==
|
||||||
|
|
||||||
|
resolve-url@^0.2.1:
|
||||||
|
version "0.2.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
|
||||||
|
integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=
|
||||||
|
|
||||||
resolve@^1.15.1, resolve@^1.20.0:
|
resolve@^1.15.1, resolve@^1.20.0:
|
||||||
version "1.20.0"
|
version "1.20.0"
|
||||||
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
|
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user