@remix-run/render-middleware 0.2.0 → 0.3.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/README.md +2 -2
- package/dist/lib/render-ui.d.ts +2 -2
- package/dist/lib/render-ui.d.ts.map +1 -1
- package/dist/lib/render-ui.js +2 -5
- package/package.json +6 -6
- package/src/lib/render-ui.ts +7 -10
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Request-scoped response rendering for Remix. It provides the conventional Remix
|
|
|
6
6
|
|
|
7
7
|
- **Remix UI rendering** - Stream nodes to HTML responses with `render()`
|
|
8
8
|
- **Framework-owned frames** - Resolve nested and targeted `<Frame>` requests through the current router
|
|
9
|
-
- **Client entry assets** - Resolve source-based `clientEntry()` modules and
|
|
9
|
+
- **Client entry assets** - Resolve source-based `clientEntry()` modules, import maps, and preloads through an asset server
|
|
10
10
|
- **Typed context** - Preserve renderer input and response option types on `context.render`
|
|
11
11
|
- **Custom renderers** - Install JSON, email, or other response pipelines with `renderWith()`
|
|
12
12
|
|
|
@@ -72,7 +72,7 @@ The middleware forwards request credentials and session headers to internal fram
|
|
|
72
72
|
|
|
73
73
|
### Options
|
|
74
74
|
|
|
75
|
-
- **`assets`** - An asset server that resolves source-based client entry IDs to browser module URLs and preload URLs. Omit it when client entries already use public URLs or the app has no client entries.
|
|
75
|
+
- **`assets`** - An asset server that resolves source-based client entry IDs to browser module URLs, import maps, and preload URLs. Omit it when client entries already use public URLs or the app has no client entries.
|
|
76
76
|
- **`onError`** - A callback for server rendering errors. When omitted, the UI renderer uses its default error reporting.
|
|
77
77
|
|
|
78
78
|
## Custom renderers
|
package/dist/lib/render-ui.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ import { type Renderer } from './render.ts';
|
|
|
5
5
|
type RemixNode = Parameters<typeof renderToStream>[0];
|
|
6
6
|
/** Options for the standard Remix UI renderer. */
|
|
7
7
|
export interface RenderOptions {
|
|
8
|
-
/** Asset server used to turn source-based client entry IDs into browser module
|
|
9
|
-
assets?: Pick<AssetServer, '
|
|
8
|
+
/** Asset server used to turn source-based client entry IDs into browser module metadata. */
|
|
9
|
+
assets?: Pick<AssetServer, 'getScriptEntry'>;
|
|
10
10
|
/** Error hook invoked when server rendering fails. */
|
|
11
11
|
onError?: (error: unknown) => void;
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-ui.d.ts","sourceRoot":"","sources":["../../src/lib/render-ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,yBAAyB,CAAA;AAEzE,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"render-ui.d.ts","sourceRoot":"","sources":["../../src/lib/render-ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,yBAAyB,CAAA;AAEzE,OAAO,EAAE,cAAc,EAAgD,MAAM,sBAAsB,CAAA;AAEnG,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAA;AAGvD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;AAqCrD,kDAAkD;AAClD,MAAM,WAAW,aAAa;IAC5B,4FAA4F;IAC5F,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAA;IAC5C,sDAAsD;IACtD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;CACnC;AAED,mDAAmD;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,YAAY,KAAK,QAAQ,CAAA;AAE/E;;;;;GAKG;AACH,wBAAgB,MAAM,CACpB,OAAO,GAAE,aAAkB,GAC1B,UAAU,CAAC;IAAE,GAAG,EAAE,OAAO,QAAQ,CAAC;IAAC,KAAK,EAAE,cAAc,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC,CAqBjF"}
|
package/dist/lib/render-ui.js
CHANGED
|
@@ -146,11 +146,8 @@ async function resolveClientEntry(assets, entryId, component) {
|
|
|
146
146
|
}
|
|
147
147
|
if (!exportName)
|
|
148
148
|
throw createMissingExportNameError(entryId, true);
|
|
149
|
-
let
|
|
150
|
-
|
|
151
|
-
assets.getPreloads(sourceId),
|
|
152
|
-
]);
|
|
153
|
-
return { href, exportName, preloads };
|
|
149
|
+
let { href, importMap, preloads } = await assets.getScriptEntry(sourceId);
|
|
150
|
+
return { href, importMap, exportName, preloads };
|
|
154
151
|
}
|
|
155
152
|
if (!exportName)
|
|
156
153
|
throw createMissingExportNameError(entryId, assets != null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remix-run/render-middleware",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Conventional Remix UI and custom request-scoped render middleware",
|
|
5
5
|
"author": "Michael Jackson <mjijackson@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^24.6.0",
|
|
30
30
|
"typescript": "^7.0.2",
|
|
31
|
-
"@remix-run/fetch-router": "0.21.0",
|
|
32
31
|
"@remix-run/assert": "0.3.0",
|
|
33
|
-
"@remix-run/test": "0.6.0"
|
|
32
|
+
"@remix-run/test": "0.6.0",
|
|
33
|
+
"@remix-run/fetch-router": "0.22.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@remix-run/assets": "^0.
|
|
37
|
-
"@remix-run/ui": "^0.8.0",
|
|
36
|
+
"@remix-run/assets": "^0.7.0",
|
|
38
37
|
"@remix-run/response": "^0.3.8",
|
|
39
|
-
"@remix-run/fetch-router": "^0.
|
|
38
|
+
"@remix-run/fetch-router": "^0.22.0",
|
|
39
|
+
"@remix-run/ui": "^0.9.0"
|
|
40
40
|
},
|
|
41
41
|
"keywords": [
|
|
42
42
|
"fetch",
|
package/src/lib/render-ui.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AssetServer } from '@remix-run/assets'
|
|
2
2
|
import type { Middleware, RequestContext } from '@remix-run/fetch-router'
|
|
3
3
|
import { createHtmlResponse } from '@remix-run/response/html'
|
|
4
|
-
import { renderToStream, type ResolveFrameContext } from '@remix-run/ui/server'
|
|
4
|
+
import { renderToStream, type ImportMapData, type ResolveFrameContext } from '@remix-run/ui/server'
|
|
5
5
|
|
|
6
6
|
import { renderWith, type Renderer } from './render.ts'
|
|
7
7
|
|
|
@@ -45,8 +45,8 @@ const CROSS_ORIGIN_FRAME_HEADERS = [
|
|
|
45
45
|
|
|
46
46
|
/** Options for the standard Remix UI renderer. */
|
|
47
47
|
export interface RenderOptions {
|
|
48
|
-
/** Asset server used to turn source-based client entry IDs into browser module
|
|
49
|
-
assets?: Pick<AssetServer, '
|
|
48
|
+
/** Asset server used to turn source-based client entry IDs into browser module metadata. */
|
|
49
|
+
assets?: Pick<AssetServer, 'getScriptEntry'>
|
|
50
50
|
/** Error hook invoked when server rendering fails. */
|
|
51
51
|
onError?: (error: unknown) => void
|
|
52
52
|
}
|
|
@@ -191,10 +191,10 @@ function createCrossOriginFrameHeaders(headers: Headers): Headers {
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
async function resolveClientEntry(
|
|
194
|
-
assets: Pick<AssetServer, '
|
|
194
|
+
assets: Pick<AssetServer, 'getScriptEntry'> | undefined,
|
|
195
195
|
entryId: string,
|
|
196
196
|
component: { readonly name: string },
|
|
197
|
-
): Promise<{ href: string; exportName: string; preloads?: string[] }> {
|
|
197
|
+
): Promise<{ href: string; importMap?: ImportMapData; exportName: string; preloads?: string[] }> {
|
|
198
198
|
let hashIndex = entryId.lastIndexOf('#')
|
|
199
199
|
let sourceId = hashIndex === -1 ? entryId : entryId.slice(0, hashIndex)
|
|
200
200
|
let explicitExportName = hashIndex === -1 ? '' : entryId.slice(hashIndex + 1)
|
|
@@ -208,12 +208,9 @@ async function resolveClientEntry(
|
|
|
208
208
|
}
|
|
209
209
|
if (!exportName) throw createMissingExportNameError(entryId, true)
|
|
210
210
|
|
|
211
|
-
let
|
|
212
|
-
assets.getHref(sourceId),
|
|
213
|
-
assets.getPreloads(sourceId),
|
|
214
|
-
])
|
|
211
|
+
let { href, importMap, preloads } = await assets.getScriptEntry(sourceId)
|
|
215
212
|
|
|
216
|
-
return { href, exportName, preloads }
|
|
213
|
+
return { href, importMap, exportName, preloads }
|
|
217
214
|
}
|
|
218
215
|
|
|
219
216
|
if (!exportName) throw createMissingExportNameError(entryId, assets != null)
|