Fixed comp

This commit is contained in:
SamTv12345 2024-07-23 08:19:00 +02:00
parent 99c834651c
commit d70387966b
7 changed files with 33 additions and 31 deletions

View file

@ -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()) {

View file

@ -122,17 +122,18 @@ const generateLocaleIndex = (locales:MapArrayType<string>) => {
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])}}`);

View file

@ -61,7 +61,7 @@ const requestURI = async (url: string, method: string, headers: MapArrayType<any
let mockResponse;
const p = new Promise((resolve) => {
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<any
}
}
},
setHeader: (header, value) => {
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('')]);
},

View file

@ -1,5 +1,5 @@
<%
var settings = require("ep_etherpad-lite/node/utils/Settings");
import settings from 'ep_etherpad-lite/node/utils/Settings'
%>
<!doctype html>
<html>

View file

@ -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'
%>
<!doctype html>
<html translate="no" class="pad <%=pluginUtils.clientPluginNames().join(' '); %> <%=settings.skinVariants%>">

View file

@ -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([

View file

@ -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;