remix 3.0.0-beta.6 → 3.0.0-beta.9

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.
@@ -0,0 +1,2 @@
1
+ export * from '@remix-run/static-files-middleware';
2
+ //# sourceMappingURL=static-files-middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static-files-middleware.d.ts","sourceRoot":"","sources":["../src/static-files-middleware.ts"],"names":[],"mappings":"AACA,cAAc,oCAAoC,CAAA"}
@@ -1,2 +1,2 @@
1
1
  // IMPORTANT: This file is auto-generated, please do not edit manually.
2
- export * from '@remix-run/static-middleware'
2
+ export * from '@remix-run/static-files-middleware';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remix",
3
- "version": "3.0.0-beta.6",
3
+ "version": "3.0.0-beta.9",
4
4
  "description": "The Remix web framework",
5
5
  "author": "Michael Jackson <mjijackson@gmail.com>",
6
6
  "license": "MIT",
@@ -245,8 +245,8 @@
245
245
  "default": "./dist/session-middleware.js"
246
246
  },
247
247
  "./middleware/static": {
248
- "types": "./dist/static-middleware.d.ts",
249
- "default": "./dist/static-middleware.js"
248
+ "types": "./dist/static-files-middleware.d.ts",
249
+ "default": "./dist/static-files-middleware.js"
250
250
  },
251
251
  "./mime": {
252
252
  "types": "./dist/mime.d.ts",
@@ -509,50 +509,50 @@
509
509
  "dependencies": {
510
510
  "@remix-run/assets": "^0.5.0",
511
511
  "@remix-run/async-context-middleware": "^0.3.5",
512
- "@remix-run/compression-middleware": "^0.1.13",
512
+ "@remix-run/auth": "^0.2.7",
513
513
  "@remix-run/auth-middleware": "^0.2.5",
514
- "@remix-run/ui": "^0.5.0",
514
+ "@remix-run/ui": "^0.7.0",
515
+ "@remix-run/compression-middleware": "^0.1.13",
515
516
  "@remix-run/cop-middleware": "^0.1.8",
516
- "@remix-run/auth": "^0.2.7",
517
- "@remix-run/cookie": "^0.6.0",
518
517
  "@remix-run/csrf-middleware": "^0.1.8",
519
- "@remix-run/cors-middleware": "^0.1.8",
520
- "@remix-run/data-table": "^0.4.0",
521
- "@remix-run/data-table-postgres": "^0.5.0",
518
+ "@remix-run/cookie": "^0.6.0",
522
519
  "@remix-run/data-schema": "^0.3.0",
523
520
  "@remix-run/data-table-mysql": "^0.5.0",
521
+ "@remix-run/data-table-postgres": "^0.5.0",
522
+ "@remix-run/data-table": "^0.4.0",
524
523
  "@remix-run/data-table-sqlite": "^0.6.0",
524
+ "@remix-run/cors-middleware": "^0.1.8",
525
525
  "@remix-run/fetch-proxy": "^0.8.5",
526
- "@remix-run/file-storage": "^0.13.7",
527
526
  "@remix-run/fetch-router": "^0.21.0",
527
+ "@remix-run/file-storage": "^0.13.7",
528
528
  "@remix-run/form-data-middleware": "^0.3.5",
529
- "@remix-run/form-data-parser": "^0.17.5",
530
529
  "@remix-run/file-storage-s3": "^0.1.4",
530
+ "@remix-run/form-data-parser": "^0.17.5",
531
531
  "@remix-run/fs": "^0.4.6",
532
532
  "@remix-run/lazy-file": "^5.0.6",
533
- "@remix-run/method-override-middleware": "^0.1.13",
534
533
  "@remix-run/logger-middleware": "^0.3.5",
534
+ "@remix-run/html-template": "^0.3.1",
535
535
  "@remix-run/headers": "^0.21.1",
536
- "@remix-run/multipart-parser": "^0.16.4",
536
+ "@remix-run/method-override-middleware": "^0.1.13",
537
537
  "@remix-run/mime": "^0.4.2",
538
+ "@remix-run/multipart-parser": "^0.16.4",
538
539
  "@remix-run/node-fetch-server": "^0.14.1",
539
- "@remix-run/html-template": "^0.3.1",
540
540
  "@remix-run/response": "^0.3.8",
541
541
  "@remix-run/route-pattern": "^0.24.0",
542
542
  "@remix-run/node-tsx": "^0.1.1",
543
+ "@remix-run/session": "^0.4.2",
543
544
  "@remix-run/session-middleware": "^0.4.0",
544
- "@remix-run/session-storage-redis": "^0.1.1",
545
545
  "@remix-run/session-storage-memcache": "^0.1.2",
546
- "@remix-run/static-middleware": "^0.4.13",
546
+ "@remix-run/session-storage-redis": "^0.1.1",
547
547
  "@remix-run/tar-parser": "^0.7.1",
548
548
  "@remix-run/assert": "^0.3.0",
549
- "@remix-run/session": "^0.4.2",
550
- "@remix-run/cli": "^0.4.0",
549
+ "@remix-run/cli": "^0.5.0",
550
+ "@remix-run/terminal": "^0.1.1",
551
+ "@remix-run/render-middleware": "^0.1.5",
552
+ "@remix-run/test": "^0.6.0",
551
553
  "@remix-run/node-hmr": "^0.1.0",
552
554
  "@remix-run/ui-hmr": "^0.1.0",
553
- "@remix-run/test": "^0.6.0",
554
- "@remix-run/terminal": "^0.1.1",
555
- "@remix-run/render-middleware": "^0.1.5"
555
+ "@remix-run/static-files-middleware": "^0.1.0"
556
556
  },
557
557
  "bin": {
558
558
  "remix": "./dist/cli-entry.js"
@@ -1,4 +1,4 @@
1
- # static-middleware
1
+ # static-files-middleware
2
2
 
3
3
  Static file serving middleware for Remix. Serves static files from a directory with support for ETags, range requests, and conditional requests.
4
4
 
@@ -75,7 +75,7 @@ let router = createRouter({
75
75
 
76
76
  ## Security
77
77
 
78
- - Prevents path traversal attacks (e.g., `../../../etc/passwd`)
78
+ - Prevents path traversal attacks
79
79
  - Only serves files with GET and HEAD requests
80
80
  - Respects the configured root directory boundary
81
81
 
@@ -1,2 +1,2 @@
1
1
  // IMPORTANT: This file is auto-generated, please do not edit manually.
2
- export * from '@remix-run/static-middleware';
2
+ export * from '@remix-run/static-files-middleware'
package/src/ui/README.md CHANGED
@@ -81,10 +81,10 @@ function Actions() {
81
81
 
82
82
  ## Frame Navigation
83
83
 
84
- Configure `resolveFrame` once to progressively enhance same-origin links and forms. The resolver owns the fetch request and receives native submission metadata for non-GET forms:
84
+ `run()` progressively enhances same-origin links and forms using a default `resolveFrame` that
85
+ fetches the frame source:
85
86
 
86
87
  ```tsx
87
- import type { ResolveFrameOptions } from 'remix/ui'
88
88
  import { run } from 'remix/ui'
89
89
 
90
90
  let app = run({
@@ -92,20 +92,44 @@ let app = run({
92
92
  let mod = await import(moduleUrl)
93
93
  return mod[exportName]
94
94
  },
95
- async resolveFrame(src, options) {
96
- return fetch(src, {
97
- headers: { Accept: 'text/html', 'X-Remix-Frame': 'true' },
98
- method: options?.method,
99
- body: getRequestBody(options),
100
- signal: options?.signal,
101
- })
102
- },
103
95
  })
104
96
 
105
- function getRequestBody(options?: ResolveFrameOptions): BodyInit | undefined {
97
+ await app.ready()
98
+ ```
99
+
100
+ The default resolver is equivalent to:
101
+
102
+ ```js
103
+ async function resolveFrame(src, options) {
104
+ let response = await fetch(src, {
105
+ body: getRequestBody(options),
106
+ headers: { Accept: 'text/html' },
107
+ method: options?.method,
108
+ signal: options?.signal,
109
+ })
110
+
111
+ if (!response.ok) {
112
+ throw new Error(`Failed to resolve frame: ${response.status} ${response.statusText}`.trimEnd())
113
+ }
114
+
115
+ return response
116
+ }
117
+
118
+ function getRequestBody(options) {
106
119
  let formData = options?.formData
107
- if (!formData) return
108
- if (options.encType !== 'application/x-www-form-urlencoded') return formData
120
+ if (!formData || options?.method?.toLowerCase() === 'get') return
121
+
122
+ if (options?.encType === 'text/plain') {
123
+ let body = ''
124
+ for (let [name, value] of formData) {
125
+ name = normalizeLineBreaks(name)
126
+ value = normalizeLineBreaks(typeof value === 'string' ? value : value.name)
127
+ body += `${name}=${value}\r\n`
128
+ }
129
+ return new Blob([body], { type: 'text/plain' })
130
+ }
131
+
132
+ if (options?.encType !== 'application/x-www-form-urlencoded') return formData
109
133
 
110
134
  let body = new URLSearchParams()
111
135
  for (let [name, value] of formData) {
@@ -114,9 +138,23 @@ function getRequestBody(options?: ResolveFrameOptions): BodyInit | undefined {
114
138
  return body
115
139
  }
116
140
 
117
- await app.ready()
141
+ function normalizeLineBreaks(value) {
142
+ return value.replace(/\r\n|\r|\n/g, '\r\n')
143
+ }
118
144
  ```
119
145
 
146
+ The default resolver requests HTML. GET form values are already encoded in `src`;
147
+ `application/x-www-form-urlencoded` submissions use `URLSearchParams`, `text/plain` submissions use
148
+ CRLF-delimited text, and `multipart/form-data` submissions use `FormData`. Pass a custom
149
+ `resolveFrame` when the server requires additional headers, another body encoding, or a different
150
+ response policy.
151
+
152
+ Add `rmx-document` to a link or form to leave its navigation to the browser.
153
+
154
+ The default resolver rejects non-OK responses with an error containing their status and status text.
155
+ A custom `resolveFrame` may return a `Response` with any status when it wants Remix UI to render the
156
+ response body.
157
+
120
158
  Forms remain ordinary HTML forms before the runtime starts. Add `rmx-target` to reload a named frame, or `rmx-document` to require a full-document submission:
121
159
 
122
160
  ```tsx
@@ -23,6 +23,7 @@ Renders a component tree to a streaming response. The initial HTML is sent immed
23
23
 
24
24
  ```tsx
25
25
  import { renderToStream } from 'remix/ui/server'
26
+ import { assetServer } from './assets.ts'
26
27
 
27
28
  let stream = renderToStream(<App />, {
28
29
  frameSrc: request.url,
@@ -31,6 +32,17 @@ let stream = renderToStream(<App />, {
31
32
  let frameUrl = new URL(src, context?.currentFrameSrc ?? request.url)
32
33
  return fetchHtml(frameUrl)
33
34
  },
35
+ async resolveClientEntry(entryId, component) {
36
+ let [href, preloads] = await Promise.all([
37
+ assetServer.getHref(entryId),
38
+ assetServer.getPreloads(entryId),
39
+ ])
40
+ return {
41
+ href,
42
+ exportName: entryId.split('#')[1] || component.name,
43
+ preloads,
44
+ }
45
+ },
34
46
  onError(error) {
35
47
  console.error(error)
36
48
  },
@@ -47,6 +59,7 @@ return new Response(stream, {
47
59
  - **`topFrameSrc`** - Overrides the root frame URL used for `handle.frames.top.src`. This is mainly useful when calling `renderToStream()` from inside `resolveFrame()` for a nested frame render.
48
60
  - **`signal`** - Cancels pending server rendering work. Pass `request.signal` so client disconnects can stop unresolved frame work without invoking `onError` for the disconnect itself.
49
61
  - **`resolveFrame(src, target, context)`** - Called when a `<Frame>` needs its content. Return a string of HTML, a `ReadableStream<Uint8Array>`, or a promise of either. `context.currentFrameSrc` is the URL for the frame that contains the `<Frame>`, and `context.topFrameSrc` is the outer document URL. Required if your component tree contains `<Frame>` elements.
62
+ - **`resolveClientEntry(entryId, component)`** - Resolves the public module URL, export name, and optional module preload hrefs for a hydrated client entry.
50
63
  - **`onError(error)`** - Called when a rendering error occurs. If not provided, the stream rejects with the error.
51
64
 
52
65
  When you render nested frame responses with `renderToStream()` inside `resolveFrame()`, pass `frameSrc` for the frame being rendered and carry `topFrameSrc` forward from the parent context. That preserves `handle.frames.top.src` across the whole SSR frame tree.
@@ -1,2 +0,0 @@
1
- export * from '@remix-run/static-middleware';
2
- //# sourceMappingURL=static-middleware.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"static-middleware.d.ts","sourceRoot":"","sources":["../src/static-middleware.ts"],"names":[],"mappings":"AACA,cAAc,8BAA8B,CAAA"}