@quilted/quilt 0.5.145 → 0.5.147

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.
@@ -1,2 +1,8 @@
1
- export {};
1
+ import { type AsyncModulesGlobal } from '@quilted/async';
2
+ export interface QuiltGlobal {
3
+ readonly AsyncModules: AsyncModulesGlobal;
4
+ }
5
+ declare const quilt: QuiltGlobal;
6
+ export default quilt;
7
+ export { quilt, quilt as global };
2
8
  //# sourceMappingURL=global.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../source/global.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../source/global.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,YAAY,EAAE,kBAAkB,CAAC;CAC3C;AAGD,QAAA,MAAM,KAAK,aAAuD,CAAC;AAanE,eAAe,KAAK,CAAC;AACrB,OAAO,EAAC,KAAK,EAAE,KAAK,IAAI,MAAM,EAAC,CAAC"}
@@ -2,7 +2,7 @@ import { type ReactElement } from 'react';
2
2
  import { type AssetsCacheKey, type BrowserAssets, type BrowserAssetsEntry } from '@quilted/assets';
3
3
  import { AssetsManager } from '@quilted/react-assets/server';
4
4
  import { HttpManager } from '@quilted/react-http/server';
5
- import { HtmlManager } from '@quilted/react-html/server';
5
+ import { HtmlManager, type HtmlProps } from '@quilted/react-html/server';
6
6
  import type { Options as ExtractOptions, ServerRenderRequestContext } from '@quilted/react-server-render/server';
7
7
  import type { EnhancedRequest, RequestHandler, RequestContext } from '@quilted/request-router';
8
8
  export interface ServerRenderOptions<Context = RequestContext, CacheKey = AssetsCacheKey> {
@@ -11,11 +11,17 @@ export interface ServerRenderOptions<Context = RequestContext, CacheKey = Assets
11
11
  extract?: Omit<ExtractOptions, 'context'> & {
12
12
  readonly context?: ServerRenderRequestContext | ((request: EnhancedRequest, context: Context) => ServerRenderRequestContext);
13
13
  };
14
- renderHtml?(content: string | undefined, details: Pick<ServerRenderAppDetails, 'http' | 'html'> & {
14
+ html?: ServerRenderHtmlRender<Context> | {
15
+ readonly rootElement?: HtmlProps['rootElement'];
16
+ };
17
+ }
18
+ export interface ServerRenderHtmlRender<Context> {
19
+ (content: string | undefined, details: Pick<ServerRenderAppDetails, 'http' | 'html'> & {
15
20
  readonly request: EnhancedRequest;
16
21
  readonly context: Context;
17
22
  readonly assets?: BrowserAssetsEntry;
18
23
  readonly preloadAssets?: BrowserAssetsEntry;
24
+ readonly rootElement?: HtmlProps['rootElement'];
19
25
  }): ReactElement<any> | Promise<ReactElement<any>>;
20
26
  }
21
27
  export interface ServerRenderAppDetails<_Context = RequestContext, CacheKey = AssetsCacheKey> {
@@ -24,12 +30,13 @@ export interface ServerRenderAppDetails<_Context = RequestContext, CacheKey = As
24
30
  readonly assets: AssetsManager<CacheKey>;
25
31
  readonly rendered?: string;
26
32
  }
27
- export declare function createServerRender<Context = RequestContext, CacheKey = AssetsCacheKey>(getApp: ReactElement<any> | ((request: EnhancedRequest, context: Context) => ReactElement<any> | Promise<ReactElement<any>>), { stream, ...options }?: ServerRenderOptions<Context, CacheKey>): RequestHandler<Context>;
28
- export declare function renderAppToResponse<Context = RequestContext, CacheKey = AssetsCacheKey>(getApp: ReactElement<any> | (() => ReactElement<any> | Promise<ReactElement<any>>), { request, context, assets, extract, renderHtml, }: Pick<ServerRenderOptions<Context, CacheKey>, 'assets' | 'renderHtml' | 'extract'> & {
33
+ export declare function createServerRender<Context = RequestContext, CacheKey = AssetsCacheKey>(getApp: ReactElement<any> | ((request: EnhancedRequest, context: Context) => ReactElement<any> | undefined | Promise<ReactElement<any> | undefined>), options?: ServerRenderOptions<Context, CacheKey>): RequestHandler<Context>;
34
+ export declare function createServerRender<Context = RequestContext, CacheKey = AssetsCacheKey>(options?: ServerRenderOptions<Context, CacheKey>): RequestHandler<Context>;
35
+ export declare function renderAppToResponse<Context = RequestContext, CacheKey = AssetsCacheKey>(getApp: ReactElement<any> | (() => ReactElement<any> | undefined | Promise<ReactElement<any> | undefined>) | undefined, { request, context, assets, extract, html: htmlOptions, }: Pick<ServerRenderOptions<Context, CacheKey>, 'assets' | 'html' | 'extract'> & {
29
36
  readonly request: EnhancedRequest;
30
37
  readonly context: Context;
31
38
  }): Promise<import("@quilted/request-router").EnhancedResponse>;
32
- export declare function renderAppToStreamedResponse<Context = RequestContext, CacheKey = AssetsCacheKey>(getApp: ReactElement<any> | (() => ReactElement<any> | Promise<ReactElement<any>>), { request, context, assets, extract, renderHtml, }: Pick<ServerRenderOptions<Context, CacheKey>, 'assets' | 'renderHtml' | 'extract'> & {
39
+ export declare function renderAppToStreamedResponse<Context = RequestContext, CacheKey = AssetsCacheKey>(getApp: ReactElement<any> | (() => ReactElement<any> | undefined | Promise<ReactElement<any> | undefined>) | undefined, { request, context, assets, extract, html: htmlOptions, }: Pick<ServerRenderOptions<Context, CacheKey>, 'assets' | 'html' | 'extract'> & {
33
40
  readonly request: EnhancedRequest;
34
41
  readonly context: Context;
35
42
  }): Promise<import("@quilted/request-router").EnhancedResponse>;
@@ -1 +1 @@
1
- {"version":3,"file":"request-router.d.ts","sourceRoot":"","sources":["../../../source/server/request-router.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,YAAY,EAAC,MAAM,OAAO,CAAC;AAElD,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,aAAa,EAAC,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAC,WAAW,EAAC,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAEL,WAAW,EAEZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EACV,OAAO,IAAI,cAAc,EACzB,0BAA0B,EAC3B,MAAM,qCAAqC,CAAC;AAI7C,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CAAC,OAAO,CAAC,CAAC;AAuE7E,wBAAsB,mBAAmB,CACvC,OAAO,GAAG,cAAc,EACxB,QAAQ,GAAG,cAAc,EAEzB,MAAM,EACF,YAAY,CAAC,GAAG,CAAC,GACjB,CAAC,MACG,YAAY,CAAC,GAAG,CAAC,GACjB,SAAS,GACT,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,GAC3C,SAAS,EACb,EACE,OAAO,EACP,OAAO,EACP,MAAM,EACN,OAAO,EACP,IAAI,EAAE,WAAW,GAClB,EAAE,IAAI,CACL,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,EACtC,QAAQ,GAAG,MAAM,GAAG,SAAS,CAC9B,GAAG;IAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAC,+DAmCnE;AAED,wBAAsB,2BAA2B,CAC/C,OAAO,GAAG,cAAc,EACxB,QAAQ,GAAG,cAAc,EAEzB,MAAM,EACF,YAAY,CAAC,GAAG,CAAC,GACjB,CAAC,MACG,YAAY,CAAC,GAAG,CAAC,GACjB,SAAS,GACT,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,GAC3C,SAAS,EACb,EACE,OAAO,EACP,OAAO,EACP,MAAM,EACN,OAAO,EACP,IAAI,EAAE,WAAW,GAClB,EAAE,IAAI,CACL,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,EACtC,QAAQ,GAAG,MAAM,GAAG,SAAS,CAC9B,GAAG;IAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAC,+DAqDnE"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@quilted/quilt",
3
3
  "type": "module",
4
- "version": "0.5.145",
4
+ "version": "0.5.147",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/lemonmade/quilt.git",
@@ -258,7 +258,7 @@
258
258
  "@quilted/assets": "^0.0.3",
259
259
  "@quilted/async": "^0.3.34",
260
260
  "@quilted/events": "^0.1.0",
261
- "@quilted/graphql": "^1.0.0",
261
+ "@quilted/graphql": "^1.1.0",
262
262
  "@quilted/polyfills": "^0.2.12",
263
263
  "@quilted/react": "^18.2.0",
264
264
  "@quilted/react-assets": "^0.0.4",
package/source/global.ts CHANGED
@@ -1,3 +1,25 @@
1
- import {installAsyncAssetsGlobal} from '@quilted/async';
1
+ import {
2
+ createAsyncModulesGlobal,
3
+ type AsyncModulesGlobal,
4
+ } from '@quilted/async';
2
5
 
3
- installAsyncAssetsGlobal();
6
+ export interface QuiltGlobal {
7
+ readonly AsyncModules: AsyncModulesGlobal;
8
+ }
9
+
10
+ const property = Symbol.for('quilt');
11
+ const quilt = ((globalThis as any)[property] ?? {}) as QuiltGlobal;
12
+
13
+ (quilt as any).AsyncModules = createAsyncModulesGlobal({
14
+ cache: quilt.AsyncModules,
15
+ });
16
+
17
+ Object.defineProperty(globalThis, property, {
18
+ value: quilt,
19
+ enumerable: false,
20
+ configurable: true,
21
+ writable: true,
22
+ });
23
+
24
+ export default quilt;
25
+ export {quilt, quilt as global};
@@ -15,6 +15,7 @@ import {
15
15
  renderHtmlToString,
16
16
  HtmlManager,
17
17
  Html,
18
+ type HtmlProps,
18
19
  } from '@quilted/react-html/server';
19
20
  import type {
20
21
  Options as ExtractOptions,
@@ -45,13 +46,22 @@ export interface ServerRenderOptions<
45
46
  context: Context,
46
47
  ) => ServerRenderRequestContext);
47
48
  };
48
- renderHtml?(
49
+ html?:
50
+ | ServerRenderHtmlRender<Context>
51
+ | {
52
+ readonly rootElement?: HtmlProps['rootElement'];
53
+ };
54
+ }
55
+
56
+ export interface ServerRenderHtmlRender<Context> {
57
+ (
49
58
  content: string | undefined,
50
59
  details: Pick<ServerRenderAppDetails, 'http' | 'html'> & {
51
60
  readonly request: EnhancedRequest;
52
61
  readonly context: Context;
53
62
  readonly assets?: BrowserAssetsEntry;
54
63
  readonly preloadAssets?: BrowserAssetsEntry;
64
+ readonly rootElement?: HtmlProps['rootElement'];
55
65
  },
56
66
  ): ReactElement<any> | Promise<ReactElement<any>>;
57
67
  }
@@ -75,9 +85,57 @@ export function createServerRender<
75
85
  | ((
76
86
  request: EnhancedRequest,
77
87
  context: Context,
78
- ) => ReactElement<any> | Promise<ReactElement<any>>),
79
- {stream, ...options}: ServerRenderOptions<Context, CacheKey> = {},
88
+ ) =>
89
+ | ReactElement<any>
90
+ | undefined
91
+ | Promise<ReactElement<any> | undefined>),
92
+ options?: ServerRenderOptions<Context, CacheKey>,
93
+ ): RequestHandler<Context>;
94
+ export function createServerRender<
95
+ Context = RequestContext,
96
+ CacheKey = AssetsCacheKey,
97
+ >(options?: ServerRenderOptions<Context, CacheKey>): RequestHandler<Context>;
98
+ export function createServerRender<
99
+ Context = RequestContext,
100
+ CacheKey = AssetsCacheKey,
101
+ >(
102
+ ...args: [
103
+ (
104
+ | ReactElement<any>
105
+ | ((
106
+ request: EnhancedRequest,
107
+ context: Context,
108
+ ) =>
109
+ | ReactElement<any>
110
+ | undefined
111
+ | Promise<ReactElement<any> | undefined>)
112
+ | ServerRenderOptions<Context, CacheKey>
113
+ | undefined
114
+ ),
115
+ ServerRenderOptions<Context, CacheKey>?,
116
+ ]
80
117
  ): RequestHandler<Context> {
118
+ let getApp:
119
+ | ReactElement<any>
120
+ | ((
121
+ request: EnhancedRequest,
122
+ context: Context,
123
+ ) =>
124
+ | ReactElement<any>
125
+ | undefined
126
+ | Promise<ReactElement<any> | undefined>)
127
+ | undefined;
128
+ let options: ServerRenderOptions<Context, CacheKey>;
129
+
130
+ if (args.length > 1) {
131
+ getApp = args[0] as any;
132
+ options = (args[1] ?? {}) as any;
133
+ } else {
134
+ options = (args[0] ?? {}) as any;
135
+ }
136
+
137
+ const stream = options.stream;
138
+
81
139
  return async (request, requestContext) => {
82
140
  const accepts = request.headers.get('Accept');
83
141
 
@@ -89,7 +147,7 @@ export function createServerRender<
89
147
 
90
148
  return renderResponse(
91
149
  typeof getApp === 'function'
92
- ? () => getApp(request, requestContext)
150
+ ? () => (getApp as any)(request, requestContext)
93
151
  : getApp,
94
152
  {
95
153
  ...options,
@@ -113,16 +171,20 @@ export async function renderAppToResponse<
113
171
  >(
114
172
  getApp:
115
173
  | ReactElement<any>
116
- | (() => ReactElement<any> | Promise<ReactElement<any>>),
174
+ | (() =>
175
+ | ReactElement<any>
176
+ | undefined
177
+ | Promise<ReactElement<any> | undefined>)
178
+ | undefined,
117
179
  {
118
180
  request,
119
181
  context,
120
182
  assets,
121
183
  extract,
122
- renderHtml,
184
+ html: htmlOptions,
123
185
  }: Pick<
124
186
  ServerRenderOptions<Context, CacheKey>,
125
- 'assets' | 'renderHtml' | 'extract'
187
+ 'assets' | 'html' | 'extract'
126
188
  > & {readonly request: EnhancedRequest; readonly context: Context},
127
189
  ) {
128
190
  const app = typeof getApp === 'function' ? await getApp() : getApp;
@@ -150,7 +212,7 @@ export async function renderAppToResponse<
150
212
  request,
151
213
  context,
152
214
  assets,
153
- renderHtml,
215
+ html: htmlOptions,
154
216
  },
155
217
  );
156
218
 
@@ -166,16 +228,20 @@ export async function renderAppToStreamedResponse<
166
228
  >(
167
229
  getApp:
168
230
  | ReactElement<any>
169
- | (() => ReactElement<any> | Promise<ReactElement<any>>),
231
+ | (() =>
232
+ | ReactElement<any>
233
+ | undefined
234
+ | Promise<ReactElement<any> | undefined>)
235
+ | undefined,
170
236
  {
171
237
  request,
172
238
  context,
173
239
  assets,
174
240
  extract,
175
- renderHtml,
241
+ html: htmlOptions,
176
242
  }: Pick<
177
243
  ServerRenderOptions<Context, CacheKey>,
178
- 'assets' | 'renderHtml' | 'extract'
244
+ 'assets' | 'html' | 'extract'
179
245
  > & {readonly request: EnhancedRequest; readonly context: Context},
180
246
  ) {
181
247
  const headers = new Headers();
@@ -220,7 +286,7 @@ export async function renderAppToStreamedResponse<
220
286
  request,
221
287
  context,
222
288
  assets,
223
- renderHtml,
289
+ html: htmlOptions,
224
290
  },
225
291
  );
226
292
 
@@ -235,7 +301,7 @@ async function serverRenderDetailsForApp<
235
301
  Context = RequestContext,
236
302
  CacheKey = AssetsCacheKey,
237
303
  >(
238
- app: ReactElement<any>,
304
+ app: ReactElement<any> | undefined,
239
305
  {
240
306
  url,
241
307
  headers,
@@ -255,16 +321,18 @@ async function serverRenderDetailsForApp<
255
321
 
256
322
  const {decorate, ...rest} = extractOptions ?? {};
257
323
 
258
- const rendered = await extract(app, {
259
- decorate(app) {
260
- return (
261
- <ServerContext http={http} html={html} url={url} assets={assets}>
262
- {decorate?.(app) ?? app}
263
- </ServerContext>
264
- );
265
- },
266
- ...rest,
267
- });
324
+ const rendered = app
325
+ ? await extract(app, {
326
+ decorate(app) {
327
+ return (
328
+ <ServerContext http={http} html={html} url={url} assets={assets}>
329
+ {decorate?.(app) ?? app}
330
+ </ServerContext>
331
+ );
332
+ },
333
+ ...rest,
334
+ })
335
+ : undefined;
268
336
 
269
337
  return {rendered, http, html, assets};
270
338
  }
@@ -278,8 +346,8 @@ async function renderAppDetailsToHtmlString<
278
346
  request,
279
347
  context,
280
348
  assets,
281
- renderHtml = defaultRenderHtml,
282
- }: Pick<ServerRenderOptions<Context, CacheKey>, 'assets' | 'renderHtml'> & {
349
+ html: htmlOptions,
350
+ }: Pick<ServerRenderOptions<Context, CacheKey>, 'assets' | 'html'> & {
283
351
  readonly request: EnhancedRequest;
284
352
  readonly context: Context;
285
353
  readonly cacheKey?: Partial<CacheKey>;
@@ -299,6 +367,16 @@ async function renderAppDetailsToHtmlString<
299
367
  ])
300
368
  : [];
301
369
 
370
+ let renderHtml: ServerRenderHtmlRender<Context>;
371
+ let rootElement: HtmlProps['rootElement'];
372
+
373
+ if (typeof htmlOptions === 'function') {
374
+ renderHtml = htmlOptions;
375
+ } else {
376
+ rootElement = htmlOptions?.rootElement;
377
+ renderHtml = defaultRenderHtml;
378
+ }
379
+
302
380
  const htmlElement = await renderHtml(rendered, {
303
381
  request,
304
382
  context,
@@ -306,18 +384,23 @@ async function renderAppDetailsToHtmlString<
306
384
  http,
307
385
  assets: entryAssets,
308
386
  preloadAssets,
387
+ rootElement,
309
388
  });
310
389
 
311
390
  return renderHtmlToString(htmlElement);
312
391
  }
313
392
 
314
- const defaultRenderHtml: NonNullable<ServerRenderOptions<any>['renderHtml']> =
315
- function defaultRenderHtml(content, {request, html, assets, preloadAssets}) {
393
+ const defaultRenderHtml: ServerRenderHtmlRender<any> =
394
+ function defaultRenderHtml(
395
+ content,
396
+ {request, html, assets, preloadAssets, rootElement},
397
+ ) {
316
398
  const baseUrl = new URL(request.url);
317
399
 
318
400
  return (
319
401
  <Html
320
402
  manager={html}
403
+ rootElement={rootElement}
321
404
  headEndContent={
322
405
  <>
323
406
  {assets &&