astro 1.6.6 → 1.6.7
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/@types/astro.d.ts +3 -4
- package/dist/core/build/css-asset-name.d.ts +8 -0
- package/dist/core/build/css-asset-name.js +61 -0
- package/dist/core/build/vite-plugin-css.js +5 -16
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/package.json +1 -1
package/dist/@types/astro.d.ts
CHANGED
|
@@ -920,6 +920,7 @@ export interface MarkdownInstance<T extends Record<string, any>> {
|
|
|
920
920
|
getHeaders(): void;
|
|
921
921
|
default: AstroComponentFactory;
|
|
922
922
|
}
|
|
923
|
+
declare type MD = MarkdownInstance<Record<string, any>>;
|
|
923
924
|
export interface MDXInstance<T extends Record<string, any>> extends Omit<MarkdownInstance<T>, 'rawContent' | 'compiledContent'> {
|
|
924
925
|
/** MDX does not support rawContent! If you need to read the Markdown contents to calculate values (ex. reading time), we suggest injecting frontmatter via remark plugins. Learn more on our docs: https://docs.astro.build/en/guides/integrations-guide/mdx/#inject-frontmatter-via-remark-or-rehype-plugins */
|
|
925
926
|
rawContent: never;
|
|
@@ -978,9 +979,7 @@ export interface ManifestData {
|
|
|
978
979
|
routes: RouteData[];
|
|
979
980
|
}
|
|
980
981
|
export interface MarkdownParserResponse extends MarkdownRenderingResult {
|
|
981
|
-
frontmatter:
|
|
982
|
-
[key: string]: any;
|
|
983
|
-
};
|
|
982
|
+
frontmatter: MD['frontmatter'];
|
|
984
983
|
}
|
|
985
984
|
/**
|
|
986
985
|
* The `content` prop given to a Layout
|
|
@@ -1275,7 +1274,7 @@ export interface SSRResult {
|
|
|
1275
1274
|
_metadata: SSRMetadata;
|
|
1276
1275
|
}
|
|
1277
1276
|
export declare type MarkdownAstroData = {
|
|
1278
|
-
frontmatter:
|
|
1277
|
+
frontmatter: MD['frontmatter'];
|
|
1279
1278
|
};
|
|
1280
1279
|
export interface PreviewServer {
|
|
1281
1280
|
host?: string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GetModuleInfo } from 'rollup';
|
|
2
|
+
import { AstroSettings } from '../../@types/astro';
|
|
3
|
+
export declare function shortHashedName(id: string, ctx: {
|
|
4
|
+
getModuleInfo: GetModuleInfo;
|
|
5
|
+
}): string;
|
|
6
|
+
export declare function createSlugger(settings: AstroSettings): (id: string, ctx: {
|
|
7
|
+
getModuleInfo: GetModuleInfo;
|
|
8
|
+
}) => string;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import crypto from "crypto";
|
|
2
|
+
import npath from "path";
|
|
3
|
+
import { viteID } from "../util.js";
|
|
4
|
+
import { getTopLevelPages } from "./graph.js";
|
|
5
|
+
function shortHashedName(id, ctx) {
|
|
6
|
+
var _a;
|
|
7
|
+
const parents = Array.from(getTopLevelPages(id, ctx));
|
|
8
|
+
const firstParentId = (_a = parents[0]) == null ? void 0 : _a[0].id;
|
|
9
|
+
const firstParentName = firstParentId ? npath.parse(firstParentId).name : "index";
|
|
10
|
+
const hash = crypto.createHash("sha256");
|
|
11
|
+
for (const [page] of parents) {
|
|
12
|
+
hash.update(page.id, "utf-8");
|
|
13
|
+
}
|
|
14
|
+
const h = hash.digest("hex").slice(0, 8);
|
|
15
|
+
const proposedName = firstParentName + "." + h;
|
|
16
|
+
return proposedName;
|
|
17
|
+
}
|
|
18
|
+
function createSlugger(settings) {
|
|
19
|
+
const pagesDir = viteID(new URL("./pages", settings.config.srcDir));
|
|
20
|
+
const map = /* @__PURE__ */ new Map();
|
|
21
|
+
const sep = "-";
|
|
22
|
+
return function(id, ctx) {
|
|
23
|
+
var _a;
|
|
24
|
+
const parents = Array.from(getTopLevelPages(id, ctx));
|
|
25
|
+
const allParentsKey = parents.map(([page]) => page.id).sort().join("-");
|
|
26
|
+
const firstParentId = ((_a = parents[0]) == null ? void 0 : _a[0].id) || "index";
|
|
27
|
+
let dir = firstParentId;
|
|
28
|
+
let key = "";
|
|
29
|
+
let i = 0;
|
|
30
|
+
while (i < 2) {
|
|
31
|
+
if (dir === pagesDir) {
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
const name2 = npath.parse(npath.basename(dir)).name;
|
|
35
|
+
key = key.length ? name2 + sep + key : name2;
|
|
36
|
+
dir = npath.dirname(dir);
|
|
37
|
+
i++;
|
|
38
|
+
}
|
|
39
|
+
let name = key;
|
|
40
|
+
if (!map.has(key)) {
|
|
41
|
+
map.set(key, /* @__PURE__ */ new Map([[allParentsKey, 0]]));
|
|
42
|
+
} else {
|
|
43
|
+
const inner = map.get(key);
|
|
44
|
+
if (inner.has(allParentsKey)) {
|
|
45
|
+
const num = inner.get(allParentsKey);
|
|
46
|
+
if (num > 0) {
|
|
47
|
+
name = name + sep + num;
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
const num = inner.size;
|
|
51
|
+
inner.set(allParentsKey, num);
|
|
52
|
+
name = name + sep + num;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return name;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
createSlugger,
|
|
60
|
+
shortHashedName
|
|
61
|
+
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import crypto from "crypto";
|
|
2
1
|
import esbuild from "esbuild";
|
|
3
|
-
import npath from "path";
|
|
4
2
|
import { isCSSRequest } from "../render/util.js";
|
|
5
|
-
import
|
|
3
|
+
import * as assetName from "./css-asset-name.js";
|
|
4
|
+
import { moduleIsTopLevelPage, walkParentInfos } from "./graph.js";
|
|
6
5
|
import {
|
|
7
6
|
eachPageData,
|
|
8
7
|
getPageDataByViteID,
|
|
@@ -14,19 +13,6 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
14
13
|
const { internals, buildOptions } = options;
|
|
15
14
|
const { settings } = buildOptions;
|
|
16
15
|
let resolvedConfig;
|
|
17
|
-
function createNameForParentPages(id, ctx) {
|
|
18
|
-
var _a;
|
|
19
|
-
const parents = Array.from(getTopLevelPages(id, ctx));
|
|
20
|
-
const firstParentId = (_a = parents[0]) == null ? void 0 : _a[0].id;
|
|
21
|
-
const firstParentName = firstParentId ? npath.parse(firstParentId).name : "index";
|
|
22
|
-
const hash = crypto.createHash("sha256");
|
|
23
|
-
for (const [page] of parents) {
|
|
24
|
-
hash.update(page.id, "utf-8");
|
|
25
|
-
}
|
|
26
|
-
const h = hash.digest("hex").slice(0, 8);
|
|
27
|
-
const proposedName = firstParentName + "." + h;
|
|
28
|
-
return proposedName;
|
|
29
|
-
}
|
|
30
16
|
function* getParentClientOnlys(id, ctx) {
|
|
31
17
|
for (const [info] of walkParentInfos(id, ctx)) {
|
|
32
18
|
yield* getPageDatasByClientOnlyID(internals, info.id);
|
|
@@ -37,6 +23,9 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
37
23
|
name: "astro:rollup-plugin-build-css",
|
|
38
24
|
outputOptions(outputOptions) {
|
|
39
25
|
const manualChunks = outputOptions.manualChunks || Function.prototype;
|
|
26
|
+
const assetFileNames = outputOptions.assetFileNames;
|
|
27
|
+
const namingIncludesHash = assetFileNames == null ? void 0 : assetFileNames.toString().includes("[hash]");
|
|
28
|
+
const createNameForParentPages = namingIncludesHash ? assetName.shortHashedName : assetName.createSlugger(settings);
|
|
40
29
|
outputOptions.manualChunks = function(id, ...args) {
|
|
41
30
|
if (typeof manualChunks == "object") {
|
|
42
31
|
if (id in manualChunks) {
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -30,7 +30,7 @@ async function dev(settings, options) {
|
|
|
30
30
|
isRestart: options.isRestart
|
|
31
31
|
})
|
|
32
32
|
);
|
|
33
|
-
const currentVersion = "1.6.
|
|
33
|
+
const currentVersion = "1.6.7";
|
|
34
34
|
if (currentVersion.includes("-")) {
|
|
35
35
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
36
36
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -47,7 +47,7 @@ function serverStart({
|
|
|
47
47
|
site,
|
|
48
48
|
isRestart = false
|
|
49
49
|
}) {
|
|
50
|
-
const version = "1.6.
|
|
50
|
+
const version = "1.6.7";
|
|
51
51
|
const rootPath = site ? site.pathname : "/";
|
|
52
52
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
53
53
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
@@ -264,7 +264,7 @@ function printHelp({
|
|
|
264
264
|
message.push(
|
|
265
265
|
linebreak(),
|
|
266
266
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
267
|
-
`v${"1.6.
|
|
267
|
+
`v${"1.6.7"}`
|
|
268
268
|
)} ${headline}`
|
|
269
269
|
);
|
|
270
270
|
}
|