2022-10-28 19:08:34 +00:00
|
|
|
import "reflect-metadata";
|
|
|
|
import Vue from "vue";
|
|
|
|
import VueVirtualScroller from "vue-virtual-scroller";
|
|
|
|
import "vue-virtual-scroller/dist/vue-virtual-scroller.css";
|
2023-02-26 00:35:08 +00:00
|
|
|
import XImg from "./components/frame/XImg.vue";
|
2022-12-10 09:01:44 +00:00
|
|
|
import GlobalMixin from "./mixins/GlobalMixin";
|
2022-08-14 20:54:18 +00:00
|
|
|
|
2022-10-28 19:08:34 +00:00
|
|
|
import App from "./App.vue";
|
2023-04-19 22:26:08 +00:00
|
|
|
import Admin from "./components/admin/AdminMain.vue";
|
2022-10-28 19:08:34 +00:00
|
|
|
import router from "./router";
|
2022-11-24 19:36:41 +00:00
|
|
|
import { generateFilePath } from "@nextcloud/router";
|
|
|
|
import { getRequestToken } from "@nextcloud/auth";
|
2022-08-14 20:54:18 +00:00
|
|
|
|
2023-04-19 02:19:05 +00:00
|
|
|
import type { Route } from "vue-router";
|
|
|
|
import type { IPhoto } from "./types";
|
2023-04-12 14:45:56 +00:00
|
|
|
import type PlyrType from "plyr";
|
|
|
|
import type videojsType from "video.js";
|
|
|
|
|
2022-12-11 04:01:57 +00:00
|
|
|
import "./global.scss";
|
|
|
|
|
2022-10-28 22:46:13 +00:00
|
|
|
// Global exposed variables
|
|
|
|
declare global {
|
2023-04-13 04:46:46 +00:00
|
|
|
var mode: "admin" | "user";
|
|
|
|
|
2022-12-10 17:58:30 +00:00
|
|
|
var vueroute: () => Route;
|
2022-10-29 02:34:04 +00:00
|
|
|
var OC: Nextcloud.v24.OC;
|
|
|
|
var OCP: Nextcloud.v24.OCP;
|
2022-11-08 01:29:58 +00:00
|
|
|
|
2023-03-08 16:56:00 +00:00
|
|
|
var editMetadata: (photos: IPhoto[], sections?: number[]) => void;
|
2023-03-10 23:27:12 +00:00
|
|
|
var sharePhoto: (photo: IPhoto) => void;
|
2023-03-11 01:18:07 +00:00
|
|
|
var shareNodeLink: (path: string, immediate?: boolean) => Promise<void>;
|
2023-03-09 21:47:14 +00:00
|
|
|
|
|
|
|
var mSidebar: {
|
2023-03-16 16:58:43 +00:00
|
|
|
open: (fileid: number, filename?: string, forceNative?: boolean) => void;
|
2023-03-09 21:47:14 +00:00
|
|
|
close: () => void;
|
|
|
|
setTab: (tab: string) => void;
|
2023-03-18 18:39:11 +00:00
|
|
|
getWidth: () => number;
|
2023-03-09 21:47:14 +00:00
|
|
|
};
|
|
|
|
|
2022-11-08 01:29:58 +00:00
|
|
|
var currentViewerPhoto: IPhoto;
|
2022-11-23 11:03:06 +00:00
|
|
|
|
2022-11-23 11:16:45 +00:00
|
|
|
var windowInnerWidth: number; // cache
|
|
|
|
var windowInnerHeight: number; // cache
|
2022-11-24 19:36:41 +00:00
|
|
|
|
|
|
|
var __webpack_nonce__: string;
|
|
|
|
var __webpack_public_path__: string;
|
2022-11-27 20:49:04 +00:00
|
|
|
|
2023-04-12 14:45:56 +00:00
|
|
|
var vidjs: typeof videojsType;
|
|
|
|
var Plyr: typeof PlyrType;
|
2022-11-29 22:09:48 +00:00
|
|
|
var videoClientId: string;
|
2022-11-29 22:36:14 +00:00
|
|
|
var videoClientIdPersistent: string;
|
2022-10-28 22:46:13 +00:00
|
|
|
}
|
2022-11-23 11:16:45 +00:00
|
|
|
|
2022-11-29 22:09:48 +00:00
|
|
|
// Allow global access to the router
|
2022-12-10 17:58:30 +00:00
|
|
|
globalThis.vueroute = () => router.currentRoute;
|
2022-11-23 11:16:45 +00:00
|
|
|
|
2022-11-29 22:09:48 +00:00
|
|
|
// Cache these for better performance
|
2022-11-23 11:16:45 +00:00
|
|
|
globalThis.windowInnerWidth = window.innerWidth;
|
|
|
|
globalThis.windowInnerHeight = window.innerHeight;
|
2022-10-28 22:46:13 +00:00
|
|
|
|
2022-11-24 19:36:41 +00:00
|
|
|
// CSP config for webpack dynamic chunk loading
|
2023-04-19 02:19:05 +00:00
|
|
|
__webpack_nonce__ = window.btoa(getRequestToken() ?? "");
|
2022-11-24 19:36:41 +00:00
|
|
|
|
|
|
|
// 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/");
|
|
|
|
|
2022-11-29 22:09:48 +00:00
|
|
|
// Generate client id for this instance
|
|
|
|
// Does not need to be cryptographically secure
|
2023-04-19 02:19:05 +00:00
|
|
|
const getClientId = (): string =>
|
2022-11-29 22:36:14 +00:00
|
|
|
Math.random().toString(36).substring(2, 15).padEnd(12, "0");
|
|
|
|
globalThis.videoClientId = getClientId();
|
2023-04-19 02:19:05 +00:00
|
|
|
globalThis.videoClientIdPersistent =
|
|
|
|
localStorage.getItem("videoClientIdPersistent") ?? getClientId();
|
|
|
|
localStorage.setItem(
|
|
|
|
"videoClientIdPersistent",
|
|
|
|
globalThis.videoClientIdPersistent
|
2022-11-29 22:36:14 +00:00
|
|
|
);
|
2022-11-29 22:09:48 +00:00
|
|
|
|
2023-04-19 02:19:05 +00:00
|
|
|
Vue.mixin(GlobalMixin as any);
|
2022-11-29 22:09:48 +00:00
|
|
|
Vue.use(VueVirtualScroller);
|
2023-02-26 00:35:08 +00:00
|
|
|
Vue.component("XImg", XImg);
|
2022-11-29 22:09:48 +00:00
|
|
|
|
2022-08-21 04:10:00 +00:00
|
|
|
// https://github.com/nextcloud/photos/blob/156f280c0476c483cb9ce81769ccb0c1c6500a4e/src/main.js
|
|
|
|
// TODO: remove when we have a proper fileinfo standalone library
|
|
|
|
// original scripts are loaded from
|
|
|
|
// https://github.com/nextcloud/server/blob/5bf3d1bb384da56adbf205752be8f840aac3b0c5/lib/private/legacy/template.php#L120-L122
|
2022-10-28 19:08:34 +00:00
|
|
|
window.addEventListener("DOMContentLoaded", () => {
|
|
|
|
if (!globalThis.OCA.Files) {
|
|
|
|
globalThis.OCA.Files = {};
|
|
|
|
}
|
|
|
|
// register unused client for the sidebar to have access to its parser methods
|
|
|
|
Object.assign(
|
|
|
|
globalThis.OCA.Files,
|
2022-10-29 02:36:01 +00:00
|
|
|
{
|
|
|
|
App: {
|
|
|
|
fileList: { filesClient: (<any>globalThis.OC.Files).getClient() },
|
|
|
|
},
|
|
|
|
},
|
2022-10-28 19:08:34 +00:00
|
|
|
globalThis.OCA.Files
|
|
|
|
);
|
|
|
|
});
|
2022-08-21 04:10:00 +00:00
|
|
|
|
2023-04-10 06:24:59 +00:00
|
|
|
let app = null;
|
|
|
|
|
|
|
|
const adminSection = document.getElementById("memories-admin-content");
|
|
|
|
if (adminSection) {
|
|
|
|
app = new Vue({
|
|
|
|
el: "#memories-admin-content",
|
|
|
|
render: (h) => h(Admin),
|
|
|
|
});
|
2023-04-13 04:46:46 +00:00
|
|
|
globalThis.mode = "admin";
|
2023-04-10 06:24:59 +00:00
|
|
|
} else {
|
|
|
|
app = new Vue({
|
|
|
|
el: "#content",
|
|
|
|
router,
|
|
|
|
render: (h) => h(App),
|
|
|
|
});
|
2023-04-13 04:46:46 +00:00
|
|
|
globalThis.mode = "user";
|
2023-04-10 06:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default app;
|