From d70387966b8a0c70eba22878e4ad41cb5074fbb9 Mon Sep 17 00:00:00 2001 From: SamTv12345 Date: Tue, 23 Jul 2024 08:19:00 +0200 Subject: [PATCH] Fixed comp --- src/node/hooks/express/specialpages.ts | 10 ++++++---- src/node/hooks/i18n.ts | 7 ++++--- src/node/utils/Minify.ts | 8 ++++---- src/templates/index.html | 2 +- src/templates/pad.html | 7 +++---- src/templates/padBootstrap.ts | 22 +++++++++++----------- src/templates/timeSliderBootstrap.ts | 8 ++++---- 7 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/node/hooks/express/specialpages.ts b/src/node/hooks/express/specialpages.ts index ad25ca8d0..304c5fd0e 100644 --- a/src/node/hooks/express/specialpages.ts +++ b/src/node/hooks/express/specialpages.ts @@ -14,12 +14,12 @@ import {pluginDefs} from '../../../static/js/pluginfw/plugin_defs'; import {build, buildSync} from 'esbuild' let ioI: { sockets: { sockets: any[]; }; } | null = null -exports.socketio = (hookName: string, {io}: any) => { +export const socketio = (hookName: string, {io}: any) => { ioI = io } -exports.expressPreSession = async (hookName:string, {app}:any) => { +export const expressPreSession = async (hookName:string, {app}:any) => { // This endpoint is intended to conform to: // https://www.ietf.org/archive/id/draft-inadarei-api-health-check-06.html app.get('/health', (req:any, res:any) => { @@ -227,7 +227,7 @@ const convertTypescriptWatched = (content: string, cb: (output:string, hash: str }) } -exports.expressCreateServer = async (hookName: string, args: any, cb: Function) => { +export const expressCreateServer = async (hookName: string, args: any, cb: Function) => { // serve index.html under / args.app.get('/', (req: any, res: any) => { res.send(requireP('ep_etherpad-lite/templates/index.html', {req})); @@ -235,7 +235,8 @@ exports.expressCreateServer = async (hookName: string, args: any, cb: Function) const padString = requireP('ep_etherpad-lite/templates/padBootstrap.ts', { - pluginModules: (() => { + // @ts-ignore + pluginModules: (() => { const pluginModules = new Set(); for (const part of pluginDefs.getParts()) { for (const [, hookFnName] of Object.entries(part.client_hooks || {})) { @@ -249,6 +250,7 @@ exports.expressCreateServer = async (hookName: string, args: any, cb: Function) }) const timeSliderString = requireP('ep_etherpad-lite/templates/timeSliderBootstrap.ts', { + // @ts-ignore pluginModules: (() => { const pluginModules = new Set(); for (const part of pluginDefs.getParts()) { diff --git a/src/node/hooks/i18n.ts b/src/node/hooks/i18n.ts index e18be54ea..e5112defe 100644 --- a/src/node/hooks/i18n.ts +++ b/src/node/hooks/i18n.ts @@ -122,17 +122,18 @@ const generateLocaleIndex = (locales:MapArrayType) => { return JSON.stringify(result); }; +export let availableLangs: any -exports.expressPreSession = async (hookName:string, {app}:any) => { +export const expressPreSession = async (hookName:string, {app}:any) => { // regenerate locales on server restart const locales = getAllLocales(); const localeIndex = generateLocaleIndex(locales); - exports.availableLangs = getAvailableLangs(locales); + availableLangs = getAvailableLangs(locales); app.get('/locales/:locale', (req:any, res:any) => { // works with /locale/en and /locale/en.json requests const locale = req.params.locale.split('.')[0]; - if (Object.prototype.hasOwnProperty.call(exports.availableLangs, locale)) { + if (Object.prototype.hasOwnProperty.call(availableLangs, locale)) { res.setHeader('Cache-Control', `public, max-age=${settings.maxAge}`); res.setHeader('Content-Type', 'application/json; charset=utf-8'); res.send(`{"${locale}":${JSON.stringify(locales[locale])}}`); diff --git a/src/node/utils/Minify.ts b/src/node/utils/Minify.ts index e36f45334..b88ac05ad 100644 --- a/src/node/utils/Minify.ts +++ b/src/node/utils/Minify.ts @@ -61,7 +61,7 @@ const requestURI = async (url: string, method: string, headers: MapArrayType { mockResponse = { - writeHead: (_status, _headers) => { + writeHead: (_status: number, _headers: { [x: string]: any; }) => { status = _status; for (const header in _headers) { if (Object.prototype.hasOwnProperty.call(_headers, header)) { @@ -69,16 +69,16 @@ const requestURI = async (url: string, method: string, headers: MapArrayType { + setHeader: (header: string, value: { toString: () => any; }) => { headers[header.toLowerCase()] = value.toString(); }, header: (header: string, value: string) => { headers[header.toLowerCase()] = value.toString(); }, - write: (_content) => { + write: (_content: string) => { _content && content.push(_content); }, - end: (_content) => { + end: (_content: string) => { _content && content.push(_content); resolve([status, headers, content.join('')]); }, diff --git a/src/templates/index.html b/src/templates/index.html index 39a0997ce..e58e8384e 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -1,5 +1,5 @@ <% - var settings = require("ep_etherpad-lite/node/utils/Settings"); +import settings from 'ep_etherpad-lite/node/utils/Settings' %> diff --git a/src/templates/pad.html b/src/templates/pad.html index 08437b628..17a523e83 100644 --- a/src/templates/pad.html +++ b/src/templates/pad.html @@ -1,8 +1,7 @@ <% - var settings = require("ep_etherpad-lite/node/utils/Settings") - , langs = require("ep_etherpad-lite/node/hooks/i18n").availableLangs - , pluginUtils = require('ep_etherpad-lite/static/js/pluginfw/shared') - ; + import settings from 'ep_etherpad-lite/node/utils/Settings' + import langs from 'ep_etherpad-lite/node/hooks/i18n' + import {pluginUtils} from 'ep_etherpad-lite/static/js/pluginfw/shared' %> diff --git a/src/templates/padBootstrap.ts b/src/templates/padBootstrap.ts index cec25a601..28927f537 100644 --- a/src/templates/padBootstrap.ts +++ b/src/templates/padBootstrap.ts @@ -1,6 +1,6 @@ -import browser from '../static/js/vendors/browser' -import {padeditbar} from '../static/js/pad_editbar' -import {padImpExp} from '../static/js/pad_impexp' +import browser from 'ep_etherpad-lite/static/js/vendors/browser' +import {padeditbar} from 'ep_etherpad-lite/static/js/pad_editbar' +import {padImpExp} from 'ep_etherpad-lite/static/js/pad_impexp' (async () => { @@ -17,20 +17,20 @@ import {padImpExp} from '../static/js/pad_impexp' //window.require.resolveTmp = require.resolve('ep_etherpad-lite/static/js/pad_cookie'); const basePath = new URL('..', window.location.href).pathname; - window.$ = window.jQuery = require('../../src/static/js/vendors/jquery'); + window.$ = window.jQuery = require('ep_etherpad-lite/static/js/vendors/jquery'); window.browser = browser; - const pad = require('../../src/static/js/pad'); + const pad = require('ep_etherpad-lite/static/js/pad'); pad.baseURL = basePath; - window.plugins = require('../../src/static/js/pluginfw/client_plugins'); - const hooks = require('../../src/static/js/pluginfw/hooks'); + window.plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins'); + const hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks'); // TODO: These globals shouldn't exist. window.pad = pad.pad; - window.chat = require('../../src/static/js/chat').chat; + window.chat = require('ep_etherpad-lite/static/js/chat').chat; window.padeditbar = padeditbar; - window.padimpexp = padimpexp; - await import('../../src/static/js/skin_variants') - await import('../../src/static/js/basic_error_handler') + window.padimpexp = padImpExp; + await import('ep_etherpad-lite/static/js/skin_variants') + await import('ep_etherpad-lite/static/js/basic_error_handler') window.plugins.baseURL = basePath; await window.plugins.update(new Map([ diff --git a/src/templates/timeSliderBootstrap.ts b/src/templates/timeSliderBootstrap.ts index b6f0d5aea..a973879c1 100644 --- a/src/templates/timeSliderBootstrap.ts +++ b/src/templates/timeSliderBootstrap.ts @@ -1,9 +1,9 @@ // @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt import {setBaseURl} from "ep_etherpad-lite/static/js/timeslider"; -import {padeditbar as padbar} from '../static/js/pad_editbar' -import {padImpExp as padExp} from '../static/js/pad_impexp' - +import {padeditbar as padbar} from 'ep_etherpad-lite/static/js/pad_editbar' +import {padImpExp as padExp} from 'ep_etherpad-lite/static/js/pad_impexp' +import browser from "ep_etherpad-lite/static/js/vendors/browser"; window.clientVars = { // This is needed to fetch /pluginfw/plugin-definitions.json, which happens before the // server sends the CLIENT_VARS message. @@ -21,7 +21,7 @@ import * as timeSlider from 'ep_etherpad-lite/static/js/timeslider' window.$ = window.jQuery = require('ep_etherpad-lite/static/js/vendors/jquery'); // Expose jQuery #HACK require('ep_etherpad-lite/static/js/vendors/gritter') - window.browser = require('src/static/js/vendors/browser'); + window.browser = browser; window.plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins'); const socket = timeSlider.socket;