Convert require to import: timeslider (dynamic), vendors/jquery

- Convert dynamic requires to dynamic imports for circular dependency handling
- Make timeslider.init async to support dynamic imports
- Update exports references to use module scope or window
- Add ESM export default for jquery library
- Keep CommonJS compatibility for jquery

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
SamTV12345 2026-04-26 14:32:18 +02:00
parent f95e38eba6
commit 50bf17c977
2 changed files with 12 additions and 12 deletions

View File

@ -88,7 +88,7 @@ const init = () => {
Cookies.set(`${cp}token`, token, {expires: 60});
}
socket = socketio.connect(exports.baseURL, '/', {query: {padId}});
socket = socketio.connect(baseURL, '/', {query: {padId}});
// send the ready message once we're connected
socket.on('connect', () => {
@ -120,8 +120,8 @@ const init = () => {
window.location.reload();
});
exports.socket = socket; // make the socket available
exports.BroadcastSlider = BroadcastSlider; // Make the slider available
window.socket = socket; // make the socket available
window.BroadcastSlider = BroadcastSlider; // Make the slider available
hooks.aCallAll('postTimesliderInit');
});
@ -141,7 +141,7 @@ const sendSocketMsg = (type, data) => {
const fireWhenAllScriptsAreLoaded = [];
const handleClientVars = (message) => {
const handleClientVars = async (message) => {
// save the client Vars
window.clientVars = message.data;
cp = (window as any).clientVars?.cookiePrefix || '';
@ -160,16 +160,14 @@ const handleClientVars = (message) => {
})
}
// load all script that doesn't work without the clientVars
BroadcastSlider = require('./broadcast_slider')
.loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded);
// load all script that doesn't work without the clientVars
BroadcastSlider = (await import('./broadcast_slider.js')).loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded);
require('./broadcast_revisions').loadBroadcastRevisionsJS();
changesetLoader = require('./broadcast')
.loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, BroadcastSlider);
(await import('./broadcast_revisions.js')).loadBroadcastRevisionsJS();
changesetLoader = (await import('./broadcast.js')).loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, BroadcastSlider);
// initialize export ui
require('./pad_impexp').padimpexp.init();
// initialize export ui
(await import('./pad_impexp.js')).padimpexp.init();
// Create a base URI used for timeslider exports
const baseURI = document.location.pathname;

View File

@ -10711,3 +10711,5 @@
}
return jQuery;
} );
export default (typeof window !== "undefined" && typeof window.$ === "object" ? window.$ : null);