mirror of
https://github.com/prdlk/dotfiles.git
synced 2026-11-05 20:17:42 +00:00
chs: re-add drifted files
This commit is contained in:
1 parent
fc4837392a
commit
063e9839ce
50 files changed
+516
-482
No files matched your search
@@ -103,7 +103,6 @@ The resolved `preloads` array contains browser module hrefs. During server rende
|
||||
Use `run` to start the client runtime. It scans the document for client entry markers, loads modules, and hydrates each one:
|
||||
|
||||
```tsx
|
||||
import type { ResolveFrameOptions } from 'remix/ui'
|
||||
import { run } from 'remix/ui'
|
||||
|
||||
const app = run({
|
||||
@@ -111,31 +110,8 @@ const app = run({
|
||||
let mod = await import(moduleUrl)
|
||||
return mod[exportName]
|
||||
},
|
||||
async resolveFrame(src, options) {
|
||||
let headers = new Headers({ accept: 'text/html', 'x-remix-frame': 'true' })
|
||||
if (options?.target) headers.set('x-remix-target', options.target)
|
||||
let response = await fetch(src, {
|
||||
body: getRequestBody(options),
|
||||
headers,
|
||||
method: options?.method,
|
||||
signal: options?.signal,
|
||||
})
|
||||
return response.body ?? (await response.text())
|
||||
},
|
||||
})
|
||||
|
||||
function getRequestBody(options?: ResolveFrameOptions): BodyInit | undefined {
|
||||
let formData = options?.formData
|
||||
if (!formData) return
|
||||
if (options.encType !== 'application/x-www-form-urlencoded') return formData
|
||||
|
||||
let body = new URLSearchParams()
|
||||
for (let [name, value] of formData) {
|
||||
body.append(name, typeof value === 'string' ? value : value.name)
|
||||
}
|
||||
return body
|
||||
}
|
||||
|
||||
app.addEventListener('error', (event) => {
|
||||
console.error('Component error:', event.error)
|
||||
})
|
||||
@@ -143,10 +119,22 @@ app.addEventListener('error', (event) => {
|
||||
await app.ready()
|
||||
```
|
||||
|
||||
By default, `run()` resolves frames with `fetch()`, requests `text/html`, and forwards the submitted
|
||||
method and abort signal. GET form values are already encoded in `src`; non-GET submissions use
|
||||
`URLSearchParams` for `application/x-www-form-urlencoded`, CRLF-delimited text for `text/plain`, and
|
||||
`FormData` for `multipart/form-data`. Provide `resolveFrame` when an app needs additional headers,
|
||||
another body encoding, or a different response policy.
|
||||
|
||||
Add `rmx-document` to a link or form to leave its navigation to the browser.
|
||||
|
||||
The default resolver rejects non-OK responses with an error containing their status and status text.
|
||||
A custom `resolveFrame` may return a `Response` with any status when it wants the runtime to render
|
||||
the response body.
|
||||
|
||||
### `run` options
|
||||
|
||||
- **`loadModule(moduleUrl, exportName)`** (required) — return the component function for each client entry. Typically uses dynamic `import()`.
|
||||
- **`resolveFrame(src, options)`** (optional) — called when a `<Frame>` loads or reloads content and for intercepted link and form navigations. `options` may contain `signal` and `target`; non-GET forms also provide `formData`, `method`, and `encType`.
|
||||
- **`resolveFrame(src, options)`** (optional) — overrides the default `fetch()` resolver when a `<Frame>` loads or reloads content and for intercepted link and form navigations. `options` may contain `signal` and `target`; non-GET forms also provide `formData`, `method`, and `encType`.
|
||||
|
||||
### `app` methods
|
||||
|
||||
@@ -217,7 +205,7 @@ When a frame reloads, matching DOM nodes are updated in place. Client entries re
|
||||
|
||||
### Form navigation
|
||||
|
||||
When `run({ resolveFrame })` is active, eligible same-origin forms progressively enhance into frame navigations. Native validation and the form's `submit` event still run first.
|
||||
When `run()` is active, eligible same-origin forms progressively enhance into frame navigations. Native validation and the form's `submit` event still run first.
|
||||
|
||||
- Forms target `handle.frames.top` by default.
|
||||
- `rmx-target` selects a named frame.
|
||||
|
||||
Reference in new issue
Block a user