@celljs/serve-static 4.0.0 → 4.1.0
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/esm/node/embedded-assets.d.ts +1 -1
- package/esm/node/embedded-assets.js +13 -7
- package/esm/node/embedded-assets.js.map +1 -1
- package/esm/node/serve-static-middleware.d.ts +18 -1
- package/esm/node/serve-static-middleware.js +72 -29
- package/esm/node/serve-static-middleware.js.map +1 -1
- package/esm/node/serve-static.d.ts +1 -1
- package/esm/node/serve-static.js +5 -4
- package/esm/node/serve-static.js.map +1 -1
- package/lib/node/embedded-assets.d.ts +1 -1
- package/lib/node/embedded-assets.d.ts.map +1 -1
- package/lib/node/embedded-assets.js +13 -7
- package/lib/node/embedded-assets.js.map +1 -1
- package/lib/node/serve-static-middleware.d.ts +18 -1
- package/lib/node/serve-static-middleware.d.ts.map +1 -1
- package/lib/node/serve-static-middleware.js +71 -28
- package/lib/node/serve-static-middleware.js.map +1 -1
- package/lib/node/serve-static-middleware.spec.d.ts +2 -0
- package/lib/node/serve-static-middleware.spec.d.ts.map +1 -0
- package/lib/node/serve-static-middleware.spec.js +232 -0
- package/lib/node/serve-static-middleware.spec.js.map +1 -0
- package/lib/node/serve-static.d.ts +1 -1
- package/lib/node/serve-static.d.ts.map +1 -1
- package/lib/node/serve-static.js +5 -4
- package/lib/node/serve-static.js.map +1 -1
- package/package.json +5 -6
- package/src/node/embedded-assets.ts +13 -7
- package/src/node/serve-static-middleware.spec.ts +284 -0
- package/src/node/serve-static-middleware.ts +78 -31
- package/src/node/serve-static.ts +5 -4
|
@@ -16,5 +16,5 @@ export declare namespace EmbeddedAssets {
|
|
|
16
16
|
/** The counterpart of `serveStatic`: same options, same `next()` when a file is not there. */
|
|
17
17
|
function serve(assets: Map<string, EmbeddedAsset>, opts: ServeStaticOption & {
|
|
18
18
|
maxAge?: number;
|
|
19
|
-
}): (req: any, res: any, next: (err?: unknown) => void) => void;
|
|
19
|
+
}): (req: any, res: any, next: (err?: unknown) => void, url?: string) => void;
|
|
20
20
|
}
|
|
@@ -7,22 +7,28 @@ import send from 'send';
|
|
|
7
7
|
export var EmbeddedAssets;
|
|
8
8
|
(function (EmbeddedAssets) {
|
|
9
9
|
EmbeddedAssets.KEY = Symbol.for('@celljs/serve-static/assets');
|
|
10
|
-
|
|
10
|
+
/** Decoded bodies, per table of assets: a table that is registered again is decoded again. */
|
|
11
|
+
const decoded = new WeakMap();
|
|
11
12
|
function get() {
|
|
12
13
|
return globalThis[EmbeddedAssets.KEY];
|
|
13
14
|
}
|
|
14
15
|
EmbeddedAssets.get = get;
|
|
15
|
-
function content(path, asset) {
|
|
16
|
-
let
|
|
16
|
+
function content(assets, path, asset) {
|
|
17
|
+
let bodies = decoded.get(assets);
|
|
18
|
+
if (!bodies) {
|
|
19
|
+
bodies = new Map();
|
|
20
|
+
decoded.set(assets, bodies);
|
|
21
|
+
}
|
|
22
|
+
let body = bodies.get(path);
|
|
17
23
|
if (!body) {
|
|
18
24
|
body = Buffer.from(asset.body, 'base64');
|
|
19
|
-
|
|
25
|
+
bodies.set(path, body);
|
|
20
26
|
}
|
|
21
27
|
return body;
|
|
22
28
|
}
|
|
23
29
|
/** The counterpart of `serveStatic`: same options, same `next()` when a file is not there. */
|
|
24
30
|
function serve(assets, opts) {
|
|
25
|
-
return (req, res, next) => {
|
|
31
|
+
return (req, res, next, url = req.url) => {
|
|
26
32
|
var _a;
|
|
27
33
|
var _b, _c;
|
|
28
34
|
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
|
@@ -31,7 +37,7 @@ export var EmbeddedAssets;
|
|
|
31
37
|
}
|
|
32
38
|
let path;
|
|
33
39
|
try {
|
|
34
|
-
path = decodeURIComponent(new URL(
|
|
40
|
+
path = decodeURIComponent(new URL(url.replace(opts.baseHref, '/'), 'http://localhost').pathname);
|
|
35
41
|
}
|
|
36
42
|
catch (_d) {
|
|
37
43
|
next();
|
|
@@ -59,7 +65,7 @@ export var EmbeddedAssets;
|
|
|
59
65
|
res.end();
|
|
60
66
|
return;
|
|
61
67
|
}
|
|
62
|
-
const body = content(path, asset);
|
|
68
|
+
const body = content(assets, path, asset);
|
|
63
69
|
res.statusCode = 200;
|
|
64
70
|
res.setHeader('Content-Length', body.length);
|
|
65
71
|
res.end(req.method === 'HEAD' ? undefined : body);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedded-assets.js","sourceRoot":"","sources":["../../src/node/embedded-assets.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAUxB;;;;GAIG;AACH,MAAM,KAAW,cAAc,
|
|
1
|
+
{"version":3,"file":"embedded-assets.js","sourceRoot":"","sources":["../../src/node/embedded-assets.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAUxB;;;;GAIG;AACH,MAAM,KAAW,cAAc,CAkE9B;AAlED,WAAiB,cAAc;IACd,kBAAG,GAAG,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAE7D,8FAA8F;IAC9F,MAAM,OAAO,GAAG,IAAI,OAAO,EAAmD,CAAC;IAE/E,SAAgB,GAAG;QACf,OAAQ,UAAqE,CAAC,kBAAG,CAAC,CAAC;IACvF,CAAC;IAFe,eAAA,GAAG,MAElB,CAAA;IAED,SAAS,OAAO,CAAC,MAAkC,EAAE,IAAY,EAAE,KAAoB;QACnF,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACjC,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;YACnB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,C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AlEgB,cAAc,KAAd,cAAc,QAkE9B"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Middleware, Context, RequestMatcher } from '@celljs/web/lib/node';
|
|
2
|
+
import { OutgoingMessage } from 'http';
|
|
3
|
+
import type { ServeStaticOption } from './type.js';
|
|
4
|
+
type Serve = (req: any, res: any, next: (err?: any) => void, url?: string) => void;
|
|
2
5
|
export declare class ServeStaticMiddleware implements Middleware {
|
|
3
6
|
protected config: {
|
|
4
7
|
spa: boolean;
|
|
@@ -13,7 +16,21 @@ export declare class ServeStaticMiddleware implements Middleware {
|
|
|
13
16
|
* Whether there is a frontend to serve: embedded in the bundle (`--single`) or on disk. On
|
|
14
17
|
* Cloudflare Workers the platform serves the frontend and the worker has no copy.
|
|
15
18
|
*/
|
|
16
|
-
protected hasFrontend
|
|
19
|
+
protected hasFrontend: boolean;
|
|
20
|
+
/** Options of the file server: a copy of `cell.serve-static.options`, which stays untouched. */
|
|
21
|
+
protected options: ServeStaticOption & Record<string, any>;
|
|
22
|
+
protected serve: Serve;
|
|
23
|
+
/**
|
|
24
|
+
* Sets up the file server once. Cloudflare Workers allow I/O (`existsSync`) only while a request is
|
|
25
|
+
* handled; the application, and with it this component, starts on the first request there.
|
|
26
|
+
*/
|
|
27
|
+
protected init(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Adds the configured `headers` to every file, and gives HTML files their own Cache-Control
|
|
30
|
+
* (`htmlMaxAge` in milliseconds, default 0) so that a new build of the page is picked up.
|
|
31
|
+
*/
|
|
32
|
+
protected createSetHeaders(headers: Record<string, string> | undefined, htmlMaxAge: unknown): (res: OutgoingMessage, path: string) => void;
|
|
17
33
|
handle(ctx: Context, next: () => Promise<void>): Promise<void>;
|
|
18
34
|
priority: number;
|
|
19
35
|
}
|
|
36
|
+
export {};
|
|
@@ -10,19 +10,53 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
import { Middleware, RequestMatcher, HTTP_MIDDLEWARE_PRIORITY } from '@celljs/web/lib/node';
|
|
11
11
|
import { serveStatic, mime } from './serve-static.js';
|
|
12
12
|
import { EmbeddedAssets } from './embedded-assets.js';
|
|
13
|
-
import { Value, Component, Autowired } from '@celljs/core';
|
|
13
|
+
import { Value, Component, Autowired, PostConstruct } from '@celljs/core';
|
|
14
14
|
import { HttpMethod, MediaType, HttpHeaders } from '@celljs/http';
|
|
15
15
|
import { SERVER_PATH } from '@celljs/web';
|
|
16
16
|
import { existsSync } from 'fs';
|
|
17
|
+
const SPA_INDEX = '/index.html';
|
|
17
18
|
let ServeStaticMiddleware = class ServeStaticMiddleware {
|
|
18
19
|
constructor() {
|
|
19
20
|
this.priority = HTTP_MIDDLEWARE_PRIORITY + 500;
|
|
20
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Sets up the file server once. Cloudflare Workers allow I/O (`existsSync`) only while a request is
|
|
24
|
+
* handled; the application, and with it this component, starts on the first request there.
|
|
25
|
+
*/
|
|
26
|
+
init() {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
var _c;
|
|
29
|
+
const { headers, htmlMaxAge, ...options } = (_a = this.config.options) !== null && _a !== void 0 ? _a : {};
|
|
30
|
+
this.options = { ...options, baseHref: this.path };
|
|
31
|
+
(_b = (_c = this.options).setHeaders) !== null && _b !== void 0 ? _b : (_c.setHeaders = this.createSetHeaders(headers, htmlMaxAge));
|
|
32
|
+
const embedded = EmbeddedAssets.get();
|
|
33
|
+
const root = this.config.root;
|
|
34
|
+
// No frontend (no `paths.public`, or nothing built there): every request goes on to the chain.
|
|
35
|
+
this.hasFrontend = !!embedded || (typeof root === 'string' && existsSync(root));
|
|
36
|
+
if (embedded) {
|
|
37
|
+
this.serve = EmbeddedAssets.serve(embedded, this.options);
|
|
38
|
+
}
|
|
39
|
+
else if (this.hasFrontend) {
|
|
40
|
+
this.serve = serveStatic(root, this.options);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Adds the configured `headers` to every file, and gives HTML files their own Cache-Control
|
|
45
|
+
* (`htmlMaxAge` in milliseconds, default 0) so that a new build of the page is picked up.
|
|
46
|
+
*/
|
|
47
|
+
createSetHeaders(headers, htmlMaxAge) {
|
|
48
|
+
const htmlCacheControl = `public, max-age=${Math.floor(Math.max(0, Number(htmlMaxAge !== null && htmlMaxAge !== void 0 ? htmlMaxAge : 0) || 0) / 1000)}`;
|
|
49
|
+
return (res, path) => {
|
|
50
|
+
if (headers) {
|
|
51
|
+
Object.keys(headers).forEach(key => res.setHeader(key, headers[key]));
|
|
52
|
+
}
|
|
53
|
+
if (mime.lookup(path) === MediaType.TEXT_HTML) {
|
|
54
|
+
res.setHeader(HttpHeaders.CACHE_CONTROL, htmlCacheControl);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
21
58
|
async handle(ctx, next) {
|
|
22
|
-
var _a;
|
|
23
|
-
this.config.options.baseHref = this.path;
|
|
24
59
|
const method = ctx.request.method;
|
|
25
|
-
(_a = this.hasFrontend) !== null && _a !== void 0 ? _a : (this.hasFrontend = !!EmbeddedAssets.get() || existsSync(this.config.root));
|
|
26
60
|
if (!this.hasFrontend || !(method === HttpMethod.GET || method === HttpMethod.HEAD) || ctx.request.query['static'] === 'skip') {
|
|
27
61
|
await next();
|
|
28
62
|
return;
|
|
@@ -35,40 +69,43 @@ let ServeStaticMiddleware = class ServeStaticMiddleware {
|
|
|
35
69
|
await next();
|
|
36
70
|
return;
|
|
37
71
|
}
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
72
|
+
return new Promise((resolve, reject) => {
|
|
73
|
+
const response = ctx.response;
|
|
74
|
+
// A file that is sent ends the response without calling back: the request is done then.
|
|
75
|
+
const done = () => {
|
|
76
|
+
stopWaiting();
|
|
77
|
+
resolve();
|
|
78
|
+
};
|
|
79
|
+
const stopWaiting = () => {
|
|
80
|
+
response.off('finish', done);
|
|
81
|
+
response.off('close', done);
|
|
82
|
+
};
|
|
83
|
+
// The rest of the chain answers instead: its outcome is this middleware's outcome.
|
|
84
|
+
const passOn = () => {
|
|
85
|
+
stopWaiting();
|
|
86
|
+
next().then(resolve, reject);
|
|
87
|
+
};
|
|
88
|
+
response.once('finish', done);
|
|
89
|
+
response.once('close', done);
|
|
90
|
+
// The SPA fallback serves /index.html for the request without changing request.url.
|
|
91
|
+
const attempt = (url) => this.serve(ctx.request, response, (err) => {
|
|
92
|
+
if (url !== SPA_INDEX) {
|
|
56
93
|
if (!this.config.spa) {
|
|
57
|
-
|
|
94
|
+
passOn();
|
|
58
95
|
return;
|
|
59
96
|
}
|
|
60
|
-
|
|
61
|
-
executor(resolve, reject);
|
|
97
|
+
attempt(SPA_INDEX);
|
|
62
98
|
}
|
|
63
99
|
else if (err) {
|
|
100
|
+
stopWaiting();
|
|
64
101
|
reject(err);
|
|
65
102
|
}
|
|
66
103
|
else {
|
|
67
|
-
|
|
104
|
+
passOn();
|
|
68
105
|
}
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
|
|
106
|
+
}, url);
|
|
107
|
+
attempt(ctx.request.url);
|
|
108
|
+
});
|
|
72
109
|
}
|
|
73
110
|
};
|
|
74
111
|
__decorate([
|
|
@@ -83,6 +120,12 @@ __decorate([
|
|
|
83
120
|
Autowired(RequestMatcher),
|
|
84
121
|
__metadata("design:type", Object)
|
|
85
122
|
], ServeStaticMiddleware.prototype, "requestMatcher", void 0);
|
|
123
|
+
__decorate([
|
|
124
|
+
PostConstruct(),
|
|
125
|
+
__metadata("design:type", Function),
|
|
126
|
+
__metadata("design:paramtypes", []),
|
|
127
|
+
__metadata("design:returntype", void 0)
|
|
128
|
+
], ServeStaticMiddleware.prototype, "init", null);
|
|
86
129
|
ServeStaticMiddleware = __decorate([
|
|
87
130
|
Component(Middleware)
|
|
88
131
|
], ServeStaticMiddleware);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve-static-middleware.js","sourceRoot":"","sources":["../../src/node/serve-static-middleware.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAW,cAAc,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrG,OAAO,EAAC,WAAW,EAAE,IAAI,EAAC,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"serve-static-middleware.js","sourceRoot":"","sources":["../../src/node/serve-static-middleware.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAW,cAAc,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrG,OAAO,EAAC,WAAW,EAAE,IAAI,EAAC,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAKhC,MAAM,SAAS,GAAG,aAAa,CAAC;AAGzB,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAA3B;QAiHH,aAAQ,GAAG,wBAAwB,GAAG,GAAG,CAAC;IAE9C,CAAC;IA7FG;;;OAGG;IAEO,IAAI;;;QACV,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,OAAO,EAAE,SAAG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AAK,CAAC,WAAW,CAAC;;mDACI;AAGJ;IADlB,SAAS,CAAC,cAAc,CAAC;;6DACwB;AAkBxC;IADT,aAAa,EAAE;;;;iDAcf;AAxCQ,qBAAqB;IADjC,SAAS,CAAC,UAAU,CAAC;GACT,qBAAqB,CAmHjC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ServeStaticOption } from './type.js';
|
|
2
|
-
export declare const serveStatic: (root: string, opts: ServeStaticOption) => (req: any, res: any, next: Function) => any;
|
|
2
|
+
export declare const serveStatic: (root: string, opts: ServeStaticOption) => (req: any, res: any, next: Function, url?: string) => any;
|
|
3
3
|
export declare const mime: typeof import("mime");
|
package/esm/node/serve-static.js
CHANGED
|
@@ -7,7 +7,8 @@ export const serveStatic = (root, opts) => {
|
|
|
7
7
|
createRedirectDirectoryListener :
|
|
8
8
|
createNotFoundDirectoryListener;
|
|
9
9
|
opts.root = resolve(root);
|
|
10
|
-
|
|
10
|
+
/** `url` (default `req.url`) is what to serve; the SPA fallback passes `/index.html` without changing the request. */
|
|
11
|
+
return (req, res, next, url = req.url) => {
|
|
11
12
|
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
|
12
13
|
if (fallthrough) {
|
|
13
14
|
return next();
|
|
@@ -21,9 +22,9 @@ export const serveStatic = (root, opts) => {
|
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
24
|
let forwardError = !fallthrough;
|
|
24
|
-
const
|
|
25
|
-
const stream = send(req,
|
|
26
|
-
stream.on('directory', onDirectory(
|
|
25
|
+
const target = new URL(`${url.replace(baseHref, '/')}`, `http://${req.headers.host}`);
|
|
26
|
+
const stream = send(req, target.pathname, opts);
|
|
27
|
+
stream.on('directory', onDirectory(target));
|
|
27
28
|
if (setHeaders) {
|
|
28
29
|
stream.on('headers', setHeaders);
|
|
29
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve-static.js","sourceRoot":"","sources":["../../src/node/serve-static.ts"],"names":[],"mappings":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AY;YAChC,WAAW;YACX,UAAU;YACV,OAAO,GAAG,IAAI,GAAG,UAAU;YAC3B,WAAW;YACX,WAAW,CAAC;IACpB,CAAC;AAEL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC"}
|
|
@@ -16,6 +16,6 @@ export declare namespace EmbeddedAssets {
|
|
|
16
16
|
/** The counterpart of `serveStatic`: same options, same `next()` when a file is not there. */
|
|
17
17
|
function serve(assets: Map<string, EmbeddedAsset>, opts: ServeStaticOption & {
|
|
18
18
|
maxAge?: number;
|
|
19
|
-
}): (req: any, res: any, next: (err?: unknown) => void) => void;
|
|
19
|
+
}): (req: any, res: any, next: (err?: unknown) => void, url?: string) => void;
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=embedded-assets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedded-assets.d.ts","sourceRoot":"","sources":["../../src/node/embedded-assets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAEhD,+EAA+E;AAC/E,MAAM,WAAW,aAAa;IAC1B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,yBAAiB,cAAc,CAAC;IACrB,MAAM,GAAG,eAA4C,CAAC;
|
|
1
|
+
{"version":3,"file":"embedded-assets.d.ts","sourceRoot":"","sources":["../../src/node/embedded-assets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAEhD,+EAA+E;AAC/E,MAAM,WAAW,aAAa;IAC1B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,yBAAiB,cAAc,CAAC;IACrB,MAAM,GAAG,eAA4C,CAAC;IAK7D,SAAgB,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,SAAS,CAE5D;IAgBD,8FAA8F;IAC9F,SAAgB,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,IAAI,EAAE,iBAAiB,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,SACtF,GAAG,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,IAAI,QAAO,MAAM,UAuCzE;CACJ"}
|
|
@@ -13,22 +13,28 @@ const send_1 = __importDefault(require("send"));
|
|
|
13
13
|
var EmbeddedAssets;
|
|
14
14
|
(function (EmbeddedAssets) {
|
|
15
15
|
EmbeddedAssets.KEY = Symbol.for('@celljs/serve-static/assets');
|
|
16
|
-
|
|
16
|
+
/** Decoded bodies, per table of assets: a table that is registered again is decoded again. */
|
|
17
|
+
const decoded = new WeakMap();
|
|
17
18
|
function get() {
|
|
18
19
|
return globalThis[EmbeddedAssets.KEY];
|
|
19
20
|
}
|
|
20
21
|
EmbeddedAssets.get = get;
|
|
21
|
-
function content(path, asset) {
|
|
22
|
-
let
|
|
22
|
+
function content(assets, path, asset) {
|
|
23
|
+
let bodies = decoded.get(assets);
|
|
24
|
+
if (!bodies) {
|
|
25
|
+
bodies = new Map();
|
|
26
|
+
decoded.set(assets, bodies);
|
|
27
|
+
}
|
|
28
|
+
let body = bodies.get(path);
|
|
23
29
|
if (!body) {
|
|
24
30
|
body = Buffer.from(asset.body, 'base64');
|
|
25
|
-
|
|
31
|
+
bodies.set(path, body);
|
|
26
32
|
}
|
|
27
33
|
return body;
|
|
28
34
|
}
|
|
29
35
|
/** The counterpart of `serveStatic`: same options, same `next()` when a file is not there. */
|
|
30
36
|
function serve(assets, opts) {
|
|
31
|
-
return (req, res, next) => {
|
|
37
|
+
return (req, res, next, url = req.url) => {
|
|
32
38
|
var _a;
|
|
33
39
|
var _b, _c;
|
|
34
40
|
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
|
@@ -37,7 +43,7 @@ var EmbeddedAssets;
|
|
|
37
43
|
}
|
|
38
44
|
let path;
|
|
39
45
|
try {
|
|
40
|
-
path = decodeURIComponent(new URL(
|
|
46
|
+
path = decodeURIComponent(new URL(url.replace(opts.baseHref, '/'), 'http://localhost').pathname);
|
|
41
47
|
}
|
|
42
48
|
catch (_d) {
|
|
43
49
|
next();
|
|
@@ -65,7 +71,7 @@ var EmbeddedAssets;
|
|
|
65
71
|
res.end();
|
|
66
72
|
return;
|
|
67
73
|
}
|
|
68
|
-
const body = content(path, asset);
|
|
74
|
+
const body = content(assets, path, asset);
|
|
69
75
|
res.statusCode = 200;
|
|
70
76
|
res.setHeader('Content-Length', body.length);
|
|
71
77
|
res.end(req.method === 'HEAD' ? undefined : body);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedded-assets.js","sourceRoot":"","sources":["../../src/node/embedded-assets.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAUxB;;;;GAIG;AACH,IAAiB,cAAc,
|
|
1
|
+
{"version":3,"file":"embedded-assets.js","sourceRoot":"","sources":["../../src/node/embedded-assets.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAUxB;;;;GAIG;AACH,IAAiB,cAAc,CAkE9B;AAlED,WAAiB,cAAc;IACd,kBAAG,GAAG,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAE7D,8FAA8F;IAC9F,MAAM,OAAO,GAAG,IAAI,OAAO,EAAmD,CAAC;IAE/E,SAAgB,GAAG;QACf,OAAQ,UAAqE,CAAC,kBAAG,CAAC,CAAC;IACvF,CAAC;IAFe,eAAA,GAAG,MAElB,CAAA;IAED,SAAS,OAAO,CAAC,MAAkC,EAAE,IAAY,EAAE,KAAoB;QACnF,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACjC,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM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,SAAS,CAAC,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAC7C,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACtD,CAAC,CAAC;IACN,CAAC;IAxCe,eAAA,KAAK,QAwCpB,CAAA;AACL,CAAC,EAlEgB,cAAc,aAAd,cAAc,GAAd,cAAc,QAkE9B"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Middleware, Context, RequestMatcher } from '@celljs/web/lib/node';
|
|
2
|
+
import { OutgoingMessage } from 'http';
|
|
3
|
+
import type { ServeStaticOption } from './type';
|
|
4
|
+
type Serve = (req: any, res: any, next: (err?: any) => void, url?: string) => void;
|
|
2
5
|
export declare class ServeStaticMiddleware implements Middleware {
|
|
3
6
|
protected config: {
|
|
4
7
|
spa: boolean;
|
|
@@ -13,8 +16,22 @@ export declare class ServeStaticMiddleware implements Middleware {
|
|
|
13
16
|
* Whether there is a frontend to serve: embedded in the bundle (`--single`) or on disk. On
|
|
14
17
|
* Cloudflare Workers the platform serves the frontend and the worker has no copy.
|
|
15
18
|
*/
|
|
16
|
-
protected hasFrontend
|
|
19
|
+
protected hasFrontend: boolean;
|
|
20
|
+
/** Options of the file server: a copy of `cell.serve-static.options`, which stays untouched. */
|
|
21
|
+
protected options: ServeStaticOption & Record<string, any>;
|
|
22
|
+
protected serve: Serve;
|
|
23
|
+
/**
|
|
24
|
+
* Sets up the file server once. Cloudflare Workers allow I/O (`existsSync`) only while a request is
|
|
25
|
+
* handled; the application, and with it this component, starts on the first request there.
|
|
26
|
+
*/
|
|
27
|
+
protected init(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Adds the configured `headers` to every file, and gives HTML files their own Cache-Control
|
|
30
|
+
* (`htmlMaxAge` in milliseconds, default 0) so that a new build of the page is picked up.
|
|
31
|
+
*/
|
|
32
|
+
protected createSetHeaders(headers: Record<string, string> | undefined, htmlMaxAge: unknown): (res: OutgoingMessage, path: string) => void;
|
|
17
33
|
handle(ctx: Context, next: () => Promise<void>): Promise<void>;
|
|
18
34
|
priority: number;
|
|
19
35
|
}
|
|
36
|
+
export {};
|
|
20
37
|
//# sourceMappingURL=serve-static-middleware.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve-static-middleware.d.ts","sourceRoot":"","sources":["../../src/node/serve-static-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAA4B,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"serve-static-middleware.d.ts","sourceRoot":"","sources":["../../src/node/serve-static-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAA4B,MAAM,sBAAsB,CAAC;AAMrG,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAEhD,KAAK,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAInF,qBACa,qBAAsB,YAAW,UAAU;IAGpD,SAAS,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,GAAG,CAAA;KAAC,CAAC;IAG7F,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC;IAGvB,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAElD;;;OAGG;IACH,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC;IAE/B,gGAAgG;IAChG,SAAS,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE3D,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;IAEvB;;;OAGG;IAEH,SAAS,CAAC,IAAI,IAAI,IAAI,CAarB;IAED;;;OAGG;IACH,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAAE,UAAU,EAAE,OAAO,GAAG,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAUzI;IAEK,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDnE;IACD,QAAQ,SAAkC;CAE7C"}
|
|
@@ -17,15 +17,49 @@ const core_1 = require("@celljs/core");
|
|
|
17
17
|
const http_1 = require("@celljs/http");
|
|
18
18
|
const web_1 = require("@celljs/web");
|
|
19
19
|
const fs_1 = require("fs");
|
|
20
|
+
const SPA_INDEX = '/index.html';
|
|
20
21
|
let ServeStaticMiddleware = class ServeStaticMiddleware {
|
|
21
22
|
constructor() {
|
|
22
23
|
this.priority = node_1.HTTP_MIDDLEWARE_PRIORITY + 500;
|
|
23
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Sets up the file server once. Cloudflare Workers allow I/O (`existsSync`) only while a request is
|
|
27
|
+
* handled; the application, and with it this component, starts on the first request there.
|
|
28
|
+
*/
|
|
29
|
+
init() {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
var _c;
|
|
32
|
+
const { headers, htmlMaxAge, ...options } = (_a = this.config.options) !== null && _a !== void 0 ? _a : {};
|
|
33
|
+
this.options = { ...options, baseHref: this.path };
|
|
34
|
+
(_b = (_c = this.options).setHeaders) !== null && _b !== void 0 ? _b : (_c.setHeaders = this.createSetHeaders(headers, htmlMaxAge));
|
|
35
|
+
const embedded = embedded_assets_1.EmbeddedAssets.get();
|
|
36
|
+
const root = this.config.root;
|
|
37
|
+
// No frontend (no `paths.public`, or nothing built there): every request goes on to the chain.
|
|
38
|
+
this.hasFrontend = !!embedded || (typeof root === 'string' && (0, fs_1.existsSync)(root));
|
|
39
|
+
if (embedded) {
|
|
40
|
+
this.serve = embedded_assets_1.EmbeddedAssets.serve(embedded, this.options);
|
|
41
|
+
}
|
|
42
|
+
else if (this.hasFrontend) {
|
|
43
|
+
this.serve = (0, serve_static_1.serveStatic)(root, this.options);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Adds the configured `headers` to every file, and gives HTML files their own Cache-Control
|
|
48
|
+
* (`htmlMaxAge` in milliseconds, default 0) so that a new build of the page is picked up.
|
|
49
|
+
*/
|
|
50
|
+
createSetHeaders(headers, htmlMaxAge) {
|
|
51
|
+
const htmlCacheControl = `public, max-age=${Math.floor(Math.max(0, Number(htmlMaxAge !== null && htmlMaxAge !== void 0 ? htmlMaxAge : 0) || 0) / 1000)}`;
|
|
52
|
+
return (res, path) => {
|
|
53
|
+
if (headers) {
|
|
54
|
+
Object.keys(headers).forEach(key => res.setHeader(key, headers[key]));
|
|
55
|
+
}
|
|
56
|
+
if (serve_static_1.mime.lookup(path) === http_1.MediaType.TEXT_HTML) {
|
|
57
|
+
res.setHeader(http_1.HttpHeaders.CACHE_CONTROL, htmlCacheControl);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
24
61
|
async handle(ctx, next) {
|
|
25
|
-
var _a;
|
|
26
|
-
this.config.options.baseHref = this.path;
|
|
27
62
|
const method = ctx.request.method;
|
|
28
|
-
(_a = this.hasFrontend) !== null && _a !== void 0 ? _a : (this.hasFrontend = !!embedded_assets_1.EmbeddedAssets.get() || (0, fs_1.existsSync)(this.config.root));
|
|
29
63
|
if (!this.hasFrontend || !(method === http_1.HttpMethod.GET || method === http_1.HttpMethod.HEAD) || ctx.request.query['static'] === 'skip') {
|
|
30
64
|
await next();
|
|
31
65
|
return;
|
|
@@ -38,40 +72,43 @@ let ServeStaticMiddleware = class ServeStaticMiddleware {
|
|
|
38
72
|
await next();
|
|
39
73
|
return;
|
|
40
74
|
}
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
75
|
+
return new Promise((resolve, reject) => {
|
|
76
|
+
const response = ctx.response;
|
|
77
|
+
// A file that is sent ends the response without calling back: the request is done then.
|
|
78
|
+
const done = () => {
|
|
79
|
+
stopWaiting();
|
|
80
|
+
resolve();
|
|
81
|
+
};
|
|
82
|
+
const stopWaiting = () => {
|
|
83
|
+
response.off('finish', done);
|
|
84
|
+
response.off('close', done);
|
|
85
|
+
};
|
|
86
|
+
// The rest of the chain answers instead: its outcome is this middleware's outcome.
|
|
87
|
+
const passOn = () => {
|
|
88
|
+
stopWaiting();
|
|
89
|
+
next().then(resolve, reject);
|
|
90
|
+
};
|
|
91
|
+
response.once('finish', done);
|
|
92
|
+
response.once('close', done);
|
|
93
|
+
// The SPA fallback serves /index.html for the request without changing request.url.
|
|
94
|
+
const attempt = (url) => this.serve(ctx.request, response, (err) => {
|
|
95
|
+
if (url !== SPA_INDEX) {
|
|
59
96
|
if (!this.config.spa) {
|
|
60
|
-
|
|
97
|
+
passOn();
|
|
61
98
|
return;
|
|
62
99
|
}
|
|
63
|
-
|
|
64
|
-
executor(resolve, reject);
|
|
100
|
+
attempt(SPA_INDEX);
|
|
65
101
|
}
|
|
66
102
|
else if (err) {
|
|
103
|
+
stopWaiting();
|
|
67
104
|
reject(err);
|
|
68
105
|
}
|
|
69
106
|
else {
|
|
70
|
-
|
|
107
|
+
passOn();
|
|
71
108
|
}
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
|
|
109
|
+
}, url);
|
|
110
|
+
attempt(ctx.request.url);
|
|
111
|
+
});
|
|
75
112
|
}
|
|
76
113
|
};
|
|
77
114
|
exports.ServeStaticMiddleware = ServeStaticMiddleware;
|
|
@@ -87,6 +124,12 @@ __decorate([
|
|
|
87
124
|
(0, core_1.Autowired)(node_1.RequestMatcher),
|
|
88
125
|
__metadata("design:type", Object)
|
|
89
126
|
], ServeStaticMiddleware.prototype, "requestMatcher", void 0);
|
|
127
|
+
__decorate([
|
|
128
|
+
(0, core_1.PostConstruct)(),
|
|
129
|
+
__metadata("design:type", Function),
|
|
130
|
+
__metadata("design:paramtypes", []),
|
|
131
|
+
__metadata("design:returntype", void 0)
|
|
132
|
+
], ServeStaticMiddleware.prototype, "init", null);
|
|
90
133
|
exports.ServeStaticMiddleware = ServeStaticMiddleware = __decorate([
|
|
91
134
|
(0, core_1.Component)(node_1.Middleware)
|
|
92
135
|
], ServeStaticMiddleware);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve-static-middleware.js","sourceRoot":"","sources":["../../src/node/serve-static-middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAqG;AACrG,iDAAiD;AACjD,uDAAmD;AACnD,
|
|
1
|
+
{"version":3,"file":"serve-static-middleware.js","sourceRoot":"","sources":["../../src/node/serve-static-middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAqG;AACrG,iDAAiD;AACjD,uDAAmD;AACnD,uCAA0E;AAC1E,uCAAkE;AAClE,qCAA0C;AAE1C,2BAAgC;AAKhC,MAAM,SAAS,GAAG,aAAa,CAAC;AAGzB,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAA3B;QAiHH,aAAQ,GAAG,+BAAwB,GAAG,GAAG,CAAC;IAE9C,CAAC;IA7FG;;;OAGG;IAEO,IAAI;;;QACV,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,G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