Skip to content

Commit

Permalink
Dropped require-kernel and etherpad-yamsl (#6520)
Browse files Browse the repository at this point in the history
* Dropped require-kernel and etherpad-yamsl

* Removed tests

---------

Co-authored-by: SamTv12345 <samtv12345@samtv12345.com>
  • Loading branch information
SamTV12345 and SamTv12345 committed Jul 18, 2024
1 parent 983b799 commit b1139e1
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 212 deletions.
20 changes: 0 additions & 20 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions src/node/hooks/express/specialpages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
19 changes: 0 additions & 19 deletions src/node/hooks/express/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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");
Expand Down
38 changes: 0 additions & 38 deletions src/node/utils/Minify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down Expand Up @@ -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));
};

Expand Down
2 changes: 0 additions & 2 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
125 changes: 0 additions & 125 deletions src/tests/backend/specs/caching_middleware.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/tests/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<div id="iframe-container"></div>
</div>

<script src="../../static/js/require-kernel.js"></script>
<script src="../../static/js/vendors/jquery.js"></script>
<script src="lib/sendkeys.js"></script>
<script src="../../static/js/vendors/browser.js"></script>
Expand Down
1 change: 0 additions & 1 deletion src/tests/frontend/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ $(() => (async () => {
// mutates the module definition function to temporarily replace Mocha's functions with
// placeholders. The placeholders make it possible to defer the actual Mocha function calls until
// after the modules are all loaded in parallel. require.setGlobalKeyPath() is used to coax
// require-kernel into using the wrapper define() method instead of require.define().

// Per-module log of attempted Mocha function calls. Key is module path, value is an array of
// [functionName, argsArray] arrays.
Expand Down

0 comments on commit b1139e1

Please sign in to comment.