@quilted/quilt 0.5.157 → 0.6.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/CHANGELOG.md +42 -0
- package/build/esm/graphql/testing/matchers/operations.mjs +1 -1
- package/build/esm/graphql/testing/matchers/utilities.mjs +1 -1
- package/build/esm/graphql/testing/matchers.mjs +4 -3
- package/build/esm/graphql/testing.mjs +5 -1
- package/build/esm/react/testing.mjs +5 -2
- package/build/esnext/globals.esnext +1 -1
- package/build/esnext/graphql/testing/matchers/operations.esnext +49 -19
- package/build/esnext/graphql/testing/matchers/utilities.esnext +18 -15
- package/build/esnext/graphql/testing/matchers.esnext +4 -3
- package/build/esnext/graphql/testing.esnext +4 -1
- package/build/esnext/html/HTML.esnext +6 -9
- package/build/esnext/react/testing.esnext +4 -2
- package/build/esnext/server/ServerContext.esnext +14 -2
- package/build/esnext/server/preload.esnext +9 -10
- package/build/esnext/server/request-router.esnext +138 -141
- package/build/esnext/utilities/react.esnext +1 -4
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/globals.d.ts +1 -0
- package/build/typescript/globals.d.ts.map +1 -1
- package/build/typescript/graphql/testing/matchers/utilities.d.ts +1 -1
- package/build/typescript/graphql/testing/matchers/utilities.d.ts.map +1 -1
- package/build/typescript/graphql/testing/matchers.d.ts +10 -8
- package/build/typescript/graphql/testing/matchers.d.ts.map +1 -1
- package/build/typescript/graphql/testing.d.ts +7 -1
- package/build/typescript/graphql/testing.d.ts.map +1 -1
- package/build/typescript/modules.d.ts +23 -0
- package/build/typescript/modules.d.ts.map +1 -0
- package/build/typescript/react/testing.d.ts +7 -2
- package/build/typescript/react/testing.d.ts.map +1 -1
- package/configuration/rollup.config.js +3 -0
- package/package.json +66 -197
- package/source/globals.ts +2 -0
- package/source/graphql/testing/matchers/operations.ts +1 -1
- package/source/graphql/testing/matchers/utilities.ts +1 -1
- package/source/graphql/testing/matchers.ts +15 -22
- package/source/graphql/testing.ts +11 -1
- package/source/modules.ts +31 -0
- package/source/react/testing.ts +10 -3
- package/tsconfig.json +1 -3
- package/build/cjs/assets.cjs +0 -39
- package/build/cjs/async.cjs +0 -32
- package/build/cjs/env.cjs +0 -7
- package/build/cjs/events.cjs +0 -46
- package/build/cjs/globals.cjs +0 -21
- package/build/cjs/graphql/server.cjs +0 -14
- package/build/cjs/graphql/testing/matchers/operations.cjs +0 -42
- package/build/cjs/graphql/testing/matchers/utilities.cjs +0 -43
- package/build/cjs/graphql/testing/matchers.cjs +0 -10
- package/build/cjs/graphql/testing.cjs +0 -18
- package/build/cjs/graphql.cjs +0 -21
- package/build/cjs/html/HTML.cjs +0 -21
- package/build/cjs/html.cjs +0 -133
- package/build/cjs/http.cjs +0 -146
- package/build/cjs/index.cjs +0 -2
- package/build/cjs/localize.cjs +0 -46
- package/build/cjs/magic/app.cjs +0 -2
- package/build/cjs/magic/assets.cjs +0 -2
- package/build/cjs/magic/request-router.cjs +0 -2
- package/build/cjs/navigate/testing.cjs +0 -12
- package/build/cjs/navigate.cjs +0 -70
- package/build/cjs/performance.cjs +0 -26
- package/build/cjs/polyfills/abort-controller.cjs +0 -4
- package/build/cjs/polyfills/base.cjs +0 -4
- package/build/cjs/polyfills/crypto.cjs +0 -4
- package/build/cjs/polyfills/fetch-get-set-cookie.cjs +0 -4
- package/build/cjs/polyfills/fetch.cjs +0 -4
- package/build/cjs/polyfills/noop.cjs +0 -4
- package/build/cjs/react/testing.cjs +0 -30
- package/build/cjs/react/tools.cjs +0 -19
- package/build/cjs/react.cjs +0 -15
- package/build/cjs/request-router/index.cjs +0 -12
- package/build/cjs/request-router/node.cjs +0 -12
- package/build/cjs/server/ServerContext.cjs +0 -20
- package/build/cjs/server/preload.cjs +0 -37
- package/build/cjs/server/request-router.cjs +0 -266
- package/build/cjs/server.cjs +0 -114
- package/build/cjs/signals.cjs +0 -51
- package/build/cjs/static/StaticContext.cjs +0 -20
- package/build/cjs/static/index.cjs +0 -261
- package/build/cjs/static/render.cjs +0 -44
- package/build/cjs/testing.cjs +0 -12
- package/build/cjs/threads.cjs +0 -117
- package/build/cjs/utilities/react.cjs +0 -12
- package/build/esm/magic/request-router.mjs +0 -1
- package/build/esm/polyfills/abort-controller.mjs +0 -1
- package/build/esm/polyfills/base.mjs +0 -1
- package/build/esm/polyfills/crypto.mjs +0 -1
- package/build/esm/polyfills/fetch-get-set-cookie.mjs +0 -1
- package/build/esm/polyfills/fetch.mjs +0 -1
- package/build/esm/polyfills/noop.mjs +0 -1
- package/build/esm/static/StaticContext.mjs +0 -18
- package/build/esm/static/index.mjs +0 -259
- package/build/esm/static/render.mjs +0 -42
- package/build/esm/testing.mjs +0 -1
- package/build/esnext/magic/app.esnext +0 -1
- package/build/esnext/magic/assets.esnext +0 -1
- package/build/esnext/magic/request-router.esnext +0 -1
- package/build/esnext/polyfills/abort-controller.esnext +0 -1
- package/build/esnext/polyfills/base.esnext +0 -1
- package/build/esnext/polyfills/crypto.esnext +0 -1
- package/build/esnext/polyfills/fetch-get-set-cookie.esnext +0 -1
- package/build/esnext/polyfills/fetch.esnext +0 -1
- package/build/esnext/polyfills/noop.esnext +0 -1
- package/build/esnext/static/StaticContext.esnext +0 -18
- package/build/esnext/static/index.esnext +0 -259
- package/build/esnext/static/render.esnext +0 -42
- package/build/esnext/testing.esnext +0 -1
- package/build/typescript/App.d.ts +0 -48
- package/build/typescript/App.d.ts.map +0 -1
- package/build/typescript/TestApp.d.ts +0 -17
- package/build/typescript/TestApp.d.ts.map +0 -1
- package/build/typescript/global.d.ts +0 -8
- package/build/typescript/global.d.ts.map +0 -1
- package/build/typescript/magic/app.d.ts +0 -4
- package/build/typescript/magic/app.d.ts.map +0 -1
- package/build/typescript/magic/assets.d.ts +0 -5
- package/build/typescript/magic/assets.d.ts.map +0 -1
- package/build/typescript/magic/request-router.d.ts +0 -4
- package/build/typescript/magic/request-router.d.ts.map +0 -1
- package/build/typescript/matchers/graphql/operations.d.ts +0 -7
- package/build/typescript/matchers/graphql/operations.d.ts.map +0 -1
- package/build/typescript/matchers/graphql/utilities.d.ts +0 -8
- package/build/typescript/matchers/graphql/utilities.d.ts.map +0 -1
- package/build/typescript/matchers/graphql.d.ts +0 -9
- package/build/typescript/matchers/graphql.d.ts.map +0 -1
- package/build/typescript/matchers.d.ts +0 -3
- package/build/typescript/matchers.d.ts.map +0 -1
- package/build/typescript/polyfills/abort-controller.d.ts +0 -2
- package/build/typescript/polyfills/abort-controller.d.ts.map +0 -1
- package/build/typescript/polyfills/base.d.ts +0 -2
- package/build/typescript/polyfills/base.d.ts.map +0 -1
- package/build/typescript/polyfills/crypto.d.ts +0 -2
- package/build/typescript/polyfills/crypto.d.ts.map +0 -1
- package/build/typescript/polyfills/fetch-get-set-cookie.d.ts +0 -2
- package/build/typescript/polyfills/fetch-get-set-cookie.d.ts.map +0 -1
- package/build/typescript/polyfills/fetch.d.ts +0 -2
- package/build/typescript/polyfills/fetch.d.ts.map +0 -1
- package/build/typescript/polyfills/noop.d.ts +0 -2
- package/build/typescript/polyfills/noop.d.ts.map +0 -1
- package/build/typescript/react/index.d.ts +0 -3
- package/build/typescript/react/index.d.ts.map +0 -1
- package/build/typescript/react-dom/index.d.ts +0 -3
- package/build/typescript/react-dom/index.d.ts.map +0 -1
- package/build/typescript/server/index.d.ts +0 -16
- package/build/typescript/server/index.d.ts.map +0 -1
- package/build/typescript/static/StaticContext.d.ts +0 -13
- package/build/typescript/static/StaticContext.d.ts.map +0 -1
- package/build/typescript/static/index.d.ts +0 -20
- package/build/typescript/static/index.d.ts.map +0 -1
- package/build/typescript/static/render.d.ts +0 -19
- package/build/typescript/static/render.d.ts.map +0 -1
- package/build/typescript/testing.d.ts +0 -2
- package/build/typescript/testing.d.ts.map +0 -1
- package/quilt.project.ts +0 -5
- package/source/magic/app.ts +0 -5
- package/source/magic/assets.ts +0 -8
- package/source/magic/request-router.ts +0 -5
- package/source/polyfills/README.md +0 -3
- package/source/polyfills/abort-controller.ts +0 -1
- package/source/polyfills/base.ts +0 -1
- package/source/polyfills/crypto.ts +0 -1
- package/source/polyfills/fetch-get-set-cookie.ts +0 -1
- package/source/polyfills/fetch.ts +0 -1
- package/source/polyfills/noop.ts +0 -1
- package/source/static/StaticContext.tsx +0 -39
- package/source/static/index.tsx +0 -315
- package/source/static/render.tsx +0 -40
- package/source/testing.ts +0 -1
- /package/build/esm/{magic/app.mjs → modules.mjs} +0 -0
- /package/build/{esm/magic/assets.mjs → esnext/modules.esnext} +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
1
2
|
import { isValidElement } from 'react';
|
|
2
3
|
import { renderToStaticMarkup } from 'react-dom/server';
|
|
3
4
|
import { styleAssetPreloadAttributes, scriptAssetPreloadAttributes } from '@quilted/assets';
|
|
@@ -7,12 +8,11 @@ import { HTMLManager, Head, Script, Style, StylePreload, ScriptPreload } from '@
|
|
|
7
8
|
import { extract } from '@quilted/react-server-render/server';
|
|
8
9
|
import { RedirectResponse, HTMLResponse } from '@quilted/request-router';
|
|
9
10
|
import { ServerContext } from './ServerContext.esnext';
|
|
10
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
11
11
|
|
|
12
12
|
async function renderToResponse(optionsOrElement, definitelyOptions) {
|
|
13
13
|
let element;
|
|
14
14
|
let options;
|
|
15
|
-
if (
|
|
15
|
+
if (isValidElement(optionsOrElement)) {
|
|
16
16
|
element = optionsOrElement;
|
|
17
17
|
options = definitelyOptions;
|
|
18
18
|
} else {
|
|
@@ -27,42 +27,37 @@ async function renderToResponse(optionsOrElement, definitelyOptions) {
|
|
|
27
27
|
renderHTML
|
|
28
28
|
} = options;
|
|
29
29
|
const baseUrl = request.URL ?? new URL(request.url);
|
|
30
|
-
const cacheKey = explicitCacheKey ?? (await assets?.cacheKey?.(request)
|
|
30
|
+
const cacheKey = explicitCacheKey ?? (await assets?.cacheKey?.(request) ?? {});
|
|
31
31
|
const html = new HTMLManager();
|
|
32
|
-
const http = new HttpManager({
|
|
33
|
-
|
|
34
|
-
});
|
|
35
|
-
const assetsManager = new AssetsManager({
|
|
36
|
-
cacheKey
|
|
37
|
-
});
|
|
32
|
+
const http = new HttpManager({ headers: request.headers });
|
|
33
|
+
const assetsManager = new AssetsManager({ cacheKey });
|
|
38
34
|
let responseStatus = 200;
|
|
39
35
|
let appHeaders;
|
|
40
36
|
let appStream;
|
|
41
37
|
if (shouldStream === false && element != null) {
|
|
42
38
|
const rendered = await extract(element, {
|
|
43
|
-
decorate(
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
decorate(element2) {
|
|
40
|
+
return /* @__PURE__ */ jsx(
|
|
41
|
+
ServerContext,
|
|
42
|
+
{
|
|
43
|
+
http,
|
|
44
|
+
html,
|
|
45
|
+
url: baseUrl,
|
|
46
|
+
assets: assetsManager,
|
|
47
|
+
children: element2
|
|
48
|
+
}
|
|
49
|
+
);
|
|
51
50
|
}
|
|
52
51
|
});
|
|
53
|
-
const {
|
|
54
|
-
headers,
|
|
55
|
-
statusCode = 200,
|
|
56
|
-
redirectUrl
|
|
57
|
-
} = http.state;
|
|
52
|
+
const { headers: headers2, statusCode = 200, redirectUrl } = http.state;
|
|
58
53
|
if (redirectUrl) {
|
|
59
54
|
return new RedirectResponse(redirectUrl, {
|
|
60
55
|
status: statusCode,
|
|
61
|
-
headers,
|
|
56
|
+
headers: headers2,
|
|
62
57
|
request
|
|
63
58
|
});
|
|
64
59
|
}
|
|
65
|
-
appHeaders =
|
|
60
|
+
appHeaders = headers2;
|
|
66
61
|
responseStatus = statusCode;
|
|
67
62
|
const appTransformStream = new TransformStream();
|
|
68
63
|
const appWriter = appTransformStream.writable.getWriter();
|
|
@@ -73,18 +68,21 @@ async function renderToResponse(optionsOrElement, definitelyOptions) {
|
|
|
73
68
|
if (appStream == null) {
|
|
74
69
|
const appTransformStream = new TransformStream();
|
|
75
70
|
appStream = appTransformStream.readable;
|
|
76
|
-
const renderAppStream = async function
|
|
71
|
+
const renderAppStream = async function renderAppStream2() {
|
|
77
72
|
const appWriter = appTransformStream.writable.getWriter();
|
|
78
73
|
if (element != null) {
|
|
79
74
|
const rendered = await extract(element, {
|
|
80
|
-
decorate(
|
|
81
|
-
return
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
75
|
+
decorate(element2) {
|
|
76
|
+
return /* @__PURE__ */ jsx(
|
|
77
|
+
ServerContext,
|
|
78
|
+
{
|
|
79
|
+
http,
|
|
80
|
+
html,
|
|
81
|
+
url: baseUrl,
|
|
82
|
+
assets: assetsManager,
|
|
83
|
+
children: element2
|
|
84
|
+
}
|
|
85
|
+
);
|
|
88
86
|
}
|
|
89
87
|
});
|
|
90
88
|
appWriter.write(rendered);
|
|
@@ -93,172 +91,171 @@ async function renderToResponse(optionsOrElement, definitelyOptions) {
|
|
|
93
91
|
};
|
|
94
92
|
waitUntil(renderAppStream());
|
|
95
93
|
}
|
|
96
|
-
const {
|
|
97
|
-
headers,
|
|
98
|
-
body
|
|
99
|
-
} = await renderToHTMLStream(appStream);
|
|
94
|
+
const { headers, body } = await renderToHTMLStream(appStream);
|
|
100
95
|
return new HTMLResponse(body, {
|
|
101
96
|
status: responseStatus,
|
|
102
97
|
headers
|
|
103
98
|
});
|
|
104
99
|
async function renderToHTMLStream(content) {
|
|
105
|
-
const
|
|
106
|
-
const [synchronousAssets, preloadAssets] = await Promise.all([
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
timing:
|
|
100
|
+
const headers2 = new Headers(appHeaders);
|
|
101
|
+
const [synchronousAssets, preloadAssets] = await Promise.all([
|
|
102
|
+
assets?.entry({
|
|
103
|
+
cacheKey,
|
|
104
|
+
modules: assetsManager.usedModules({ timing: "load" })
|
|
105
|
+
}),
|
|
106
|
+
assets?.modules(assetsManager.usedModules({ timing: "preload" }), {
|
|
107
|
+
cacheKey
|
|
110
108
|
})
|
|
111
|
-
|
|
112
|
-
timing: 'preload'
|
|
113
|
-
}), {
|
|
114
|
-
cacheKey
|
|
115
|
-
})]);
|
|
109
|
+
]);
|
|
116
110
|
if (synchronousAssets) {
|
|
117
111
|
for (const style of synchronousAssets.styles) {
|
|
118
|
-
|
|
112
|
+
headers2.append(
|
|
113
|
+
"Link",
|
|
114
|
+
preloadHeader(styleAssetPreloadAttributes(style))
|
|
115
|
+
);
|
|
119
116
|
}
|
|
120
117
|
for (const script of synchronousAssets.scripts) {
|
|
121
|
-
|
|
118
|
+
headers2.append(
|
|
119
|
+
"Link",
|
|
120
|
+
preloadHeader(scriptAssetPreloadAttributes(script))
|
|
121
|
+
);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
if (renderHTML) {
|
|
125
|
-
const
|
|
125
|
+
const body3 = await renderHTML(content, {
|
|
126
126
|
manager: html,
|
|
127
127
|
assets: synchronousAssets,
|
|
128
128
|
preloadAssets
|
|
129
129
|
});
|
|
130
|
-
return {
|
|
131
|
-
headers,
|
|
132
|
-
body
|
|
133
|
-
};
|
|
130
|
+
return { headers: headers2, body: body3 };
|
|
134
131
|
}
|
|
135
132
|
const responseStream = new TextEncoderStream();
|
|
136
|
-
const
|
|
137
|
-
const renderFullHTML = async function
|
|
133
|
+
const body2 = responseStream.readable;
|
|
134
|
+
const renderFullHTML = async function renderFullHTML2() {
|
|
138
135
|
const writer = responseStream.writable.getWriter();
|
|
139
136
|
writer.write(`<!DOCTYPE html>`);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
/* eslint-enable jsx-a11y/html-has-lang */
|
|
175
|
-
|
|
176
|
-
const [firstChunk, secondChunk] = htmlContent.split('%%CONTENT%%');
|
|
137
|
+
const { htmlAttributes, bodyAttributes, ...headProps } = html.state;
|
|
138
|
+
const htmlContent = renderToStaticMarkup(
|
|
139
|
+
/* @__PURE__ */ jsxs("html", { ...htmlAttributes, children: [
|
|
140
|
+
/* @__PURE__ */ jsxs("head", { children: [
|
|
141
|
+
/* @__PURE__ */ jsx(Head, { ...headProps }),
|
|
142
|
+
synchronousAssets?.scripts.map((script) => /* @__PURE__ */ jsx(Script, { asset: script, baseUrl }, script.source)),
|
|
143
|
+
synchronousAssets?.styles.map((style) => /* @__PURE__ */ jsx(Style, { asset: style, baseUrl }, style.source)),
|
|
144
|
+
preloadAssets?.styles.map((style) => /* @__PURE__ */ jsx(
|
|
145
|
+
StylePreload,
|
|
146
|
+
{
|
|
147
|
+
asset: style,
|
|
148
|
+
baseUrl
|
|
149
|
+
},
|
|
150
|
+
style.source
|
|
151
|
+
)),
|
|
152
|
+
preloadAssets?.scripts.map((script) => /* @__PURE__ */ jsx(
|
|
153
|
+
ScriptPreload,
|
|
154
|
+
{
|
|
155
|
+
asset: script,
|
|
156
|
+
baseUrl
|
|
157
|
+
},
|
|
158
|
+
script.source
|
|
159
|
+
))
|
|
160
|
+
] }),
|
|
161
|
+
/* @__PURE__ */ jsx(
|
|
162
|
+
"body",
|
|
163
|
+
{
|
|
164
|
+
...bodyAttributes,
|
|
165
|
+
dangerouslySetInnerHTML: { __html: "%%CONTENT%%" }
|
|
166
|
+
}
|
|
167
|
+
)
|
|
168
|
+
] })
|
|
169
|
+
);
|
|
170
|
+
const [firstChunk, secondChunk] = htmlContent.split("%%CONTENT%%");
|
|
177
171
|
writer.write(firstChunk);
|
|
178
|
-
if (element != null)
|
|
172
|
+
if (element != null)
|
|
173
|
+
writer.write(`<div id="app">`);
|
|
179
174
|
const reader = content.getReader();
|
|
180
|
-
|
|
181
|
-
// eslint-disable-next-line no-constant-condition
|
|
182
175
|
while (true) {
|
|
183
|
-
const {
|
|
184
|
-
done,
|
|
185
|
-
value
|
|
186
|
-
} = await reader.read();
|
|
176
|
+
const { done, value } = await reader.read();
|
|
187
177
|
if (done) {
|
|
188
178
|
break;
|
|
189
179
|
}
|
|
190
180
|
writer.write(value);
|
|
191
181
|
}
|
|
192
|
-
if (element != null)
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
182
|
+
if (element != null)
|
|
183
|
+
writer.write(`</div>`);
|
|
184
|
+
const [newSynchronousAssets, newPreloadAssets] = await Promise.all([
|
|
185
|
+
assets?.entry({
|
|
186
|
+
cacheKey,
|
|
187
|
+
modules: assetsManager.usedModules({ timing: "load" })
|
|
188
|
+
}),
|
|
189
|
+
assets?.modules(assetsManager.usedModules({ timing: "preload" }), {
|
|
190
|
+
cacheKey
|
|
197
191
|
})
|
|
198
|
-
|
|
199
|
-
timing: 'preload'
|
|
200
|
-
}), {
|
|
201
|
-
cacheKey
|
|
202
|
-
})]);
|
|
192
|
+
]);
|
|
203
193
|
if (newSynchronousAssets) {
|
|
204
|
-
const diffedSynchronousAssets = diffBrowserAssetsEntries(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
asset:
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
194
|
+
const diffedSynchronousAssets = diffBrowserAssetsEntries(
|
|
195
|
+
newSynchronousAssets,
|
|
196
|
+
synchronousAssets
|
|
197
|
+
);
|
|
198
|
+
const diffedPreloadAssets = diffBrowserAssetsEntries(
|
|
199
|
+
newPreloadAssets,
|
|
200
|
+
preloadAssets
|
|
201
|
+
);
|
|
202
|
+
const additionalAssetsContent = renderToStaticMarkup(
|
|
203
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
204
|
+
diffedSynchronousAssets.scripts.map((script) => /* @__PURE__ */ jsx(Script, { asset: script, baseUrl }, script.source)),
|
|
205
|
+
diffedSynchronousAssets.styles.map((style) => /* @__PURE__ */ jsx(Style, { asset: style, baseUrl }, style.source)),
|
|
206
|
+
diffedPreloadAssets.styles.map((style) => /* @__PURE__ */ jsx(
|
|
207
|
+
StylePreload,
|
|
208
|
+
{
|
|
209
|
+
asset: style,
|
|
210
|
+
baseUrl
|
|
211
|
+
},
|
|
212
|
+
style.source
|
|
213
|
+
)),
|
|
214
|
+
diffedPreloadAssets.scripts.map((script) => /* @__PURE__ */ jsx(
|
|
215
|
+
ScriptPreload,
|
|
216
|
+
{
|
|
217
|
+
asset: script,
|
|
218
|
+
baseUrl
|
|
219
|
+
},
|
|
220
|
+
script.source
|
|
221
|
+
))
|
|
222
|
+
] })
|
|
223
|
+
);
|
|
221
224
|
writer.write(additionalAssetsContent);
|
|
222
225
|
}
|
|
223
226
|
writer.write(secondChunk);
|
|
224
227
|
writer.close();
|
|
225
228
|
};
|
|
226
229
|
waitUntil(renderFullHTML());
|
|
227
|
-
return {
|
|
228
|
-
headers,
|
|
229
|
-
body
|
|
230
|
-
};
|
|
230
|
+
return { headers: headers2, body: body2 };
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
function preloadHeader(attributes) {
|
|
234
234
|
const {
|
|
235
235
|
as,
|
|
236
|
-
rel =
|
|
236
|
+
rel = "preload",
|
|
237
237
|
href,
|
|
238
238
|
crossOrigin,
|
|
239
239
|
crossorigin
|
|
240
240
|
} = attributes;
|
|
241
|
-
|
|
242
|
-
// Support both property and attribute versions of the casing
|
|
243
241
|
const finalCrossOrigin = crossOrigin ?? crossorigin;
|
|
244
242
|
let header = `<${href}>; rel="${rel}"; as="${as}"`;
|
|
245
|
-
if (finalCrossOrigin ===
|
|
243
|
+
if (finalCrossOrigin === "" || finalCrossOrigin === true) {
|
|
246
244
|
header += `; crossorigin`;
|
|
247
|
-
} else if (typeof finalCrossOrigin ===
|
|
245
|
+
} else if (typeof finalCrossOrigin === "string") {
|
|
248
246
|
header += `; crossorigin="${finalCrossOrigin}"`;
|
|
249
247
|
}
|
|
250
248
|
return header;
|
|
251
249
|
}
|
|
252
250
|
function diffBrowserAssetsEntries(newList, oldList) {
|
|
253
|
-
const oldStyles = new Set(oldList.styles.map(style => style.source));
|
|
254
|
-
const oldScripts = new Set(oldList.scripts.map(script => script.source));
|
|
251
|
+
const oldStyles = new Set(oldList.styles.map((style) => style.source));
|
|
252
|
+
const oldScripts = new Set(oldList.scripts.map((script) => script.source));
|
|
255
253
|
return {
|
|
256
|
-
styles: newList.styles.filter(style => !oldStyles.has(style.source)),
|
|
257
|
-
scripts: newList.scripts.filter(script => !oldScripts.has(script.source))
|
|
254
|
+
styles: newList.styles.filter((style) => !oldStyles.has(style.source)),
|
|
255
|
+
scripts: newList.scripts.filter((script) => !oldScripts.has(script.source))
|
|
258
256
|
};
|
|
259
257
|
}
|
|
260
258
|
function noop(..._args) {
|
|
261
|
-
// noop
|
|
262
259
|
}
|
|
263
260
|
|
|
264
261
|
export { renderToResponse };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
|
|
3
3
|
function maybeWrapContext(Context, value, children) {
|
|
4
|
-
return value ?
|
|
5
|
-
value: value,
|
|
6
|
-
children: children
|
|
7
|
-
}) : children;
|
|
4
|
+
return value ? /* @__PURE__ */ jsx(Context.Provider, { value, children }) : children;
|
|
8
5
|
}
|
|
9
6
|
|
|
10
7
|
export { maybeWrapContext };
|