fix(core): update

This commit is contained in:
Philipp Kunz 2023-04-10 00:55:16 +02:00
parent 23dccae01b
commit c305ca517a
4 changed files with 19 additions and 10 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@apiglobal/typedserver',
version: '2.0.52',
version: '2.0.53',
description: 'easy serving of static files'
}

View File

@ -129,7 +129,7 @@ export class TypedServer {
<script async defer type="module" src="/typedserver/devtools"></script>
<script>
globalThis.typedserver = {
lastReload: '${this.lastReload}',
lastReload: ${this.lastReload},
versionInfo: ${JSON.stringify({}, null, 2)},
}
</script>

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@apiglobal/typedserver',
version: '2.0.52',
version: '2.0.53',
description: 'easy serving of static files'
}

View File

@ -62,7 +62,10 @@ export class ReloadChecker {
public async checkReload(lastServerChange: number) {
let reloadJustified = false;
let storedLastServerChange = await this.store.get(this.storeKey);
storedLastServerChange && storedLastServerChange !== lastServerChange ? (reloadJustified = true) : null;
if (storedLastServerChange && storedLastServerChange !== lastServerChange) {
reloadJustified = true;
} else {
}
if (reloadJustified) {
this.store.set(this.storeKey, lastServerChange);
@ -100,22 +103,28 @@ export class ReloadChecker {
plugins.typedsocket.TypedSocket.useWindowLocationOriginUrl()
);
this.typedsocket.addTag('typedserver_frontend', {});
this.typedsocket.eventSubject.subscribe(async eventArg => {
this.typedsocket.eventSubject.subscribe(async (eventArg) => {
console.log(`typedsocket event subscription: ${eventArg}`);
if (eventArg === 'disconnected' || eventArg === 'disconnecting' || eventArg === 'timedOut') {
if (
eventArg === 'disconnected' ||
eventArg === 'disconnecting' ||
eventArg === 'timedOut'
) {
this.backendConnectionLost = true;
this.infoscreen.setText(`typedsocket ${eventArg}!`)
this.infoscreen.setText(`typedsocket ${eventArg}!`);
} else if (eventArg === 'connected' && this.backendConnectionLost) {
this.backendConnectionLost = false;
this.infoscreen.setSuccess('typedsocket connected!');
// lets check if a reload is necessary
const getLatestServerChangeTime = this.typedsocket.createTypedRequest<interfaces.IReq_GetLatestServerChangeTime>('getLatestServerChangeTime');
const getLatestServerChangeTime =
this.typedsocket.createTypedRequest<interfaces.IReq_GetLatestServerChangeTime>(
'getLatestServerChangeTime'
);
const response = await getLatestServerChangeTime.fire({});
this.checkReload(response.time);
}
});
logger.log('success', `ReloadChecker connected through typedsocket!`)
logger.log('success', `ReloadChecker connected through typedsocket!`);
}
}