@remix-run/assets 0.4.2 → 0.4.4
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/dist/lib/routes.d.ts.map +1 -1
- package/dist/lib/routes.js +12 -12
- package/package.json +7 -7
- package/src/lib/routes.ts +24 -14
package/dist/lib/routes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/lib/routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/lib/routes.ts"],"names":[],"mappings":"AAqBA,UAAU,WAAW;IACnB,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACzC,OAAO,EAAE,MAAM,CAAA;CAChB;AAUD,MAAM,WAAW,cAAc;IAC7B,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IACnD,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;CAC/C;AAYD,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,SAAS,WAAW,EAAE,GACnC,cAAc,CAgDhB"}
|
package/dist/lib/routes.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RoutePattern } from '@remix-run/route-pattern';
|
|
1
|
+
import { getRoutePatternCaptures, RoutePattern, } from '@remix-run/route-pattern';
|
|
2
2
|
import { createHref } from '@remix-run/route-pattern/href';
|
|
3
3
|
import { createMatcher } from '@remix-run/route-pattern/match';
|
|
4
4
|
import { getRelativeFilePath, isAbsoluteFilePath, normalizeFilePath, normalizePathname, resolveFilePath, } from "./paths.js";
|
|
@@ -26,7 +26,7 @@ export function compileRoutes(basePath, routeConfigs) {
|
|
|
26
26
|
let match = route.urlMatcher.match(`http://remix.run${normalizedPathname}`);
|
|
27
27
|
if (!match)
|
|
28
28
|
continue;
|
|
29
|
-
let relativeFilePath = createHref(route.filePattern, match.params).replace(/^\/+/, '');
|
|
29
|
+
let relativeFilePath = decodeURIComponent(createHref(route.filePattern, match.params)).replace(/^\/+/, '');
|
|
30
30
|
return resolveFilePath(route.rootDir, relativeFilePath);
|
|
31
31
|
}
|
|
32
32
|
return null;
|
|
@@ -76,24 +76,24 @@ function stripDotSegments(pattern) {
|
|
|
76
76
|
return segments.join('/');
|
|
77
77
|
}
|
|
78
78
|
function validateRoutePatterns(urlPattern, filePattern) {
|
|
79
|
-
let
|
|
80
|
-
let
|
|
81
|
-
if (
|
|
79
|
+
let urlCaptures = getPathnameCaptures(urlPattern);
|
|
80
|
+
let fileCaptures = getPathnameCaptures(filePattern);
|
|
81
|
+
if (urlCaptures.length !== fileCaptures.length) {
|
|
82
82
|
throw new Error(`Route patterns must have matching capture structure.\nURL: ${urlPattern}\nFile: ${filePattern}`);
|
|
83
83
|
}
|
|
84
|
-
for (let i = 0; i <
|
|
85
|
-
let
|
|
86
|
-
let
|
|
87
|
-
if (
|
|
84
|
+
for (let i = 0; i < urlCaptures.length; i++) {
|
|
85
|
+
let urlCapture = urlCaptures[i];
|
|
86
|
+
let fileCapture = fileCaptures[i];
|
|
87
|
+
if (urlCapture.type !== fileCapture.type || urlCapture.name !== fileCapture.name) {
|
|
88
88
|
throw new Error(`Route patterns must have matching capture structure.\nURL: ${urlPattern}\nFile: ${filePattern}`);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
function validateNoUnnamedWildcards(pattern, label) {
|
|
93
|
-
if (pattern.
|
|
93
|
+
if (getRoutePatternCaptures(pattern).some((capture) => capture.part === 'pathname' && capture.type === '*' && capture.name === '*')) {
|
|
94
94
|
throw new Error(`${label} route patterns must use named wildcards for reversible mapping.\nPattern: ${pattern}`);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
return pattern.
|
|
97
|
+
function getPathnameCaptures(pattern) {
|
|
98
|
+
return getRoutePatternCaptures(pattern).filter((capture) => capture.part === 'pathname');
|
|
99
99
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remix-run/assets",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "Fetch-based server for compiling browser JS/TS and CSS assets on demand",
|
|
5
5
|
"author": "Michael Jackson <mjijackson@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,17 +38,17 @@
|
|
|
38
38
|
"oxc-transform": "^0.121.0",
|
|
39
39
|
"picomatch": "^4.0.4",
|
|
40
40
|
"source-map-js": "^1.2.1",
|
|
41
|
-
"@remix-run/
|
|
42
|
-
"@remix-run/
|
|
43
|
-
"@remix-run/route-pattern": "0.
|
|
44
|
-
"@remix-run/
|
|
41
|
+
"@remix-run/headers": "0.21.1",
|
|
42
|
+
"@remix-run/file-storage": "0.13.7",
|
|
43
|
+
"@remix-run/route-pattern": "0.23.0",
|
|
44
|
+
"@remix-run/mime": "0.4.2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "^24.6.0",
|
|
48
48
|
"@types/picomatch": "^4.0.3",
|
|
49
49
|
"@typescript/native-preview": "7.0.0-dev.20251125.1",
|
|
50
|
-
"@remix-run/assert": "0.
|
|
51
|
-
"@remix-run/test": "0.
|
|
50
|
+
"@remix-run/assert": "0.3.0",
|
|
51
|
+
"@remix-run/test": "0.5.0"
|
|
52
52
|
},
|
|
53
53
|
"keywords": [
|
|
54
54
|
"remix",
|
package/src/lib/routes.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getRoutePatternCaptures,
|
|
3
|
+
RoutePattern,
|
|
4
|
+
type RoutePatternCapture,
|
|
5
|
+
} from '@remix-run/route-pattern'
|
|
2
6
|
import { createHref } from '@remix-run/route-pattern/href'
|
|
3
7
|
import { createMatcher, type Matcher } from '@remix-run/route-pattern/match'
|
|
4
8
|
|
|
@@ -73,7 +77,9 @@ export function compileRoutes(
|
|
|
73
77
|
for (let route of compiledRoutes) {
|
|
74
78
|
let match = route.urlMatcher.match(`http://remix.run${normalizedPathname}`)
|
|
75
79
|
if (!match) continue
|
|
76
|
-
let relativeFilePath =
|
|
80
|
+
let relativeFilePath = decodeURIComponent(
|
|
81
|
+
createHref(route.filePattern, match.params),
|
|
82
|
+
).replace(/^\/+/, '')
|
|
77
83
|
return resolveFilePath(route.rootDir, relativeFilePath)
|
|
78
84
|
}
|
|
79
85
|
|
|
@@ -140,18 +146,18 @@ function stripDotSegments(pattern: string): string {
|
|
|
140
146
|
}
|
|
141
147
|
|
|
142
148
|
function validateRoutePatterns(urlPattern: RoutePattern, filePattern: RoutePattern): void {
|
|
143
|
-
let
|
|
144
|
-
let
|
|
145
|
-
if (
|
|
149
|
+
let urlCaptures = getPathnameCaptures(urlPattern)
|
|
150
|
+
let fileCaptures = getPathnameCaptures(filePattern)
|
|
151
|
+
if (urlCaptures.length !== fileCaptures.length) {
|
|
146
152
|
throw new Error(
|
|
147
153
|
`Route patterns must have matching capture structure.\nURL: ${urlPattern}\nFile: ${filePattern}`,
|
|
148
154
|
)
|
|
149
155
|
}
|
|
150
156
|
|
|
151
|
-
for (let i = 0; i <
|
|
152
|
-
let
|
|
153
|
-
let
|
|
154
|
-
if (
|
|
157
|
+
for (let i = 0; i < urlCaptures.length; i++) {
|
|
158
|
+
let urlCapture = urlCaptures[i]
|
|
159
|
+
let fileCapture = fileCaptures[i]
|
|
160
|
+
if (urlCapture.type !== fileCapture.type || urlCapture.name !== fileCapture.name) {
|
|
155
161
|
throw new Error(
|
|
156
162
|
`Route patterns must have matching capture structure.\nURL: ${urlPattern}\nFile: ${filePattern}`,
|
|
157
163
|
)
|
|
@@ -160,17 +166,21 @@ function validateRoutePatterns(urlPattern: RoutePattern, filePattern: RoutePatte
|
|
|
160
166
|
}
|
|
161
167
|
|
|
162
168
|
function validateNoUnnamedWildcards(pattern: RoutePattern, label: string): void {
|
|
163
|
-
if (
|
|
169
|
+
if (
|
|
170
|
+
getRoutePatternCaptures(pattern).some(
|
|
171
|
+
(capture) => capture.part === 'pathname' && capture.type === '*' && capture.name === '*',
|
|
172
|
+
)
|
|
173
|
+
) {
|
|
164
174
|
throw new Error(
|
|
165
175
|
`${label} route patterns must use named wildcards for reversible mapping.\nPattern: ${pattern}`,
|
|
166
176
|
)
|
|
167
177
|
}
|
|
168
178
|
}
|
|
169
179
|
|
|
170
|
-
type
|
|
180
|
+
type PathnameCapture = RoutePatternCapture & { readonly part: 'pathname' }
|
|
171
181
|
|
|
172
|
-
function
|
|
173
|
-
return pattern.
|
|
174
|
-
(
|
|
182
|
+
function getPathnameCaptures(pattern: RoutePattern): Array<PathnameCapture> {
|
|
183
|
+
return getRoutePatternCaptures(pattern).filter(
|
|
184
|
+
(capture): capture is PathnameCapture => capture.part === 'pathname',
|
|
175
185
|
)
|
|
176
186
|
}
|