From b72c5e68831f3dbe7b807961c8d0660f63df85f9 Mon Sep 17 00:00:00 2001 From: SamTv12345 Date: Thu, 18 Jul 2024 09:35:54 +0200 Subject: [PATCH] Dropped require-kernel and etherpad-yamsl --- pnpm-lock.yaml | 20 -------------- src/node/hooks/express/specialpages.ts | 6 ---- src/node/hooks/express/static.ts | 19 ------------- src/node/utils/Minify.js | 38 -------------------------- src/package.json | 2 -- 5 files changed, 85 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5f2324f6d..eca4dceb3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -164,12 +164,6 @@ importers: esbuild: specifier: ^0.23.0 version: 0.23.0 - etherpad-require-kernel: - specifier: ^1.0.16 - version: 1.0.16 - etherpad-yajsml: - specifier: 0.0.12 - version: 0.0.12 express: specifier: 4.19.2 version: 4.19.2 @@ -2524,14 +2518,6 @@ packages: engines: {node: '>=18.0.0'} hasBin: true - etherpad-require-kernel@1.0.16: - resolution: {integrity: sha512-Zym7acX8tsB0mjZmQgcHnx9W+8djpFGeSA6/LhbKEGALaoaKBxCH/QQwJmsqfbvfYQBEg+NbUfDp9gD8QVjhsg==} - engines: {node: '>=12.13.0'} - - etherpad-yajsml@0.0.12: - resolution: {integrity: sha512-lVCqsZYpFsuIz417h+O83I7eadNXJ3MnQavriFa52/KTwj6xPAzEYr0PvH7KTxcqyAFtW7ItoTNVXe2h7zGxlw==} - engines: {node: '>=12.13.0'} - express-rate-limit@7.3.1: resolution: {integrity: sha512-BbaryvkY4wEgDqLgD18/NSy2lDO2jTuT9Y8c1Mpx0X63Yz0sYd5zN6KPe7UvpuSVvV33T6RaE1o1IVZQjHMYgw==} engines: {node: '>= 16'} @@ -6740,12 +6726,6 @@ snapshots: - supports-color - utf-8-validate - etherpad-require-kernel@1.0.16: {} - - etherpad-yajsml@0.0.12: - optionalDependencies: - mime: 1.6.0 - express-rate-limit@7.3.1(express@4.19.2): dependencies: express: 4.19.2 diff --git a/src/node/hooks/express/specialpages.ts b/src/node/hooks/express/specialpages.ts index 3677bbfa6..90bb4e2fe 100644 --- a/src/node/hooks/express/specialpages.ts +++ b/src/node/hooks/express/specialpages.ts @@ -154,8 +154,6 @@ const handleLiveReload = async (args: any, padString: string, timeSliderString: isReadOnly }); - // can be removed when require-kernel is dropped - res.header('Feature-Policy', 'sync-xhr \'self\''); const content = eejs.require('ep_etherpad-lite/templates/pad.html', { req, toolbar, @@ -185,8 +183,6 @@ const handleLiveReload = async (args: any, padString: string, timeSliderString: isReadOnly }); - // can be removed when require-kernel is dropped - res.header('Feature-Policy', 'sync-xhr \'self\''); const content = eejs.require('ep_etherpad-lite/templates/timeslider.html', { req, toolbar, @@ -308,8 +304,6 @@ exports.expressCreateServer = async (hookName: string, args: any, cb: Function) isReadOnly }); - // can be removed when require-kernel is dropped - res.header('Feature-Policy', 'sync-xhr \'self\''); const content = eejs.require('ep_etherpad-lite/templates/pad.html', { req, toolbar, diff --git a/src/node/hooks/express/static.ts b/src/node/hooks/express/static.ts index 1d9ba01e9..18ff8c76a 100644 --- a/src/node/hooks/express/static.ts +++ b/src/node/hooks/express/static.ts @@ -9,7 +9,6 @@ const path = require('path'); const plugins = require('../../../static/js/pluginfw/plugin_defs'); const settings = require('../../utils/Settings'); import CachingMiddleware from '../../utils/caching_middleware'; -const Yajsml = require('etherpad-yajsml'); // Rewrite tar to include modules with no extensions and proper rooted paths. const getTar = async () => { @@ -43,24 +42,6 @@ exports.expressPreSession = async (hookName:string, {app}:any) => { // file-specific hacks for ace/require-kernel/etc. app.all('/static/:filename(*)', minify.minify); - // Setup middleware that will package JavaScript files served by minify for - // CommonJS loader on the client-side. - // Hostname "invalid.invalid" is a dummy value to allow parsing as a URI. - const jsServer = new (Yajsml.Server)({ - rootPath: 'javascripts/src/', - rootURI: 'http://invalid.invalid/static/js/', - libraryPath: 'javascripts/lib/', - libraryURI: 'http://invalid.invalid/static/plugins/', - requestURIs: minify.requestURIs, // Loop-back is causing problems, this is a workaround. - }); - - const StaticAssociator = Yajsml.associators.StaticAssociator; - const associations = Yajsml.associators.associationsForSimpleMapping(await getTar()); - const associator = new StaticAssociator(associations); - jsServer.setAssociator(associator); - - app.use(jsServer.handle.bind(jsServer)); - // serve plugin definitions // not very static, but served here so that client can do // require("pluginfw/static/js/plugin-definitions.js"); diff --git a/src/node/utils/Minify.js b/src/node/utils/Minify.js index 2af200e1a..a151a4d7a 100644 --- a/src/node/utils/Minify.js +++ b/src/node/utils/Minify.js @@ -25,7 +25,6 @@ const settings = require('./Settings'); const fs = require('fs').promises; const path = require('path'); const plugins = require('../../static/js/pluginfw/plugin_defs'); -const RequireKernel = require('etherpad-require-kernel'); const mime = require('mime-types'); const Threads = require('threads'); const log4js = require('log4js'); @@ -217,12 +216,6 @@ const statFile = async (filename, dirStatLimit) => { if (dirStatLimit < 1 || filename === '' || filename === '/') { return [null, false]; - } else if (filename === 'js/ace.js') { - // Sometimes static assets are inlined into this file, so we have to stat - // everything. - return [await lastModifiedDateOfEverything(), true]; - } else if (filename === 'js/require-kernel.js') { - return [_requireLastModified, true]; } else { let stats; try { @@ -239,36 +232,6 @@ const statFile = async (filename, dirStatLimit) => { } }; -const lastModifiedDateOfEverything = async () => { - const folders2check = [path.join(ROOT_DIR, 'js/'), path.join(ROOT_DIR, 'css/')]; - let latestModification = null; - // go through this two folders - await Promise.all(folders2check.map(async (dir) => { - // read the files in the folder - const files = await fs.readdir(dir); - - // we wanna check the directory itself for changes too - files.push('.'); - - // go through all files in this folder - await Promise.all(files.map(async (filename) => { - // get the stat data of this file - const stats = await fs.stat(path.join(dir, filename)); - - // compare the modification time to the highest found - if (latestModification == null || stats.mtime > latestModification) { - latestModification = stats.mtime; - } - })); - })); - return latestModification; -}; - -// This should be provided by the module, but until then, just use startup -// time. -const _requireLastModified = new Date(); -const requireDefinition = () => `var require = ${RequireKernel.kernelSource};\n`; - const getFileCompressed = async (filename, contentType) => { let content = await getFile(filename); if (!content || !settings.minify) { @@ -319,7 +282,6 @@ const getFileCompressed = async (filename, contentType) => { }; const getFile = async (filename) => { - if (filename === 'js/require-kernel.js') return requireDefinition(); return await fs.readFile(path.resolve(ROOT_DIR, filename)); }; diff --git a/src/package.json b/src/package.json index ffd243e96..10806bae7 100644 --- a/src/package.json +++ b/src/package.json @@ -38,8 +38,6 @@ "cross-spawn": "^7.0.3", "ejs": "^3.1.10", "esbuild": "^0.23.0", - "etherpad-require-kernel": "^1.0.16", - "etherpad-yajsml": "0.0.12", "express": "4.19.2", "express-rate-limit": "^7.3.1", "fast-deep-equal": "^3.1.3",