@remix-run/static-middleware 0.4.0 → 0.4.2

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.
@@ -3,7 +3,7 @@ import { type FileResponseOptions } from '@remix-run/response/file';
3
3
  /**
4
4
  * Function that determines if HTTP Range requests should be supported for a given file.
5
5
  *
6
- * @param file - The File object being served
6
+ * @param file The File object being served
7
7
  * @returns true if range requests should be supported
8
8
  */
9
9
  export type AcceptRangesFunction = (file: File) => boolean;
@@ -15,7 +15,7 @@ export interface StaticFilesOptions extends Omit<FileResponseOptions, 'acceptRan
15
15
  * Filter function to determine which files should be served.
16
16
  *
17
17
  * @param path The relative path being requested
18
- * @return Whether to serve the file
18
+ * @returns Whether to serve the file
19
19
  */
20
20
  filter?: (path: string) => boolean;
21
21
  /**
@@ -68,7 +68,7 @@ export interface StaticFilesOptions extends Omit<FileResponseOptions, 'acceptRan
68
68
  *
69
69
  * @param root The root directory to serve files from (absolute or relative to cwd)
70
70
  * @param options Configuration for file responses
71
- * @return The static files middleware
71
+ * @returns The static files middleware
72
72
  */
73
73
  export declare function staticFiles(root: string, options?: StaticFilesOptions): Middleware;
74
74
  //# sourceMappingURL=static.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import * as path from 'node:path';
2
2
  import * as fsp from 'node:fs/promises';
3
- import { openFile } from '@remix-run/fs';
3
+ import { openLazyFile } from '@remix-run/fs';
4
4
  import { createFileResponse as sendFile } from '@remix-run/response/file';
5
5
  import { generateDirectoryListing } from "./directory-listing.js";
6
6
  /**
@@ -11,7 +11,7 @@ import { generateDirectoryListing } from "./directory-listing.js";
11
11
  *
12
12
  * @param root The root directory to serve files from (absolute or relative to cwd)
13
13
  * @param options Configuration for file responses
14
- * @return The static files middleware
14
+ * @returns The static files middleware
15
15
  */
16
16
  export function staticFiles(root, options = {}) {
17
17
  // Ensure root is an absolute path
@@ -69,17 +69,17 @@ export function staticFiles(root, options = {}) {
69
69
  }
70
70
  if (filePath) {
71
71
  let fileName = path.relative(root, filePath);
72
- let file = openFile(filePath, { name: fileName });
72
+ let lazyFile = openLazyFile(filePath, { name: fileName });
73
73
  let finalFileOptions = { ...fileOptions };
74
- // If acceptRanges is a function, evaluate it with the file
74
+ // If acceptRanges is a function, evaluate it with the lazyFile
75
75
  // Otherwise, pass it directly to sendFile
76
76
  if (typeof acceptRanges === 'function') {
77
- finalFileOptions.acceptRanges = acceptRanges(file);
77
+ finalFileOptions.acceptRanges = acceptRanges(lazyFile);
78
78
  }
79
79
  else if (acceptRanges !== undefined) {
80
80
  finalFileOptions.acceptRanges = acceptRanges;
81
81
  }
82
- return sendFile(file, context.request, finalFileOptions);
82
+ return sendFile(lazyFile, context.request, finalFileOptions);
83
83
  }
84
84
  return next();
85
85
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix-run/static-middleware",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Middleware for serving static files from the filesystem",
5
5
  "author": "Michael Jackson <mjijackson@gmail.com>",
6
6
  "license": "MIT",
@@ -27,19 +27,19 @@
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^24.6.0",
30
- "typescript": "^5.9.3",
31
- "@remix-run/fetch-router": "0.12.0",
32
- "@remix-run/form-data-middleware": "0.1.0",
33
- "@remix-run/method-override-middleware": "0.1.1",
34
- "@remix-run/response": "^0.2.0",
35
- "@remix-run/mime": "^0.1.0"
30
+ "@typescript/native-preview": "7.0.0-dev.20251125.1",
31
+ "@remix-run/fetch-router": "0.15.1",
32
+ "@remix-run/form-data-middleware": "0.1.2",
33
+ "@remix-run/method-override-middleware": "0.1.2",
34
+ "@remix-run/mime": "0.3.0",
35
+ "@remix-run/response": "0.3.1"
36
36
  },
37
- "peerDependencies": {
38
- "@remix-run/fetch-router": "^0.12.0",
39
- "@remix-run/fs": "^0.2.0",
40
- "@remix-run/mime": "^0.1.0",
41
- "@remix-run/response": "^0.2.0",
42
- "@remix-run/html-template": "^0.3.0"
37
+ "dependencies": {
38
+ "@remix-run/fetch-router": "^0.15.1",
39
+ "@remix-run/fs": "^0.4.1",
40
+ "@remix-run/html-template": "^0.3.0",
41
+ "@remix-run/mime": "^0.3.0",
42
+ "@remix-run/response": "^0.3.1"
43
43
  },
44
44
  "keywords": [
45
45
  "fetch",
@@ -49,9 +49,9 @@
49
49
  "file-server"
50
50
  ],
51
51
  "scripts": {
52
- "build": "tsc -p tsconfig.build.json",
52
+ "build": "tsgo -p tsconfig.build.json",
53
53
  "clean": "git clean -fdX",
54
- "test": "node --disable-warning=ExperimentalWarning --test './src/**/*.test.ts'",
55
- "typecheck": "tsc --noEmit"
54
+ "test": "node --disable-warning=ExperimentalWarning --test",
55
+ "typecheck": "tsgo --noEmit"
56
56
  }
57
57
  }
package/src/lib/static.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as path from 'node:path'
2
2
  import * as fsp from 'node:fs/promises'
3
- import { openFile } from '@remix-run/fs'
3
+ import { openLazyFile } from '@remix-run/fs'
4
4
  import type { Middleware } from '@remix-run/fetch-router'
5
5
  import { createFileResponse as sendFile, type FileResponseOptions } from '@remix-run/response/file'
6
6
 
@@ -9,7 +9,7 @@ import { generateDirectoryListing } from './directory-listing.ts'
9
9
  /**
10
10
  * Function that determines if HTTP Range requests should be supported for a given file.
11
11
  *
12
- * @param file - The File object being served
12
+ * @param file The File object being served
13
13
  * @returns true if range requests should be supported
14
14
  */
15
15
  export type AcceptRangesFunction = (file: File) => boolean
@@ -22,7 +22,7 @@ export interface StaticFilesOptions extends Omit<FileResponseOptions, 'acceptRan
22
22
  * Filter function to determine which files should be served.
23
23
  *
24
24
  * @param path The relative path being requested
25
- * @return Whether to serve the file
25
+ * @returns Whether to serve the file
26
26
  */
27
27
  filter?: (path: string) => boolean
28
28
 
@@ -78,7 +78,7 @@ export interface StaticFilesOptions extends Omit<FileResponseOptions, 'acceptRan
78
78
  *
79
79
  * @param root The root directory to serve files from (absolute or relative to cwd)
80
80
  * @param options Configuration for file responses
81
- * @return The static files middleware
81
+ * @returns The static files middleware
82
82
  */
83
83
  export function staticFiles(root: string, options: StaticFilesOptions = {}): Middleware {
84
84
  // Ensure root is an absolute path
@@ -141,19 +141,19 @@ export function staticFiles(root: string, options: StaticFilesOptions = {}): Mid
141
141
 
142
142
  if (filePath) {
143
143
  let fileName = path.relative(root, filePath)
144
- let file = openFile(filePath, { name: fileName })
144
+ let lazyFile = openLazyFile(filePath, { name: fileName })
145
145
 
146
146
  let finalFileOptions: FileResponseOptions = { ...fileOptions }
147
147
 
148
- // If acceptRanges is a function, evaluate it with the file
148
+ // If acceptRanges is a function, evaluate it with the lazyFile
149
149
  // Otherwise, pass it directly to sendFile
150
150
  if (typeof acceptRanges === 'function') {
151
- finalFileOptions.acceptRanges = acceptRanges(file)
151
+ finalFileOptions.acceptRanges = acceptRanges(lazyFile)
152
152
  } else if (acceptRanges !== undefined) {
153
153
  finalFileOptions.acceptRanges = acceptRanges
154
154
  }
155
155
 
156
- return sendFile(file, context.request, finalFileOptions)
156
+ return sendFile(lazyFile, context.request, finalFileOptions)
157
157
  }
158
158
 
159
159
  return next()