mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
Dropped require-kernel and etherpad-yamsl (#6520)
* Dropped require-kernel and etherpad-yamsl * Removed tests --------- Co-authored-by: SamTv12345 <samtv12345@samtv12345.com>
This commit is contained in:
parent
983b799231
commit
b1139e1aff
8 changed files with 0 additions and 212 deletions
|
@ -164,12 +164,6 @@ importers:
|
||||||
esbuild:
|
esbuild:
|
||||||
specifier: ^0.23.0
|
specifier: ^0.23.0
|
||||||
version: 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:
|
express:
|
||||||
specifier: 4.19.2
|
specifier: 4.19.2
|
||||||
version: 4.19.2
|
version: 4.19.2
|
||||||
|
@ -2524,14 +2518,6 @@ packages:
|
||||||
engines: {node: '>=18.0.0'}
|
engines: {node: '>=18.0.0'}
|
||||||
hasBin: true
|
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:
|
express-rate-limit@7.3.1:
|
||||||
resolution: {integrity: sha512-BbaryvkY4wEgDqLgD18/NSy2lDO2jTuT9Y8c1Mpx0X63Yz0sYd5zN6KPe7UvpuSVvV33T6RaE1o1IVZQjHMYgw==}
|
resolution: {integrity: sha512-BbaryvkY4wEgDqLgD18/NSy2lDO2jTuT9Y8c1Mpx0X63Yz0sYd5zN6KPe7UvpuSVvV33T6RaE1o1IVZQjHMYgw==}
|
||||||
engines: {node: '>= 16'}
|
engines: {node: '>= 16'}
|
||||||
|
@ -6740,12 +6726,6 @@ snapshots:
|
||||||
- supports-color
|
- supports-color
|
||||||
- utf-8-validate
|
- 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):
|
express-rate-limit@7.3.1(express@4.19.2):
|
||||||
dependencies:
|
dependencies:
|
||||||
express: 4.19.2
|
express: 4.19.2
|
||||||
|
|
|
@ -154,8 +154,6 @@ const handleLiveReload = async (args: any, padString: string, timeSliderString:
|
||||||
isReadOnly
|
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', {
|
const content = eejs.require('ep_etherpad-lite/templates/pad.html', {
|
||||||
req,
|
req,
|
||||||
toolbar,
|
toolbar,
|
||||||
|
@ -185,8 +183,6 @@ const handleLiveReload = async (args: any, padString: string, timeSliderString:
|
||||||
isReadOnly
|
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', {
|
const content = eejs.require('ep_etherpad-lite/templates/timeslider.html', {
|
||||||
req,
|
req,
|
||||||
toolbar,
|
toolbar,
|
||||||
|
@ -308,8 +304,6 @@ exports.expressCreateServer = async (hookName: string, args: any, cb: Function)
|
||||||
isReadOnly
|
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', {
|
const content = eejs.require('ep_etherpad-lite/templates/pad.html', {
|
||||||
req,
|
req,
|
||||||
toolbar,
|
toolbar,
|
||||||
|
|
|
@ -9,7 +9,6 @@ const path = require('path');
|
||||||
const plugins = require('../../../static/js/pluginfw/plugin_defs');
|
const plugins = require('../../../static/js/pluginfw/plugin_defs');
|
||||||
const settings = require('../../utils/Settings');
|
const settings = require('../../utils/Settings');
|
||||||
import CachingMiddleware from '../../utils/caching_middleware';
|
import CachingMiddleware from '../../utils/caching_middleware';
|
||||||
const Yajsml = require('etherpad-yajsml');
|
|
||||||
|
|
||||||
// Rewrite tar to include modules with no extensions and proper rooted paths.
|
// Rewrite tar to include modules with no extensions and proper rooted paths.
|
||||||
const getTar = async () => {
|
const getTar = async () => {
|
||||||
|
@ -43,24 +42,6 @@ exports.expressPreSession = async (hookName:string, {app}:any) => {
|
||||||
// file-specific hacks for ace/require-kernel/etc.
|
// file-specific hacks for ace/require-kernel/etc.
|
||||||
app.all('/static/:filename(*)', minify.minify);
|
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
|
// serve plugin definitions
|
||||||
// not very static, but served here so that client can do
|
// not very static, but served here so that client can do
|
||||||
// require("pluginfw/static/js/plugin-definitions.js");
|
// require("pluginfw/static/js/plugin-definitions.js");
|
||||||
|
|
|
@ -25,7 +25,6 @@ const settings = require('./Settings');
|
||||||
const fs = require('fs').promises;
|
const fs = require('fs').promises;
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const plugins = require('../../static/js/pluginfw/plugin_defs');
|
const plugins = require('../../static/js/pluginfw/plugin_defs');
|
||||||
const RequireKernel = require('etherpad-require-kernel');
|
|
||||||
const mime = require('mime-types');
|
const mime = require('mime-types');
|
||||||
const Threads = require('threads');
|
const Threads = require('threads');
|
||||||
const log4js = require('log4js');
|
const log4js = require('log4js');
|
||||||
|
@ -217,12 +216,6 @@ const statFile = async (filename, dirStatLimit) => {
|
||||||
|
|
||||||
if (dirStatLimit < 1 || filename === '' || filename === '/') {
|
if (dirStatLimit < 1 || filename === '' || filename === '/') {
|
||||||
return [null, false];
|
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 {
|
} else {
|
||||||
let stats;
|
let stats;
|
||||||
try {
|
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) => {
|
const getFileCompressed = async (filename, contentType) => {
|
||||||
let content = await getFile(filename);
|
let content = await getFile(filename);
|
||||||
if (!content || !settings.minify) {
|
if (!content || !settings.minify) {
|
||||||
|
@ -319,7 +282,6 @@ const getFileCompressed = async (filename, contentType) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getFile = async (filename) => {
|
const getFile = async (filename) => {
|
||||||
if (filename === 'js/require-kernel.js') return requireDefinition();
|
|
||||||
return await fs.readFile(path.resolve(ROOT_DIR, filename));
|
return await fs.readFile(path.resolve(ROOT_DIR, filename));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,6 @@
|
||||||
"cross-spawn": "^7.0.3",
|
"cross-spawn": "^7.0.3",
|
||||||
"ejs": "^3.1.10",
|
"ejs": "^3.1.10",
|
||||||
"esbuild": "^0.23.0",
|
"esbuild": "^0.23.0",
|
||||||
"etherpad-require-kernel": "^1.0.16",
|
|
||||||
"etherpad-yajsml": "0.0.12",
|
|
||||||
"express": "4.19.2",
|
"express": "4.19.2",
|
||||||
"express-rate-limit": "^7.3.1",
|
"express-rate-limit": "^7.3.1",
|
||||||
"fast-deep-equal": "^3.1.3",
|
"fast-deep-equal": "^3.1.3",
|
||||||
|
|
|
@ -1,125 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
import {MapArrayType} from "../../../node/types/MapType";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* caching_middleware is responsible for serving everything under path `/javascripts/`
|
|
||||||
* That includes packages as defined in `src/node/utils/tar.json` and probably also plugin code
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
const common = require('../common');
|
|
||||||
import {strict as assert} from 'assert';
|
|
||||||
import queryString from 'querystring';
|
|
||||||
const settings = require('../../../node/utils/Settings');
|
|
||||||
import {it, describe} from 'mocha'
|
|
||||||
|
|
||||||
let agent: any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hack! Returns true if the resource is not plaintext
|
|
||||||
* The file should start with the callback method, so we need the
|
|
||||||
* URL.
|
|
||||||
*
|
|
||||||
* @param {string} fileContent the response body
|
|
||||||
* @param {URL} resource resource URI
|
|
||||||
* @returns {boolean} if it is plaintext
|
|
||||||
*/
|
|
||||||
const isPlaintextResponse = (fileContent: string, resource:string): boolean => {
|
|
||||||
// callback=require.define&v=1234
|
|
||||||
const query = (new URL(resource, 'http://localhost')).search.slice(1);
|
|
||||||
// require.define
|
|
||||||
const jsonp = queryString.parse(query).callback;
|
|
||||||
|
|
||||||
// returns true if the first letters in fileContent equal the content of `jsonp`
|
|
||||||
return fileContent.substring(0, jsonp!.length) === jsonp;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
type RequestType = {
|
|
||||||
_shouldUnzip: () => boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A hack to disable `superagent`'s auto unzip functionality
|
|
||||||
*
|
|
||||||
* @param {Request} request
|
|
||||||
*/
|
|
||||||
const disableAutoDeflate = (request: RequestType) => {
|
|
||||||
request._shouldUnzip = () => false;
|
|
||||||
};
|
|
||||||
|
|
||||||
describe(__filename, function () {
|
|
||||||
const backups:MapArrayType<any> = {};
|
|
||||||
const fantasyEncoding = 'brainwaves'; // non-working encoding until https://github.com/visionmedia/superagent/pull/1560 is resolved
|
|
||||||
const packages = [
|
|
||||||
'/javascripts/lib/ep_etherpad-lite/static/js/ace2_common.js?callback=require.define',
|
|
||||||
'/javascripts/lib/ep_etherpad-lite/static/js/ace2_inner.js?callback=require.define',
|
|
||||||
'/javascripts/lib/ep_etherpad-lite/static/js/pad.js?callback=require.define',
|
|
||||||
'/javascripts/lib/ep_etherpad-lite/static/js/timeslider.js?callback=require.define',
|
|
||||||
];
|
|
||||||
|
|
||||||
before(async function () {
|
|
||||||
agent = await common.init();
|
|
||||||
backups.settings = {};
|
|
||||||
backups.settings.minify = settings.minify;
|
|
||||||
});
|
|
||||||
after(async function () {
|
|
||||||
Object.assign(settings, backups.settings);
|
|
||||||
});
|
|
||||||
|
|
||||||
for (const minify of [false, true]) {
|
|
||||||
context(`when minify is ${minify}`, function () {
|
|
||||||
before(async function () {
|
|
||||||
settings.minify = minify;
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('gets packages uncompressed without Accept-Encoding gzip', function () {
|
|
||||||
for (const resource of packages) {
|
|
||||||
it(resource, async function () {
|
|
||||||
await agent.get(resource)
|
|
||||||
.set('Accept-Encoding', fantasyEncoding)
|
|
||||||
.use(disableAutoDeflate)
|
|
||||||
.expect(200)
|
|
||||||
.expect('Content-Type', /application\/javascript/)
|
|
||||||
.expect((res:any) => {
|
|
||||||
assert.equal(res.header['content-encoding'], undefined);
|
|
||||||
assert(isPlaintextResponse(res.text, resource));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('gets packages compressed with Accept-Encoding gzip', function () {
|
|
||||||
for (const resource of packages) {
|
|
||||||
it(resource, async function () {
|
|
||||||
await agent.get(resource)
|
|
||||||
.set('Accept-Encoding', 'gzip')
|
|
||||||
.use(disableAutoDeflate)
|
|
||||||
.expect(200)
|
|
||||||
.expect('Content-Type', /application\/javascript/)
|
|
||||||
.expect('Content-Encoding', 'gzip')
|
|
||||||
.expect((res:any) => {
|
|
||||||
assert(!isPlaintextResponse(res.text, resource));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not cache content-encoding headers', async function () {
|
|
||||||
await agent.get(packages[0])
|
|
||||||
.set('Accept-Encoding', fantasyEncoding)
|
|
||||||
.expect(200)
|
|
||||||
.expect((res:any) => assert.equal(res.header['content-encoding'], undefined));
|
|
||||||
await agent.get(packages[0])
|
|
||||||
.set('Accept-Encoding', 'gzip')
|
|
||||||
.expect(200)
|
|
||||||
.expect('Content-Encoding', 'gzip');
|
|
||||||
await agent.get(packages[0])
|
|
||||||
.set('Accept-Encoding', fantasyEncoding)
|
|
||||||
.expect(200)
|
|
||||||
.expect((res:any) => assert.equal(res.header['content-encoding'], undefined));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -14,7 +14,6 @@
|
||||||
<div id="iframe-container"></div>
|
<div id="iframe-container"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="../../static/js/require-kernel.js"></script>
|
|
||||||
<script src="../../static/js/vendors/jquery.js"></script>
|
<script src="../../static/js/vendors/jquery.js"></script>
|
||||||
<script src="lib/sendkeys.js"></script>
|
<script src="lib/sendkeys.js"></script>
|
||||||
<script src="../../static/js/vendors/browser.js"></script>
|
<script src="../../static/js/vendors/browser.js"></script>
|
||||||
|
|
|
@ -187,7 +187,6 @@ $(() => (async () => {
|
||||||
// mutates the module definition function to temporarily replace Mocha's functions with
|
// 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
|
// 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
|
// 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
|
// Per-module log of attempted Mocha function calls. Key is module path, value is an array of
|
||||||
// [functionName, argsArray] arrays.
|
// [functionName, argsArray] arrays.
|
||||||
|
|
Loading…
Reference in a new issue