Compare commits

...

18 Commits

Author SHA1 Message Date
3d4f8d1bbe 2.0.51 2023-04-04 17:23:50 +02:00
4724629efa fix(core): update 2023-04-04 17:23:49 +02:00
ff9aea12c3 2.0.50 2023-04-04 17:14:54 +02:00
910b9a495e fix(core): update 2023-04-04 17:14:54 +02:00
7fdf0a71a7 2.0.49 2023-04-01 15:12:55 +02:00
bf2c6660f2 fix(core): update 2023-04-01 15:12:54 +02:00
49afc16422 2.0.48 2023-03-31 18:04:22 +02:00
bb6f239075 fix(core): update 2023-03-31 18:04:21 +02:00
5bd5916696 2.0.47 2023-03-31 15:27:00 +02:00
62df38d083 fix(core): update 2023-03-31 15:26:59 +02:00
d7fe947107 2.0.46 2023-03-31 15:10:43 +02:00
dd426a4ca4 fix(core): update 2023-03-31 15:10:42 +02:00
2a2d4dabe4 2.0.45 2023-03-31 13:18:23 +02:00
830682d382 fix(core): update 2023-03-31 13:18:23 +02:00
d160a92bee 2.0.44 2023-03-30 19:44:44 +02:00
cc421c3321 fix(core): update 2023-03-30 19:44:44 +02:00
92ecef30d3 2.0.43 2023-03-30 19:42:55 +02:00
de4aab6df0 fix(core): update 2023-03-30 19:42:55 +02:00
8 changed files with 42 additions and 11 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@apiglobal/typedserver",
"version": "2.0.42",
"version": "2.0.51",
"description": "easy serving of static files",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",

View File

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

View File

@ -10,3 +10,14 @@ export interface IReq_PushLatestServerChangeTime extends typedrequestInterfaces.
};
response: {}
}
export interface IReq_GetLatestServerChangeTime extends typedrequestInterfaces.implementsTR<
typedrequestInterfaces.ITypedRequest,
IReq_GetLatestServerChangeTime
> {
method: 'getLatestServerChangeTime',
request: {};
response: {
time: number;
}
}

View File

@ -140,6 +140,9 @@ export class Server {
res.setHeader('Cross-Origin-Resource-Policy', 'cross-origin');
res.setHeader('Cross-Origin-Embedder-Policy', 'unsafe-none');
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('SERVEZONE_ROUTE', 'LOSSLESS_ORIGIN_CONTAINER');
res.setHeader('Cache-Control', 'no-cache');
res.setHeader('Expires', new Date(Date.now()).toUTCString());
next();
});

View File

@ -72,8 +72,8 @@ export class TypedServer {
public ended = false;
constructor(optionsArg: IServerOptions) {
const standardOptions: IServerOptions = {
injectReload: true,
port: 3000,
injectReload: false,
serveDir: null,
watch: false,
cors: true,
@ -176,6 +176,13 @@ export class TypedServer {
this.server
);
// lets setup typedrouter
this.typedrouter.addTypedHandler<interfaces.IReq_GetLatestServerChangeTime>(new plugins.typedrequest.TypedHandler('getLatestServerChangeTime', async reqDataArg => {
return {
time: this.lastReload,
}
}))
// console.log('open url in browser');
// await plugins.smartopen.openUrl(`http://testing.git.zone:${this.options.port}`);
}
@ -185,7 +192,7 @@ export class TypedServer {
*/
public async reload() {
this.lastReload = Date.now();
for (const connectionArg of await this.typedsocket.findAllTargetConnections(async () => true)) {
for (const connectionArg of await this.typedsocket.findAllTargetConnectionsByTag('typedserver_frontend')) {
const pushTime =
this.typedsocket.createTypedRequest<interfaces.IReq_PushLatestServerChangeTime>(
'pushLatestServerChangeTime',
@ -201,7 +208,9 @@ export class TypedServer {
this.ended = true;
await this.server.stop();
await this.typedsocket.stop();
await this.smartchokInstance.stop();
if (this.smartchokInstance) {
await this.smartchokInstance.stop();
}
}
public async createServeDirHash() {

View File

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

View File

@ -65,7 +65,7 @@ export class ReloadChecker {
if (reloadJustified) {
this.store.set(this.storeKey, lastServerChange);
const reloadText = `about to reload ${
const reloadText = `upgrading... ${
globalThis.globalSw ? '(purging the sw cache first...)' : ''
}`;
this.infoscreen.setText(reloadText);
@ -98,14 +98,19 @@ export class ReloadChecker {
this.typedrouter,
plugins.typedsocket.TypedSocket.useWindowLocationOriginUrl()
);
this.typedsocket.eventSubject.subscribe(eventArg => {
this.typedsocket.addTag('typedserver_frontend', {});
this.typedsocket.eventSubject.subscribe(async eventArg => {
console.log(`typedsocket event subscription: ${eventArg}`);
if (eventArg === 'disconnected' || eventArg === 'disconnecting' || eventArg === 'timedOut') {
this.backendConnectionLost = true;
this.infoscreen.setText(`typedsocket ${eventArg}!`)
} else if (eventArg === 'connected' && this.backendConnectionLost) {
this.backendConnectionLost = false;
this.infoscreen.setSuccess('typedsocket connected!')
this.infoscreen.setSuccess('typedsocket connected!');
// lets check if a reload is necessary
const getLatestServerChangeTime = this.typedsocket.createTypedRequest<interfaces.IReq_GetLatestServerChangeTime>('getLatestServerChangeTime');
const response = await getLatestServerChangeTime.fire({});
this.checkReload(response.time);
}
});

View File

@ -95,10 +95,13 @@ export class TypedserverInfoscreen extends LitElement {
public async hide() {
this.text = '';
const mainbox = this.shadowRoot.querySelector('.mainbox');
mainbox.classList.add('show');
if (this.appended) {
const mainbox = this.shadowRoot.querySelector('.mainbox');
mainbox.classList.remove('show');
}
await plugins.smartdelay.delayFor(300);
if (this.appended) {
this.appended = false;
document.body.removeChild(this);
}
}