refactor: change types import strategy

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/900/head
Varun Patil 2023-10-29 17:30:11 -07:00
parent c1ebdb9e34
commit 4de74e0af1
67 changed files with 385 additions and 382 deletions

1
.gitignore vendored
View File

@ -4,6 +4,7 @@ npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
js/ js/
*.tsbuildinfo
# Editor directories and files # Editor directories and files
.idea .idea

View File

@ -30,7 +30,7 @@ import { defineComponent } from 'vue';
import Cluster from '@components/frame/Cluster.vue'; import Cluster from '@components/frame/Cluster.vue';
import type { ICluster } from '@types'; import type { ICluster } from '@typings';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
export default defineComponent({ export default defineComponent({

View File

@ -25,7 +25,7 @@ import { defineComponent, PropType } from 'vue';
import Cluster from './frame/Cluster.vue'; import Cluster from './frame/Cluster.vue';
import type { ICluster } from '@types'; import type { ICluster } from '@typings';
export default defineComponent({ export default defineComponent({
name: 'ClusterHList', name: 'ClusterHList',

View File

@ -30,7 +30,7 @@ import DynamicTopMatter from '@components/top-matter/DynamicTopMatter.vue';
import * as dav from '@services/dav'; import * as dav from '@services/dav';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import type { ICluster } from '@types'; import type { ICluster } from '@typings';
export default defineComponent({ export default defineComponent({
name: 'ClusterView', name: 'ClusterView',

View File

@ -58,7 +58,7 @@ import { translate as t } from '@services/l10n';
import config from '@services/static-config'; import config from '@services/static-config';
import * as dav from '@services/dav'; import * as dav from '@services/dav';
import type { ICluster, IConfig } from '@types'; import type { ICluster, IConfig } from '@typings';
export default defineComponent({ export default defineComponent({
name: 'Explore', name: 'Explore',

View File

@ -59,7 +59,7 @@ import banner from '@assets/banner.svg';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import { API } from '@services/API'; import { API } from '@services/API';
import type { IDay } from '@types'; import type { IDay } from '@typings';
export default defineComponent({ export default defineComponent({
name: 'FirstStart', name: 'FirstStart',

View File

@ -91,7 +91,7 @@ import * as utils from '@services/utils';
import * as dav from '@services/dav'; import * as dav from '@services/dav';
import { API } from '@services/API'; import { API } from '@services/API';
import type { IAlbum, IFace, IImageInfo, IPhoto, IExif } from '@types'; import type { IAlbum, IFace, IImageInfo, IPhoto, IExif } from '@typings';
interface TopField { interface TopField {
id?: string; id?: string;

View File

@ -54,7 +54,7 @@ import { defineComponent, PropType } from 'vue';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import { IRow, IRowType, ITick } from '@types'; import type { IRow, ITick } from '@typings';
import ScrollUpIcon from 'vue-material-design-icons/MenuUp.vue'; import ScrollUpIcon from 'vue-material-design-icons/MenuUp.vue';
import ScrollDownIcon from 'vue-material-design-icons/MenuDown.vue'; import ScrollDownIcon from 'vue-material-design-icons/MenuDown.vue';
@ -295,7 +295,7 @@ export default defineComponent({
// Iterate over rows // Iterate over rows
for (const row of this.rows) { for (const row of this.rows) {
if (row.type === IRowType.HEAD) { if (row.type === 0) {
// Make date string // Make date string
const dateTaken = utils.dayIdToDate(row.dayId); const dateTaken = utils.dayIdToDate(row.dayId);

View File

@ -63,7 +63,7 @@ import AlbumsIcon from 'vue-material-design-icons/ImageAlbum.vue';
import AlbumRemoveIcon from 'vue-material-design-icons/BookRemove.vue'; import AlbumRemoveIcon from 'vue-material-design-icons/BookRemove.vue';
import FolderMoveIcon from 'vue-material-design-icons/FolderMove.vue'; import FolderMoveIcon from 'vue-material-design-icons/FolderMove.vue';
import { IDay, IHeadRow, IPhoto, IRow, IRowType } from '@types'; import type { IDay, IHeadRow, IPhoto, IRow } from '@typings';
/** /**
* The distance for which the touch selection is clamped. * The distance for which the touch selection is clamped.
@ -630,7 +630,7 @@ export default defineComponent({
// Look behind // Look behind
for (let i = rowIdx; i > rowIdx - 100; i--) { for (let i = rowIdx; i > rowIdx - 100; i--) {
if (i < 0) break; if (i < 0) break;
if (rows[i].type !== IRowType.PHOTOS) continue; if (rows[i].type !== 1) continue;
if (!rows[i].photos?.length) break; if (!rows[i].photos?.length) break;
const sj = i === rowIdx ? pIdx : rows[i].photos!.length - 1; const sj = i === rowIdx ? pIdx : rows[i].photos!.length - 1;

View File

@ -172,7 +172,7 @@ const NcCheckboxRadioSwitch = () => import('@nextcloud/vue/dist/Components/NcChe
import MultiPathSelectionModal from '@components/modal/MultiPathSelectionModal.vue'; import MultiPathSelectionModal from '@components/modal/MultiPathSelectionModal.vue';
import type { IConfig } from '@types'; import type { IConfig } from '@typings';
export default defineComponent({ export default defineComponent({
name: 'Settings', name: 'Settings',

View File

@ -25,7 +25,7 @@ import Metadata from '@components/Metadata.vue';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import { IPhoto } from '@types'; import type { IPhoto } from '@typings';
import CloseIcon from 'vue-material-design-icons/Close.vue'; import CloseIcon from 'vue-material-design-icons/Close.vue';
import InfoSvg from '@assets/info.svg'; import InfoSvg from '@assets/info.svg';

View File

@ -114,7 +114,7 @@ import * as nativex from '@native';
import { API, DaysFilterType } from '@services/API'; import { API, DaysFilterType } from '@services/API';
import { IDay, IHeadRow, IPhoto, IRow, IRowType } from '@types'; import type { IDay, IHeadRow, IPhoto, IRow } from '@typings';
const SCROLL_LOAD_DELAY = 100; // Delay in loading data when scrolling const SCROLL_LOAD_DELAY = 100; // Delay in loading data when scrolling
const DESKTOP_ROW_HEIGHT = 200; // Height of row on desktop const DESKTOP_ROW_HEIGHT = 200; // Height of row on desktop
@ -767,7 +767,7 @@ export default defineComponent({
id: `${day.dayid}-head`, id: `${day.dayid}-head`,
num: -1, num: -1,
size: 40, size: 40,
type: IRowType.HEAD, type: 0, // head
selected: false, selected: false,
dayId: day.dayid, dayId: day.dayid,
day: day, day: day,
@ -1165,7 +1165,7 @@ export default defineComponent({
let dataIdx = 0; let dataIdx = 0;
while (dataIdx < data.length) { while (dataIdx < data.length) {
// Check if we ran out of rows // Check if we ran out of rows
if (rowIdx >= this.list.length || this.list[rowIdx].type === IRowType.HEAD) { if (rowIdx >= this.list.length || this.list[rowIdx].type === 0) {
const newRow = this.addRow(day); const newRow = this.addRow(day);
addedRows.push(newRow); addedRows.push(newRow);
this.list.splice(rowIdx, 0, newRow); this.list.splice(rowIdx, 0, newRow);
@ -1276,7 +1276,7 @@ export default defineComponent({
// Get rid of any extra rows // Get rid of any extra rows
let spliceCount = 0; let spliceCount = 0;
for (let i = rowIdx + 1; i < this.list.length && this.list[i].type !== IRowType.HEAD; i++) { for (let i = rowIdx + 1; i < this.list.length && this.list[i].type !== 0; i++) {
spliceCount++; spliceCount++;
} }
if (spliceCount > 0) { if (spliceCount > 0) {
@ -1320,11 +1320,11 @@ export default defineComponent({
day.rows ??= []; day.rows ??= [];
// Create new row // Create new row
const row = { const row: IRow = {
id: `${day.dayid}-${day.rows.length}`, id: `${day.dayid}-${day.rows.length}`,
num: day.rows.length, num: day.rows.length,
photos: [], photos: [],
type: IRowType.PHOTOS, type: 1, // photos
size: this.rowHeight, size: this.rowHeight,
dayId: day.dayid, dayId: day.dayid,
day: day, day: day,

View File

@ -43,7 +43,7 @@ import VideoTranscoder from './sections/VideoTranscoder.vue';
import VideoAccel from './sections/VideoAccel.vue'; import VideoAccel from './sections/VideoAccel.vue';
import type { ISystemConfig, ISystemStatus } from './AdminTypes'; import type { ISystemConfig, ISystemStatus } from './AdminTypes';
import type { IConfig } from '@types'; import type { IConfig } from '@typings';
export default defineComponent({ export default defineComponent({
name: 'Admin', name: 'Admin',

View File

@ -7,7 +7,7 @@ const NcTextField = () => import('@nextcloud/vue/dist/Components/NcTextField');
import NcButton from '@nextcloud/vue/dist/Components/NcButton'; import NcButton from '@nextcloud/vue/dist/Components/NcButton';
import type { ISystemStatus, ISystemConfig, IBinaryStatus } from './AdminTypes'; import type { ISystemStatus, ISystemConfig, IBinaryStatus } from './AdminTypes';
import type { IConfig } from '@types'; import type { IConfig } from '@typings';
export default defineComponent({ export default defineComponent({
name: 'AdminMixin', name: 'AdminMixin',

View File

@ -1,4 +1,4 @@
import type { IConfig } from '@types'; import type { IConfig } from '@typings';
/** System configuration */ /** System configuration */
export type ISystemConfig = { export type ISystemConfig = {

View File

@ -37,7 +37,7 @@ import { defineComponent, PropType } from 'vue';
import NcCounterBubble from '@nextcloud/vue/dist/Components/NcCounterBubble'; import NcCounterBubble from '@nextcloud/vue/dist/Components/NcCounterBubble';
import type { IAlbum, ICluster, IFace, IPhoto } from '@types'; import type { IAlbum, ICluster, IFace, IPhoto } from '@typings';
import { getPreviewUrl } from '@services/utils/helpers'; import { getPreviewUrl } from '@services/utils/helpers';
import errorsvg from '@assets/error.svg'; import errorsvg from '@assets/error.svg';
import plussvg from '@assets/plus.svg'; import plussvg from '@assets/plus.svg';

View File

@ -30,7 +30,7 @@ import UserConfig from '@mixins/UserConfig';
import * as utils from '@services/utils/helpers'; import * as utils from '@services/utils/helpers';
import { IFolder, IPhoto } from '@types'; import type { IFolder, IPhoto } from '@typings';
import FolderIcon from 'vue-material-design-icons/Folder.vue'; import FolderIcon from 'vue-material-design-icons/Folder.vue';

View File

@ -82,7 +82,7 @@ import LivePhotoIcon from 'vue-material-design-icons/MotionPlayOutline.vue';
import LocalIcon from 'vue-material-design-icons/CloudOff.vue'; import LocalIcon from 'vue-material-design-icons/CloudOff.vue';
import RawIcon from 'vue-material-design-icons/Raw.vue'; import RawIcon from 'vue-material-design-icons/Raw.vue';
import type { IDay, IPhoto } from '@types'; import type { IDay, IPhoto } from '@typings';
import type XImg from '@components/XImg.vue'; import type XImg from '@components/XImg.vue';
import errorsvg from '@assets/error.svg'; import errorsvg from '@assets/error.svg';

View File

@ -15,7 +15,7 @@ import { defineComponent, PropType } from 'vue';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import type { IHeadRow } from '@types'; import type { IHeadRow } from '@typings';
import CheckCircle from 'vue-material-design-icons/CheckCircle.vue'; import CheckCircle from 'vue-material-design-icons/CheckCircle.vue';

View File

@ -27,7 +27,7 @@ import AlbumPicker from './AlbumPicker.vue';
import * as dav from '@services/dav'; import * as dav from '@services/dav';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import { IAlbum, IPhoto } from '@types'; import type { IAlbum, IPhoto } from '@typings';
export default defineComponent({ export default defineComponent({
name: 'AddToAlbumModal', name: 'AddToAlbumModal',

View File

@ -86,7 +86,7 @@ import AlbumsList from './AlbumsList.vue';
import * as dav from '@services/dav'; import * as dav from '@services/dav';
import type { IAlbum, IPhoto } from '@types'; import type { IAlbum, IPhoto } from '@typings';
import PlusIcon from 'vue-material-design-icons/Plus.vue'; import PlusIcon from 'vue-material-design-icons/Plus.vue';
import CheckIcon from 'vue-material-design-icons/Check.vue'; import CheckIcon from 'vue-material-design-icons/Check.vue';

View File

@ -38,7 +38,7 @@ const NcListItem = () => import('@nextcloud/vue/dist/Components/NcListItem');
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import type { IAlbum, IPhoto } from '@types'; import type { IAlbum, IPhoto } from '@typings';
import ImageMultipleIcon from 'vue-material-design-icons/ImageMultiple.vue'; import ImageMultipleIcon from 'vue-material-design-icons/ImageMultiple.vue';

View File

@ -117,7 +117,7 @@ const NcTextField = () => import('@nextcloud/vue/dist/Components/NcTextField');
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import { IPhoto } from '@types'; import type { IPhoto } from '@typings';
export default defineComponent({ export default defineComponent({
name: 'EditDate', name: 'EditDate',

View File

@ -28,7 +28,7 @@ const NcTextField = () => import('@nextcloud/vue/dist/Components/NcTextField');
import { translate as t } from '@services/l10n'; import { translate as t } from '@services/l10n';
import { IExif, IPhoto } from '@types'; import type { IExif, IPhoto } from '@typings';
interface IField { interface IField {
field: keyof IExif; field: keyof IExif;

View File

@ -73,7 +73,7 @@ import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton';
const NcTextField = () => import('@nextcloud/vue/dist/Components/NcTextField'); const NcTextField = () => import('@nextcloud/vue/dist/Components/NcTextField');
const NcListItem = () => import('@nextcloud/vue/dist/Components/NcListItem'); const NcListItem = () => import('@nextcloud/vue/dist/Components/NcListItem');
import { IPhoto } from '@types'; import type { IPhoto } from '@typings';
import MagnifyIcon from 'vue-material-design-icons/Magnify.vue'; import MagnifyIcon from 'vue-material-design-icons/Magnify.vue';
import CloseIcon from 'vue-material-design-icons/Close.vue'; import CloseIcon from 'vue-material-design-icons/Close.vue';

View File

@ -71,7 +71,7 @@ import * as dav from '@services/dav';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import { API } from '@services/API'; import { API } from '@services/API';
import { IExif, IImageInfo, IPhoto } from '@types'; import type { IExif, IImageInfo, IPhoto } from '@typings';
export default defineComponent({ export default defineComponent({
components: { components: {

View File

@ -22,7 +22,7 @@ const NcSelectTags = () => import('@nextcloud/vue/dist/Components/NcSelectTags')
import * as dav from '@services/dav'; import * as dav from '@services/dav';
import type { IPhoto } from '@types'; import type { IPhoto } from '@typings';
export default defineComponent({ export default defineComponent({
name: 'EditTags', name: 'EditTags',

View File

@ -38,7 +38,7 @@ import ClusterGrid from '@components/ClusterGrid.vue';
import * as dav from '@services/dav'; import * as dav from '@services/dav';
import type { ICluster, IFace } from '@types'; import type { ICluster, IFace } from '@typings';
import MagnifyIcon from 'vue-material-design-icons/Magnify.vue'; import MagnifyIcon from 'vue-material-design-icons/Magnify.vue';

View File

@ -38,7 +38,7 @@ import client from '@services/dav/client';
import * as dav from '@services/dav'; import * as dav from '@services/dav';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import { IFileInfo, IFace } from '@types'; import type { IFileInfo, IFace } from '@typings';
export default defineComponent({ export default defineComponent({
name: 'FaceMergeModal', name: 'FaceMergeModal',

View File

@ -33,7 +33,7 @@ import ModalMixin from './ModalMixin';
import * as dav from '@services/dav'; import * as dav from '@services/dav';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import type { IPhoto, IFace } from '@types'; import type { IPhoto, IFace } from '@typings';
export default defineComponent({ export default defineComponent({
name: 'FaceMoveModal', name: 'FaceMoveModal',

View File

@ -26,7 +26,7 @@ import ModalMixin from './ModalMixin';
import * as dav from '@services/dav'; import * as dav from '@services/dav';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import type { IPhoto } from '@types'; import type { IPhoto } from '@typings';
export default defineComponent({ export default defineComponent({
name: 'MoveToFolderModal', name: 'MoveToFolderModal',

View File

@ -89,7 +89,7 @@ import * as dav from '@services/dav';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import * as nativex from '@native'; import * as nativex from '@native';
import type { IPhoto } from '@types'; import type { IPhoto } from '@typings';
import PhotoIcon from 'vue-material-design-icons/Image.vue'; import PhotoIcon from 'vue-material-design-icons/Image.vue';
import LargePhotoIcon from 'vue-material-design-icons/ImageArea.vue'; import LargePhotoIcon from 'vue-material-design-icons/ImageArea.vue';

View File

@ -14,7 +14,7 @@ import FolderGrid from './FolderGrid.vue';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import { API } from '@services/API'; import { API } from '@services/API';
import type { IFolder } from '@types'; import type { IFolder } from '@typings';
export default defineComponent({ export default defineComponent({
name: 'FolderDynamicTopMatter', name: 'FolderDynamicTopMatter',

View File

@ -12,7 +12,7 @@ import { defineComponent } from 'vue';
import UserConfig from '@mixins/UserConfig'; import UserConfig from '@mixins/UserConfig';
import Folder from '@components/frame/Folder.vue'; import Folder from '@components/frame/Folder.vue';
import type { IFolder } from '@types'; import type { IFolder } from '@typings';
export default defineComponent({ export default defineComponent({
name: 'ClusterGrid', name: 'ClusterGrid',

View File

@ -44,7 +44,7 @@ import axios from '@nextcloud/axios';
import { API } from '@services/API'; import { API } from '@services/API';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import type { IPhoto } from '@types'; import type { IPhoto } from '@typings';
import 'leaflet/dist/leaflet.css'; import 'leaflet/dist/leaflet.css';
import 'leaflet-edgebuffer'; import 'leaflet-edgebuffer';

View File

@ -37,7 +37,7 @@ import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import * as dav from '@services/dav'; import * as dav from '@services/dav';
import type { IPhoto } from '@types'; import type { IPhoto } from '@typings';
import LeftMoveIcon from 'vue-material-design-icons/ChevronLeft.vue'; import LeftMoveIcon from 'vue-material-design-icons/ChevronLeft.vue';
import RightMoveIcon from 'vue-material-design-icons/ChevronRight.vue'; import RightMoveIcon from 'vue-material-design-icons/ChevronRight.vue';

View File

@ -14,7 +14,7 @@ import NcButton from '@nextcloud/vue/dist/Components/NcButton';
import { API } from '@services/API'; import { API } from '@services/API';
import type { ICluster } from '@types'; import type { ICluster } from '@typings';
export default defineComponent({ export default defineComponent({
name: 'PlacesDynamicTopMatter', name: 'PlacesDynamicTopMatter',

View File

@ -23,7 +23,7 @@ import { fetchImage } from '@components/frame/XImgCache';
import { API } from '@services/API'; import { API } from '@services/API';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import { IImageInfo, IPhoto } from '@types'; import type { IImageInfo, IPhoto } from '@typings';
// Crop preset icons // Crop preset icons
import LandscapeIcon from '@scaleflex/icons/landscape'; import LandscapeIcon from '@scaleflex/icons/landscape';

View File

@ -191,7 +191,7 @@ import PsImage from './PsImage';
import PsVideo from './PsVideo'; import PsVideo from './PsVideo';
import PsLivePhoto from './PsLivePhoto'; import PsLivePhoto from './PsLivePhoto';
import { IImageInfo, IPhoto, TimelineState } from '@types'; import type { IImageInfo, IPhoto, TimelineState } from '@typings';
import type { PsContent } from './types'; import type { PsContent } from './types';
import ShareIcon from 'vue-material-design-icons/ShareVariant.vue'; import ShareIcon from 'vue-material-design-icons/ShareVariant.vue';

View File

@ -1,6 +1,6 @@
import Content from 'photoswipe/dist/types/slide/content'; import Content from 'photoswipe/dist/types/slide/content';
import Slide, { _SlideData } from 'photoswipe/dist/types/slide/slide'; import Slide, { _SlideData } from 'photoswipe/dist/types/slide/slide';
import type { IPhoto, IConfig } from '@types'; import type { IPhoto, IConfig } from '@typings';
type PsAugment = { type PsAugment = {
data: _SlideData & { data: _SlideData & {

2
src/globals.d.ts vendored
View File

@ -4,7 +4,7 @@ import type { ComponentPublicInstance } from 'vue';
import type PlyrType from 'plyr'; import type PlyrType from 'plyr';
import type videojsType from 'video.js'; import type videojsType from 'video.js';
import type { IPhoto, TimelineState } from '@types'; import type { IPhoto, TimelineState } from '@typings';
import type { constants, initstate } from '@services/utils'; import type { constants, initstate } from '@services/utils';
import type { translate, translatePlural } from '@services/l10n'; import type { translate, translatePlural } from '@services/l10n';
import type { GlobalRouteCheckers, routes } from './router'; import type { GlobalRouteCheckers, routes } from './router';

View File

@ -6,7 +6,7 @@ import { API } from '@services/API';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import staticConfig from '../services/static-config'; import staticConfig from '../services/static-config';
import type { IConfig } from '@types'; import type { IConfig } from '@typings';
const eventName: keyof utils.BusEvent = 'memories:user-config-changed'; const eventName: keyof utils.BusEvent = 'memories:user-config-changed';

View File

@ -4,7 +4,7 @@ import { has } from './basic';
import { API } from '@services/API'; import { API } from '@services/API';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import type { IDay, IPhoto } from '@types'; import type { IDay, IPhoto } from '@typings';
/** Memcache for <dayId, Photos> */ /** Memcache for <dayId, Photos> */
const daysCache = new Map<number, IPhoto[]>(); const daysCache = new Map<number, IPhoto[]>();

View File

@ -1,7 +1,7 @@
import axios from '@nextcloud/axios'; import axios from '@nextcloud/axios';
import { BASE_URL, NAPI, nativex } from './api'; import { BASE_URL, NAPI, nativex } from './api';
import { addOrigin } from './basic'; import { addOrigin } from './basic';
import type { IPhoto } from '@types'; import type { IPhoto } from '@typings';
/** /**
* Download a file from the given URL. * Download a file from the given URL.

View File

@ -1,6 +1,6 @@
import { nativex } from './api'; import { nativex } from './api';
import { addOrigin } from './basic'; import { addOrigin } from './basic';
import type { IPhoto } from '@types'; import type { IPhoto } from '@typings';
/** /**
* Play a video from the given URL. * Play a video from the given URL.

View File

@ -1,5 +1,5 @@
import { generateUrl } from '@nextcloud/router'; import { generateUrl } from '@nextcloud/router';
import { ClusterTypes } from '@types'; import type { ClusterTypes } from '@typings';
const BASE = '/apps/memories/api'; const BASE = '/apps/memories/api';

View File

@ -9,7 +9,7 @@ import { API } from '@services/API';
import client from '@services/dav/client'; import client from '@services/dav/client';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import { IAlbum, IFileInfo, IPhoto } from '@types'; import type { IAlbum, IFileInfo, IPhoto } from '@typings';
/** /**
* Get DAV path for album * Get DAV path for album

View File

@ -9,7 +9,7 @@ import { translate as t } from '@services/l10n';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import * as nativex from '@native'; import * as nativex from '@native';
import { IFileInfo, IPhoto } from '@types'; import type { IFileInfo, IPhoto } from '@typings';
const GET_FILE_CHUNK_SIZE = 50; const GET_FILE_CHUNK_SIZE = 50;

View File

@ -5,7 +5,7 @@ import { translate as t } from '@services/l10n';
import { API } from '@services/API'; import { API } from '@services/API';
import * as nativex from '@native'; import * as nativex from '@native';
import type { IPhoto } from '@types'; import type { IPhoto } from '@typings';
/** /**
* Download files * Download files

View File

@ -9,7 +9,7 @@ import { translate as t } from '@services/l10n';
import { constants as c } from '@services/utils'; import { constants as c } from '@services/utils';
import { API } from '@services/API'; import { API } from '@services/API';
import { IFace, IPhoto } from '@types'; import type { IFace, IPhoto } from '@typings';
/** /**
* Get list of faces * Get list of faces

View File

@ -6,7 +6,7 @@ import * as base from './base';
import { translate as t } from '@services/l10n'; import { translate as t } from '@services/l10n';
import { constants as c } from '@services/utils'; import { constants as c } from '@services/utils';
import type { IFileInfo, IPhoto } from '@types'; import type { IFileInfo, IPhoto } from '@typings';
/** /**
* Favorite a file * Favorite a file

View File

@ -3,7 +3,7 @@ import axios from '@nextcloud/axios';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import { API } from '@services/API'; import { API } from '@services/API';
import { IDay, IPhoto } from '@types'; import type { IDay, IPhoto } from '@typings';
/** /**
* Get original onThisDay response. * Get original onThisDay response.

View File

@ -3,7 +3,7 @@ import { generateUrl } from '@nextcloud/router';
import { API } from '@services/API'; import { API } from '@services/API';
import { IPhoto } from '@types'; import type { IPhoto } from '@typings';
/** /**
* Open the files app with the given photo * Open the files app with the given photo

View File

@ -1,7 +1,7 @@
import axios from '@nextcloud/axios'; import axios from '@nextcloud/axios';
import { API } from '@services/API'; import { API } from '@services/API';
import { ICluster } from '@types'; import type { ICluster } from '@typings';
export async function getPlaces() { export async function getPlaces() {
return (await axios.get<ICluster[]>(API.PLACE_LIST())).data; return (await axios.get<ICluster[]>(API.PLACE_LIST())).data;

View File

@ -1,5 +1,5 @@
import { initstate } from '@services/utils'; import { initstate } from '@services/utils';
import { IDay } from '@types'; import type { IDay } from '@typings';
const { singleItem } = initstate; const { singleItem } = initstate;

View File

@ -6,7 +6,7 @@ import client from './client';
import { API } from '@services/API'; import { API } from '@services/API';
import { translate as t } from '@services/l10n'; import { translate as t } from '@services/l10n';
import { ICluster } from '@types'; import type { ICluster } from '@typings';
export interface ITag { export interface ITag {
id: number; id: number;

View File

@ -7,7 +7,7 @@ import { translate as t } from '@services/l10n';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import type Storage from '@nextcloud/browser-storage/dist/storage'; import type Storage from '@nextcloud/browser-storage/dist/storage';
import type { IConfig } from '@types'; import type { IConfig } from '@typings';
class StaticConfig { class StaticConfig {
private config: IConfig | null = null; private config: IConfig | null = null;

View File

@ -1,5 +1,5 @@
import { loadState } from '@nextcloud/initial-state'; import { loadState } from '@nextcloud/initial-state';
import type { IPhoto } from '@types'; import type { IPhoto } from '@typings';
/** Global constants */ /** Global constants */
export const constants = Object.freeze({ export const constants = Object.freeze({

View File

@ -1,6 +1,6 @@
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'; import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus';
import type { FragmentName, Fragment } from './fragment'; import type { FragmentName, Fragment } from './fragment';
import type { IConfig, IPhoto } from '@types'; import type { IConfig, IPhoto } from '@typings';
export type BusEvent = { export type BusEvent = {
/** Open/close the navigation drawer */ /** Open/close the navigation drawer */

View File

@ -4,7 +4,7 @@ import { constants as c } from './const';
import { API } from '@services/API'; import { API } from '@services/API';
import * as nativex from '@native'; import * as nativex from '@native';
import type { IImageInfo, IPhoto } from '@types'; import type { IImageInfo, IPhoto } from '@typings';
/** /**
* Get the current user UID * Get the current user UID

View File

@ -1,312 +0,0 @@
export type IFileInfo = {
/** Same as fileid */
id: number;
/** Database file ID */
fileid: number;
/** Full file name, e.g. /pi/test/Qx0dq7dvEXA.jpg */
filename: string;
/** Original file name, e.g. /files/admin/pi/test/Qx0dq7dvEXA.jpg */
originalFilename: string;
/** Base name of file e.g. Qx0dq7dvEXA.jpg */
basename: string;
};
export type IDay = {
/** Day ID */
dayid: number;
/** Number of photos in this day */
count: number;
/** Rows in the day */
rows?: IRow[];
/** List of photos for this day */
detail?: IPhoto[];
/** This day has some local photos */
haslocal?: boolean;
};
export type IPhoto = {
/** Nextcloud ID of file */
fileid: number;
/**
* Vue key unique to this object.
* 1/ File ID by default.
* 2/ Indexed if duplicates present.
* 3/ Face ID for people views.
*/
key?: string;
/** Etag from server */
etag?: string;
/** Base name of file */
basename?: string;
/** Mime type of file */
mimetype?: string;
/** Bit flags */
flag: number;
/** DayID from server */
dayid: number;
/** Width of full image */
w?: number;
/** Height of full image */
h?: number;
/** Live Photo identifier */
liveid?: string;
/** Grid display width px */
dispW?: number;
/** Grid display height px */
dispH?: number;
/** Grid display X px */
dispX?: number;
/** Grid display Y px */
dispY?: number;
/** Grid display row id (relative to head) */
dispRowNum?: number;
/** Reference to day object */
d?: IDay;
/** Reference to exif object */
imageInfo?: IImageInfo | null;
/** Face detection ID */
faceid?: number;
/** Face dimensions */
facerect?: IFaceRect;
/** Video flag from server */
isvideo?: boolean;
/** Video duration from server */
video_duration?: number;
/** Favorite flag from server */
isfavorite?: boolean;
/** Local file from native */
islocal?: boolean;
/**
* Photo is hidden from timeline; discard immediately.
* This field exists so that we can merge with locals.
*/
ishidden?: boolean;
/** AUID of file (optional, NativeX) */
auid?: string;
/** BUID of file (optional, NativeX) */
buid?: string;
/** Epoch of file (optional, NativeX) */
epoch?: number;
/** Date taken UTC value (lazy fetched) */
datetaken?: number;
/** Stacked RAW photos */
stackraw?: IPhoto[];
};
export interface IImageInfo {
fileid: number;
etag: string;
h: number;
w: number;
datetaken: number;
permissions: string;
basename: string;
mimetype: string;
size: number;
filename?: string;
address?: string;
tags?: { [id: string]: string };
exif?: IExif;
clusters?: {
albums?: IAlbum[];
recognize?: IFace[];
facerecognition?: IFace[];
};
}
export interface IExif {
Rotation?: number;
Orientation?: number;
ImageWidth?: number;
ImageHeight?: number;
Megapixels?: number;
Title?: string;
Description?: string;
Make?: string;
Model?: string;
CreateDate?: string;
DateTimeOriginal?: string;
DateTimeEpoch?: number;
OffsetTimeOriginal?: string;
OffsetTime?: string;
LocationTZID?: string;
ExposureTime?: number;
ShutterSpeed?: number;
ShutterSpeedValue?: number;
Aperture?: number;
ApertureValue?: number;
ISO?: number;
FNumber?: number;
FocalLength?: number;
GPSAltitude?: number;
GPSLatitude?: number;
GPSLongitude?: number;
}
export interface IFolder extends IPhoto {
/** Photos for preview images */
previews?: IPhoto[];
/** Name of folder */
name: string;
}
export type ClusterTypes = 'tags' | 'albums' | 'places' | 'recognize' | 'facerecognition' | 'plus';
export interface ICluster {
/** A unique identifier for the cluster */
cluster_id: number | string;
/** Type of cluster */
cluster_type: ClusterTypes;
/** Number of images in this cluster */
count: number;
/** Name of cluster */
name: string;
/** Display name, e.g. translated */
display_name?: string;
/** Preview loading failed */
previewError?: boolean;
}
export interface IAlbum extends ICluster {
/** ID of album */
album_id: number;
/** Owner of album */
user: string;
/** Display name of album owner */
user_display?: string;
/** Created timestamp */
created: number;
/** Location string */
location: string;
/** File ID of last added photo */
last_added_photo: number;
}
export interface IFace extends ICluster {
/** User for face */
user_id: string;
}
export interface IFaceRect {
w: number;
h: number;
x: number;
y: number;
}
export type IRow = {
/** Vue Recycler identifier */
id?: string;
/** Row ID from head */
num: number;
/** Day ID */
dayId: number;
/** Refrence to day object */
day: IDay;
/** Whether this is a head row */
type: IRowType;
/** [Head only] Title of the header */
name?: string;
/** [Head only] Boolean if the entire day is selected */
selected?: boolean;
/** Main list of photo items */
photos?: IPhoto[];
/** Height in px of the row */
size: number;
/** Count of placeholders to create */
pct?: number;
/** Don't remove dom element */
virtualSticky?: boolean;
};
export type IHeadRow = IRow & {
type: IRowType.HEAD;
selected: boolean;
super?: string;
};
export enum IRowType {
HEAD = 0,
PHOTOS = 1,
}
export type ITick = {
/** Day ID */
dayId: number;
/** Display top position */
topF: number;
/** Display top position (truncated to 1 decimal pt) */
top: number;
/** Y coordinate on recycler */
y: number;
/** Cumulative number of photos before this tick */
count: number;
/** Is a new month */
isMonth: boolean;
/** Text if any (e.g. year) */
text?: string | number;
/** Whether this tick should be shown */
s?: boolean;
/** Key for vue component */
key?: number;
};
export type IConfig = {
// general stuff
version: string;
vod_disable: boolean;
video_default_quality: string;
places_gis: number;
// enabled apps
systemtags_enabled: boolean;
albums_enabled: boolean;
recognize_installed: boolean;
recognize_enabled: boolean;
facerecognition_installed: boolean;
facerecognition_enabled: boolean;
preview_generator_enabled: boolean;
// general settings
timeline_path: string;
enable_top_memories: boolean;
// viewer settings
high_res_cond_default: 'always' | 'zoom' | 'never';
livephoto_autoplay: boolean;
sidebar_filepath: boolean;
// folder settings
folders_path: string;
show_hidden_folders: boolean;
sort_folder_month: boolean;
// album settings
sort_album_month: boolean;
// local settings
square_thumbs: boolean;
high_res_cond: IConfig['high_res_cond_default'] | null;
show_face_rect: boolean;
album_list_sort: 1 | 2;
};
export interface TimelineState {
list: IRow[];
heads: Map<number, IHeadRow>;
}

53
src/typings/cluster.d.ts vendored 100644
View File

@ -0,0 +1,53 @@
declare module '@typings' {
export interface IFolder extends IPhoto {
/** Photos for preview images */
previews?: IPhoto[];
/** Name of folder */
name: string;
}
export type ClusterTypes = 'tags' | 'albums' | 'places' | 'recognize' | 'facerecognition' | 'plus';
export interface ICluster {
/** A unique identifier for the cluster */
cluster_id: number | string;
/** Type of cluster */
cluster_type: ClusterTypes;
/** Number of images in this cluster */
count: number;
/** Name of cluster */
name: string;
/** Display name, e.g. translated */
display_name?: string;
/** Preview loading failed */
previewError?: boolean;
}
export interface IAlbum extends ICluster {
/** ID of album */
album_id: number;
/** Owner of album */
user: string;
/** Display name of album owner */
user_display?: string;
/** Created timestamp */
created: number;
/** Location string */
location: string;
/** File ID of last added photo */
last_added_photo: number;
}
export interface IFace extends ICluster {
/** User for face */
user_id: string;
}
export interface IFaceRect {
w: number;
h: number;
x: number;
y: number;
}
}

41
src/typings/config.d.ts vendored 100644
View File

@ -0,0 +1,41 @@
declare module '@typings' {
export type IConfig = {
// general stuff
version: string;
vod_disable: boolean;
video_default_quality: string;
places_gis: number;
// enabled apps
systemtags_enabled: boolean;
albums_enabled: boolean;
recognize_installed: boolean;
recognize_enabled: boolean;
facerecognition_installed: boolean;
facerecognition_enabled: boolean;
preview_generator_enabled: boolean;
// general settings
timeline_path: string;
enable_top_memories: boolean;
// viewer settings
high_res_cond_default: 'always' | 'zoom' | 'never';
livephoto_autoplay: boolean;
sidebar_filepath: boolean;
// folder settings
folders_path: string;
show_hidden_folders: boolean;
sort_folder_month: boolean;
// album settings
sort_album_month: boolean;
// local settings
square_thumbs: boolean;
high_res_cond: IConfig['high_res_cond_default'] | null;
show_face_rect: boolean;
album_list_sort: 1 | 2;
};
}

161
src/typings/data.d.ts vendored 100644
View File

@ -0,0 +1,161 @@
declare module '@typings' {
export type IFileInfo = {
/** Same as fileid */
id: number;
/** Database file ID */
fileid: number;
/** Full file name, e.g. /pi/test/Qx0dq7dvEXA.jpg */
filename: string;
/** Original file name, e.g. /files/admin/pi/test/Qx0dq7dvEXA.jpg */
originalFilename: string;
/** Base name of file e.g. Qx0dq7dvEXA.jpg */
basename: string;
};
export type IDay = {
/** Day ID */
dayid: number;
/** Number of photos in this day */
count: number;
/** Rows in the day */
rows?: IRow[];
/** List of photos for this day */
detail?: IPhoto[];
/** This day has some local photos */
haslocal?: boolean;
};
export type IPhoto = {
/** Nextcloud ID of file */
fileid: number;
/**
* Vue key unique to this object.
* 1/ File ID by default.
* 2/ Indexed if duplicates present.
* 3/ Face ID for people views.
*/
key?: string;
/** Etag from server */
etag?: string;
/** Base name of file */
basename?: string;
/** Mime type of file */
mimetype?: string;
/** Bit flags */
flag: number;
/** DayID from server */
dayid: number;
/** Width of full image */
w?: number;
/** Height of full image */
h?: number;
/** Live Photo identifier */
liveid?: string;
/** Grid display width px */
dispW?: number;
/** Grid display height px */
dispH?: number;
/** Grid display X px */
dispX?: number;
/** Grid display Y px */
dispY?: number;
/** Grid display row id (relative to head) */
dispRowNum?: number;
/** Reference to day object */
d?: IDay;
/** Reference to exif object */
imageInfo?: IImageInfo | null;
/** Face detection ID */
faceid?: number;
/** Face dimensions */
facerect?: IFaceRect;
/** Video flag from server */
isvideo?: boolean;
/** Video duration from server */
video_duration?: number;
/** Favorite flag from server */
isfavorite?: boolean;
/** Local file from native */
islocal?: boolean;
/**
* Photo is hidden from timeline; discard immediately.
* This field exists so that we can merge with locals.
*/
ishidden?: boolean;
/** AUID of file (optional, NativeX) */
auid?: string;
/** BUID of file (optional, NativeX) */
buid?: string;
/** Epoch of file (optional, NativeX) */
epoch?: number;
/** Date taken UTC value (lazy fetched) */
datetaken?: number;
/** Stacked RAW photos */
stackraw?: IPhoto[];
};
export interface IImageInfo {
fileid: number;
etag: string;
h: number;
w: number;
datetaken: number;
permissions: string;
basename: string;
mimetype: string;
size: number;
filename?: string;
address?: string;
tags?: { [id: string]: string };
exif?: IExif;
clusters?: {
albums?: IAlbum[];
recognize?: IFace[];
facerecognition?: IFace[];
};
}
export interface IExif {
Rotation?: number;
Orientation?: number;
ImageWidth?: number;
ImageHeight?: number;
Megapixels?: number;
Title?: string;
Description?: string;
Make?: string;
Model?: string;
CreateDate?: string;
DateTimeOriginal?: string;
DateTimeEpoch?: number;
OffsetTimeOriginal?: string;
OffsetTime?: string;
LocationTZID?: string;
ExposureTime?: number;
ShutterSpeed?: number;
ShutterSpeedValue?: number;
Aperture?: number;
ApertureValue?: number;
ISO?: number;
FNumber?: number;
FocalLength?: number;
GPSAltitude?: number;
GPSLatitude?: number;
GPSLongitude?: number;
}
}

62
src/typings/timeline.d.ts vendored 100644
View File

@ -0,0 +1,62 @@
declare module '@typings' {
export type ITick = {
/** Day ID */
dayId: number;
/** Display top position */
topF: number;
/** Display top position (truncated to 1 decimal pt) */
top: number;
/** Y coordinate on recycler */
y: number;
/** Cumulative number of photos before this tick */
count: number;
/** Is a new month */
isMonth: boolean;
/** Text if any (e.g. year) */
text?: string | number;
/** Whether this tick should be shown */
s?: boolean;
/** Key for vue component */
key?: number;
};
export interface TimelineState {
list: IRow[];
heads: Map<number, IHeadRow>;
}
/** Type of IRow (0 = head, 1 = photos) */
export type IRowType = 0 | 1;
export type IRow = {
/** Vue Recycler identifier */
id?: string;
/** Row ID from head */
num: number;
/** Day ID */
dayId: number;
/** Refrence to day object */
day: IDay;
/** Whether this is a head row */
type: IRowType;
/** [Head only] Title of the header */
name?: string;
/** [Head only] Boolean if the entire day is selected */
selected?: boolean;
/** Main list of photo items */
photos?: IPhoto[];
/** Height in px of the row */
size: number;
/** Count of placeholders to create */
pct?: number;
/** Don't remove dom element */
virtualSticky?: boolean;
};
export type IHeadRow = IRow & {
type: 0;
selected: boolean;
super?: string;
};
}

View File

@ -15,6 +15,7 @@
"noImplicitAny": true, "noImplicitAny": true,
"esModuleInterop": true, "esModuleInterop": true,
"strictNullChecks": true, "strictNullChecks": true,
"incremental": true,
"paths": { "paths": {
"@services/*": [ "@services/*": [
"./src/services/*" "./src/services/*"
@ -31,9 +32,6 @@
"@native": [ "@native": [
"./src/native", "./src/native",
"./src/native/*" "./src/native/*"
],
"@types": [
"./src/types"
] ]
} }
}, },

View File

@ -139,7 +139,6 @@ module.exports = {
'@components': path.resolve(__dirname, 'src', 'components'), '@components': path.resolve(__dirname, 'src', 'components'),
'@mixins': path.resolve(__dirname, 'src', 'mixins'), '@mixins': path.resolve(__dirname, 'src', 'mixins'),
'@native': path.resolve(__dirname, 'src', 'native'), '@native': path.resolve(__dirname, 'src', 'native'),
'@types$': path.resolve(__dirname, 'src', 'types'),
}, },
}, },
}; };