@quilted/quilt 0.5.64 → 0.5.67

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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @quilted/quilt
2
2
 
3
+ ## 0.5.67
4
+
5
+ ### Patch Changes
6
+
7
+ - [`ec90a3f`](https://github.com/lemonmade/quilt/commit/ec90a3f0de7366a42fd1e13b903154f5bc8c0a54) Thanks [@lemonmade](https://github.com/lemonmade)! - Add simpler way of rendering React to a http-handlers response
8
+
9
+ ## 0.5.66
10
+
11
+ ### Patch Changes
12
+
13
+ - [`fb10e01`](https://github.com/lemonmade/quilt/commit/fb10e0181c26b6faedaea6f7fc5d88d7ccccc3d1) Thanks [@lemonmade](https://github.com/lemonmade)! - Add web crypto polyfill
14
+
15
+ * [`33c1a59`](https://github.com/lemonmade/quilt/commit/33c1a59c89fd9aeae81cb6072b4100d706268985) Thanks [@lemonmade](https://github.com/lemonmade)! - Add ability to nest http handlers
16
+
17
+ ## 0.5.65
18
+
19
+ ### Patch Changes
20
+
21
+ - [`c58ca94`](https://github.com/lemonmade/quilt/commit/c58ca9468f24c1cc193d67f56692e07e71e918ab) Thanks [@lemonmade](https://github.com/lemonmade)! - Add `Serialize` component
22
+
23
+ * [`f75a035`](https://github.com/lemonmade/quilt/commit/f75a035e5a6ec857497f28da9f0f0ba2d5d6112a) Thanks [@lemonmade](https://github.com/lemonmade)! - Add props customization to Quilt server handler
24
+
3
25
  ## 0.5.64
4
26
 
5
27
  ### Patch Changes
@@ -38,6 +38,10 @@ Object.defineProperty(exports, 'SearchRobots', {
38
38
  enumerable: true,
39
39
  get: function () { return reactHtml.SearchRobots; }
40
40
  });
41
+ Object.defineProperty(exports, 'Serialize', {
42
+ enumerable: true,
43
+ get: function () { return reactHtml.Serialize; }
44
+ });
41
45
  Object.defineProperty(exports, 'ThemeColor', {
42
46
  enumerable: true,
43
47
  get: function () { return reactHtml.ThemeColor; }
@@ -8,74 +8,85 @@ var render = require('./render.cjs');
8
8
  var jsxRuntime = require('react/jsx-runtime');
9
9
 
10
10
  function createServerRenderingRequestHandler(App, {
11
- assets
12
- }) {
13
- return async request => {
14
- const accepts = request.headers.get('Accept');
15
- if (accepts != null && !accepts.includes('text/html')) return;
16
- const {
17
- html: htmlManager,
18
- http,
19
- markup,
20
- asyncAssets
21
- } = await render.renderApp( /*#__PURE__*/jsxRuntime.jsx(App, {}), {
22
- url: request.url,
23
- headers: request.headers
24
- });
25
- const {
26
- headers,
27
- statusCode = 200,
28
- redirectUrl
29
- } = http.state;
30
-
31
- if (redirectUrl) {
32
- return httpHandlers.redirect(redirectUrl, {
33
- status: statusCode,
34
- headers
35
- });
36
- }
37
-
38
- const usedAssets = asyncAssets.used({
39
- timing: 'load'
40
- });
41
- const assetOptions = {
42
- userAgent: request.headers.get('User-Agent')
43
- };
44
- const [styles, scripts, preload] = await Promise.all([assets.styles({
45
- async: usedAssets,
46
- options: assetOptions
47
- }), assets.scripts({
48
- async: usedAssets,
49
- options: assetOptions
50
- }), assets.asyncAssets(asyncAssets.used({
51
- timing: 'preload'
52
- }), {
53
- options: assetOptions
54
- })]);
55
- return httpHandlers.html(server.render( /*#__PURE__*/jsxRuntime.jsx(server.Html, {
56
- manager: htmlManager,
57
- styles: styles,
58
- scripts: scripts,
59
- preloadAssets: preload,
60
- children: markup
61
- })), {
62
- headers,
63
- status: statusCode
11
+ assets,
12
+ renderProps
13
+ } = {}) {
14
+ return request => {
15
+ return renderToResponse( /*#__PURE__*/jsxRuntime.jsx(App, { ...renderProps?.({
16
+ request
17
+ })
18
+ }), request, {
19
+ assets
64
20
  });
65
21
  };
66
22
  }
67
23
  function createServerRenderingHttpHandler(App, {
68
24
  assets,
69
- before,
70
- handler = httpHandlers.createHttpHandler({
71
- before
72
- })
25
+ renderProps,
26
+ handler = httpHandlers.createHttpHandler()
73
27
  }) {
74
28
  handler.get(createServerRenderingRequestHandler(App, {
75
- assets
29
+ assets,
30
+ renderProps
76
31
  }));
77
32
  return handler;
78
33
  }
34
+ async function renderToResponse(element, request, {
35
+ assets
36
+ } = {}) {
37
+ const accepts = request.headers.get('Accept');
38
+ if (accepts != null && !accepts.includes('text/html')) return;
39
+ const {
40
+ html: htmlManager,
41
+ http,
42
+ markup,
43
+ asyncAssets
44
+ } = await render.renderApp(element, {
45
+ url: request.url,
46
+ headers: request.headers
47
+ });
48
+ const {
49
+ headers,
50
+ statusCode = 200,
51
+ redirectUrl
52
+ } = http.state;
53
+
54
+ if (redirectUrl) {
55
+ return httpHandlers.redirect(redirectUrl, {
56
+ status: statusCode,
57
+ headers
58
+ });
59
+ }
60
+
61
+ const usedAssets = asyncAssets.used({
62
+ timing: 'load'
63
+ });
64
+ const assetOptions = {
65
+ userAgent: request.headers.get('User-Agent')
66
+ };
67
+ const [styles, scripts, preload] = assets ? await Promise.all([assets.styles({
68
+ async: usedAssets,
69
+ options: assetOptions
70
+ }), assets.scripts({
71
+ async: usedAssets,
72
+ options: assetOptions
73
+ }), assets.asyncAssets(asyncAssets.used({
74
+ timing: 'preload'
75
+ }), {
76
+ options: assetOptions
77
+ })]) : [];
78
+ return httpHandlers.html(server.render( /*#__PURE__*/jsxRuntime.jsx(server.Html, {
79
+ manager: htmlManager,
80
+ styles: styles,
81
+ scripts: scripts,
82
+ preloadAssets: preload,
83
+ children: markup
84
+ })), {
85
+ headers,
86
+ status: statusCode
87
+ });
88
+ }
79
89
 
80
90
  exports.createServerRenderingHttpHandler = createServerRenderingHttpHandler;
81
91
  exports.createServerRenderingRequestHandler = createServerRenderingRequestHandler;
92
+ exports.renderToResponse = renderToResponse;
@@ -86,3 +86,4 @@ exports.renderApp = render.renderApp;
86
86
  exports.ServerContext = ServerContext.ServerContext;
87
87
  exports.createServerRenderingHttpHandler = httpHandler.createServerRenderingHttpHandler;
88
88
  exports.createServerRenderingRequestHandler = httpHandler.createServerRenderingRequestHandler;
89
+ exports.renderToResponse = httpHandler.renderToResponse;
@@ -1 +1 @@
1
- export { Alternate, BodyAttributes, Favicon, HtmlAttributes, Hydrator, Link, Meta, SearchRobots, ThemeColor, Title, Viewport, getSerialized, useAlternateUrl, useBodyAttributes, useFavicon, useHtmlAttributes, useHtmlUpdater, useLink, useLocale, useMeta, useSearchRobots, useSerialized, useThemeColor, useTitle, useViewport } from '@quilted/react-html';
1
+ export { Alternate, BodyAttributes, Favicon, HtmlAttributes, Hydrator, Link, Meta, SearchRobots, Serialize, ThemeColor, Title, Viewport, getSerialized, useAlternateUrl, useBodyAttributes, useFavicon, useHtmlAttributes, useHtmlUpdater, useLink, useLocale, useMeta, useSearchRobots, useSerialized, useThemeColor, useTitle, useViewport } from '@quilted/react-html';
@@ -1,76 +1,86 @@
1
1
  import { render, Html } from '@quilted/react-html/server';
2
- import { redirect, html, createHttpHandler } from '@quilted/http-handlers';
2
+ import { createHttpHandler, redirect, html } from '@quilted/http-handlers';
3
3
  import { renderApp } from './render.mjs';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
 
6
6
  function createServerRenderingRequestHandler(App, {
7
- assets
8
- }) {
9
- return async request => {
10
- const accepts = request.headers.get('Accept');
11
- if (accepts != null && !accepts.includes('text/html')) return;
12
- const {
13
- html: htmlManager,
14
- http,
15
- markup,
16
- asyncAssets
17
- } = await renderApp( /*#__PURE__*/jsx(App, {}), {
18
- url: request.url,
19
- headers: request.headers
20
- });
21
- const {
22
- headers,
23
- statusCode = 200,
24
- redirectUrl
25
- } = http.state;
26
-
27
- if (redirectUrl) {
28
- return redirect(redirectUrl, {
29
- status: statusCode,
30
- headers
31
- });
32
- }
33
-
34
- const usedAssets = asyncAssets.used({
35
- timing: 'load'
36
- });
37
- const assetOptions = {
38
- userAgent: request.headers.get('User-Agent')
39
- };
40
- const [styles, scripts, preload] = await Promise.all([assets.styles({
41
- async: usedAssets,
42
- options: assetOptions
43
- }), assets.scripts({
44
- async: usedAssets,
45
- options: assetOptions
46
- }), assets.asyncAssets(asyncAssets.used({
47
- timing: 'preload'
48
- }), {
49
- options: assetOptions
50
- })]);
51
- return html(render( /*#__PURE__*/jsx(Html, {
52
- manager: htmlManager,
53
- styles: styles,
54
- scripts: scripts,
55
- preloadAssets: preload,
56
- children: markup
57
- })), {
58
- headers,
59
- status: statusCode
7
+ assets,
8
+ renderProps
9
+ } = {}) {
10
+ return request => {
11
+ return renderToResponse( /*#__PURE__*/jsx(App, { ...renderProps?.({
12
+ request
13
+ })
14
+ }), request, {
15
+ assets
60
16
  });
61
17
  };
62
18
  }
63
19
  function createServerRenderingHttpHandler(App, {
64
20
  assets,
65
- before,
66
- handler = createHttpHandler({
67
- before
68
- })
21
+ renderProps,
22
+ handler = createHttpHandler()
69
23
  }) {
70
24
  handler.get(createServerRenderingRequestHandler(App, {
71
- assets
25
+ assets,
26
+ renderProps
72
27
  }));
73
28
  return handler;
74
29
  }
30
+ async function renderToResponse(element, request, {
31
+ assets
32
+ } = {}) {
33
+ const accepts = request.headers.get('Accept');
34
+ if (accepts != null && !accepts.includes('text/html')) return;
35
+ const {
36
+ html: htmlManager,
37
+ http,
38
+ markup,
39
+ asyncAssets
40
+ } = await renderApp(element, {
41
+ url: request.url,
42
+ headers: request.headers
43
+ });
44
+ const {
45
+ headers,
46
+ statusCode = 200,
47
+ redirectUrl
48
+ } = http.state;
49
+
50
+ if (redirectUrl) {
51
+ return redirect(redirectUrl, {
52
+ status: statusCode,
53
+ headers
54
+ });
55
+ }
56
+
57
+ const usedAssets = asyncAssets.used({
58
+ timing: 'load'
59
+ });
60
+ const assetOptions = {
61
+ userAgent: request.headers.get('User-Agent')
62
+ };
63
+ const [styles, scripts, preload] = assets ? await Promise.all([assets.styles({
64
+ async: usedAssets,
65
+ options: assetOptions
66
+ }), assets.scripts({
67
+ async: usedAssets,
68
+ options: assetOptions
69
+ }), assets.asyncAssets(asyncAssets.used({
70
+ timing: 'preload'
71
+ }), {
72
+ options: assetOptions
73
+ })]) : [];
74
+ return html(render( /*#__PURE__*/jsx(Html, {
75
+ manager: htmlManager,
76
+ styles: styles,
77
+ scripts: scripts,
78
+ preloadAssets: preload,
79
+ children: markup
80
+ })), {
81
+ headers,
82
+ status: statusCode
83
+ });
84
+ }
75
85
 
76
- export { createServerRenderingHttpHandler, createServerRenderingRequestHandler };
86
+ export { createServerRenderingHttpHandler, createServerRenderingRequestHandler, renderToResponse };
@@ -6,4 +6,4 @@ export { renderEmail } from '@quilted/react-email/server';
6
6
  export { createHttpHandler } from '@quilted/http-handlers';
7
7
  export { renderApp } from './render.mjs';
8
8
  export { ServerContext } from './ServerContext.mjs';
9
- export { createServerRenderingHttpHandler, createServerRenderingRequestHandler } from './http-handler.mjs';
9
+ export { createServerRenderingHttpHandler, createServerRenderingRequestHandler, renderToResponse } from './http-handler.mjs';
@@ -1 +1 @@
1
- export { Alternate, BodyAttributes, Favicon, HtmlAttributes, Hydrator, Link, Meta, SearchRobots, ThemeColor, Title, Viewport, getSerialized, useAlternateUrl, useBodyAttributes, useFavicon, useHtmlAttributes, useHtmlUpdater, useLink, useLocale, useMeta, useSearchRobots, useSerialized, useThemeColor, useTitle, useViewport } from '@quilted/react-html';
1
+ export { Alternate, BodyAttributes, Favicon, HtmlAttributes, Hydrator, Link, Meta, SearchRobots, Serialize, ThemeColor, Title, Viewport, getSerialized, useAlternateUrl, useBodyAttributes, useFavicon, useHtmlAttributes, useHtmlUpdater, useLink, useLocale, useMeta, useSearchRobots, useSerialized, useThemeColor, useTitle, useViewport } from '@quilted/react-html';
@@ -1,76 +1,86 @@
1
1
  import { render, Html } from '@quilted/react-html/server';
2
- import { redirect, html, createHttpHandler } from '@quilted/http-handlers';
2
+ import { createHttpHandler, redirect, html } from '@quilted/http-handlers';
3
3
  import { renderApp } from './render.esnext';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
 
6
6
  function createServerRenderingRequestHandler(App, {
7
- assets
8
- }) {
9
- return async request => {
10
- const accepts = request.headers.get('Accept');
11
- if (accepts != null && !accepts.includes('text/html')) return;
12
- const {
13
- html: htmlManager,
14
- http,
15
- markup,
16
- asyncAssets
17
- } = await renderApp( /*#__PURE__*/jsx(App, {}), {
18
- url: request.url,
19
- headers: request.headers
20
- });
21
- const {
22
- headers,
23
- statusCode = 200,
24
- redirectUrl
25
- } = http.state;
26
-
27
- if (redirectUrl) {
28
- return redirect(redirectUrl, {
29
- status: statusCode,
30
- headers
31
- });
32
- }
33
-
34
- const usedAssets = asyncAssets.used({
35
- timing: 'load'
36
- });
37
- const assetOptions = {
38
- userAgent: request.headers.get('User-Agent')
39
- };
40
- const [styles, scripts, preload] = await Promise.all([assets.styles({
41
- async: usedAssets,
42
- options: assetOptions
43
- }), assets.scripts({
44
- async: usedAssets,
45
- options: assetOptions
46
- }), assets.asyncAssets(asyncAssets.used({
47
- timing: 'preload'
48
- }), {
49
- options: assetOptions
50
- })]);
51
- return html(render( /*#__PURE__*/jsx(Html, {
52
- manager: htmlManager,
53
- styles: styles,
54
- scripts: scripts,
55
- preloadAssets: preload,
56
- children: markup
57
- })), {
58
- headers,
59
- status: statusCode
7
+ assets,
8
+ renderProps
9
+ } = {}) {
10
+ return request => {
11
+ return renderToResponse( /*#__PURE__*/jsx(App, { ...renderProps?.({
12
+ request
13
+ })
14
+ }), request, {
15
+ assets
60
16
  });
61
17
  };
62
18
  }
63
19
  function createServerRenderingHttpHandler(App, {
64
20
  assets,
65
- before,
66
- handler = createHttpHandler({
67
- before
68
- })
21
+ renderProps,
22
+ handler = createHttpHandler()
69
23
  }) {
70
24
  handler.get(createServerRenderingRequestHandler(App, {
71
- assets
25
+ assets,
26
+ renderProps
72
27
  }));
73
28
  return handler;
74
29
  }
30
+ async function renderToResponse(element, request, {
31
+ assets
32
+ } = {}) {
33
+ const accepts = request.headers.get('Accept');
34
+ if (accepts != null && !accepts.includes('text/html')) return;
35
+ const {
36
+ html: htmlManager,
37
+ http,
38
+ markup,
39
+ asyncAssets
40
+ } = await renderApp(element, {
41
+ url: request.url,
42
+ headers: request.headers
43
+ });
44
+ const {
45
+ headers,
46
+ statusCode = 200,
47
+ redirectUrl
48
+ } = http.state;
49
+
50
+ if (redirectUrl) {
51
+ return redirect(redirectUrl, {
52
+ status: statusCode,
53
+ headers
54
+ });
55
+ }
56
+
57
+ const usedAssets = asyncAssets.used({
58
+ timing: 'load'
59
+ });
60
+ const assetOptions = {
61
+ userAgent: request.headers.get('User-Agent')
62
+ };
63
+ const [styles, scripts, preload] = assets ? await Promise.all([assets.styles({
64
+ async: usedAssets,
65
+ options: assetOptions
66
+ }), assets.scripts({
67
+ async: usedAssets,
68
+ options: assetOptions
69
+ }), assets.asyncAssets(asyncAssets.used({
70
+ timing: 'preload'
71
+ }), {
72
+ options: assetOptions
73
+ })]) : [];
74
+ return html(render( /*#__PURE__*/jsx(Html, {
75
+ manager: htmlManager,
76
+ styles: styles,
77
+ scripts: scripts,
78
+ preloadAssets: preload,
79
+ children: markup
80
+ })), {
81
+ headers,
82
+ status: statusCode
83
+ });
84
+ }
75
85
 
76
- export { createServerRenderingHttpHandler, createServerRenderingRequestHandler };
86
+ export { createServerRenderingHttpHandler, createServerRenderingRequestHandler, renderToResponse };
@@ -6,4 +6,4 @@ export { renderEmail } from '@quilted/react-email/server';
6
6
  export { createHttpHandler } from '@quilted/http-handlers';
7
7
  export { renderApp } from './render.esnext';
8
8
  export { ServerContext } from './ServerContext.esnext';
9
- export { createServerRenderingHttpHandler, createServerRenderingRequestHandler } from './http-handler.esnext';
9
+ export { createServerRenderingHttpHandler, createServerRenderingRequestHandler, renderToResponse } from './http-handler.esnext';