arcway 0.4.15 → 0.4.17
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/package.json
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import boot from '#server/boot.js';
|
|
2
1
|
import { loadEnvFiles } from '#server/env.js';
|
|
3
2
|
|
|
4
3
|
async function startServer(mode) {
|
|
@@ -11,6 +10,11 @@ async function startServer(mode) {
|
|
|
11
10
|
// dotenv never overrides already-set variables.
|
|
12
11
|
loadEnvFiles(process.cwd(), mode);
|
|
13
12
|
|
|
13
|
+
// Importing the application boot graph loads React-backed page modules.
|
|
14
|
+
// Production mode must be established first so React and react-dom/server
|
|
15
|
+
// select matching builds. A static import here can cache development React
|
|
16
|
+
// before `arcway start` gets a chance to set NODE_ENV.
|
|
17
|
+
const { default: boot } = await import('#server/boot.js');
|
|
14
18
|
const app = await boot({ mode, rootDir: process.cwd() });
|
|
15
19
|
app.logger.info('Arcway framework ready', { mode, port: app.port });
|
|
16
20
|
|
|
@@ -72,6 +72,13 @@ function resolve(config, { rootDir } = {}) {
|
|
|
72
72
|
...(hmr ? { hmr } : {}),
|
|
73
73
|
},
|
|
74
74
|
};
|
|
75
|
+
if (
|
|
76
|
+
pages.language != null &&
|
|
77
|
+
(typeof pages.language !== 'string' ||
|
|
78
|
+
!/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/.test(pages.language))
|
|
79
|
+
) {
|
|
80
|
+
throw new TypeError('Invalid config: pages.language must be a valid language tag');
|
|
81
|
+
}
|
|
75
82
|
if (pages.rewrite != null) {
|
|
76
83
|
if (
|
|
77
84
|
typeof pages.rewrite !== 'object' ||
|
package/server/mail/index.js
CHANGED
|
@@ -95,13 +95,9 @@ function registerSendJob(driver, queue, throughput) {
|
|
|
95
95
|
handler: async () => {
|
|
96
96
|
if (!queue) return;
|
|
97
97
|
const items = await queue.pop(MAIL_TOPIC, 10);
|
|
98
|
-
const ids = [];
|
|
99
98
|
for (const item of items) {
|
|
100
99
|
await driver.send(item.data);
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
if (ids.length > 0) {
|
|
104
|
-
await queue.remove(ids);
|
|
100
|
+
await queue.remove([item.id]);
|
|
105
101
|
}
|
|
106
102
|
},
|
|
107
103
|
throughput,
|
package/server/pages/handler.js
CHANGED
|
@@ -35,6 +35,7 @@ function createPagesHandler(options) {
|
|
|
35
35
|
let manifestPath = path.join(outDir, 'pages-manifest.json');
|
|
36
36
|
const sessionConfig = options.session;
|
|
37
37
|
const appContext = options.appContext ?? null;
|
|
38
|
+
const documentLanguage = options.documentLanguage;
|
|
38
39
|
const rewrite = options.rewrite ?? null;
|
|
39
40
|
const mode = options.mode ?? 'production';
|
|
40
41
|
const devMode = mode === 'development';
|
|
@@ -141,6 +142,7 @@ function createPagesHandler(options) {
|
|
|
141
142
|
manifest,
|
|
142
143
|
cacheVersion,
|
|
143
144
|
projectReact,
|
|
145
|
+
documentLanguage,
|
|
144
146
|
);
|
|
145
147
|
} else if (!res.headersSent) {
|
|
146
148
|
res.writeHead(500, getHtmlHeaders());
|
|
@@ -225,6 +227,7 @@ function createPagesHandler(options) {
|
|
|
225
227
|
componentCache,
|
|
226
228
|
cacheVersion,
|
|
227
229
|
projectReact,
|
|
230
|
+
documentLanguage,
|
|
228
231
|
);
|
|
229
232
|
return true;
|
|
230
233
|
}
|
|
@@ -315,6 +318,7 @@ function createPagesHandler(options) {
|
|
|
315
318
|
status: loaderResult?.status,
|
|
316
319
|
headers: loaderResult?.headers,
|
|
317
320
|
},
|
|
321
|
+
documentLanguage,
|
|
318
322
|
);
|
|
319
323
|
} catch (err) {
|
|
320
324
|
await renderRuntimeError(err, res);
|
|
@@ -333,6 +337,7 @@ function createPagesHandler(options) {
|
|
|
333
337
|
manifest,
|
|
334
338
|
cacheVersion,
|
|
335
339
|
projectReact,
|
|
340
|
+
documentLanguage,
|
|
336
341
|
);
|
|
337
342
|
} else {
|
|
338
343
|
res.writeHead(404, getHtmlHeaders());
|
|
@@ -363,6 +368,7 @@ async function renderDevBuildError(
|
|
|
363
368
|
componentCache,
|
|
364
369
|
cacheVersion,
|
|
365
370
|
projectReact,
|
|
371
|
+
documentLanguage,
|
|
366
372
|
) {
|
|
367
373
|
const errorMessage = err instanceof Error ? err.stack || err.message : String(err);
|
|
368
374
|
if (manifest.errorBundle && !res.headersSent) {
|
|
@@ -376,6 +382,7 @@ async function renderDevBuildError(
|
|
|
376
382
|
manifest,
|
|
377
383
|
cacheVersion,
|
|
378
384
|
projectReact,
|
|
385
|
+
documentLanguage,
|
|
379
386
|
);
|
|
380
387
|
return;
|
|
381
388
|
}
|
package/server/pages/ssr.js
CHANGED
|
@@ -130,10 +130,18 @@ window.__vite_plugin_react_preamble_installed__ = true;
|
|
|
130
130
|
`<script type="module" src="${route.clientBundle}"></script>`,
|
|
131
131
|
].join('\n');
|
|
132
132
|
}
|
|
133
|
-
function buildHtmlShell({
|
|
133
|
+
function buildHtmlShell({
|
|
134
|
+
headHtml,
|
|
135
|
+
fontPreloadTags,
|
|
136
|
+
cssLinkTag,
|
|
137
|
+
bodysuffix,
|
|
138
|
+
documentLanguage,
|
|
139
|
+
}) {
|
|
140
|
+
const languageAttribute = documentLanguage ? ` lang="${documentLanguage}"` : '';
|
|
141
|
+
|
|
134
142
|
return {
|
|
135
143
|
head: `<!DOCTYPE html>
|
|
136
|
-
<html>
|
|
144
|
+
<html${languageAttribute}>
|
|
137
145
|
<head>
|
|
138
146
|
<meta charset="utf-8" />
|
|
139
147
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
|
|
@@ -165,6 +173,7 @@ async function renderPage(
|
|
|
165
173
|
onRenderFailure = null,
|
|
166
174
|
pageProps = params,
|
|
167
175
|
response = {},
|
|
176
|
+
documentLanguage,
|
|
168
177
|
) {
|
|
169
178
|
const { createElement, renderToPipeableStream } = react;
|
|
170
179
|
const bundlePath = path.join(outDir, route.serverBundle);
|
|
@@ -243,6 +252,7 @@ async function renderPage(
|
|
|
243
252
|
${hmrTag}
|
|
244
253
|
${scriptTags}
|
|
245
254
|
${liveReloadTag}`,
|
|
255
|
+
documentLanguage,
|
|
246
256
|
});
|
|
247
257
|
res.write(shell.head);
|
|
248
258
|
pass = new PassThrough();
|
|
@@ -310,6 +320,7 @@ async function renderErrorPage(
|
|
|
310
320
|
manifest,
|
|
311
321
|
cacheVersion,
|
|
312
322
|
react,
|
|
323
|
+
documentLanguage,
|
|
313
324
|
) {
|
|
314
325
|
const { createElement, renderToPipeableStream } = react;
|
|
315
326
|
const fullPath = path.join(outDir, bundlePath);
|
|
@@ -349,7 +360,12 @@ async function renderErrorPage(
|
|
|
349
360
|
if (res.headersSent || closed) return;
|
|
350
361
|
const headHtml = renderHeadToString(headData);
|
|
351
362
|
res.writeHead(statusCode, getHtmlHeaders());
|
|
352
|
-
const shell = buildHtmlShell({
|
|
363
|
+
const shell = buildHtmlShell({
|
|
364
|
+
headHtml,
|
|
365
|
+
fontPreloadTags,
|
|
366
|
+
cssLinkTag,
|
|
367
|
+
documentLanguage,
|
|
368
|
+
});
|
|
353
369
|
res.write(shell.head);
|
|
354
370
|
pass = new PassThrough();
|
|
355
371
|
pass.on('data', (chunk) => {
|