astro 1.6.8 → 1.6.10
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/components/Code.astro +4 -1
- package/components/Shiki.js +48 -6
- package/components/shiki-languages.js +2020 -0
- package/components/shiki-themes.js +33 -0
- package/dist/cli/index.js +3 -2
- package/dist/core/add/index.js +2 -2
- package/dist/core/build/css-asset-name.js +2 -1
- package/dist/core/config/config.d.ts +3 -1
- package/dist/core/config/config.js +16 -49
- package/dist/core/config/settings.js +6 -2
- package/dist/core/config/vite-load.d.ts +17 -0
- package/dist/core/config/vite-load.js +111 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +3 -4
- package/dist/runtime/server/render/astro.d.ts +1 -0
- package/dist/runtime/server/render/astro.js +13 -1
- package/dist/vite-plugin-jsx/tag.js +8 -7
- package/dist/vite-plugin-load-fallback/index.d.ts +2 -3
- package/dist/vite-plugin-load-fallback/index.js +15 -9
- package/package.json +5 -5
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const themes = {
|
|
2
|
+
'css-variables': () => import('shiki/themes/css-variables.json').then((mod) => mod.default),
|
|
3
|
+
'dark-plus': () => import('shiki/themes/dark-plus.json').then((mod) => mod.default),
|
|
4
|
+
'dracula-soft': () => import('shiki/themes/dracula-soft.json').then((mod) => mod.default),
|
|
5
|
+
dracula: () => import('shiki/themes/dracula.json').then((mod) => mod.default),
|
|
6
|
+
'github-dark-dimmed': () =>
|
|
7
|
+
import('shiki/themes/github-dark-dimmed.json').then((mod) => mod.default),
|
|
8
|
+
'github-dark': () => import('shiki/themes/github-dark.json').then((mod) => mod.default),
|
|
9
|
+
'github-light': () => import('shiki/themes/github-light.json').then((mod) => mod.default),
|
|
10
|
+
hc_light: () => import('shiki/themes/hc_light.json').then((mod) => mod.default),
|
|
11
|
+
'light-plus': () => import('shiki/themes/light-plus.json').then((mod) => mod.default),
|
|
12
|
+
'material-darker': () => import('shiki/themes/material-darker.json').then((mod) => mod.default),
|
|
13
|
+
'material-default': () => import('shiki/themes/material-default.json').then((mod) => mod.default),
|
|
14
|
+
'material-lighter': () => import('shiki/themes/material-lighter.json').then((mod) => mod.default),
|
|
15
|
+
'material-ocean': () => import('shiki/themes/material-ocean.json').then((mod) => mod.default),
|
|
16
|
+
'material-palenight': () =>
|
|
17
|
+
import('shiki/themes/material-palenight.json').then((mod) => mod.default),
|
|
18
|
+
'min-dark': () => import('shiki/themes/min-dark.json').then((mod) => mod.default),
|
|
19
|
+
'min-light': () => import('shiki/themes/min-light.json').then((mod) => mod.default),
|
|
20
|
+
monokai: () => import('shiki/themes/monokai.json').then((mod) => mod.default),
|
|
21
|
+
nord: () => import('shiki/themes/nord.json').then((mod) => mod.default),
|
|
22
|
+
'one-dark-pro': () => import('shiki/themes/one-dark-pro.json').then((mod) => mod.default),
|
|
23
|
+
poimandres: () => import('shiki/themes/poimandres.json').then((mod) => mod.default),
|
|
24
|
+
'rose-pine-dawn': () => import('shiki/themes/rose-pine-dawn.json').then((mod) => mod.default),
|
|
25
|
+
'rose-pine-moon': () => import('shiki/themes/rose-pine-moon.json').then((mod) => mod.default),
|
|
26
|
+
'rose-pine': () => import('shiki/themes/rose-pine.json').then((mod) => mod.default),
|
|
27
|
+
'slack-dark': () => import('shiki/themes/slack-dark.json').then((mod) => mod.default),
|
|
28
|
+
'slack-ochin': () => import('shiki/themes/slack-ochin.json').then((mod) => mod.default),
|
|
29
|
+
'solarized-dark': () => import('shiki/themes/solarized-dark.json').then((mod) => mod.default),
|
|
30
|
+
'solarized-light': () => import('shiki/themes/solarized-light.json').then((mod) => mod.default),
|
|
31
|
+
'vitesse-dark': () => import('shiki/themes/vitesse-dark.json').then((mod) => mod.default),
|
|
32
|
+
'vitesse-light': () => import('shiki/themes/vitesse-light.json').then((mod) => mod.default),
|
|
33
|
+
};
|
package/dist/cli/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import fs from "fs";
|
|
1
2
|
import * as colors from "kleur/colors";
|
|
2
3
|
import yargs from "yargs-parser";
|
|
3
4
|
import { z } from "zod";
|
|
@@ -66,7 +67,7 @@ function resolveCommand(flags) {
|
|
|
66
67
|
return "help";
|
|
67
68
|
}
|
|
68
69
|
async function handleConfigError(e, { cwd, flags, logging }) {
|
|
69
|
-
const path = await resolveConfigPath({ cwd, flags });
|
|
70
|
+
const path = await resolveConfigPath({ cwd, flags, fs });
|
|
70
71
|
if (e instanceof Error) {
|
|
71
72
|
if (path) {
|
|
72
73
|
error(logging, "astro", `Unable to load ${colors.bold(path)}
|
|
@@ -130,7 +131,7 @@ async function runCommand(cmd, flags) {
|
|
|
130
131
|
case "dev": {
|
|
131
132
|
const { default: devServer } = await import("../core/dev/index.js");
|
|
132
133
|
const configFlag = resolveFlags(flags).config;
|
|
133
|
-
const configFlagPath = configFlag ? await resolveConfigPath({ cwd: root, flags }) : void 0;
|
|
134
|
+
const configFlagPath = configFlag ? await resolveConfigPath({ cwd: root, flags, fs }) : void 0;
|
|
134
135
|
await devServer(settings, {
|
|
135
136
|
configFlag,
|
|
136
137
|
configFlagPath,
|
package/dist/core/add/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import boxen from "boxen";
|
|
2
2
|
import { diffWords } from "diff";
|
|
3
3
|
import { execa } from "execa";
|
|
4
|
-
import { existsSync, promises as fs } from "fs";
|
|
4
|
+
import fsMod, { existsSync, promises as fs } from "fs";
|
|
5
5
|
import { bold, cyan, dim, green, magenta, red, yellow } from "kleur/colors";
|
|
6
6
|
import ora from "ora";
|
|
7
7
|
import path from "path";
|
|
@@ -145,7 +145,7 @@ async function add(names, { cwd, flags, logging, telemetry }) {
|
|
|
145
145
|
throw createPrettyError(new Error(`Unable to install dependencies`));
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
const rawConfigPath = await resolveConfigPath({ cwd, flags });
|
|
148
|
+
const rawConfigPath = await resolveConfigPath({ cwd, flags, fs: fsMod });
|
|
149
149
|
let configURL = rawConfigPath ? pathToFileURL(rawConfigPath) : void 0;
|
|
150
150
|
if (configURL) {
|
|
151
151
|
debug("add", `Found config at ${configURL}`);
|
|
@@ -17,13 +17,14 @@ function shortHashedName(id, ctx) {
|
|
|
17
17
|
}
|
|
18
18
|
function createSlugger(settings) {
|
|
19
19
|
const pagesDir = viteID(new URL("./pages", settings.config.srcDir));
|
|
20
|
+
const indexPage = viteID(new URL("./pages/index", settings.config.srcDir));
|
|
20
21
|
const map = /* @__PURE__ */ new Map();
|
|
21
22
|
const sep = "-";
|
|
22
23
|
return function(id, ctx) {
|
|
23
24
|
var _a;
|
|
24
25
|
const parents = Array.from(getTopLevelPages(id, ctx));
|
|
25
26
|
const allParentsKey = parents.map(([page]) => page.id).sort().join("-");
|
|
26
|
-
const firstParentId = ((_a = parents[0]) == null ? void 0 : _a[0].id) ||
|
|
27
|
+
const firstParentId = ((_a = parents[0]) == null ? void 0 : _a[0].id) || indexPage;
|
|
27
28
|
let dir = firstParentId;
|
|
28
29
|
let key = "";
|
|
29
30
|
let i = 0;
|
|
@@ -24,7 +24,9 @@ interface LoadConfigOptions {
|
|
|
24
24
|
* Note: currently the same as loadConfig but only returns the `filePath`
|
|
25
25
|
* instead of the resolved config
|
|
26
26
|
*/
|
|
27
|
-
export declare function resolveConfigPath(configOptions: Pick<LoadConfigOptions, 'cwd' | 'flags'>
|
|
27
|
+
export declare function resolveConfigPath(configOptions: Pick<LoadConfigOptions, 'cwd' | 'flags'> & {
|
|
28
|
+
fs: typeof fs;
|
|
29
|
+
}): Promise<string | undefined>;
|
|
28
30
|
interface OpenConfigResult {
|
|
29
31
|
userConfig: AstroUserConfig;
|
|
30
32
|
astroConfig: AstroConfig;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import load, { ProloadError, resolve } from "@proload/core";
|
|
2
|
-
import loadTypeScript from "@proload/plugin-tsm";
|
|
3
1
|
import fs from "fs";
|
|
4
2
|
import * as colors from "kleur/colors";
|
|
5
3
|
import path from "path";
|
|
6
4
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
7
|
-
import * as vite from "vite";
|
|
8
5
|
import { mergeConfig as mergeViteConfig } from "vite";
|
|
9
6
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
10
7
|
import { arraify, isObject, isURL } from "../util.js";
|
|
11
8
|
import { createRelativeSchema } from "./schema.js";
|
|
12
|
-
load.
|
|
9
|
+
import { loadConfigWithVite } from "./vite-load.js";
|
|
13
10
|
const LEGACY_ASTRO_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
14
11
|
"projectRoot",
|
|
15
12
|
"src",
|
|
@@ -111,14 +108,14 @@ async function resolveConfigPath(configOptions) {
|
|
|
111
108
|
userConfigPath = fileURLToPath(new URL(userConfigPath, `file://${root}/`));
|
|
112
109
|
}
|
|
113
110
|
try {
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
const config = await loadConfigWithVite({
|
|
112
|
+
configPath: userConfigPath,
|
|
113
|
+
root,
|
|
114
|
+
fs: configOptions.fs
|
|
118
115
|
});
|
|
119
|
-
return
|
|
116
|
+
return config.filePath;
|
|
120
117
|
} catch (e) {
|
|
121
|
-
if (
|
|
118
|
+
if (flags.config) {
|
|
122
119
|
throw new AstroError({
|
|
123
120
|
...AstroErrorData.ConfigNotFound,
|
|
124
121
|
message: AstroErrorData.ConfigNotFound.message(flags.config)
|
|
@@ -131,7 +128,7 @@ async function openConfig(configOptions) {
|
|
|
131
128
|
const root = resolveRoot(configOptions.cwd);
|
|
132
129
|
const flags = resolveFlags(configOptions.flags || {});
|
|
133
130
|
let userConfig = {};
|
|
134
|
-
const config = await tryLoadConfig(configOptions,
|
|
131
|
+
const config = await tryLoadConfig(configOptions, root);
|
|
135
132
|
if (config) {
|
|
136
133
|
userConfig = config.value;
|
|
137
134
|
}
|
|
@@ -143,14 +140,15 @@ async function openConfig(configOptions) {
|
|
|
143
140
|
root
|
|
144
141
|
};
|
|
145
142
|
}
|
|
146
|
-
async function tryLoadConfig(configOptions,
|
|
143
|
+
async function tryLoadConfig(configOptions, root) {
|
|
147
144
|
const fsMod = configOptions.fsMod ?? fs;
|
|
148
145
|
let finallyCleanup = async () => {
|
|
149
146
|
};
|
|
150
147
|
try {
|
|
151
148
|
let configPath = await resolveConfigPath({
|
|
152
149
|
cwd: configOptions.cwd,
|
|
153
|
-
flags: configOptions.flags
|
|
150
|
+
flags: configOptions.flags,
|
|
151
|
+
fs: fsMod
|
|
154
152
|
});
|
|
155
153
|
if (!configPath)
|
|
156
154
|
return void 0;
|
|
@@ -169,43 +167,12 @@ async function tryLoadConfig(configOptions, flags, root) {
|
|
|
169
167
|
};
|
|
170
168
|
configPath = tempConfigPath;
|
|
171
169
|
}
|
|
172
|
-
const config = await
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
170
|
+
const config = await loadConfigWithVite({
|
|
171
|
+
configPath,
|
|
172
|
+
fs: fsMod,
|
|
173
|
+
root
|
|
176
174
|
});
|
|
177
175
|
return config;
|
|
178
|
-
} catch (e) {
|
|
179
|
-
if (e instanceof ProloadError && flags.config) {
|
|
180
|
-
throw new AstroError({
|
|
181
|
-
...AstroErrorData.ConfigNotFound,
|
|
182
|
-
message: AstroErrorData.ConfigNotFound.message(flags.config)
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
const configPath = await resolveConfigPath(configOptions);
|
|
186
|
-
if (!configPath) {
|
|
187
|
-
throw e;
|
|
188
|
-
}
|
|
189
|
-
const viteServer = await vite.createServer({
|
|
190
|
-
server: { middlewareMode: true, hmr: false },
|
|
191
|
-
optimizeDeps: { entries: [] },
|
|
192
|
-
clearScreen: false,
|
|
193
|
-
appType: "custom",
|
|
194
|
-
ssr: {
|
|
195
|
-
external: ["@astrojs/mdx", "@astrojs/react"]
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
try {
|
|
199
|
-
const mod = await viteServer.ssrLoadModule(configPath);
|
|
200
|
-
if (mod == null ? void 0 : mod.default) {
|
|
201
|
-
return {
|
|
202
|
-
value: mod.default,
|
|
203
|
-
filePath: configPath
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
} finally {
|
|
207
|
-
await viteServer.close();
|
|
208
|
-
}
|
|
209
176
|
} finally {
|
|
210
177
|
await finallyCleanup();
|
|
211
178
|
}
|
|
@@ -214,7 +181,7 @@ async function loadConfig(configOptions) {
|
|
|
214
181
|
const root = resolveRoot(configOptions.cwd);
|
|
215
182
|
const flags = resolveFlags(configOptions.flags || {});
|
|
216
183
|
let userConfig = {};
|
|
217
|
-
const config = await tryLoadConfig(configOptions,
|
|
184
|
+
const config = await tryLoadConfig(configOptions, root);
|
|
218
185
|
if (config) {
|
|
219
186
|
userConfig = config.value;
|
|
220
187
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from "./../constants.js";
|
|
2
|
-
import { fileURLToPath } from "url";
|
|
2
|
+
import { fileURLToPath, pathToFileURL } from "url";
|
|
3
3
|
import jsxRenderer from "../../jsx/renderer.js";
|
|
4
4
|
import { createDefaultDevConfig } from "./config.js";
|
|
5
5
|
import { loadTSConfig } from "./tsconfig.js";
|
|
@@ -19,9 +19,13 @@ function createBaseSettings(config) {
|
|
|
19
19
|
function createSettings(config, cwd) {
|
|
20
20
|
const tsconfig = loadTSConfig(cwd);
|
|
21
21
|
const settings = createBaseSettings(config);
|
|
22
|
+
const watchFiles = (tsconfig == null ? void 0 : tsconfig.exists) ? [tsconfig.path, ...tsconfig.extendedPaths] : [];
|
|
23
|
+
if (cwd) {
|
|
24
|
+
watchFiles.push(fileURLToPath(new URL("./package.json", pathToFileURL(cwd))));
|
|
25
|
+
}
|
|
22
26
|
settings.tsConfig = tsconfig == null ? void 0 : tsconfig.config;
|
|
23
27
|
settings.tsConfigPath = tsconfig == null ? void 0 : tsconfig.path;
|
|
24
|
-
settings.watchFiles =
|
|
28
|
+
settings.watchFiles = watchFiles;
|
|
25
29
|
return settings;
|
|
26
30
|
}
|
|
27
31
|
async function createDefaultDevSettings(userConfig = {}, root) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type fsType from 'fs';
|
|
3
|
+
import * as vite from 'vite';
|
|
4
|
+
export interface ViteLoader {
|
|
5
|
+
root: string;
|
|
6
|
+
viteServer: vite.ViteDevServer;
|
|
7
|
+
}
|
|
8
|
+
interface LoadConfigWithViteOptions {
|
|
9
|
+
root: string;
|
|
10
|
+
configPath: string | undefined;
|
|
11
|
+
fs: typeof fsType;
|
|
12
|
+
}
|
|
13
|
+
export declare function loadConfigWithVite({ configPath, fs, root, }: LoadConfigWithViteOptions): Promise<{
|
|
14
|
+
value: Record<string, any>;
|
|
15
|
+
filePath?: string;
|
|
16
|
+
}>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import npath from "path";
|
|
2
|
+
import { pathToFileURL } from "url";
|
|
3
|
+
import * as vite from "vite";
|
|
4
|
+
import loadFallbackPlugin from "../../vite-plugin-load-fallback/index.js";
|
|
5
|
+
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
6
|
+
import load from "@proload/core";
|
|
7
|
+
import loadTypeScript from "@proload/plugin-tsm";
|
|
8
|
+
load.use([loadTypeScript]);
|
|
9
|
+
async function createViteLoader(root, fs) {
|
|
10
|
+
const viteServer = await vite.createServer({
|
|
11
|
+
server: { middlewareMode: true, hmr: false },
|
|
12
|
+
optimizeDeps: { entries: [] },
|
|
13
|
+
clearScreen: false,
|
|
14
|
+
appType: "custom",
|
|
15
|
+
ssr: {
|
|
16
|
+
external: ["@astrojs/tailwind", "@astrojs/mdx", "@astrojs/react"]
|
|
17
|
+
},
|
|
18
|
+
plugins: [loadFallbackPlugin({ fs, root: pathToFileURL(root) })]
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
root,
|
|
22
|
+
viteServer
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async function stat(fs, configPath, mustExist) {
|
|
26
|
+
try {
|
|
27
|
+
await fs.promises.stat(configPath);
|
|
28
|
+
return true;
|
|
29
|
+
} catch {
|
|
30
|
+
if (mustExist) {
|
|
31
|
+
throw new AstroError({
|
|
32
|
+
...AstroErrorData.ConfigNotFound,
|
|
33
|
+
message: AstroErrorData.ConfigNotFound.message(configPath)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async function search(fs, root) {
|
|
40
|
+
const paths = [
|
|
41
|
+
"astro.config.mjs",
|
|
42
|
+
"astro.config.js",
|
|
43
|
+
"astro.config.ts",
|
|
44
|
+
"astro.config.mts",
|
|
45
|
+
"astro.config.cjs",
|
|
46
|
+
"astro.config.cjs"
|
|
47
|
+
].map((path) => npath.join(root, path));
|
|
48
|
+
for (const file of paths) {
|
|
49
|
+
const exists = await stat(fs, file, false);
|
|
50
|
+
if (exists) {
|
|
51
|
+
return file;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function loadConfigWithVite({
|
|
56
|
+
configPath,
|
|
57
|
+
fs,
|
|
58
|
+
root
|
|
59
|
+
}) {
|
|
60
|
+
let file;
|
|
61
|
+
if (configPath) {
|
|
62
|
+
await stat(fs, configPath, true);
|
|
63
|
+
file = configPath;
|
|
64
|
+
} else {
|
|
65
|
+
const found = await search(fs, root);
|
|
66
|
+
if (!found) {
|
|
67
|
+
return {
|
|
68
|
+
value: {},
|
|
69
|
+
filePath: void 0
|
|
70
|
+
};
|
|
71
|
+
} else {
|
|
72
|
+
file = found;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (/\.[cm]?js$/.test(file)) {
|
|
76
|
+
try {
|
|
77
|
+
const config = await import(pathToFileURL(file).toString());
|
|
78
|
+
return {
|
|
79
|
+
value: config.default ?? {},
|
|
80
|
+
filePath: file
|
|
81
|
+
};
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
let loader;
|
|
86
|
+
try {
|
|
87
|
+
loader = await createViteLoader(root, fs);
|
|
88
|
+
const mod = await loader.viteServer.ssrLoadModule(file);
|
|
89
|
+
return {
|
|
90
|
+
value: mod.default ?? {},
|
|
91
|
+
filePath: file
|
|
92
|
+
};
|
|
93
|
+
} catch {
|
|
94
|
+
const res = await load("astro", {
|
|
95
|
+
mustExist: true,
|
|
96
|
+
cwd: root,
|
|
97
|
+
filePath: file
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
value: (res == null ? void 0 : res.value) ?? {},
|
|
101
|
+
filePath: file
|
|
102
|
+
};
|
|
103
|
+
} finally {
|
|
104
|
+
if (loader) {
|
|
105
|
+
await loader.viteServer.close();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
loadConfigWithVite
|
|
111
|
+
};
|
package/dist/core/constants.js
CHANGED
package/dist/core/create-vite.js
CHANGED
|
@@ -63,7 +63,7 @@ async function createVite(commandConfig, { settings, logging, mode, fs = nodeFs
|
|
|
63
63
|
},
|
|
64
64
|
plugins: [
|
|
65
65
|
configAliasVitePlugin({ settings }),
|
|
66
|
-
astroLoadFallbackPlugin({ fs, settings }),
|
|
66
|
+
astroLoadFallbackPlugin({ fs, root: settings.config.root }),
|
|
67
67
|
astroVitePlugin({ settings, logging }),
|
|
68
68
|
astroScriptsPlugin({ settings }),
|
|
69
69
|
mode !== "build" && vitePluginAstroServer({ settings, logging, fs }),
|
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.10";
|
|
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.10";
|
|
51
51
|
const rootPath = site ? site.pathname : "/";
|
|
52
52
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
53
53
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
@@ -93,9 +93,8 @@ function resolveServerUrls({
|
|
|
93
93
|
let local = toDisplayUrl(localAddress);
|
|
94
94
|
let network = null;
|
|
95
95
|
if (networkLogging === "visible") {
|
|
96
|
-
const nodeVersion = Number(process.version.substring(1, process.version.indexOf(".", 5)));
|
|
97
96
|
const ipv4Networks = Object.values(os.networkInterfaces()).flatMap((networkInterface) => networkInterface ?? []).filter(
|
|
98
|
-
(networkInterface) => (networkInterface == null ? void 0 : networkInterface.address) && (networkInterface
|
|
97
|
+
(networkInterface) => (networkInterface == null ? void 0 : networkInterface.address) && (typeof networkInterface.family === "string" && networkInterface.family === "IPv4" || typeof networkInterface.family === "number" && networkInterface.family === 4)
|
|
99
98
|
);
|
|
100
99
|
for (let { address: ipv4Address } of ipv4Networks) {
|
|
101
100
|
if (ipv4Address.includes("127.0.0.1")) {
|
|
@@ -264,7 +263,7 @@ function printHelp({
|
|
|
264
263
|
message.push(
|
|
265
264
|
linebreak(),
|
|
266
265
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
267
|
-
`v${"1.6.
|
|
266
|
+
`v${"1.6.10"}`
|
|
268
267
|
)} ${headline}`
|
|
269
268
|
);
|
|
270
269
|
}
|
|
@@ -5,6 +5,7 @@ import { HTMLBytes } from '../escape.js';
|
|
|
5
5
|
export declare class AstroComponent {
|
|
6
6
|
private htmlParts;
|
|
7
7
|
private expressions;
|
|
8
|
+
private error;
|
|
8
9
|
constructor(htmlParts: TemplateStringsArray, expressions: any[]);
|
|
9
10
|
get [Symbol.toStringTag](): string;
|
|
10
11
|
[Symbol.asyncIterator](): AsyncGenerator<any, void, undefined>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { markHTMLString } from "../escape.js";
|
|
2
2
|
import { HydrationDirectiveProps } from "../hydration.js";
|
|
3
|
+
import { isPromise } from "../util.js";
|
|
3
4
|
import { renderChild } from "./any.js";
|
|
4
5
|
import { HTMLParts } from "./common.js";
|
|
5
6
|
function validateComponentProps(props, displayName) {
|
|
@@ -17,7 +18,18 @@ function validateComponentProps(props, displayName) {
|
|
|
17
18
|
class AstroComponent {
|
|
18
19
|
constructor(htmlParts, expressions) {
|
|
19
20
|
this.htmlParts = htmlParts;
|
|
20
|
-
this.
|
|
21
|
+
this.error = void 0;
|
|
22
|
+
this.expressions = expressions.map((expression) => {
|
|
23
|
+
if (isPromise(expression)) {
|
|
24
|
+
return Promise.resolve(expression).catch((err) => {
|
|
25
|
+
if (!this.error) {
|
|
26
|
+
this.error = err;
|
|
27
|
+
throw err;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return expression;
|
|
32
|
+
});
|
|
21
33
|
}
|
|
22
34
|
get [Symbol.toStringTag]() {
|
|
23
35
|
return "AstroComponent";
|
|
@@ -44,19 +44,20 @@ async function tagExportsWithRenderer({
|
|
|
44
44
|
},
|
|
45
45
|
ExportDeclaration: {
|
|
46
46
|
enter(path) {
|
|
47
|
-
var _a
|
|
47
|
+
var _a;
|
|
48
48
|
const node = path.node;
|
|
49
|
-
if (node
|
|
49
|
+
if (!t.isExportDefaultDeclaration(node))
|
|
50
50
|
return;
|
|
51
|
-
if ((
|
|
52
|
-
const
|
|
51
|
+
if (t.isArrowFunctionExpression(node.declaration) || t.isCallExpression(node.declaration)) {
|
|
52
|
+
const varName = t.isArrowFunctionExpression(node.declaration) ? "_arrow_function" : "_hoc_function";
|
|
53
|
+
const uidIdentifier = path.scope.generateUidIdentifier(varName);
|
|
53
54
|
path.insertBefore(
|
|
54
55
|
t.variableDeclaration("const", [
|
|
55
56
|
t.variableDeclarator(uidIdentifier, node.declaration)
|
|
56
57
|
])
|
|
57
58
|
);
|
|
58
59
|
node.declaration = uidIdentifier;
|
|
59
|
-
} else if ((
|
|
60
|
+
} else if (t.isFunctionDeclaration(node.declaration) && !((_a = node.declaration.id) == null ? void 0 : _a.name)) {
|
|
60
61
|
const uidIdentifier = path.scope.generateUidIdentifier("_function");
|
|
61
62
|
node.declaration.id = uidIdentifier;
|
|
62
63
|
}
|
|
@@ -66,13 +67,13 @@ async function tagExportsWithRenderer({
|
|
|
66
67
|
const node = path.node;
|
|
67
68
|
if (node.exportKind === "type")
|
|
68
69
|
return;
|
|
69
|
-
if (node
|
|
70
|
+
if (t.isExportAllDeclaration(node))
|
|
70
71
|
return;
|
|
71
72
|
const addTag = (id) => {
|
|
72
73
|
const tags = state.get("astro:tags") ?? [];
|
|
73
74
|
state.set("astro:tags", [...tags, id]);
|
|
74
75
|
};
|
|
75
|
-
if (node
|
|
76
|
+
if (t.isExportNamedDeclaration(node) || t.isExportDefaultDeclaration(node)) {
|
|
76
77
|
if (t.isIdentifier(node.declaration)) {
|
|
77
78
|
addTag(node.declaration.name);
|
|
78
79
|
} else if (t.isFunctionDeclaration(node.declaration) && ((_a = node.declaration.id) == null ? void 0 : _a.name)) {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import nodeFs from 'fs';
|
|
3
3
|
import type * as vite from 'vite';
|
|
4
|
-
import type { AstroSettings } from '../@types/astro';
|
|
5
4
|
declare type NodeFileSystemModule = typeof nodeFs;
|
|
6
5
|
export interface LoadFallbackPluginParams {
|
|
7
6
|
fs?: NodeFileSystemModule;
|
|
8
|
-
|
|
7
|
+
root: URL;
|
|
9
8
|
}
|
|
10
|
-
export default function loadFallbackPlugin({ fs,
|
|
9
|
+
export default function loadFallbackPlugin({ fs, root, }: LoadFallbackPluginParams): vite.Plugin[] | false;
|
|
11
10
|
export {};
|
|
@@ -3,7 +3,7 @@ import npath from "path";
|
|
|
3
3
|
import slashify from "slash";
|
|
4
4
|
function loadFallbackPlugin({
|
|
5
5
|
fs,
|
|
6
|
-
|
|
6
|
+
root
|
|
7
7
|
}) {
|
|
8
8
|
if (!fs || fs === nodeFs) {
|
|
9
9
|
return false;
|
|
@@ -16,7 +16,7 @@ function loadFallbackPlugin({
|
|
|
16
16
|
return await fs.promises.readFile(id, "utf-8");
|
|
17
17
|
} catch (e2) {
|
|
18
18
|
try {
|
|
19
|
-
const fullpath = new URL("." + id,
|
|
19
|
+
const fullpath = new URL("." + id, root);
|
|
20
20
|
return await fs.promises.readFile(fullpath, "utf-8");
|
|
21
21
|
} catch (e3) {
|
|
22
22
|
}
|
|
@@ -28,15 +28,21 @@ function loadFallbackPlugin({
|
|
|
28
28
|
name: "astro:load-fallback",
|
|
29
29
|
enforce: "post",
|
|
30
30
|
async resolveId(id, parent) {
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
if (parent) {
|
|
32
|
+
const candidateId = npath.posix.join(npath.posix.dirname(parent), id);
|
|
33
|
+
try {
|
|
34
|
+
const stats = await fs.promises.stat(candidateId);
|
|
35
|
+
if (!stats.isDirectory()) {
|
|
36
|
+
return candidateId;
|
|
37
|
+
}
|
|
38
|
+
} catch {
|
|
37
39
|
}
|
|
38
|
-
return slashify(id);
|
|
39
40
|
}
|
|
41
|
+
let resolved = await this.resolve(id, parent, { skipSelf: true });
|
|
42
|
+
if (resolved) {
|
|
43
|
+
return resolved.id;
|
|
44
|
+
}
|
|
45
|
+
return slashify(id);
|
|
40
46
|
},
|
|
41
47
|
async load(id) {
|
|
42
48
|
const source = await tryLoadModule(id);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.10",
|
|
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",
|
|
@@ -98,11 +98,11 @@
|
|
|
98
98
|
"@babel/plugin-transform-react-jsx": "^7.17.12",
|
|
99
99
|
"@babel/traverse": "^7.18.2",
|
|
100
100
|
"@babel/types": "^7.18.4",
|
|
101
|
-
"@proload/core": "^0.3.3",
|
|
102
|
-
"@proload/plugin-tsm": "^0.2.1",
|
|
103
101
|
"@types/babel__core": "^7.1.19",
|
|
104
102
|
"@types/html-escaper": "^3.0.0",
|
|
105
103
|
"@types/yargs-parser": "^21.0.0",
|
|
104
|
+
"@proload/core": "^0.3.3",
|
|
105
|
+
"@proload/plugin-tsm": "^0.2.1",
|
|
106
106
|
"boxen": "^6.2.1",
|
|
107
107
|
"ci-info": "^3.3.1",
|
|
108
108
|
"common-ancestor-path": "^1.0.1",
|
|
@@ -144,8 +144,8 @@
|
|
|
144
144
|
"typescript": "*",
|
|
145
145
|
"unist-util-visit": "^4.1.0",
|
|
146
146
|
"vfile": "^5.3.2",
|
|
147
|
-
"vite": "~3.2.
|
|
148
|
-
"vitefu": "^0.2.
|
|
147
|
+
"vite": "~3.2.4",
|
|
148
|
+
"vitefu": "^0.2.1",
|
|
149
149
|
"yargs-parser": "^21.0.1",
|
|
150
150
|
"zod": "^3.17.3"
|
|
151
151
|
},
|