memories/src/main.ts

74 lines
2.1 KiB
TypeScript
Raw Normal View History

2022-10-29 02:34:04 +00:00
/// <reference types="@nextcloud/typings" />
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";
2022-08-14 20:54:18 +00:00
2022-10-28 19:08:34 +00:00
import App from "./App.vue";
import router from "./router";
2022-11-24 19:36:41 +00:00
import { generateFilePath } from "@nextcloud/router";
import { getRequestToken } from "@nextcloud/auth";
2022-11-08 01:29:58 +00:00
import { IPhoto } from "./types";
2022-08-14 20:54:18 +00:00
2022-10-28 22:46:13 +00:00
// Global exposed variables
declare global {
var vuerouter: typeof router;
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
var editDate: (photo: IPhoto) => void;
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
var vidjs: typeof import("video.js").default;
var Plyr: typeof import("plyr");
2022-10-28 22:46:13 +00:00
}
2022-11-23 11:16:45 +00:00
2022-10-28 22:46:13 +00:00
globalThis.vuerouter = router;
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-10-28 19:08:34 +00:00
Vue.use(VueVirtualScroller);
2022-08-14 21:38:29 +00:00
2022-11-24 19:36:41 +00:00
// 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/");
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
2022-08-14 20:54:18 +00:00
export default new Vue({
2022-10-28 19:08:34 +00:00
el: "#content",
router,
render: (h) => h(App),
});