2023-05-26 16:47:05 +00:00
|
|
|
// Library imports
|
|
|
|
import 'reflect-metadata';
|
|
|
|
import Vue from 'vue';
|
|
|
|
import { generateFilePath } from '@nextcloud/router';
|
|
|
|
import { getRequestToken } from '@nextcloud/auth';
|
|
|
|
|
|
|
|
// Global components
|
|
|
|
import XImg from './components/frame/XImg.vue';
|
|
|
|
import XLoadingIcon from './components/XLoadingIcon.vue';
|
|
|
|
import GlobalMixin from './mixins/GlobalMixin';
|
|
|
|
import VueVirtualScroller from 'vue-virtual-scroller';
|
|
|
|
|
|
|
|
// Locals
|
|
|
|
import router from './router';
|
|
|
|
|
|
|
|
// Types
|
|
|
|
import type { Route } from 'vue-router';
|
|
|
|
import type { IPhoto, IRow } from './types';
|
|
|
|
import type PlyrType from 'plyr';
|
|
|
|
import type videojsType from 'video.js';
|
|
|
|
|
|
|
|
// CSS for components
|
|
|
|
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css';
|
|
|
|
|
|
|
|
// Global CSS
|
2023-08-22 01:17:55 +00:00
|
|
|
import './styles/global.scss';
|
2023-05-26 16:47:05 +00:00
|
|
|
|
|
|
|
// Global exposed variables
|
|
|
|
declare global {
|
2023-10-12 05:56:53 +00:00
|
|
|
var __webpack_nonce__: string;
|
|
|
|
var __webpack_public_path__: string;
|
2023-05-26 16:47:05 +00:00
|
|
|
|
2023-09-30 17:30:59 +00:00
|
|
|
var OC: Nextcloud.Common.OC;
|
|
|
|
var OCP: Nextcloud.Common.OCP;
|
2023-10-12 05:56:53 +00:00
|
|
|
var OCA: {
|
|
|
|
Files?: {
|
|
|
|
Sidebar?: any;
|
|
|
|
App?: any;
|
|
|
|
};
|
|
|
|
Theming?: {
|
|
|
|
name: string;
|
|
|
|
enabledThemes: any[];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
var mode: 'admin' | 'user';
|
|
|
|
var vueroute: () => Route;
|
2023-09-30 17:30:59 +00:00
|
|
|
|
|
|
|
var mModals: {
|
|
|
|
editMetadata: (photos: IPhoto[], sections?: number[]) => void;
|
|
|
|
updateAlbums: (photos: IPhoto[]) => void;
|
|
|
|
sharePhoto: (photo: IPhoto) => void;
|
|
|
|
shareNodeLink: (path: string, immediate?: boolean) => Promise<void>;
|
|
|
|
moveToFolder: (photos: IPhoto[]) => void;
|
|
|
|
moveToFace: (photos: IPhoto[]) => void;
|
|
|
|
showSettings: () => void;
|
|
|
|
};
|
2023-05-26 16:47:05 +00:00
|
|
|
|
|
|
|
var mSidebar: {
|
|
|
|
open: (photo: IPhoto | number, filename?: string, forceNative?: boolean) => void;
|
|
|
|
close: () => void;
|
|
|
|
setTab: (tab: string) => void;
|
|
|
|
getWidth: () => number;
|
|
|
|
};
|
|
|
|
|
|
|
|
var mViewer: {
|
|
|
|
open: (anchorPhoto: IPhoto, rows: IRow[]) => Promise<void>;
|
2023-06-04 17:44:35 +00:00
|
|
|
openStatic(photo: IPhoto, list: IPhoto[], thumbSize?: 256 | 512): Promise<void>;
|
2023-05-26 16:47:05 +00:00
|
|
|
close: () => void;
|
|
|
|
isOpen: () => boolean;
|
|
|
|
};
|
|
|
|
|
|
|
|
var currentViewerPhoto: IPhoto;
|
|
|
|
|
|
|
|
var windowInnerWidth: number; // cache
|
|
|
|
var windowInnerHeight: number; // cache
|
|
|
|
|
|
|
|
var vidjs: typeof videojsType;
|
|
|
|
var Plyr: typeof PlyrType;
|
|
|
|
var videoClientId: string;
|
|
|
|
var videoClientIdPersistent: string;
|
2023-10-12 05:56:53 +00:00
|
|
|
|
|
|
|
var photoswipe: unknown;
|
2023-05-26 16:47:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Allow global access to the router
|
|
|
|
globalThis.vueroute = () => router.currentRoute;
|
|
|
|
|
2023-09-30 17:30:59 +00:00
|
|
|
// Initialize blank arrays
|
|
|
|
globalThis.mModals = {} as any;
|
|
|
|
|
2023-05-26 16:47:05 +00:00
|
|
|
// Cache these for better performance
|
|
|
|
globalThis.windowInnerWidth = window.innerWidth;
|
|
|
|
globalThis.windowInnerHeight = window.innerHeight;
|
|
|
|
|
|
|
|
// CSP config for webpack dynamic chunk loading
|
|
|
|
__webpack_nonce__ = window.btoa(getRequestToken() ?? '');
|
|
|
|
|
|
|
|
// Correct the root of the app for chunk loading
|
|
|
|
// OC.linkTo matches the apps folders
|
|
|
|
// OC.generateUrl ensure the index.php (or not)
|
|
|
|
// We do not want the index.php since we're loading files
|
|
|
|
__webpack_public_path__ = generateFilePath('memories', '', 'js/');
|
|
|
|
|
|
|
|
// Generate client id for this instance
|
|
|
|
// Does not need to be cryptographically secure
|
|
|
|
const getClientId = (): string => Math.random().toString(36).substring(2, 15).padEnd(12, '0');
|
|
|
|
globalThis.videoClientId = getClientId();
|
|
|
|
globalThis.videoClientIdPersistent = localStorage.getItem('videoClientIdPersistent') ?? getClientId();
|
|
|
|
localStorage.setItem('videoClientIdPersistent', globalThis.videoClientIdPersistent);
|
|
|
|
|
|
|
|
// Turn on virtual keyboard support
|
|
|
|
if ('virtualKeyboard' in navigator) {
|
|
|
|
(<any>navigator.virtualKeyboard).overlaysContent = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vue.mixin(GlobalMixin as any);
|
|
|
|
Vue.use(VueVirtualScroller);
|
|
|
|
Vue.component('XImg', XImg);
|
|
|
|
Vue.component('XLoadingIcon', XLoadingIcon);
|