astro 1.2.1 → 1.2.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.
@@ -1,8 +1,8 @@
1
1
  import type { GetModuleInfo, ModuleInfo } from 'rollup';
2
2
  export declare function walkParentInfos(id: string, ctx: {
3
3
  getModuleInfo: GetModuleInfo;
4
- }, depth?: number, seen?: Set<string>): Generator<[ModuleInfo, number], void, unknown>;
4
+ }, depth?: number, seen?: Set<string>, childId?: string): Generator<[ModuleInfo, number, number], void, unknown>;
5
5
  export declare function moduleIsTopLevelPage(info: ModuleInfo): boolean;
6
6
  export declare function getTopLevelPages(id: string, ctx: {
7
7
  getModuleInfo: GetModuleInfo;
8
- }): Generator<[ModuleInfo, number], void, unknown>;
8
+ }): Generator<[ModuleInfo, number, number], void, unknown>;
@@ -1,16 +1,17 @@
1
1
  import { resolvedPagesVirtualModuleId } from "../app/index.js";
2
- function* walkParentInfos(id, ctx, depth = 0, seen = /* @__PURE__ */ new Set()) {
2
+ function* walkParentInfos(id, ctx, depth = 0, seen = /* @__PURE__ */ new Set(), childId = "") {
3
3
  seen.add(id);
4
4
  const info = ctx.getModuleInfo(id);
5
5
  if (info) {
6
- yield [info, depth];
6
+ let order = childId ? info.importedIds.indexOf(childId) : 0;
7
+ yield [info, depth, order];
7
8
  }
8
9
  const importers = ((info == null ? void 0 : info.importers) || []).concat((info == null ? void 0 : info.dynamicImporters) || []);
9
10
  for (const imp of importers) {
10
11
  if (seen.has(imp)) {
11
12
  continue;
12
13
  }
13
- yield* walkParentInfos(imp, ctx, ++depth, seen);
14
+ yield* walkParentInfos(imp, ctx, ++depth, seen, id);
14
15
  }
15
16
  }
16
17
  function moduleIsTopLevelPage(info) {
@@ -78,13 +78,23 @@ function* eachPageData(internals) {
78
78
  }
79
79
  function sortedCSS(pageData) {
80
80
  return Array.from(pageData.css).sort((a, b) => {
81
- let depthA = a[1].depth, depthB = b[1].depth;
82
- if (depthA === -1) {
81
+ let depthA = a[1].depth, depthB = b[1].depth, orderA = a[1].order, orderB = b[1].order;
82
+ if (orderA === -1 && orderB >= 0) {
83
+ return 1;
84
+ } else if (orderB === -1 && orderA >= 0) {
83
85
  return -1;
84
- } else if (depthB === -1) {
86
+ } else if (orderA > orderB) {
85
87
  return 1;
88
+ } else if (orderA < orderB) {
89
+ return -1;
86
90
  } else {
87
- return depthA > depthB ? -1 : 1;
91
+ if (depthA === -1) {
92
+ return -1;
93
+ } else if (depthB === -1) {
94
+ return 1;
95
+ } else {
96
+ return depthA > depthB ? -1 : 1;
97
+ }
88
98
  }
89
99
  }).map(([id]) => id);
90
100
  }
@@ -10,6 +10,7 @@ export interface PageBuildData {
10
10
  moduleSpecifier: string;
11
11
  css: Map<string, {
12
12
  depth: number;
13
+ order: number;
13
14
  }>;
14
15
  hoistedScript: {
15
16
  type: 'inline' | 'external';
@@ -65,15 +65,20 @@ function rollupPluginAstroBuildCSS(options) {
65
65
  };
66
66
  },
67
67
  async generateBundle(_outputOptions, bundle) {
68
- const appendCSSToPage = (pageData, meta, depth) => {
68
+ const appendCSSToPage = (pageData, meta, depth, order) => {
69
69
  for (const importedCssImport of meta.importedCss) {
70
70
  if (pageData == null ? void 0 : pageData.css.has(importedCssImport)) {
71
71
  const cssInfo = pageData == null ? void 0 : pageData.css.get(importedCssImport);
72
72
  if (depth < cssInfo.depth) {
73
73
  cssInfo.depth = depth;
74
74
  }
75
+ if (cssInfo.order === -1) {
76
+ cssInfo.order = order;
77
+ } else if (order < cssInfo.order && order > -1) {
78
+ cssInfo.order = order;
79
+ }
75
80
  } else {
76
- pageData == null ? void 0 : pageData.css.set(importedCssImport, { depth });
81
+ pageData == null ? void 0 : pageData.css.set(importedCssImport, { depth, order });
77
82
  }
78
83
  }
79
84
  };
@@ -101,25 +106,25 @@ function rollupPluginAstroBuildCSS(options) {
101
106
  for (const id of Object.keys(c.modules)) {
102
107
  for (const pageData of getParentClientOnlys(id, this)) {
103
108
  for (const importedCssImport of meta.importedCss) {
104
- pageData.css.set(importedCssImport, { depth: -1 });
109
+ pageData.css.set(importedCssImport, { depth: -1, order: -1 });
105
110
  }
106
111
  }
107
112
  }
108
113
  }
109
114
  for (const id of Object.keys(c.modules)) {
110
- for (const [pageInfo, depth] of walkParentInfos(id, this)) {
115
+ for (const [pageInfo, depth, order] of walkParentInfos(id, this)) {
111
116
  if (moduleIsTopLevelPage(pageInfo)) {
112
117
  const pageViteID = pageInfo.id;
113
118
  const pageData = getPageDataByViteID(internals, pageViteID);
114
119
  if (pageData) {
115
- appendCSSToPage(pageData, meta, depth);
120
+ appendCSSToPage(pageData, meta, depth, order);
116
121
  }
117
122
  } else if (options.target === "client" && isHoistedScript(internals, pageInfo.id)) {
118
123
  for (const pageData of getPageDatasByHoistedScriptId(
119
124
  internals,
120
125
  pageInfo.id
121
126
  )) {
122
- appendCSSToPage(pageData, meta, -1);
127
+ appendCSSToPage(pageData, meta, -1, order);
123
128
  }
124
129
  }
125
130
  }
@@ -143,7 +148,7 @@ function rollupPluginAstroBuildCSS(options) {
143
148
  );
144
149
  if (cssChunk) {
145
150
  for (const pageData of eachPageData(internals)) {
146
- pageData.css.set(cssChunk.fileName, { depth: -1 });
151
+ pageData.css.set(cssChunk.fileName, { depth: -1, order: -1 });
147
152
  }
148
153
  }
149
154
  }
@@ -36,10 +36,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
36
36
  }>, "many">>, {
37
37
  name: string;
38
38
  hooks: {};
39
- }[], {
40
- hooks?: {} | undefined;
41
- name: string;
42
- }[] | undefined>;
39
+ }[], unknown>;
43
40
  build: z.ZodDefault<z.ZodOptional<z.ZodObject<{
44
41
  format: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"file">, z.ZodLiteral<"directory">]>>>;
45
42
  }, "strip", z.ZodTypeAny, {
@@ -59,10 +56,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
59
56
  }>>>, {
60
57
  host: string | boolean;
61
58
  port: number;
62
- }, {
63
- host?: string | boolean | undefined;
64
- port?: number | undefined;
65
- } | undefined>;
59
+ }, unknown>;
66
60
  style: z.ZodDefault<z.ZodOptional<z.ZodObject<{
67
61
  postcss: z.ZodDefault<z.ZodOptional<z.ZodObject<{
68
62
  options: z.ZodAny;
@@ -206,19 +200,13 @@ export declare const AstroConfigSchema: z.ZodObject<{
206
200
  publicDir?: string | undefined;
207
201
  outDir?: string | undefined;
208
202
  trailingSlash?: "never" | "always" | "ignore" | undefined;
209
- server?: {
210
- host?: string | boolean | undefined;
211
- port?: number | undefined;
212
- } | undefined;
203
+ server?: unknown;
213
204
  output?: "static" | "server" | undefined;
214
205
  adapter?: {
215
206
  hooks?: {} | undefined;
216
207
  name: string;
217
208
  } | undefined;
218
- integrations?: {
219
- hooks?: {} | undefined;
220
- name: string;
221
- }[] | undefined;
209
+ integrations?: unknown;
222
210
  build?: {
223
211
  format?: "file" | "directory" | undefined;
224
212
  } | undefined;
@@ -48,7 +48,7 @@ async function dev(config, options) {
48
48
  isRestart
49
49
  })
50
50
  );
51
- const currentVersion = "1.2.1";
51
+ const currentVersion = "1.2.3";
52
52
  if (currentVersion.includes("-")) {
53
53
  warn(options.logging, null, msg.prerelease({ currentVersion }));
54
54
  }
@@ -17,21 +17,27 @@ function cleanErrorStack(stack) {
17
17
  function fixViteErrorMessage(_err, server, filePath) {
18
18
  var _a, _b;
19
19
  const err = createSafeError(_err);
20
- server == null ? void 0 : server.ssrFixStacktrace(err);
20
+ try {
21
+ server == null ? void 0 : server.ssrFixStacktrace(err);
22
+ } catch {
23
+ }
21
24
  if (err.message === "import.meta.glob() can only accept string literals.") {
22
25
  err.message = "Astro.glob() and import.meta.glob() can only accept string literals.";
23
26
  }
24
27
  if (filePath && /failed to load module for ssr:/.test(err.message)) {
25
28
  const importName = (_a = err.message.split("for ssr:").at(1)) == null ? void 0 : _a.trim();
26
29
  if (importName) {
27
- const content = fs.readFileSync(fileURLToPath(filePath)).toString();
28
- const lns = content.split("\n");
29
- const line = lns.findIndex((ln) => ln.includes(importName));
30
- if (line == -1)
31
- return err;
32
- const column = (_b = lns[line]) == null ? void 0 : _b.indexOf(importName);
33
- if (!err.id) {
34
- err.id = `${fileURLToPath(filePath)}:${line + 1}:${column + 1}`;
30
+ try {
31
+ const content = fs.readFileSync(fileURLToPath(filePath)).toString();
32
+ const lns = content.split("\n");
33
+ const line = lns.findIndex((ln) => ln.includes(importName));
34
+ if (line == -1)
35
+ return err;
36
+ const column = (_b = lns[line]) == null ? void 0 : _b.indexOf(importName);
37
+ if (!err.id) {
38
+ err.id = `${fileURLToPath(filePath)}:${line + 1}:${column + 1}`;
39
+ }
40
+ } catch {
35
41
  }
36
42
  }
37
43
  }
@@ -47,7 +47,7 @@ function devStart({
47
47
  site,
48
48
  isRestart = false
49
49
  }) {
50
- const version = "1.2.1";
50
+ const version = "1.2.3";
51
51
  const rootPath = site ? site.pathname : "/";
52
52
  const localPrefix = `${dim("\u2503")} Local `;
53
53
  const networkPrefix = `${dim("\u2503")} Network `;
@@ -226,7 +226,7 @@ function printHelp({
226
226
  message.push(
227
227
  linebreak(),
228
228
  ` ${bgGreen(black(` ${commandName} `))} ${green(
229
- `v${"1.2.1"}`
229
+ `v${"1.2.3"}`
230
230
  )} ${headline}`
231
231
  );
232
232
  }
package/dist/core/util.js CHANGED
@@ -5,7 +5,7 @@ import resolve from "resolve";
5
5
  import slash from "slash";
6
6
  import { fileURLToPath, pathToFileURL } from "url";
7
7
  import { prependForwardSlash, removeTrailingForwardSlash } from "./path.js";
8
- const ASTRO_VERSION = "1.2.1";
8
+ const ASTRO_VERSION = "1.2.3";
9
9
  function isObject(value) {
10
10
  return typeof value === "object" && value != null;
11
11
  }
@@ -35,6 +35,12 @@ async function runHookConfigSetup({
35
35
  config: updatedConfig,
36
36
  command,
37
37
  addRenderer(renderer) {
38
+ if (!renderer.name) {
39
+ throw new Error(`Integration ${bold(integration.name)} has an unnamed renderer.`);
40
+ }
41
+ if (!renderer.serverEntrypoint) {
42
+ throw new Error(`Renderer ${bold(renderer.name)} does not provide a serverEntrypoint.`);
43
+ }
38
44
  updatedConfig._ctx.renderers.push(renderer);
39
45
  },
40
46
  injectScript: (stage, content) => {
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "1.2.1";
1
+ const ASTRO_VERSION = "1.2.3";
2
2
  function createDeprecatedFetchContentFn() {
3
3
  return () => {
4
4
  throw new Error("Deprecated: Astro.fetchContent() has been replaced with Astro.glob().");
@@ -14,7 +14,7 @@ import { preload, ssr } from "../core/render/dev/index.js";
14
14
  import { RouteCache } from "../core/render/route-cache.js";
15
15
  import { createRequest } from "../core/request.js";
16
16
  import { createRouteManifest, matchAllRoutes } from "../core/routing/index.js";
17
- import { createSafeError, resolvePages } from "../core/util.js";
17
+ import { resolvePages } from "../core/util.js";
18
18
  import notFoundTemplate, { subpathNotUsedTemplate } from "../template/4xx.js";
19
19
  function truncateString(str, n) {
20
20
  if (str.length > n) {
@@ -255,7 +255,7 @@ async function handleRequest(routeCache, viteServer, logging, manifest, config,
255
255
  return await writeSSRResult(result, res);
256
256
  }
257
257
  } catch (_err) {
258
- const err = fixViteErrorMessage(createSafeError(_err), viteServer, filePath);
258
+ const err = fixViteErrorMessage(_err, viteServer, filePath);
259
259
  const errorWithMetadata = collectErrorMetadata(err);
260
260
  error(logging, null, msg.formatErrorMessage(errorWithMetadata));
261
261
  handle500Response(viteServer, origin, req, res, errorWithMetadata);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "1.2.1",
3
+ "version": "1.2.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",