astro 5.5.1 → 5.5.3
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/cli/add/index.js +3 -9
- package/dist/container/index.d.ts +11 -0
- package/dist/container/index.js +34 -0
- package/dist/container/pipeline.d.ts +1 -1
- package/dist/container/pipeline.js +6 -2
- package/dist/content/content-layer.js +4 -4
- package/dist/content/mutable-data-store.d.ts +5 -0
- package/dist/content/mutable-data-store.js +56 -7
- package/dist/content/runtime.js +0 -10
- package/dist/core/app/node.js +17 -5
- package/dist/core/build/plugins/plugin-css.js +27 -1
- package/dist/core/build/static-build.js +1 -9
- package/dist/core/config/merge.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/session.js +6 -0
- package/dist/vite-plugin-astro/index.d.ts +2 -2
- package/dist/vite-plugin-astro/index.js +9 -3
- package/dist/vite-plugin-astro/types.d.ts +20 -0
- package/package.json +3 -3
package/dist/cli/add/index.js
CHANGED
|
@@ -117,7 +117,7 @@ async function add(names, { flags }) {
|
|
|
117
117
|
const cwd = inlineConfig.root;
|
|
118
118
|
const logger = createLoggerFromFlags(flags);
|
|
119
119
|
const integrationNames = names.map((name) => ALIASES.has(name) ? ALIASES.get(name) : name);
|
|
120
|
-
const integrations = await validateIntegrations(integrationNames);
|
|
120
|
+
const integrations = await validateIntegrations(integrationNames, flags);
|
|
121
121
|
let installResult = await tryToInstallIntegrations({ integrations, cwd, flags, logger });
|
|
122
122
|
const rootPath = resolveRoot(cwd);
|
|
123
123
|
const root = pathToFileURL(rootPath);
|
|
@@ -585,7 +585,7 @@ ${message}`
|
|
|
585
585
|
return 2 /* cancelled */;
|
|
586
586
|
}
|
|
587
587
|
}
|
|
588
|
-
async function validateIntegrations(integrations) {
|
|
588
|
+
async function validateIntegrations(integrations, flags) {
|
|
589
589
|
const spinner = yoctoSpinner({ text: "Resolving packages..." }).start();
|
|
590
590
|
try {
|
|
591
591
|
const integrationEntries = await Promise.all(
|
|
@@ -606,13 +606,7 @@ async function validateIntegrations(integrations) {
|
|
|
606
606
|
spinner.warning(yellow(firstPartyPkgCheck.message));
|
|
607
607
|
}
|
|
608
608
|
spinner.warning(yellow(`${bold(integration)} is not an official Astro package.`));
|
|
609
|
-
|
|
610
|
-
type: "confirm",
|
|
611
|
-
name: "askToContinue",
|
|
612
|
-
message: "Continue?",
|
|
613
|
-
initial: true
|
|
614
|
-
});
|
|
615
|
-
if (!response.askToContinue) {
|
|
609
|
+
if (!await askToContinue({ flags })) {
|
|
616
610
|
throw new Error(
|
|
617
611
|
`No problem! Find our official integrations at ${cyan(
|
|
618
612
|
"https://astro.build/integrations"
|
|
@@ -243,4 +243,15 @@ export declare class experimental_AstroContainer {
|
|
|
243
243
|
* @param {ContainerRenderOptions=} options Possible options to pass when rendering the component.
|
|
244
244
|
*/
|
|
245
245
|
renderToResponse(component: AstroComponentFactory, options?: ContainerRenderOptions): Promise<Response>;
|
|
246
|
+
/**
|
|
247
|
+
* It stores an Astro **page** route. The first argument, `route`, gets associated to the `component`.
|
|
248
|
+
*
|
|
249
|
+
* This function can be useful when you want to render a route via `AstroContainer.renderToString`, where that
|
|
250
|
+
* route eventually renders another route via `Astro.rewrite`.
|
|
251
|
+
*
|
|
252
|
+
* @param {string} route - The URL that will render the component.
|
|
253
|
+
* @param {AstroComponentFactory} component - The component factory to be used for rendering the route.
|
|
254
|
+
* @param {Record<string, string | undefined>} params - An object containing key-value pairs of route parameters.
|
|
255
|
+
*/
|
|
256
|
+
insertPageRoute(route: string, component: AstroComponentFactory, params?: Record<string, string | undefined>): void;
|
|
246
257
|
}
|
package/dist/container/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import { RenderContext } from "../core/render-context.js";
|
|
|
12
12
|
import { getParts } from "../core/routing/manifest/parts.js";
|
|
13
13
|
import { getPattern } from "../core/routing/manifest/pattern.js";
|
|
14
14
|
import { validateSegment } from "../core/routing/manifest/segment.js";
|
|
15
|
+
import { SlotString } from "../runtime/server/render/slot.js";
|
|
15
16
|
import { ContainerPipeline } from "./pipeline.js";
|
|
16
17
|
function createManifest(manifest, renderers, middleware) {
|
|
17
18
|
function middlewareInstance() {
|
|
@@ -234,6 +235,9 @@ class experimental_AstroContainer {
|
|
|
234
235
|
* @param {ContainerRenderOptions=} options Possible options to pass when rendering the component.
|
|
235
236
|
*/
|
|
236
237
|
async renderToString(component, options = {}) {
|
|
238
|
+
if (options.slots) {
|
|
239
|
+
options.slots = markAllSlotsAsSlotString(options.slots);
|
|
240
|
+
}
|
|
237
241
|
const response = await this.renderToResponse(component, options);
|
|
238
242
|
return await response.text();
|
|
239
243
|
}
|
|
@@ -285,6 +289,29 @@ class experimental_AstroContainer {
|
|
|
285
289
|
}
|
|
286
290
|
return renderContext.render(componentInstance, slots);
|
|
287
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* It stores an Astro **page** route. The first argument, `route`, gets associated to the `component`.
|
|
294
|
+
*
|
|
295
|
+
* This function can be useful when you want to render a route via `AstroContainer.renderToString`, where that
|
|
296
|
+
* route eventually renders another route via `Astro.rewrite`.
|
|
297
|
+
*
|
|
298
|
+
* @param {string} route - The URL that will render the component.
|
|
299
|
+
* @param {AstroComponentFactory} component - The component factory to be used for rendering the route.
|
|
300
|
+
* @param {Record<string, string | undefined>} params - An object containing key-value pairs of route parameters.
|
|
301
|
+
*/
|
|
302
|
+
insertPageRoute(route, component, params) {
|
|
303
|
+
const url = new URL(route, "https://example.com/");
|
|
304
|
+
const routeData = this.#createRoute(url, params ?? {}, "page");
|
|
305
|
+
this.#pipeline.manifest.routes.push({
|
|
306
|
+
routeData,
|
|
307
|
+
file: "",
|
|
308
|
+
links: [],
|
|
309
|
+
styles: [],
|
|
310
|
+
scripts: []
|
|
311
|
+
});
|
|
312
|
+
const componentInstance = this.#wrapComponent(component, params);
|
|
313
|
+
this.#pipeline.insertRoute(routeData, componentInstance);
|
|
314
|
+
}
|
|
288
315
|
#createRoute(url, params, type) {
|
|
289
316
|
const segments = removeLeadingForwardSlash(url.pathname).split(posix.sep).filter(Boolean).map((s) => {
|
|
290
317
|
validateSegment(s);
|
|
@@ -331,6 +358,13 @@ class experimental_AstroContainer {
|
|
|
331
358
|
function isNamedRenderer(renderer) {
|
|
332
359
|
return !!renderer?.name;
|
|
333
360
|
}
|
|
361
|
+
function markAllSlotsAsSlotString(slots) {
|
|
362
|
+
const markedSlots = {};
|
|
363
|
+
for (const slotName in slots) {
|
|
364
|
+
markedSlots[slotName] = new SlotString(slots[slotName], null);
|
|
365
|
+
}
|
|
366
|
+
return markedSlots;
|
|
367
|
+
}
|
|
334
368
|
export {
|
|
335
369
|
experimental_AstroContainer
|
|
336
370
|
};
|
|
@@ -9,5 +9,5 @@ export declare class ContainerPipeline extends Pipeline {
|
|
|
9
9
|
headElements(routeData: RouteData): Promise<HeadElements> | HeadElements;
|
|
10
10
|
tryRewrite(payload: RewritePayload, request: Request): Promise<TryRewriteResult>;
|
|
11
11
|
insertRoute(route: RouteData, componentInstance: ComponentInstance): void;
|
|
12
|
-
getComponentByRoute(
|
|
12
|
+
getComponentByRoute(routeData: RouteData): Promise<ComponentInstance>;
|
|
13
13
|
}
|
|
@@ -71,8 +71,12 @@ class ContainerPipeline extends Pipeline {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
// At the moment it's not used by the container via any public API
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
async getComponentByRoute(routeData) {
|
|
75
|
+
const page = this.#componentsInterner.get(routeData);
|
|
76
|
+
if (page) {
|
|
77
|
+
return page.page();
|
|
78
|
+
}
|
|
79
|
+
throw new Error("Couldn't find component for route " + routeData.pathname);
|
|
76
80
|
}
|
|
77
81
|
}
|
|
78
82
|
export {
|
|
@@ -153,7 +153,7 @@ ${contentConfig.error.message}`);
|
|
|
153
153
|
logger.info("Content config changed");
|
|
154
154
|
shouldClear = true;
|
|
155
155
|
}
|
|
156
|
-
if (previousAstroVersion && previousAstroVersion !== "5.5.
|
|
156
|
+
if (previousAstroVersion && previousAstroVersion !== "5.5.3") {
|
|
157
157
|
logger.info("Astro version changed");
|
|
158
158
|
shouldClear = true;
|
|
159
159
|
}
|
|
@@ -161,8 +161,8 @@ ${contentConfig.error.message}`);
|
|
|
161
161
|
logger.info("Clearing content store");
|
|
162
162
|
this.#store.clearAll();
|
|
163
163
|
}
|
|
164
|
-
if ("5.5.
|
|
165
|
-
await this.#store.metaStore().set("astro-version", "5.5.
|
|
164
|
+
if ("5.5.3") {
|
|
165
|
+
await this.#store.metaStore().set("astro-version", "5.5.3");
|
|
166
166
|
}
|
|
167
167
|
if (currentConfigDigest) {
|
|
168
168
|
await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
|
@@ -223,11 +223,11 @@ ${contentConfig.error.message}`);
|
|
|
223
223
|
);
|
|
224
224
|
await fs.mkdir(this.#settings.config.cacheDir, { recursive: true });
|
|
225
225
|
await fs.mkdir(this.#settings.dotAstroDir, { recursive: true });
|
|
226
|
-
await this.#store.writeToDisk();
|
|
227
226
|
const assetImportsFile = new URL(ASSET_IMPORTS_FILE, this.#settings.dotAstroDir);
|
|
228
227
|
await this.#store.writeAssetImports(assetImportsFile);
|
|
229
228
|
const modulesImportsFile = new URL(MODULES_IMPORTS_FILE, this.#settings.dotAstroDir);
|
|
230
229
|
await this.#store.writeModuleImports(modulesImportsFile);
|
|
230
|
+
await this.#store.waitUntilSaveComplete();
|
|
231
231
|
logger.info("Synced content");
|
|
232
232
|
if (this.#settings.config.experimental.contentIntellisense) {
|
|
233
233
|
await this.regenerateCollectionFileManifest();
|
|
@@ -20,6 +20,11 @@ export declare class MutableDataStore extends ImmutableDataStore {
|
|
|
20
20
|
* Returns a MetaStore for a given collection, or if no collection is provided, the default meta collection.
|
|
21
21
|
*/
|
|
22
22
|
metaStore(collectionName?: string): MetaStore;
|
|
23
|
+
/**
|
|
24
|
+
* Returns a promise that resolves when all pending saves are complete.
|
|
25
|
+
* This includes any in-progress debounced saves for the data store, asset imports, and module imports.
|
|
26
|
+
*/
|
|
27
|
+
waitUntilSaveComplete(): Promise<void>;
|
|
23
28
|
toString(): string;
|
|
24
29
|
writeToDisk(): Promise<void>;
|
|
25
30
|
/**
|
|
@@ -15,6 +15,8 @@ class MutableDataStore extends ImmutableDataStore {
|
|
|
15
15
|
#saveTimeout;
|
|
16
16
|
#assetsSaveTimeout;
|
|
17
17
|
#modulesSaveTimeout;
|
|
18
|
+
#savePromise;
|
|
19
|
+
#savePromiseResolve;
|
|
18
20
|
#dirty = false;
|
|
19
21
|
#assetsDirty = false;
|
|
20
22
|
#modulesDirty = false;
|
|
@@ -118,15 +120,28 @@ ${lines.join(",\n")}]);
|
|
|
118
120
|
}
|
|
119
121
|
this.#modulesDirty = false;
|
|
120
122
|
}
|
|
123
|
+
#maybeResolveSavePromise() {
|
|
124
|
+
if (!this.#saveTimeout && !this.#assetsSaveTimeout && !this.#modulesSaveTimeout && this.#savePromiseResolve) {
|
|
125
|
+
this.#savePromiseResolve();
|
|
126
|
+
this.#savePromiseResolve = void 0;
|
|
127
|
+
this.#savePromise = void 0;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
121
130
|
#writeAssetsImportsDebounced() {
|
|
122
131
|
this.#assetsDirty = true;
|
|
123
132
|
if (this.#assetsFile) {
|
|
124
133
|
if (this.#assetsSaveTimeout) {
|
|
125
134
|
clearTimeout(this.#assetsSaveTimeout);
|
|
126
135
|
}
|
|
127
|
-
this.#
|
|
136
|
+
if (!this.#savePromise) {
|
|
137
|
+
this.#savePromise = new Promise((resolve) => {
|
|
138
|
+
this.#savePromiseResolve = resolve;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
this.#assetsSaveTimeout = setTimeout(async () => {
|
|
128
142
|
this.#assetsSaveTimeout = void 0;
|
|
129
|
-
this.writeAssetImports(this.#assetsFile);
|
|
143
|
+
await this.writeAssetImports(this.#assetsFile);
|
|
144
|
+
this.#maybeResolveSavePromise();
|
|
130
145
|
}, SAVE_DEBOUNCE_MS);
|
|
131
146
|
}
|
|
132
147
|
}
|
|
@@ -136,22 +151,45 @@ ${lines.join(",\n")}]);
|
|
|
136
151
|
if (this.#modulesSaveTimeout) {
|
|
137
152
|
clearTimeout(this.#modulesSaveTimeout);
|
|
138
153
|
}
|
|
139
|
-
this.#
|
|
154
|
+
if (!this.#savePromise) {
|
|
155
|
+
this.#savePromise = new Promise((resolve) => {
|
|
156
|
+
this.#savePromiseResolve = resolve;
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
this.#modulesSaveTimeout = setTimeout(async () => {
|
|
140
160
|
this.#modulesSaveTimeout = void 0;
|
|
141
|
-
this.writeModuleImports(this.#modulesFile);
|
|
161
|
+
await this.writeModuleImports(this.#modulesFile);
|
|
162
|
+
this.#maybeResolveSavePromise();
|
|
142
163
|
}, SAVE_DEBOUNCE_MS);
|
|
143
164
|
}
|
|
144
165
|
}
|
|
166
|
+
// Skips the debounce and writes to disk immediately
|
|
167
|
+
async #saveToDiskNow() {
|
|
168
|
+
if (this.#saveTimeout) {
|
|
169
|
+
clearTimeout(this.#saveTimeout);
|
|
170
|
+
}
|
|
171
|
+
this.#saveTimeout = void 0;
|
|
172
|
+
if (this.#file) {
|
|
173
|
+
await this.writeToDisk();
|
|
174
|
+
}
|
|
175
|
+
this.#maybeResolveSavePromise();
|
|
176
|
+
}
|
|
145
177
|
#saveToDiskDebounced() {
|
|
146
178
|
this.#dirty = true;
|
|
147
179
|
if (this.#saveTimeout) {
|
|
148
180
|
clearTimeout(this.#saveTimeout);
|
|
149
181
|
}
|
|
150
|
-
this.#
|
|
182
|
+
if (!this.#savePromise) {
|
|
183
|
+
this.#savePromise = new Promise((resolve) => {
|
|
184
|
+
this.#savePromiseResolve = resolve;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
this.#saveTimeout = setTimeout(async () => {
|
|
151
188
|
this.#saveTimeout = void 0;
|
|
152
189
|
if (this.#file) {
|
|
153
|
-
this.writeToDisk();
|
|
190
|
+
await this.writeToDisk();
|
|
154
191
|
}
|
|
192
|
+
this.#maybeResolveSavePromise();
|
|
155
193
|
}, SAVE_DEBOUNCE_MS);
|
|
156
194
|
}
|
|
157
195
|
#writing = /* @__PURE__ */ new Set();
|
|
@@ -271,6 +309,17 @@ ${lines.join(",\n")}]);
|
|
|
271
309
|
has: (key) => this.has(collectionKey, key)
|
|
272
310
|
};
|
|
273
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* Returns a promise that resolves when all pending saves are complete.
|
|
314
|
+
* This includes any in-progress debounced saves for the data store, asset imports, and module imports.
|
|
315
|
+
*/
|
|
316
|
+
async waitUntilSaveComplete() {
|
|
317
|
+
if (!this.#savePromise) {
|
|
318
|
+
return Promise.resolve();
|
|
319
|
+
}
|
|
320
|
+
await this.#saveToDiskNow();
|
|
321
|
+
return this.#savePromise;
|
|
322
|
+
}
|
|
274
323
|
toString() {
|
|
275
324
|
return devalue.stringify(this._collections);
|
|
276
325
|
}
|
|
@@ -282,8 +331,8 @@ ${lines.join(",\n")}]);
|
|
|
282
331
|
throw new AstroError(AstroErrorData.UnknownFilesystemError);
|
|
283
332
|
}
|
|
284
333
|
try {
|
|
285
|
-
await this.#writeFileAtomic(this.#file, this.toString());
|
|
286
334
|
this.#dirty = false;
|
|
335
|
+
await this.#writeFileAtomic(this.#file, this.toString());
|
|
287
336
|
} catch (err) {
|
|
288
337
|
throw new AstroError(AstroErrorData.UnknownFilesystemError, { cause: err });
|
|
289
338
|
}
|
package/dist/content/runtime.js
CHANGED
|
@@ -450,8 +450,6 @@ async function render({
|
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
452
|
function createReference({ lookupMap }) {
|
|
453
|
-
let store = null;
|
|
454
|
-
globalDataStore.get().then((s) => store = s);
|
|
455
453
|
return function reference(collection) {
|
|
456
454
|
return z.union([
|
|
457
455
|
z.string(),
|
|
@@ -465,14 +463,6 @@ function createReference({ lookupMap }) {
|
|
|
465
463
|
})
|
|
466
464
|
]).transform(
|
|
467
465
|
(lookup, ctx) => {
|
|
468
|
-
if (!store) {
|
|
469
|
-
ctx.addIssue({
|
|
470
|
-
code: ZodIssueCode.custom,
|
|
471
|
-
message: `**${ctx.path.join(".")}:** Reference to ${collection} could not be resolved: store not available.
|
|
472
|
-
This is an Astro bug, so please file an issue at https://github.com/withastro/astro/issues.`
|
|
473
|
-
});
|
|
474
|
-
return;
|
|
475
|
-
}
|
|
476
466
|
const flattenedErrorPath = ctx.path.join(".");
|
|
477
467
|
if (typeof lookup === "object") {
|
|
478
468
|
if (lookup.collection !== collection) {
|
package/dist/core/app/node.js
CHANGED
|
@@ -39,13 +39,20 @@ class NodeApp extends App {
|
|
|
39
39
|
return multiValueHeader?.toString()?.split(",").map((e) => e.trim())?.[0];
|
|
40
40
|
};
|
|
41
41
|
const forwardedProtocol = getFirstForwardedValue(req.headers["x-forwarded-proto"]);
|
|
42
|
-
const
|
|
42
|
+
const providedProtocol = isEncrypted ? "https" : "http";
|
|
43
|
+
const protocol = forwardedProtocol ?? providedProtocol;
|
|
43
44
|
const forwardedHostname = getFirstForwardedValue(req.headers["x-forwarded-host"]);
|
|
44
|
-
const
|
|
45
|
+
const providedHostname = req.headers.host ?? req.headers[":authority"];
|
|
46
|
+
const hostname = forwardedHostname ?? providedHostname;
|
|
45
47
|
const port = getFirstForwardedValue(req.headers["x-forwarded-port"]);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
let url;
|
|
49
|
+
try {
|
|
50
|
+
const hostnamePort = getHostnamePort(hostname, port);
|
|
51
|
+
url = new URL(`${protocol}://${hostnamePort}${req.url}`);
|
|
52
|
+
} catch {
|
|
53
|
+
const hostnamePort = getHostnamePort(providedHostname, port);
|
|
54
|
+
url = new URL(`${providedProtocol}://${hostnamePort}`);
|
|
55
|
+
}
|
|
49
56
|
const options = {
|
|
50
57
|
method: req.method || "GET",
|
|
51
58
|
headers: makeRequestHeaders(req)
|
|
@@ -107,6 +114,11 @@ class NodeApp extends App {
|
|
|
107
114
|
}
|
|
108
115
|
}
|
|
109
116
|
}
|
|
117
|
+
function getHostnamePort(hostname, port) {
|
|
118
|
+
const portInHostname = typeof hostname === "string" && /:\d+$/.test(hostname);
|
|
119
|
+
const hostnamePort = portInHostname ? hostname : `${hostname}${port ? `:${port}` : ""}`;
|
|
120
|
+
return hostnamePort;
|
|
121
|
+
}
|
|
110
122
|
function makeRequestHeaders(req) {
|
|
111
123
|
const headers = new Headers();
|
|
112
124
|
for (const [name, value] of Object.entries(req.headers)) {
|
|
@@ -101,6 +101,22 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
};
|
|
104
|
+
const cssScopeToPlugin = {
|
|
105
|
+
name: "astro:rollup-plugin-css-scope-to",
|
|
106
|
+
renderChunk(_, chunk, __, meta) {
|
|
107
|
+
for (const id in chunk.modules) {
|
|
108
|
+
const modMeta = this.getModuleInfo(id)?.meta;
|
|
109
|
+
const cssScopeTo = modMeta?.astroCss?.cssScopeTo;
|
|
110
|
+
if (cssScopeTo && !isCssScopeToRendered(cssScopeTo, Object.values(meta.chunks))) {
|
|
111
|
+
delete chunk.modules[id];
|
|
112
|
+
const moduleIdsIndex = chunk.moduleIds.indexOf(id);
|
|
113
|
+
if (moduleIdsIndex > -1) {
|
|
114
|
+
chunk.moduleIds.splice(moduleIdsIndex, 1);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
104
120
|
const singleCssPlugin = {
|
|
105
121
|
name: "astro:rollup-plugin-single-css",
|
|
106
122
|
enforce: "post",
|
|
@@ -162,7 +178,7 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
162
178
|
});
|
|
163
179
|
}
|
|
164
180
|
};
|
|
165
|
-
return [cssBuildPlugin, singleCssPlugin, inlineStylesheetsPlugin];
|
|
181
|
+
return [cssBuildPlugin, cssScopeToPlugin, singleCssPlugin, inlineStylesheetsPlugin];
|
|
166
182
|
}
|
|
167
183
|
function* getParentClientOnlys(id, ctx, internals) {
|
|
168
184
|
for (const info of getParentModuleInfos(id, ctx)) {
|
|
@@ -187,6 +203,16 @@ function appendCSSToPage(pageData, meta, pagesToCss, depth, order) {
|
|
|
187
203
|
}
|
|
188
204
|
}
|
|
189
205
|
}
|
|
206
|
+
function isCssScopeToRendered(cssScopeTo, chunks) {
|
|
207
|
+
for (const moduleId in cssScopeTo) {
|
|
208
|
+
const exports = cssScopeTo[moduleId];
|
|
209
|
+
const renderedModule = chunks.find((c) => c.moduleIds.includes(moduleId))?.modules[moduleId];
|
|
210
|
+
if (renderedModule?.renderedExports.some((e) => exports.includes(e))) {
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
190
216
|
export {
|
|
191
217
|
pluginCSS
|
|
192
218
|
};
|
|
@@ -137,15 +137,7 @@ async function ssrBuild(opts, internals, input, container) {
|
|
|
137
137
|
const encoded = encodeName(name);
|
|
138
138
|
return [prefix, encoded, suffix].join("");
|
|
139
139
|
},
|
|
140
|
-
assetFileNames
|
|
141
|
-
const { names } = chunkInfo;
|
|
142
|
-
const name = names[0] ?? "";
|
|
143
|
-
if (name.includes(ASTRO_PAGE_EXTENSION_POST_PATTERN)) {
|
|
144
|
-
const [sanitizedName] = name.split(ASTRO_PAGE_EXTENSION_POST_PATTERN);
|
|
145
|
-
return `${settings.config.build.assets}/${sanitizedName}.[hash][extname]`;
|
|
146
|
-
}
|
|
147
|
-
return `${settings.config.build.assets}/[name].[hash][extname]`;
|
|
148
|
-
},
|
|
140
|
+
assetFileNames: `${settings.config.build.assets}/[name].[hash][extname]`,
|
|
149
141
|
...viteConfig.build?.rollupOptions?.output,
|
|
150
142
|
entryFileNames(chunkInfo) {
|
|
151
143
|
if (chunkInfo.facadeModuleId?.startsWith(ASTRO_PAGE_RESOLVED_MODULE_ID)) {
|
|
@@ -26,6 +26,9 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
|
|
|
26
26
|
continue;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
if (key === "allowedHosts" && rootPath === "server" && typeof existing === "boolean") {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
29
32
|
if (key === "data" && rootPath === "db") {
|
|
30
33
|
if (!Array.isArray(existing) && !Array.isArray(value)) {
|
|
31
34
|
existing = [existing];
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
|
|
|
22
22
|
await telemetry.record([]);
|
|
23
23
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
24
24
|
const logger = restart.container.logger;
|
|
25
|
-
const currentVersion = "5.5.
|
|
25
|
+
const currentVersion = "5.5.3";
|
|
26
26
|
const isPrerelease = currentVersion.includes("-");
|
|
27
27
|
if (!isPrerelease) {
|
|
28
28
|
try {
|
package/dist/core/messages.js
CHANGED
|
@@ -38,7 +38,7 @@ function serverStart({
|
|
|
38
38
|
host,
|
|
39
39
|
base
|
|
40
40
|
}) {
|
|
41
|
-
const version = "5.5.
|
|
41
|
+
const version = "5.5.3";
|
|
42
42
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
43
43
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
44
44
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -282,7 +282,7 @@ function printHelp({
|
|
|
282
282
|
message.push(
|
|
283
283
|
linebreak(),
|
|
284
284
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
285
|
-
`v${"5.5.
|
|
285
|
+
`v${"5.5.3"}`
|
|
286
286
|
)} ${headline}`
|
|
287
287
|
);
|
|
288
288
|
}
|
package/dist/core/session.js
CHANGED
|
@@ -53,6 +53,7 @@ class AstroSession {
|
|
|
53
53
|
// When we load the data from storage, we need to merge it with the local partial data,
|
|
54
54
|
// preserving in-memory changes and deletions.
|
|
55
55
|
#partial = true;
|
|
56
|
+
static #sharedStorage = /* @__PURE__ */ new Map();
|
|
56
57
|
constructor(cookies, {
|
|
57
58
|
cookie: cookieConfig = DEFAULT_COOKIE_NAME,
|
|
58
59
|
...config
|
|
@@ -314,6 +315,10 @@ class AstroSession {
|
|
|
314
315
|
if (this.#storage) {
|
|
315
316
|
return this.#storage;
|
|
316
317
|
}
|
|
318
|
+
if (AstroSession.#sharedStorage.has(this.#config.driver)) {
|
|
319
|
+
this.#storage = AstroSession.#sharedStorage.get(this.#config.driver);
|
|
320
|
+
return this.#storage;
|
|
321
|
+
}
|
|
317
322
|
if (this.#config.driver === "test") {
|
|
318
323
|
this.#storage = this.#config.options.mockStorage;
|
|
319
324
|
return this.#storage;
|
|
@@ -367,6 +372,7 @@ class AstroSession {
|
|
|
367
372
|
this.#storage = createStorage({
|
|
368
373
|
driver: driver(this.#config.options)
|
|
369
374
|
});
|
|
375
|
+
AstroSession.#sharedStorage.set(this.#config.driver, this.#storage);
|
|
370
376
|
return this.#storage;
|
|
371
377
|
} catch (err) {
|
|
372
378
|
throw new AstroError(
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type * as vite from 'vite';
|
|
2
2
|
import type { Logger } from '../core/logger/core.js';
|
|
3
3
|
import type { AstroSettings } from '../types/astro.js';
|
|
4
|
-
import type { PluginMetadata as AstroPluginMetadata } from './types.js';
|
|
4
|
+
import type { PluginCssMetadata as AstroPluginCssMetadata, PluginMetadata as AstroPluginMetadata } from './types.js';
|
|
5
5
|
export { getAstroMetadata } from './metadata.js';
|
|
6
|
-
export type { AstroPluginMetadata };
|
|
6
|
+
export type { AstroPluginMetadata, AstroPluginCssMetadata };
|
|
7
7
|
interface AstroPluginOptions {
|
|
8
8
|
settings: AstroSettings;
|
|
9
9
|
logger: Logger;
|
|
@@ -89,9 +89,15 @@ function astro({ settings, logger }) {
|
|
|
89
89
|
result.dependencies?.forEach((dep) => this.addWatchFile(dep));
|
|
90
90
|
return {
|
|
91
91
|
code: result.code,
|
|
92
|
-
//
|
|
93
|
-
// if the
|
|
94
|
-
meta: result.isGlobal ? void 0 : {
|
|
92
|
+
// This metadata is used by `cssScopeToPlugin` to remove this module from the bundle
|
|
93
|
+
// if the `filename` default export (the Astro component) is unused.
|
|
94
|
+
meta: result.isGlobal ? void 0 : {
|
|
95
|
+
astroCss: {
|
|
96
|
+
cssScopeTo: {
|
|
97
|
+
[filename]: ["default"]
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
95
101
|
};
|
|
96
102
|
}
|
|
97
103
|
case "script": {
|
|
@@ -15,6 +15,26 @@ export interface PluginMetadata {
|
|
|
15
15
|
pageOptions: PageOptions;
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
+
export interface PluginCssMetadata {
|
|
19
|
+
astroCss: {
|
|
20
|
+
/**
|
|
21
|
+
* For Astro CSS virtual modules, it can scope to the main Astro module's default export
|
|
22
|
+
* so that if those exports are treeshaken away, the CSS module will also be treeshaken.
|
|
23
|
+
*
|
|
24
|
+
* Example config if the CSS id is `/src/Foo.astro?astro&type=style&lang.css`:
|
|
25
|
+
* ```js
|
|
26
|
+
* cssScopeTo: {
|
|
27
|
+
* '/src/Foo.astro': ['default']
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* The above is the only config we use today, but we're exposing as a `Record` to follow the
|
|
32
|
+
* upstream Vite implementation: https://github.com/vitejs/vite/pull/16058. When/If that lands,
|
|
33
|
+
* we can also remove our custom implementation.
|
|
34
|
+
*/
|
|
35
|
+
cssScopeTo: Record<string, string[]>;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
18
38
|
export interface CompileMetadata {
|
|
19
39
|
/** Used for HMR to compare code changes */
|
|
20
40
|
originalCode: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.3",
|
|
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",
|
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
"prompts": "^2.4.2",
|
|
143
143
|
"rehype": "^13.0.2",
|
|
144
144
|
"semver": "^7.7.1",
|
|
145
|
-
"shiki": "^
|
|
145
|
+
"shiki": "^3.0.0",
|
|
146
146
|
"tinyexec": "^0.3.2",
|
|
147
147
|
"tinyglobby": "^0.2.12",
|
|
148
148
|
"tsconfck": "^3.1.5",
|
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
"zod-to-json-schema": "^3.24.3",
|
|
160
160
|
"zod-to-ts": "^1.2.0",
|
|
161
161
|
"@astrojs/internal-helpers": "0.6.1",
|
|
162
|
-
"@astrojs/markdown-remark": "6.3.
|
|
162
|
+
"@astrojs/markdown-remark": "6.3.1",
|
|
163
163
|
"@astrojs/telemetry": "3.2.0"
|
|
164
164
|
},
|
|
165
165
|
"optionalDependencies": {
|