astro 3.0.11 → 3.0.13
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/client.d.ts +3 -5
- package/components/ViewTransitions.astro +74 -21
- package/dist/@types/astro.d.ts +6 -11
- package/dist/assets/types.d.ts +1 -3
- package/dist/content/utils.js +1 -1
- package/dist/core/build/generate.js +3 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/render/ssr-element.js +1 -3
- package/dist/runtime/client/hmr.js +1 -1
- package/dist/runtime/server/render/tags.js +1 -1
- package/dist/type-utils.d.ts +10 -0
- package/dist/type-utils.js +0 -0
- package/dist/vite-plugin-astro/index.js +1 -1
- package/dist/vite-plugin-astro-server/route.js +0 -1
- package/dist/vite-plugin-head/index.js +23 -4
- package/package.json +2 -2
package/client.d.ts
CHANGED
|
@@ -57,17 +57,15 @@ declare module 'astro:assets' {
|
|
|
57
57
|
Image: typeof import('./components/Image.astro').default;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
type
|
|
61
|
-
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
62
|
-
type ImgAttributes = WithRequired<
|
|
60
|
+
type ImgAttributes = import('./dist/type-utils.js').WithRequired<
|
|
63
61
|
Omit<import('./types').HTMLAttributes<'img'>, 'src' | 'width' | 'height'>,
|
|
64
62
|
'alt'
|
|
65
63
|
>;
|
|
66
64
|
|
|
67
|
-
export type LocalImageProps = Simplify<
|
|
65
|
+
export type LocalImageProps = import('./dist/type-utils.js').Simplify<
|
|
68
66
|
import('./dist/assets/types.js').LocalImageProps<ImgAttributes>
|
|
69
67
|
>;
|
|
70
|
-
export type RemoteImageProps = Simplify<
|
|
68
|
+
export type RemoteImageProps = import('./dist/type-utils.js').Simplify<
|
|
71
69
|
import('./dist/assets/types.js').RemoteImageProps<ImgAttributes>
|
|
72
70
|
>;
|
|
73
71
|
export const { getImage, getConfiguredImageService, imageConfig, Image }: AstroAssets;
|
|
@@ -15,6 +15,7 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
15
15
|
type Direction = 'forward' | 'back';
|
|
16
16
|
type State = {
|
|
17
17
|
index: number;
|
|
18
|
+
scrollX: number;
|
|
18
19
|
scrollY: number;
|
|
19
20
|
};
|
|
20
21
|
type Events = 'astro:page-load' | 'astro:after-swap';
|
|
@@ -37,9 +38,9 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
37
38
|
// we reloaded a page with history state
|
|
38
39
|
// (e.g. history navigation from non-transition page or browser reload)
|
|
39
40
|
currentHistoryIndex = history.state.index;
|
|
40
|
-
scrollTo({ left:
|
|
41
|
+
scrollTo({ left: history.state.scrollX, top: history.state.scrollY });
|
|
41
42
|
} else if (transitionEnabledOnThisPage()) {
|
|
42
|
-
history.replaceState({ index: currentHistoryIndex, scrollY }, '');
|
|
43
|
+
history.replaceState({ index: currentHistoryIndex, scrollX, scrollY }, '');
|
|
43
44
|
}
|
|
44
45
|
const throttle = (cb: (...args: any[]) => any, delay: number) => {
|
|
45
46
|
let wait = false;
|
|
@@ -64,9 +65,19 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
64
65
|
};
|
|
65
66
|
|
|
66
67
|
async function getHTML(href: string) {
|
|
67
|
-
|
|
68
|
+
let res;
|
|
69
|
+
try {
|
|
70
|
+
res = await fetch(href);
|
|
71
|
+
} catch (err) {
|
|
72
|
+
return { ok: false };
|
|
73
|
+
}
|
|
68
74
|
const html = await res.text();
|
|
69
|
-
return {
|
|
75
|
+
return {
|
|
76
|
+
ok: res.ok,
|
|
77
|
+
html,
|
|
78
|
+
redirected: res.redirected ? res.url : undefined,
|
|
79
|
+
contentType: res.headers.get('content-type'),
|
|
80
|
+
};
|
|
70
81
|
}
|
|
71
82
|
|
|
72
83
|
function getFallback(): Fallback {
|
|
@@ -113,6 +124,11 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
113
124
|
|
|
114
125
|
const parser = new DOMParser();
|
|
115
126
|
|
|
127
|
+
// A noop element used to prevent styles from being removed
|
|
128
|
+
if (import.meta.env.DEV) {
|
|
129
|
+
var noopEl: string | undefined = document.createElement('div');
|
|
130
|
+
}
|
|
131
|
+
|
|
116
132
|
async function updateDOM(doc: Document, loc: URL, state?: State, fallback?: Fallback) {
|
|
117
133
|
// Check for a head element that should persist, either because it has the data
|
|
118
134
|
// attribute or is a link el.
|
|
@@ -139,6 +155,18 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
139
155
|
}
|
|
140
156
|
}
|
|
141
157
|
}
|
|
158
|
+
// Only run this in dev. This will get stripped from production builds and is not needed.
|
|
159
|
+
if (import.meta.env.DEV) {
|
|
160
|
+
if (el.tagName === 'STYLE' && el.dataset.viteDevId) {
|
|
161
|
+
const devId = el.dataset.viteDevId;
|
|
162
|
+
// If this same style tag exists, remove it from the new page
|
|
163
|
+
return (
|
|
164
|
+
doc.querySelector(`style[data-astro-dev-id="${devId}"]`) ||
|
|
165
|
+
// Otherwise, keep it anyways. This is client:only styles.
|
|
166
|
+
noopEl
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
142
170
|
return null;
|
|
143
171
|
};
|
|
144
172
|
|
|
@@ -191,17 +219,29 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
191
219
|
// Chromium based browsers (Chrome, Edge, Opera, ...)
|
|
192
220
|
scrollTo({ left: 0, top: 0, behavior: 'instant' });
|
|
193
221
|
|
|
222
|
+
let initialScrollX = 0;
|
|
194
223
|
let initialScrollY = 0;
|
|
195
224
|
if (!state && loc.hash) {
|
|
196
225
|
const id = decodeURIComponent(loc.hash.slice(1));
|
|
197
226
|
const elem = document.getElementById(id);
|
|
198
227
|
// prefer scrollIntoView() over scrollTo() because it takes scroll-padding into account
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
228
|
+
if (elem) {
|
|
229
|
+
elem.scrollIntoView();
|
|
230
|
+
initialScrollX = Math.max(
|
|
231
|
+
0,
|
|
232
|
+
elem.offsetLeft + elem.offsetWidth - document.documentElement.clientWidth
|
|
233
|
+
);
|
|
234
|
+
initialScrollY = elem.offsetTop;
|
|
235
|
+
}
|
|
236
|
+
} else if (state) {
|
|
237
|
+
scrollTo(state.scrollX, state.scrollY); // usings default scrollBehavior
|
|
202
238
|
}
|
|
203
239
|
!state &&
|
|
204
|
-
history.pushState(
|
|
240
|
+
history.pushState(
|
|
241
|
+
{ index: ++currentHistoryIndex, scrollX: initialScrollX, scrollY: initialScrollY },
|
|
242
|
+
'',
|
|
243
|
+
loc.href
|
|
244
|
+
);
|
|
205
245
|
triggerEvent('astro:after-swap');
|
|
206
246
|
};
|
|
207
247
|
|
|
@@ -250,18 +290,24 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
250
290
|
async function navigate(dir: Direction, loc: URL, state?: State) {
|
|
251
291
|
let finished: Promise<void>;
|
|
252
292
|
const href = loc.href;
|
|
253
|
-
const { html, ok } = await getHTML(href);
|
|
293
|
+
const { html, ok, contentType, redirected } = await getHTML(href);
|
|
294
|
+
// if there was a redirection, show the final URL in the browser's address bar
|
|
295
|
+
redirected && (loc = new URL(redirected));
|
|
254
296
|
// If there is a problem fetching the new page, just do an MPA navigation to it.
|
|
255
|
-
if (!ok) {
|
|
297
|
+
if (!ok || contentType !== 'text/html') {
|
|
256
298
|
location.href = href;
|
|
257
299
|
return;
|
|
258
300
|
}
|
|
259
|
-
|
|
301
|
+
|
|
302
|
+
const doc = parser.parseFromString(html, contentType);
|
|
260
303
|
if (!doc.querySelector('[name="astro-view-transitions-enabled"]')) {
|
|
261
304
|
location.href = href;
|
|
262
305
|
return;
|
|
263
306
|
}
|
|
264
307
|
|
|
308
|
+
// Now we are sure that we will push state, and it is time to create a state if it is still missing.
|
|
309
|
+
!state && history.replaceState({ index: currentHistoryIndex, scrollX, scrollY }, '');
|
|
310
|
+
|
|
265
311
|
document.documentElement.dataset.astroTransition = dir;
|
|
266
312
|
if (supportsViewTransitions) {
|
|
267
313
|
finished = document.startViewTransition(() => updateDOM(doc, loc, state)).finished;
|
|
@@ -335,28 +381,31 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
335
381
|
// But we want to handle it like any other same page navigation
|
|
336
382
|
// So we scroll to the top of the page but do not start page transitions
|
|
337
383
|
ev.preventDefault();
|
|
338
|
-
|
|
339
|
-
scrollTo({ left: 0, top: 0, behavior: 'instant' });
|
|
384
|
+
// push state on the first navigation but not if we were here already
|
|
340
385
|
if (location.hash) {
|
|
341
|
-
|
|
342
|
-
|
|
386
|
+
history.replaceState(
|
|
387
|
+
{ index: currentHistoryIndex, scrollX, scrollY: -(scrollY + 1) },
|
|
388
|
+
''
|
|
389
|
+
);
|
|
390
|
+
const newState: State = { index: ++currentHistoryIndex, scrollX: 0, scrollY: 0 };
|
|
343
391
|
history.pushState(newState, '', link.href);
|
|
344
392
|
}
|
|
393
|
+
scrollTo({ left: 0, top: 0, behavior: 'instant' });
|
|
345
394
|
return;
|
|
346
395
|
}
|
|
347
396
|
}
|
|
348
397
|
|
|
349
398
|
// these are the cases we will handle: same origin, different page
|
|
350
399
|
ev.preventDefault();
|
|
351
|
-
persistState({ index: currentHistoryIndex, scrollY });
|
|
352
400
|
navigate('forward', new URL(link.href));
|
|
353
401
|
});
|
|
354
402
|
|
|
355
403
|
addEventListener('popstate', (ev) => {
|
|
356
404
|
if (!transitionEnabledOnThisPage() && ev.state) {
|
|
357
|
-
// The current page doesn't
|
|
358
|
-
//
|
|
359
|
-
//
|
|
405
|
+
// The current page doesn't have View Transitions enabled
|
|
406
|
+
// but the page we navigate to does (because it set the state).
|
|
407
|
+
// Do a full page refresh to reload the client-side router from the new page.
|
|
408
|
+
// Scroll restauration will then happen during the reload when the router's code is re-executed
|
|
360
409
|
history.scrollRestoration && (history.scrollRestoration = 'manual');
|
|
361
410
|
location.reload();
|
|
362
411
|
return;
|
|
@@ -383,7 +432,11 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
383
432
|
const nextIndex = state.index;
|
|
384
433
|
const direction: Direction = nextIndex > currentHistoryIndex ? 'forward' : 'back';
|
|
385
434
|
currentHistoryIndex = nextIndex;
|
|
386
|
-
|
|
435
|
+
if (state.scrollY < 0) {
|
|
436
|
+
scrollTo(state.scrollX, -(state.scrollY + 1));
|
|
437
|
+
} else {
|
|
438
|
+
navigate(direction, new URL(location.href), state);
|
|
439
|
+
}
|
|
387
440
|
});
|
|
388
441
|
|
|
389
442
|
['mouseenter', 'touchstart', 'focus'].forEach((evName) => {
|
|
@@ -408,7 +461,7 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
408
461
|
// There's not a good way to record scroll position before a back button.
|
|
409
462
|
// So the way we do it is by listening to scrollend if supported, and if not continuously record the scroll position.
|
|
410
463
|
const updateState = () => {
|
|
411
|
-
persistState({ ...history.state, scrollY });
|
|
464
|
+
persistState({ ...history.state, scrollX, scrollY });
|
|
412
465
|
};
|
|
413
466
|
|
|
414
467
|
if ('onscrollend' in window) addEventListener('scrollend', updateState);
|
package/dist/@types/astro.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type { AstroCookies } from '../core/cookies';
|
|
|
17
17
|
import type { ResponseWithEncoding } from '../core/endpoint/index.js';
|
|
18
18
|
import type { AstroIntegrationLogger, Logger, LoggerLevel } from '../core/logger/core';
|
|
19
19
|
import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server';
|
|
20
|
+
import type { OmitIndexSignature, Simplify } from '../type-utils';
|
|
20
21
|
import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
|
|
21
22
|
export { type AstroIntegrationLogger };
|
|
22
23
|
export type { MarkdownHeading, MarkdownMetadata, MarkdownRenderingResult, RehypePlugins, RemarkPlugins, ShikiConfig, } from '@astrojs/markdown-remark';
|
|
@@ -542,12 +543,12 @@ export interface AstroUserConfig {
|
|
|
542
543
|
* @description
|
|
543
544
|
*
|
|
544
545
|
* Specify the strategy used for scoping styles within Astro components. Choose from:
|
|
545
|
-
* - `'where'` - Use `:where` selectors, causing no
|
|
546
|
-
* - `'class'` - Use class-based selectors, causing a +1
|
|
547
|
-
* - `'attribute'` - Use `data-` attributes, causing
|
|
546
|
+
* - `'where'` - Use `:where` selectors, causing no specificity increase.
|
|
547
|
+
* - `'class'` - Use class-based selectors, causing a +1 specificity increase.
|
|
548
|
+
* - `'attribute'` - Use `data-` attributes, causing a +1 specificity increase.
|
|
548
549
|
*
|
|
549
550
|
* Using `'class'` is helpful when you want to ensure that element selectors within an Astro component override global style defaults (e.g. from a global stylesheet).
|
|
550
|
-
* Using `'where'` gives you more control over
|
|
551
|
+
* Using `'where'` gives you more control over specificity, but requires that you use higher-specificity selectors, layers, and other tools to control which selectors are applied.
|
|
551
552
|
* Using `'attribute'` is useful when you are manipulating the `class` attribute of elements and need to avoid conflicts between your own styling logic and Astro's application of styles.
|
|
552
553
|
*/
|
|
553
554
|
scopedStyleStrategy?: 'where' | 'class' | 'attribute';
|
|
@@ -910,7 +911,7 @@ export interface AstroUserConfig {
|
|
|
910
911
|
* }
|
|
911
912
|
* ```
|
|
912
913
|
*/
|
|
913
|
-
service
|
|
914
|
+
service?: ImageServiceConfig;
|
|
914
915
|
/**
|
|
915
916
|
* @docs
|
|
916
917
|
* @name image.domains
|
|
@@ -1556,12 +1557,6 @@ export interface Page<T = any> {
|
|
|
1556
1557
|
next: string | undefined;
|
|
1557
1558
|
};
|
|
1558
1559
|
}
|
|
1559
|
-
type OmitIndexSignature<ObjectType> = {
|
|
1560
|
-
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType];
|
|
1561
|
-
};
|
|
1562
|
-
type Simplify<T> = {
|
|
1563
|
-
[KeyType in keyof T]: T[KeyType];
|
|
1564
|
-
} & {};
|
|
1565
1560
|
export type PaginateFunction = <PaginateData, AdditionalPaginateProps extends Props, AdditionalPaginateParams extends Params>(data: PaginateData[], args?: PaginateOptions<AdditionalPaginateProps, AdditionalPaginateParams>) => {
|
|
1566
1561
|
params: Simplify<{
|
|
1567
1562
|
page: string | undefined;
|
package/dist/assets/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WithRequired } from '../type-utils.js';
|
|
1
2
|
import type { VALID_INPUT_FORMATS, VALID_OUTPUT_FORMATS } from './consts.js';
|
|
2
3
|
import type { ImageService } from './services/service.js';
|
|
3
4
|
export type ImageQualityPreset = 'low' | 'mid' | 'high' | 'max' | (string & {});
|
|
@@ -46,9 +47,6 @@ export interface GetImageResult {
|
|
|
46
47
|
src: string;
|
|
47
48
|
attributes: Record<string, any>;
|
|
48
49
|
}
|
|
49
|
-
type WithRequired<T, K extends keyof T> = T & {
|
|
50
|
-
[P in K]-?: T[P];
|
|
51
|
-
};
|
|
52
50
|
type ImageSharedProps<T> = T & {
|
|
53
51
|
/**
|
|
54
52
|
* Width of the image, the value of this property will be used to assign the `width` property on the final `img` element.
|
package/dist/content/utils.js
CHANGED
|
@@ -296,7 +296,7 @@ function getContentPaths({ srcDir, root }, fs = fsMod) {
|
|
|
296
296
|
};
|
|
297
297
|
}
|
|
298
298
|
function search(fs, srcDir) {
|
|
299
|
-
const paths = ["config.mjs", "config.js", "config.ts"].map(
|
|
299
|
+
const paths = ["config.mjs", "config.js", "config.mts", "config.ts"].map(
|
|
300
300
|
(p) => new URL(`./content/${p}`, srcDir)
|
|
301
301
|
);
|
|
302
302
|
for (const file of paths) {
|
|
@@ -429,6 +429,9 @@ async function generatePath(pathname, gopts, pipeline) {
|
|
|
429
429
|
<body>
|
|
430
430
|
<a href="${location}">Redirecting from <code>${fromPath}</code> to <code>${location}</code></a>
|
|
431
431
|
</body>`;
|
|
432
|
+
if (pipeline.getConfig().compressHTML === true) {
|
|
433
|
+
body = body.replaceAll("\n", "");
|
|
434
|
+
}
|
|
432
435
|
if (pageData.route.type !== "redirect") {
|
|
433
436
|
pageData.route.redirect = location;
|
|
434
437
|
}
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -20,7 +20,7 @@ async function dev(inlineConfig) {
|
|
|
20
20
|
base: restart.container.settings.config.base
|
|
21
21
|
})
|
|
22
22
|
);
|
|
23
|
-
const currentVersion = "3.0.
|
|
23
|
+
const currentVersion = "3.0.13";
|
|
24
24
|
if (currentVersion.includes("-")) {
|
|
25
25
|
logger.warn(null, msg.prerelease({ currentVersion }));
|
|
26
26
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -50,7 +50,7 @@ function serverStart({
|
|
|
50
50
|
base,
|
|
51
51
|
isRestart = false
|
|
52
52
|
}) {
|
|
53
|
-
const version = "3.0.
|
|
53
|
+
const version = "3.0.13";
|
|
54
54
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
55
55
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
56
56
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -235,7 +235,7 @@ function printHelp({
|
|
|
235
235
|
message.push(
|
|
236
236
|
linebreak(),
|
|
237
237
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
238
|
-
`v${"3.0.
|
|
238
|
+
`v${"3.0.13"}`
|
|
239
239
|
)} ${headline}`
|
|
240
240
|
);
|
|
241
241
|
}
|
|
@@ -11,9 +11,7 @@ function createAssetLink(href, base, assetsPrefix) {
|
|
|
11
11
|
function createStylesheetElement(stylesheet, base, assetsPrefix) {
|
|
12
12
|
if (stylesheet.type === "inline") {
|
|
13
13
|
return {
|
|
14
|
-
props: {
|
|
15
|
-
type: "text/css"
|
|
16
|
-
},
|
|
14
|
+
props: {},
|
|
17
15
|
children: stylesheet.content
|
|
18
16
|
};
|
|
19
17
|
} else {
|
|
@@ -32,5 +32,5 @@ function isStyle(node) {
|
|
|
32
32
|
return node.nodeType === node.ELEMENT_NODE && node.tagName.toLowerCase() === "style";
|
|
33
33
|
}
|
|
34
34
|
function isViteInjectedStyle(node) {
|
|
35
|
-
return isStyle(node) &&
|
|
35
|
+
return isStyle(node) && !!node.getAttribute("data-vite-dev-id");
|
|
36
36
|
}
|
|
@@ -14,7 +14,7 @@ function renderUniqueStylesheet(result, sheet) {
|
|
|
14
14
|
if (sheet.type === "inline") {
|
|
15
15
|
if (Array.from(result.styles).some((s) => s.children.includes(sheet.content)))
|
|
16
16
|
return "";
|
|
17
|
-
return renderElement("style", { props: {
|
|
17
|
+
return renderElement("style", { props: {}, children: sheet.content });
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
export {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type Simplify<T> = {
|
|
2
|
+
[KeyType in keyof T]: T[KeyType];
|
|
3
|
+
} & {};
|
|
4
|
+
export type WithRequired<T, K extends keyof T> = T & {
|
|
5
|
+
[P in K]-?: T[P];
|
|
6
|
+
};
|
|
7
|
+
export type OmitIndexSignature<ObjectType> = {
|
|
8
|
+
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType];
|
|
9
|
+
};
|
|
10
|
+
export type ValueOf<T> = T[keyof T];
|
|
File without changes
|
|
@@ -125,7 +125,7 @@ File: ${id}`
|
|
|
125
125
|
hydratedComponents: transformResult.hydratedComponents,
|
|
126
126
|
scripts: transformResult.scripts,
|
|
127
127
|
containsHead: transformResult.containsHead,
|
|
128
|
-
propagation: "none",
|
|
128
|
+
propagation: transformResult.propagation ? "self" : "none",
|
|
129
129
|
pageOptions: {}
|
|
130
130
|
};
|
|
131
131
|
return {
|
|
@@ -241,7 +241,6 @@ async function getScriptsAndStyles({ pipeline, filePath }) {
|
|
|
241
241
|
});
|
|
242
242
|
styles.add({
|
|
243
243
|
props: {
|
|
244
|
-
type: "text/css",
|
|
245
244
|
// Track the ID so we can match it to Vite's injected style later
|
|
246
245
|
"data-astro-dev-id": viteID(new URL(`.${url}`, settings.config.root))
|
|
247
246
|
},
|
|
@@ -34,6 +34,14 @@ function configHeadVitePlugin() {
|
|
|
34
34
|
if (info && getAstroMetadata(info)?.containsHead) {
|
|
35
35
|
propagateMetadata.call(this, id, "containsHead", true);
|
|
36
36
|
}
|
|
37
|
+
if (info && getAstroMetadata(info)?.propagation === "self") {
|
|
38
|
+
const mod = server.moduleGraph.getModuleById(id);
|
|
39
|
+
for (const parent of mod?.importers ?? []) {
|
|
40
|
+
if (parent.id) {
|
|
41
|
+
propagateMetadata.call(this, parent.id, "propagation", "in-tree");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
37
45
|
if (injectExp.test(source)) {
|
|
38
46
|
propagateMetadata.call(this, id, "propagation", "in-tree");
|
|
39
47
|
}
|
|
@@ -65,10 +73,21 @@ function astroHeadBuildPlugin(internals) {
|
|
|
65
73
|
continue;
|
|
66
74
|
for (const [id, mod] of Object.entries(output.modules)) {
|
|
67
75
|
const modinfo = this.getModuleInfo(id);
|
|
68
|
-
if (modinfo
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
76
|
+
if (modinfo) {
|
|
77
|
+
const meta = getAstroMetadata(modinfo);
|
|
78
|
+
if (meta?.containsHead) {
|
|
79
|
+
for (const [pageInfo] of getTopLevelPages(id, this)) {
|
|
80
|
+
let metadata = getOrCreateMetadata(pageInfo.id);
|
|
81
|
+
metadata.containsHead = true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (meta?.propagation === "self") {
|
|
85
|
+
for (const [info] of walkParentInfos(id, this)) {
|
|
86
|
+
let metadata = getOrCreateMetadata(info.id);
|
|
87
|
+
if (metadata.propagation !== "self") {
|
|
88
|
+
metadata.propagation = "in-tree";
|
|
89
|
+
}
|
|
90
|
+
}
|
|
72
91
|
}
|
|
73
92
|
}
|
|
74
93
|
if (mod.code && injectExp.test(mod.code)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.13",
|
|
4
4
|
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "withastro",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"vendor"
|
|
107
107
|
],
|
|
108
108
|
"dependencies": {
|
|
109
|
-
"@astrojs/compiler": "^2.0
|
|
109
|
+
"@astrojs/compiler": "^2.1.0",
|
|
110
110
|
"@babel/core": "^7.22.10",
|
|
111
111
|
"@babel/generator": "^7.22.10",
|
|
112
112
|
"@babel/parser": "^7.22.10",
|