@feng0531/dsh-vcs 0.3.103 → 0.3.106
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/client.js +4 -3
- package/dist/frontend.json +1 -0
- package/dist/interface.js +181 -0
- package/frontend-assets.mjs +15 -0
- package/index.mjs +4 -0
- package/package.json +2 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {readFile} from 'node:fs/promises';
|
|
2
|
+
import {createHash} from 'node:crypto';
|
|
3
|
+
const digest=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
4
|
+
export function registerFrontendAssets(ctx,{running,load=name=>readFile(new URL('./dist/'+name,import.meta.url))}={}){
|
|
5
|
+
for(const name of ['frontend.json','interface.js'])ctx.effect(()=>ctx.webServer.register({kind:'exact',path:'/vcs-assets/'+name,async handler(req,res){
|
|
6
|
+
const admission=ctx.connection.admit(req);if('rejection' in admission){res.writeHead(admission.rejection);res.end();return;}
|
|
7
|
+
if(!['GET','HEAD'].includes(req.method)){res.writeHead(405,{Allow:'GET, HEAD'});res.end();return;}
|
|
8
|
+
try{
|
|
9
|
+
let bytes=await load(name);
|
|
10
|
+
if(name==='frontend.json'){const installed=JSON.parse(bytes);bytes=Buffer.from(JSON.stringify({...installed,runningBackend:running.backend}));}
|
|
11
|
+
else{const hash=new URL(req.url,'http://localhost').searchParams.get('hash');if(!hash||hash!==digest(bytes)){res.writeHead(409);res.end('Frontend changed; retry reload.');return;}}
|
|
12
|
+
res.writeHead(200,{'Content-Type':name.endsWith('.json')?'application/json; charset=utf-8':'text/javascript; charset=utf-8','Cache-Control':'private, no-store','X-Content-Type-Options':'nosniff'});res.end(req.method==='HEAD'?undefined:bytes);
|
|
13
|
+
}catch{res.writeHead(503);res.end('Frontend unavailable; retry or restart DSH.');}
|
|
14
|
+
}}));
|
|
15
|
+
}
|
package/index.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import {readFileSync} from 'node:fs';
|
|
3
|
+
import {registerFrontendAssets} from './frontend-assets.mjs';
|
|
4
|
+
const runningFrontend=JSON.parse(readFileSync(new URL('./dist/frontend.json',import.meta.url),'utf8'));
|
|
2
5
|
import * as adapter from './vcs.mjs';
|
|
3
6
|
import {createSvnHttpsHost} from './dist/svn-host.mjs';
|
|
4
7
|
|
|
@@ -272,4 +275,5 @@ export function apply(ctx) {
|
|
|
272
275
|
ctx.connection.register(ctx, RPC_CHANNEL, host.handle);
|
|
273
276
|
registerAssets(ctx);
|
|
274
277
|
registerDirectAssets(ctx);
|
|
278
|
+
registerFrontendAssets(ctx,{running:runningFrontend});
|
|
275
279
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feng0531/dsh-vcs",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.106",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" },
|
|
6
6
|
"type": "module",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"index.mjs",
|
|
16
|
+
"frontend-assets.mjs",
|
|
16
17
|
"vcs.mjs",
|
|
17
18
|
"git-history.mjs",
|
|
18
19
|
"conflict-stages.mjs",
|