astro 4.5.8 → 4.5.9
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/dist/content/vite-plugin-content-assets.js +2 -2
- package/dist/core/build/css-asset-name.js +7 -7
- package/dist/core/build/graph.d.ts +13 -4
- package/dist/core/build/graph.js +31 -18
- package/dist/core/build/plugins/plugin-analyzer.js +8 -6
- package/dist/core/build/plugins/plugin-css.js +10 -8
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/runtime/server/jsx.js +10 -76
- package/dist/runtime/server/render/component.js +4 -6
- package/dist/runtime/server/render/head.d.ts +2 -2
- package/dist/runtime/server/render/head.js +4 -4
- package/dist/transitions/router.js +1 -2
- package/dist/vite-plugin-head/index.js +4 -4
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { extname } from "node:path";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
3
|
import { getAssetsPrefix } from "../assets/utils/getAssetsPrefix.js";
|
|
4
|
-
import {
|
|
4
|
+
import { getParentModuleInfos, moduleIsTopLevelPage } from "../core/build/graph.js";
|
|
5
5
|
import { getPageDataByViteID } from "../core/build/internal.js";
|
|
6
6
|
import { createViteLoader } from "../core/module-loader/vite.js";
|
|
7
7
|
import { joinPaths, prependForwardSlash } from "../core/path.js";
|
|
@@ -147,7 +147,7 @@ function astroConfigBuildPlugin(options, internals) {
|
|
|
147
147
|
}
|
|
148
148
|
} else {
|
|
149
149
|
for (const id of Object.keys(chunk.modules)) {
|
|
150
|
-
for (const
|
|
150
|
+
for (const pageInfo of getParentModuleInfos(id, ssrPluginContext)) {
|
|
151
151
|
if (moduleIsTopLevelPage(pageInfo)) {
|
|
152
152
|
const pageViteID = pageInfo.id;
|
|
153
153
|
const pageData = getPageDataByViteID(internals, pageViteID);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
2
|
import npath from "node:path";
|
|
3
3
|
import { viteID } from "../util.js";
|
|
4
|
-
import {
|
|
4
|
+
import { getTopLevelPageModuleInfos } from "./graph.js";
|
|
5
5
|
const confusingBaseNames = ["404", "500"];
|
|
6
6
|
function shortHashedName(id, ctx) {
|
|
7
|
-
const parents =
|
|
7
|
+
const parents = getTopLevelPageModuleInfos(id, ctx);
|
|
8
8
|
return createNameHash(
|
|
9
9
|
getFirstParentId(parents),
|
|
10
|
-
parents.map((
|
|
10
|
+
parents.map((page) => page.id)
|
|
11
11
|
);
|
|
12
12
|
}
|
|
13
13
|
function createNameHash(baseId, hashIds) {
|
|
@@ -26,8 +26,8 @@ function createSlugger(settings) {
|
|
|
26
26
|
const map = /* @__PURE__ */ new Map();
|
|
27
27
|
const sep = "-";
|
|
28
28
|
return function(id, ctx) {
|
|
29
|
-
const parents = Array.from(
|
|
30
|
-
const allParentsKey = parents.map((
|
|
29
|
+
const parents = Array.from(getTopLevelPageModuleInfos(id, ctx));
|
|
30
|
+
const allParentsKey = parents.map((page) => page.id).sort().join("-");
|
|
31
31
|
const firstParentId = getFirstParentId(parents) || indexPage;
|
|
32
32
|
let dir = firstParentId;
|
|
33
33
|
let key = "";
|
|
@@ -62,13 +62,13 @@ function createSlugger(settings) {
|
|
|
62
62
|
}
|
|
63
63
|
function getFirstParentId(parents) {
|
|
64
64
|
for (const parent of parents) {
|
|
65
|
-
const id = parent
|
|
65
|
+
const id = parent.id;
|
|
66
66
|
const baseName = npath.parse(id).name;
|
|
67
67
|
if (!confusingBaseNames.includes(baseName)) {
|
|
68
68
|
return id;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
return parents[0]?.
|
|
71
|
+
return parents[0]?.id;
|
|
72
72
|
}
|
|
73
73
|
const charsToReplaceRe = /[.[\]]/g;
|
|
74
74
|
const underscoresRe = /_+/g;
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import type { GetModuleInfo, ModuleInfo } from 'rollup';
|
|
2
|
-
|
|
2
|
+
interface ExtendedModuleInfo {
|
|
3
|
+
info: ModuleInfo;
|
|
4
|
+
depth: number;
|
|
5
|
+
order: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function getParentExtendedModuleInfos(id: string, ctx: {
|
|
3
8
|
getModuleInfo: GetModuleInfo;
|
|
4
|
-
}, until?: (importer: string) => boolean, depth?: number, order?: number, seen?: Set<string>,
|
|
9
|
+
}, until?: (importer: string) => boolean, depth?: number, order?: number, childId?: string, seen?: Set<string>, accumulated?: ExtendedModuleInfo[]): ExtendedModuleInfo[];
|
|
10
|
+
export declare function getParentModuleInfos(id: string, ctx: {
|
|
11
|
+
getModuleInfo: GetModuleInfo;
|
|
12
|
+
}, until?: (importer: string) => boolean, seen?: Set<string>, accumulated?: ModuleInfo[]): ModuleInfo[];
|
|
5
13
|
export declare function moduleIsTopLevelPage(info: ModuleInfo): boolean;
|
|
6
|
-
export declare function
|
|
14
|
+
export declare function getTopLevelPageModuleInfos(id: string, ctx: {
|
|
7
15
|
getModuleInfo: GetModuleInfo;
|
|
8
|
-
}):
|
|
16
|
+
}): ModuleInfo[];
|
|
17
|
+
export {};
|
package/dist/core/build/graph.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ASTRO_PAGE_RESOLVED_MODULE_ID } from "./plugins/plugin-pages.js";
|
|
2
|
-
function
|
|
2
|
+
function getParentExtendedModuleInfos(id, ctx, until, depth = 0, order = 0, childId = "", seen = /* @__PURE__ */ new Set(), accumulated = []) {
|
|
3
3
|
seen.add(id);
|
|
4
4
|
const info = ctx.getModuleInfo(id);
|
|
5
5
|
if (info) {
|
|
@@ -12,30 +12,43 @@ function* walkParentInfos(id, ctx, until, depth = 0, order = 0, seen = /* @__PUR
|
|
|
12
12
|
order += idx;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
accumulated.push({ info, depth, order });
|
|
16
16
|
}
|
|
17
|
-
if (until?.(id))
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
if (info && !until?.(id)) {
|
|
18
|
+
const importers = info.importers.concat(info.dynamicImporters);
|
|
19
|
+
for (const imp of importers) {
|
|
20
|
+
if (!seen.has(imp)) {
|
|
21
|
+
getParentExtendedModuleInfos(imp, ctx, until, depth + 1, order, id, seen, accumulated);
|
|
22
|
+
}
|
|
23
23
|
}
|
|
24
|
-
yield* walkParentInfos(imp, ctx, until, depth + 1, order, seen, id);
|
|
25
24
|
}
|
|
25
|
+
return accumulated;
|
|
26
|
+
}
|
|
27
|
+
function getParentModuleInfos(id, ctx, until, seen = /* @__PURE__ */ new Set(), accumulated = []) {
|
|
28
|
+
seen.add(id);
|
|
29
|
+
const info = ctx.getModuleInfo(id);
|
|
30
|
+
if (info) {
|
|
31
|
+
accumulated.push(info);
|
|
32
|
+
}
|
|
33
|
+
if (info && !until?.(id)) {
|
|
34
|
+
const importers = info.importers.concat(info.dynamicImporters);
|
|
35
|
+
for (const imp of importers) {
|
|
36
|
+
if (!seen.has(imp)) {
|
|
37
|
+
getParentModuleInfos(imp, ctx, until, seen, accumulated);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return accumulated;
|
|
26
42
|
}
|
|
27
43
|
function moduleIsTopLevelPage(info) {
|
|
28
44
|
return info.importers[0]?.includes(ASTRO_PAGE_RESOLVED_MODULE_ID) || info.dynamicImporters[0]?.includes(ASTRO_PAGE_RESOLVED_MODULE_ID);
|
|
29
45
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
if (moduleIsTopLevelPage(res[0])) {
|
|
33
|
-
yield res;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
46
|
+
function getTopLevelPageModuleInfos(id, ctx) {
|
|
47
|
+
return getParentModuleInfos(id, ctx).filter(moduleIsTopLevelPage);
|
|
36
48
|
}
|
|
37
49
|
export {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
50
|
+
getParentExtendedModuleInfos,
|
|
51
|
+
getParentModuleInfos,
|
|
52
|
+
getTopLevelPageModuleInfos,
|
|
53
|
+
moduleIsTopLevelPage
|
|
41
54
|
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { PROPAGATED_ASSET_FLAG } from "../../../content/consts.js";
|
|
2
2
|
import { prependForwardSlash } from "../../../core/path.js";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
getParentModuleInfos,
|
|
5
|
+
getTopLevelPageModuleInfos,
|
|
6
|
+
moduleIsTopLevelPage
|
|
7
|
+
} from "../graph.js";
|
|
4
8
|
import { getPageDataByViteID, trackClientOnlyPageDatas } from "../internal.js";
|
|
5
9
|
function isPropagatedAsset(id) {
|
|
6
10
|
try {
|
|
@@ -21,11 +25,9 @@ function vitePluginAnalyzer(options, internals) {
|
|
|
21
25
|
hoistedScripts.add(hid);
|
|
22
26
|
}
|
|
23
27
|
if (hoistedScripts.size) {
|
|
24
|
-
for (const
|
|
25
|
-
return isPropagatedAsset(importer);
|
|
26
|
-
})) {
|
|
28
|
+
for (const parentInfo of getParentModuleInfos(from, this, isPropagatedAsset)) {
|
|
27
29
|
if (isPropagatedAsset(parentInfo.id)) {
|
|
28
|
-
for (const
|
|
30
|
+
for (const nestedParentInfo of getParentModuleInfos(from, this)) {
|
|
29
31
|
if (moduleIsTopLevelPage(nestedParentInfo)) {
|
|
30
32
|
for (const hid of hoistedScripts) {
|
|
31
33
|
if (!pageScripts.has(nestedParentInfo.id)) {
|
|
@@ -131,7 +133,7 @@ function vitePluginAnalyzer(options, internals) {
|
|
|
131
133
|
clientOnlys.push(resolvedId.id);
|
|
132
134
|
}
|
|
133
135
|
}
|
|
134
|
-
for (const
|
|
136
|
+
for (const pageInfo of getTopLevelPageModuleInfos(id, this)) {
|
|
135
137
|
const newPageData = getPageDataByViteID(internals, pageInfo.id);
|
|
136
138
|
if (!newPageData)
|
|
137
139
|
continue;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { isBuildableCSSRequest } from "../../../vite-plugin-astro-server/util.js";
|
|
2
2
|
import { PROPAGATED_ASSET_FLAG } from "../../../content/consts.js";
|
|
3
3
|
import * as assetName from "../css-asset-name.js";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
getParentExtendedModuleInfos,
|
|
6
|
+
getParentModuleInfos,
|
|
7
|
+
moduleIsTopLevelPage
|
|
8
|
+
} from "../graph.js";
|
|
5
9
|
import {
|
|
6
10
|
eachPageData,
|
|
7
11
|
getPageDataByViteID,
|
|
@@ -46,9 +50,8 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
46
50
|
if (options.target === "client") {
|
|
47
51
|
return internals.cssModuleToChunkIdMap.get(id);
|
|
48
52
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
})) {
|
|
53
|
+
const ctx = { getModuleInfo: meta.getModuleInfo };
|
|
54
|
+
for (const pageInfo of getParentModuleInfos(id, ctx)) {
|
|
52
55
|
if (new URL(pageInfo.id, "file://").searchParams.has(PROPAGATED_ASSET_FLAG)) {
|
|
53
56
|
const chunkId2 = assetName.createNameHash(id, [id]);
|
|
54
57
|
internals.cssModuleToChunkIdMap.set(id, chunkId2);
|
|
@@ -87,7 +90,7 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
87
90
|
}
|
|
88
91
|
}
|
|
89
92
|
for (const id of Object.keys(chunk.modules)) {
|
|
90
|
-
for (const
|
|
93
|
+
for (const { info: pageInfo, depth, order } of getParentExtendedModuleInfos(
|
|
91
94
|
id,
|
|
92
95
|
this,
|
|
93
96
|
function until(importer) {
|
|
@@ -95,8 +98,7 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
95
98
|
}
|
|
96
99
|
)) {
|
|
97
100
|
if (new URL(pageInfo.id, "file://").searchParams.has(PROPAGATED_ASSET_FLAG)) {
|
|
98
|
-
for (const
|
|
99
|
-
const parentInfo = parent[0];
|
|
101
|
+
for (const parentInfo of getParentModuleInfos(id, this)) {
|
|
100
102
|
if (moduleIsTopLevelPage(parentInfo) === false)
|
|
101
103
|
continue;
|
|
102
104
|
const pageViteID = parentInfo.id;
|
|
@@ -216,7 +218,7 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
216
218
|
return [cssBuildPlugin, cssScopeToPlugin, singleCssPlugin, inlineStylesheetsPlugin];
|
|
217
219
|
}
|
|
218
220
|
function* getParentClientOnlys(id, ctx, internals) {
|
|
219
|
-
for (const
|
|
221
|
+
for (const info of getParentModuleInfos(id, ctx)) {
|
|
220
222
|
yield* getPageDatasByClientOnlyID(internals, info.id);
|
|
221
223
|
}
|
|
222
224
|
}
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -23,7 +23,7 @@ async function dev(inlineConfig) {
|
|
|
23
23
|
base: restart.container.settings.config.base
|
|
24
24
|
})
|
|
25
25
|
);
|
|
26
|
-
const currentVersion = "4.5.
|
|
26
|
+
const currentVersion = "4.5.9";
|
|
27
27
|
if (currentVersion.includes("-")) {
|
|
28
28
|
logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
|
|
29
29
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -36,7 +36,7 @@ function serverStart({
|
|
|
36
36
|
host,
|
|
37
37
|
base
|
|
38
38
|
}) {
|
|
39
|
-
const version = "4.5.
|
|
39
|
+
const version = "4.5.9";
|
|
40
40
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
41
41
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
42
42
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -261,7 +261,7 @@ function printHelp({
|
|
|
261
261
|
message.push(
|
|
262
262
|
linebreak(),
|
|
263
263
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
264
|
-
`v${"4.5.
|
|
264
|
+
`v${"4.5.9"}`
|
|
265
265
|
)} ${headline}`
|
|
266
266
|
);
|
|
267
267
|
}
|
|
@@ -9,25 +9,7 @@ import {
|
|
|
9
9
|
} from "./index.js";
|
|
10
10
|
import { renderComponentToString } from "./render/component.js";
|
|
11
11
|
const ClientOnlyPlaceholder = "astro-client-only";
|
|
12
|
-
|
|
13
|
-
constructor(vnode) {
|
|
14
|
-
this.vnode = vnode;
|
|
15
|
-
this.count = 0;
|
|
16
|
-
}
|
|
17
|
-
count;
|
|
18
|
-
increment() {
|
|
19
|
-
this.count++;
|
|
20
|
-
}
|
|
21
|
-
haveNoTried() {
|
|
22
|
-
return this.count === 0;
|
|
23
|
-
}
|
|
24
|
-
isCompleted() {
|
|
25
|
-
return this.count > 2;
|
|
26
|
-
}
|
|
27
|
-
static symbol = Symbol("astro:jsx:skip");
|
|
28
|
-
}
|
|
29
|
-
let originalConsoleError;
|
|
30
|
-
let consoleFilterRefs = 0;
|
|
12
|
+
const hasTriedRenderComponentSymbol = Symbol("hasTriedRenderComponent");
|
|
31
13
|
async function renderJSX(result, vnode) {
|
|
32
14
|
switch (true) {
|
|
33
15
|
case vnode instanceof HTMLString:
|
|
@@ -46,19 +28,9 @@ async function renderJSX(result, vnode) {
|
|
|
46
28
|
(await Promise.all(vnode.map((v) => renderJSX(result, v)))).join("")
|
|
47
29
|
);
|
|
48
30
|
}
|
|
49
|
-
|
|
50
|
-
if (vnode.props) {
|
|
51
|
-
if (vnode.props[Skip.symbol]) {
|
|
52
|
-
skip = vnode.props[Skip.symbol];
|
|
53
|
-
} else {
|
|
54
|
-
skip = new Skip(vnode);
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
skip = new Skip(vnode);
|
|
58
|
-
}
|
|
59
|
-
return renderJSXVNode(result, vnode, skip);
|
|
31
|
+
return renderJSXVNode(result, vnode);
|
|
60
32
|
}
|
|
61
|
-
async function renderJSXVNode(result, vnode
|
|
33
|
+
async function renderJSXVNode(result, vnode) {
|
|
62
34
|
if (isVNode(vnode)) {
|
|
63
35
|
switch (true) {
|
|
64
36
|
case !vnode.type: {
|
|
@@ -106,36 +78,20 @@ Did you forget to import the component or is it possible there is a typo?`);
|
|
|
106
78
|
_slots.default.push(child);
|
|
107
79
|
};
|
|
108
80
|
var extractSlots = extractSlots2;
|
|
109
|
-
if (typeof vnode.type === "function" && vnode.type["astro:renderer"]) {
|
|
110
|
-
skip.increment();
|
|
111
|
-
}
|
|
112
81
|
if (typeof vnode.type === "function" && vnode.props["server:root"]) {
|
|
113
82
|
const output2 = await vnode.type(vnode.props ?? {});
|
|
114
83
|
return await renderJSX(result, output2);
|
|
115
84
|
}
|
|
116
85
|
if (typeof vnode.type === "function") {
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
renderResult = await renderJSXVNode(result, output2, skip);
|
|
124
|
-
return renderResult;
|
|
125
|
-
} else if (!output2) {
|
|
126
|
-
renderResult = await renderJSXVNode(result, output2, skip);
|
|
127
|
-
return renderResult;
|
|
128
|
-
}
|
|
129
|
-
} catch (e) {
|
|
130
|
-
if (skip.isCompleted()) {
|
|
131
|
-
throw e;
|
|
132
|
-
}
|
|
133
|
-
skip.increment();
|
|
134
|
-
} finally {
|
|
135
|
-
finishUsingConsoleFilter();
|
|
86
|
+
if (vnode.props[hasTriedRenderComponentSymbol]) {
|
|
87
|
+
const output2 = await vnode.type(vnode.props ?? {});
|
|
88
|
+
if (output2?.[AstroJSX] || !output2) {
|
|
89
|
+
return await renderJSXVNode(result, output2);
|
|
90
|
+
} else {
|
|
91
|
+
return;
|
|
136
92
|
}
|
|
137
93
|
} else {
|
|
138
|
-
|
|
94
|
+
vnode.props[hasTriedRenderComponentSymbol] = true;
|
|
139
95
|
}
|
|
140
96
|
}
|
|
141
97
|
const { children = null, ...props } = vnode.props ?? {};
|
|
@@ -161,7 +117,6 @@ Did you forget to import the component or is it possible there is a typo?`);
|
|
|
161
117
|
);
|
|
162
118
|
}
|
|
163
119
|
await Promise.all(slotPromises);
|
|
164
|
-
props[Skip.symbol] = skip;
|
|
165
120
|
let output;
|
|
166
121
|
if (vnode.type === ClientOnlyPlaceholder && vnode.props["client:only"]) {
|
|
167
122
|
output = await renderComponentToString(
|
|
@@ -199,27 +154,6 @@ function prerenderElementChildren(tag, children) {
|
|
|
199
154
|
return children;
|
|
200
155
|
}
|
|
201
156
|
}
|
|
202
|
-
function useConsoleFilter() {
|
|
203
|
-
consoleFilterRefs++;
|
|
204
|
-
if (!originalConsoleError) {
|
|
205
|
-
originalConsoleError = console.error;
|
|
206
|
-
try {
|
|
207
|
-
console.error = filteredConsoleError;
|
|
208
|
-
} catch (error) {
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
function finishUsingConsoleFilter() {
|
|
213
|
-
consoleFilterRefs--;
|
|
214
|
-
}
|
|
215
|
-
function filteredConsoleError(msg, ...rest) {
|
|
216
|
-
if (consoleFilterRefs > 0 && typeof msg === "string") {
|
|
217
|
-
const isKnownReactHookError = msg.includes("Warning: Invalid hook call.") && msg.includes("https://reactjs.org/link/invalid-hook-call");
|
|
218
|
-
if (isKnownReactHookError)
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
originalConsoleError(msg, ...rest);
|
|
222
|
-
}
|
|
223
157
|
export {
|
|
224
158
|
renderJSX
|
|
225
159
|
};
|
|
@@ -382,17 +382,15 @@ async function renderComponentToString(result, displayName, Component, props, sl
|
|
|
382
382
|
let str = "";
|
|
383
383
|
let renderedFirstPageChunk = false;
|
|
384
384
|
let head = "";
|
|
385
|
-
if (nonAstroPageNeedsHeadInjection(Component)) {
|
|
386
|
-
|
|
387
|
-
head += chunkToString(result, headChunk);
|
|
388
|
-
}
|
|
385
|
+
if (isPage && !result.partial && nonAstroPageNeedsHeadInjection(Component)) {
|
|
386
|
+
head += chunkToString(result, maybeRenderHead());
|
|
389
387
|
}
|
|
390
388
|
try {
|
|
391
389
|
const destination = {
|
|
392
390
|
write(chunk) {
|
|
393
|
-
if (isPage && !renderedFirstPageChunk) {
|
|
391
|
+
if (isPage && !result.partial && !renderedFirstPageChunk) {
|
|
394
392
|
renderedFirstPageChunk = true;
|
|
395
|
-
if (
|
|
393
|
+
if (!/<!doctype html/i.test(String(chunk))) {
|
|
396
394
|
const doctype = result.compressHTML ? "<!DOCTYPE html>" : "<!DOCTYPE html>\n";
|
|
397
395
|
str += doctype + head;
|
|
398
396
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SSRResult } from '../../../@types/astro.js';
|
|
2
2
|
import type { MaybeRenderHeadInstruction, RenderHeadInstruction } from './instruction.js';
|
|
3
3
|
export declare function renderAllHeadContent(result: SSRResult): any;
|
|
4
|
-
export declare function renderHead():
|
|
5
|
-
export declare function maybeRenderHead():
|
|
4
|
+
export declare function renderHead(): RenderHeadInstruction;
|
|
5
|
+
export declare function maybeRenderHead(): MaybeRenderHeadInstruction;
|
|
@@ -24,11 +24,11 @@ function renderAllHeadContent(result) {
|
|
|
24
24
|
}
|
|
25
25
|
return markHTMLString(content);
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
27
|
+
function renderHead() {
|
|
28
|
+
return createRenderInstruction({ type: "head" });
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
30
|
+
function maybeRenderHead() {
|
|
31
|
+
return createRenderInstruction({ type: "maybe-head" });
|
|
32
32
|
}
|
|
33
33
|
export {
|
|
34
34
|
maybeRenderHead,
|
|
@@ -463,12 +463,11 @@ async function prepareForClientOnlyComponents(newDocument, toLocation) {
|
|
|
463
463
|
await hydrationDone(nextPage);
|
|
464
464
|
const nextHead = nextPage.contentDocument?.head;
|
|
465
465
|
if (nextHead) {
|
|
466
|
-
document.head.querySelectorAll(`style[${PERSIST_ATTR}=""]`).forEach((s) => s.removeAttribute(PERSIST_ATTR));
|
|
467
466
|
const viteIds = [...nextHead.querySelectorAll(`style[${VITE_ID}]`)].map(
|
|
468
467
|
(style) => style.getAttribute(VITE_ID)
|
|
469
468
|
);
|
|
470
469
|
viteIds.forEach((id) => {
|
|
471
|
-
const style =
|
|
470
|
+
const style = nextHead.querySelector(`style[${VITE_ID}="${id}"]`);
|
|
472
471
|
if (style && !newDocument.head.querySelector(`style[${VITE_ID}="${id}"]`)) {
|
|
473
472
|
newDocument.head.appendChild(style.cloneNode(true));
|
|
474
473
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getParentModuleInfos, getTopLevelPageModuleInfos } from "../core/build/graph.js";
|
|
2
2
|
import { getAstroMetadata } from "../vite-plugin-astro/index.js";
|
|
3
3
|
const injectExp = /(?:^\/\/|\/\/!)\s*astro-head-inject/;
|
|
4
4
|
function configHeadVitePlugin() {
|
|
@@ -97,13 +97,13 @@ function astroHeadBuildPlugin(internals) {
|
|
|
97
97
|
if (modinfo) {
|
|
98
98
|
const meta = getAstroMetadata(modinfo);
|
|
99
99
|
if (meta?.containsHead) {
|
|
100
|
-
for (const
|
|
100
|
+
for (const pageInfo of getTopLevelPageModuleInfos(id, this)) {
|
|
101
101
|
let metadata = getOrCreateMetadata(pageInfo.id);
|
|
102
102
|
metadata.containsHead = true;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
if (meta?.propagation === "self") {
|
|
106
|
-
for (const
|
|
106
|
+
for (const info of getParentModuleInfos(id, this)) {
|
|
107
107
|
let metadata = getOrCreateMetadata(info.id);
|
|
108
108
|
if (metadata.propagation !== "self") {
|
|
109
109
|
metadata.propagation = "in-tree";
|
|
@@ -112,7 +112,7 @@ function astroHeadBuildPlugin(internals) {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
if (mod.code && injectExp.test(mod.code)) {
|
|
115
|
-
for (const
|
|
115
|
+
for (const info of getParentModuleInfos(id, this)) {
|
|
116
116
|
getOrCreateMetadata(info.id).propagation = "in-tree";
|
|
117
117
|
}
|
|
118
118
|
}
|