refactor(frontend): use ESM

This commit is contained in:
syuilo
2023-09-19 16:37:43 +09:00
parent 299c9c4118
commit b0f6c44f36
459 changed files with 1643 additions and 1642 deletions

View File

@@ -3,8 +3,8 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import * as os from '@/os';
import { $i } from '@/account';
import * as os from '@/os.js';
import { $i } from '@/account.js';
export const ACHIEVEMENT_TYPES = [
'notes1',

View File

@@ -4,11 +4,11 @@
*/
import { utils, values } from '@syuilo/aiscript';
import * as os from '@/os';
import { $i } from '@/account';
import { miLocalStorage } from '@/local-storage';
import { customEmojis } from '@/custom-emojis';
import { lang } from '@/config';
import * as os from '@/os.js';
import { $i } from '@/account.js';
import { miLocalStorage } from '@/local-storage.js';
import { customEmojis } from '@/custom-emojis.js';
import { lang } from '@/config.js';
export function createAiScriptEnv(opts) {
return {

View File

@@ -5,8 +5,8 @@
import { Endpoints } from 'misskey-js/built/api.types';
import { ref } from 'vue';
import { apiUrl } from '@/config';
import { $i } from '@/account';
import { apiUrl } from '@/config.js';
import { $i } from '@/account.js';
export const pendingApiRequestsCount = ref(0);
// Implements Misskey.api.ApiClient.request

View File

@@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { EndoRelation, Predicate } from './relation';
import { EndoRelation, Predicate } from './relation.js';
/**
* Count the number of elements that satisfy the predicate

View File

@@ -6,7 +6,7 @@
import { nextTick, Ref, ref, defineAsyncComponent } from 'vue';
import getCaretCoordinates from 'textarea-caret';
import { toASCII } from 'punycode/';
import { popup } from '@/os';
import { popup } from '@/os.js';
export class Autocomplete {
private suggestion: {

View File

@@ -4,7 +4,7 @@
*/
import { ref, computed } from 'vue';
import * as os from '@/os';
import * as os from '@/os.js';
type SaveData = {
gameVersion: number;

View File

@@ -5,7 +5,7 @@
import * as mfm from 'mfm-js';
import * as Misskey from 'misskey-js';
import { extractUrlFromMfm } from './extract-url-from-mfm';
import { extractUrlFromMfm } from './extract-url-from-mfm.js';
export function shouldCollapsed(note: Misskey.entities.Note): boolean {
const urls = note.text ? extractUrlFromMfm(mfm.parse(note.text)) : null;

View File

@@ -4,7 +4,7 @@
*/
import _confetti from 'canvas-confetti';
import * as os from '@/os';
import * as os from '@/os.js';
export function confetti(options: { duration?: number; } = {}) {
const duration = options.duration ?? 1000 * 4;

View File

@@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { defaultStore } from '@/store';
import { defaultStore } from '@/store.js';
await defaultStore.ready;

View File

@@ -4,7 +4,7 @@
*/
import * as mfm from 'mfm-js';
import { unique } from '@/scripts/array';
import { unique } from '@/scripts/array.js';
// unique without hash
// [ http://a/#1, http://a/#2, http://b/#3 ] => [ http://a/#1, http://b/#3 ]

View File

@@ -4,7 +4,7 @@
*/
import * as Misskey from 'misskey-js';
import { host as localHost } from '@/config';
import { host as localHost } from '@/config.js';
export async function genSearchQuery(v: any, q: string) {
let host: string;

View File

@@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { get } from '@/scripts/idb-proxy';
import { get } from '@/scripts/idb-proxy.js';
export async function getAccountFromId(id: string) {
const accounts = await get('accounts') as { token: string; id: string; }[];

View File

@@ -5,11 +5,11 @@
import * as Misskey from 'misskey-js';
import { defineAsyncComponent } from 'vue';
import { i18n } from '@/i18n';
import copyToClipboard from '@/scripts/copy-to-clipboard';
import * as os from '@/os';
import { MenuItem } from '@/types/menu';
import { defaultStore } from '@/store';
import { i18n } from '@/i18n.js';
import copyToClipboard from '@/scripts/copy-to-clipboard.js';
import * as os from '@/os.js';
import { MenuItem } from '@/types/menu.js';
import { defaultStore } from '@/store.js';
function rename(file: Misskey.entities.DriveFile) {
os.inputText({

View File

@@ -6,15 +6,15 @@
import { defineAsyncComponent, Ref } from 'vue';
import * as Misskey from 'misskey-js';
import { claimAchievement } from './achievements';
import { $i } from '@/account';
import { i18n } from '@/i18n';
import { instance } from '@/instance';
import * as os from '@/os';
import copyToClipboard from '@/scripts/copy-to-clipboard';
import { url } from '@/config';
import { defaultStore, noteActions } from '@/store';
import { miLocalStorage } from '@/local-storage';
import { getUserMenu } from '@/scripts/get-user-menu';
import { $i } from '@/account.js';
import { i18n } from '@/i18n.js';
import { instance } from '@/instance.js';
import * as os from '@/os.js';
import copyToClipboard from '@/scripts/copy-to-clipboard.js';
import { url } from '@/config.js';
import { defaultStore, noteActions } from '@/store.js';
import { miLocalStorage } from '@/local-storage.js';
import { getUserMenu } from '@/scripts/get-user-menu.js';
import { clipsCache } from '@/cache';
import { MenuItem } from '@/types/menu';

View File

@@ -4,7 +4,7 @@
*/
import * as Misskey from 'misskey-js';
import { i18n } from '@/i18n';
import { i18n } from '@/i18n.js';
/**
* 投稿を表す文字列を取得します。

View File

@@ -6,15 +6,15 @@
import { toUnicode } from 'punycode';
import { defineAsyncComponent, ref, watch } from 'vue';
import * as Misskey from 'misskey-js';
import { i18n } from '@/i18n';
import copyToClipboard from '@/scripts/copy-to-clipboard';
import { host, url } from '@/config';
import * as os from '@/os';
import { defaultStore, userActions } from '@/store';
import { $i, iAmModerator } from '@/account';
import { mainRouter } from '@/router';
import { Router } from '@/nirax';
import { antennasCache, rolesCache, userListsCache } from '@/cache';
import { i18n } from '@/i18n.js';
import copyToClipboard from '@/scripts/copy-to-clipboard.js';
import { host, url } from '@/config.js';
import * as os from '@/os.js';
import { defaultStore, userActions } from '@/store.js';
import { $i, iAmModerator } from '@/account.js';
import { mainRouter } from '@/router.js';
import { Router } from '@/nirax.js';
import { antennasCache, rolesCache, userListsCache } from '@/cache.js';
export function getUserMenu(user: Misskey.entities.UserDetailed, router: Router = mainRouter) {
const meId = $i ? $i.id : null;

View File

@@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import keyCode from './keycode';
import keyCode from './keycode.js';
type Callback = (ev: KeyboardEvent) => void;

View File

@@ -24,7 +24,7 @@ import {
import gradient from 'chartjs-plugin-gradient';
import zoomPlugin from 'chartjs-plugin-zoom';
import { MatrixController, MatrixElement } from 'chartjs-chart-matrix';
import { defaultStore } from '@/store';
import { defaultStore } from '@/store.js';
import 'chartjs-adapter-date-fns';
export function initChart() {

View File

@@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { lang } from '@/config';
import { lang } from '@/config.js';
export async function initializeSw() {
if (!('serviceWorker' in navigator)) return;

View File

@@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { lang } from '@/config';
import { lang } from '@/config.js';
export const versatileLang = (lang ?? 'ja-JP').replace('ja-KS', 'ja-JP');
export const dateTimeFormat = new Intl.DateTimeFormat(versatileLang, {

View File

@@ -4,7 +4,7 @@
*/
import * as Misskey from 'misskey-js';
import { $i } from '@/account';
import { $i } from '@/account.js';
export function isFfVisibleForMe(user: Misskey.entities.UserDetailed): boolean {
if ($i && $i.id === user.id) return true;

View File

@@ -4,8 +4,8 @@
*/
import * as Misskey from 'misskey-js';
import { i18n } from '@/i18n';
import * as os from '@/os';
import { i18n } from '@/i18n.js';
import * as os from '@/os.js';
export async function lookupUser() {
const { canceled, result } = await os.inputText({

View File

@@ -3,10 +3,10 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import * as os from '@/os';
import { i18n } from '@/i18n';
import { mainRouter } from '@/router';
import { Router } from '@/nirax';
import * as os from '@/os.js';
import { i18n } from '@/i18n.js';
import { mainRouter } from '@/router.js';
import { Router } from '@/nirax.js';
export async function lookup(router?: Router) {
const _router = router ?? mainRouter;

View File

@@ -3,9 +3,9 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { query } from '@/scripts/url';
import { url } from '@/config';
import { instance } from '@/instance';
import { query } from '@/scripts/url.js';
import { url } from '@/config.js';
import { instance } from '@/instance.js';
export function getProxiedImageUrl(imageUrl: string, type?: 'preview' | 'emoji' | 'avatar', mustOrigin = false, noFallback = false): string {
const localProxy = `${url}/proxy`;

View File

@@ -4,9 +4,9 @@
*/
import { defineAsyncComponent } from 'vue';
import { $i } from '@/account';
import { i18n } from '@/i18n';
import { popup } from '@/os';
import { $i } from '@/account.js';
import { i18n } from '@/i18n.js';
import { popup } from '@/os.js';
export function pleaseLogin(path?: string) {
if ($i) return;

View File

@@ -3,8 +3,8 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { appendQuery } from './url';
import * as config from '@/config';
import { appendQuery } from './url.js';
import * as config from '@/config.js';
export function popout(path: string, w?: HTMLElement) {
let url = path.startsWith('http://') || path.startsWith('https://') ? path : config.url + path;

View File

@@ -4,7 +4,7 @@
*/
import { defineAsyncComponent, Ref, ref } from 'vue';
import { popup } from '@/os';
import { popup } from '@/os.js';
class ReactionPicker {
private src: Ref<HTMLElement | null> = ref(null);

View File

@@ -5,11 +5,11 @@
import { ref } from 'vue';
import * as Misskey from 'misskey-js';
import * as os from '@/os';
import { useStream } from '@/stream';
import { i18n } from '@/i18n';
import { defaultStore } from '@/store';
import { uploadFile } from '@/scripts/upload';
import * as os from '@/os.js';
import { useStream } from '@/stream.js';
import { i18n } from '@/i18n.js';
import { defaultStore } from '@/store.js';
import { uploadFile } from '@/scripts/upload.js';
export function chooseFileFromPc(multiple: boolean, keepOriginal = false): Promise<Misskey.entities.DriveFile[]> {
return new Promise((res, rej) => {

View File

@@ -3,9 +3,9 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import * as os from '@/os';
import { $i } from '@/account';
import { i18n } from '@/i18n';
import * as os from '@/os.js';
import { $i } from '@/account.js';
import { i18n } from '@/i18n.js';
export function showMovedDialog() {
if (!$i) return;

View File

@@ -3,8 +3,8 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import * as os from '@/os';
import { i18n } from '@/i18n';
import * as os from '@/os.js';
import { i18n } from '@/i18n.js';
export function showSuspendedDialog() {
return os.alert({

View File

@@ -4,7 +4,7 @@
*/
import { markRaw } from 'vue';
import { Storage } from '@/pizzax';
import { Storage } from '@/pizzax.js';
export const soundConfigStore = markRaw(new Storage('sound', {
mediaVolume: {

View File

@@ -5,7 +5,7 @@
import { v4 as uuid } from 'uuid';
import { themeProps, Theme } from './theme';
import { themeProps, Theme } from './theme.js';
export type Default = null;
export type Color = string;

View File

@@ -19,7 +19,7 @@ export type Theme = {
import lightTheme from '@/themes/_light.json5';
import darkTheme from '@/themes/_dark.json5';
import { deepClone } from './clone';
import { miLocalStorage } from '@/local-storage';
import { miLocalStorage } from '@/local-storage.js';
export const themeProps = Object.keys(lightTheme.props).filter(key => !key.startsWith('X'));

View File

@@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { deviceKind } from '@/scripts/device-kind';
import { deviceKind } from '@/scripts/device-kind.js';
const isTouchSupported = 'maxTouchPoints' in navigator && navigator.maxTouchPoints > 0;

View File

@@ -6,12 +6,12 @@
import { reactive, ref } from 'vue';
import * as Misskey from 'misskey-js';
import { readAndCompressImage } from 'browser-image-resizer';
import { getCompressionConfig } from './upload/compress-config';
import { defaultStore } from '@/store';
import { apiUrl } from '@/config';
import { $i } from '@/account';
import { alert } from '@/os';
import { i18n } from '@/i18n';
import { getCompressionConfig } from './upload/compress-config.js';
import { defaultStore } from '@/store.js';
import { apiUrl } from '@/config.js';
import { $i } from '@/account.js';
import { alert } from '@/os.js';
import { i18n } from '@/i18n.js';
type Uploading = {
id: string;

View File

@@ -4,7 +4,7 @@
*/
import { onUnmounted, onDeactivated, ref } from 'vue';
import * as os from '@/os';
import * as os from '@/os.js';
import MkChartTooltip from '@/components/MkChartTooltip.vue';
export function useChartTooltip(opts: { position: 'top' | 'middle' } = { position: 'top' }) {

View File

@@ -5,8 +5,8 @@
import { onUnmounted, Ref } from 'vue';
import * as Misskey from 'misskey-js';
import { useStream } from '@/stream';
import { $i } from '@/account';
import { useStream } from '@/stream.js';
import { $i } from '@/account.js';
export function useNoteCapture(props: {
rootEl: Ref<HTMLElement>;