astro 1.2.4 → 1.2.5
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 -0
- package/dist/core/app/index.js +9 -1
- package/dist/core/build/generate.js +1 -1
- package/dist/core/build/vite-plugin-ssr.js +1 -1
- package/dist/core/config.js +13 -0
- package/dist/core/dev/index.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/util.js +1 -1
- package/dist/runtime/server/astro-global.js +1 -1
- package/dist/runtime/server/astro-island.js +4 -1
- package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
- package/dist/runtime/server/astro-island.prebuilt.js +1 -1
- package/dist/runtime/server/hydration.js +4 -1
- package/dist/vite-plugin-config-alias/index.js +7 -12
- package/dist/vite-plugin-jsx/index.js +5 -0
- package/package.json +1 -1
package/dist/@types/astro.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import type { MarkdownHeading, MarkdownMetadata, MarkdownRenderingResult, RehypePlugins, RemarkPlugins, RemarkRehype, ShikiConfig } from '@astrojs/markdown-remark';
|
|
4
4
|
import type * as babel from '@babel/core';
|
|
5
5
|
import type { AddressInfo } from 'net';
|
|
6
|
+
import type { TsConfigJson } from 'tsconfig-resolver';
|
|
6
7
|
import type * as vite from 'vite';
|
|
7
8
|
import { z } from 'zod';
|
|
8
9
|
import type { SerializedSSRManifest } from '../core/app/types';
|
|
@@ -803,6 +804,8 @@ export interface InjectedRoute {
|
|
|
803
804
|
export interface AstroConfig extends z.output<typeof AstroConfigSchema> {
|
|
804
805
|
integrations: AstroIntegration[];
|
|
805
806
|
_ctx: {
|
|
807
|
+
tsConfig: TsConfigJson | undefined;
|
|
808
|
+
tsConfigPath: string | undefined;
|
|
806
809
|
pageExtensions: string[];
|
|
807
810
|
injectedRoutes: InjectedRoute[];
|
|
808
811
|
adapter: AstroAdapter | undefined;
|
package/dist/core/app/index.js
CHANGED
|
@@ -156,7 +156,15 @@ renderPage_fn = async function(request, routeData, mod, status = 200) {
|
|
|
156
156
|
throw new Error(`Unable to resolve [${specifier}]`);
|
|
157
157
|
}
|
|
158
158
|
const bundlePath = manifest.entryModules[specifier];
|
|
159
|
-
|
|
159
|
+
switch (true) {
|
|
160
|
+
case bundlePath.startsWith("data:"):
|
|
161
|
+
case bundlePath.length === 0: {
|
|
162
|
+
return bundlePath;
|
|
163
|
+
}
|
|
164
|
+
default: {
|
|
165
|
+
return prependForwardSlash(joinPaths(manifest.base, bundlePath));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
160
168
|
},
|
|
161
169
|
route: routeData,
|
|
162
170
|
routeCache: __privateGet(this, _routeCache),
|
|
@@ -246,7 +246,7 @@ async function generatePath(pathname, opts, gopts) {
|
|
|
246
246
|
const hashedFilePath = internals.entrySpecifierToBundleMap.get(specifier);
|
|
247
247
|
if (typeof hashedFilePath !== "string") {
|
|
248
248
|
if (specifier === BEFORE_HYDRATION_SCRIPT_ID) {
|
|
249
|
-
return "
|
|
249
|
+
return "";
|
|
250
250
|
}
|
|
251
251
|
throw new Error(`Cannot find the built path for ${specifier}`);
|
|
252
252
|
}
|
|
@@ -119,7 +119,7 @@ function buildManifest(opts, internals, staticFiles) {
|
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
121
|
if (!(BEFORE_HYDRATION_SCRIPT_ID in entryModules)) {
|
|
122
|
-
entryModules[BEFORE_HYDRATION_SCRIPT_ID] = "
|
|
122
|
+
entryModules[BEFORE_HYDRATION_SCRIPT_ID] = "";
|
|
123
123
|
}
|
|
124
124
|
const ssrManifest = {
|
|
125
125
|
adapterName: opts.astroConfig._ctx.adapter.name,
|
package/dist/core/config.js
CHANGED
|
@@ -5,6 +5,7 @@ import * as colors from "kleur/colors";
|
|
|
5
5
|
import path from "path";
|
|
6
6
|
import postcssrc from "postcss-load-config";
|
|
7
7
|
import { BUNDLED_THEMES } from "shiki";
|
|
8
|
+
import * as tsr from "tsconfig-resolver";
|
|
8
9
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
9
10
|
import * as vite from "vite";
|
|
10
11
|
import { mergeConfig as mergeViteConfig } from "vite";
|
|
@@ -203,10 +204,13 @@ See https://astro.build/config for more information.`
|
|
|
203
204
|
)
|
|
204
205
|
}).optional().default({})
|
|
205
206
|
});
|
|
207
|
+
const tsconfig = loadTSConfig(root);
|
|
206
208
|
const result = {
|
|
207
209
|
...await AstroConfigRelativeSchema.parseAsync(userConfig),
|
|
208
210
|
_ctx: {
|
|
209
211
|
pageExtensions: [".astro", ".md", ".html"],
|
|
212
|
+
tsConfig: tsconfig == null ? void 0 : tsconfig.config,
|
|
213
|
+
tsConfigPath: tsconfig == null ? void 0 : tsconfig.path,
|
|
210
214
|
scripts: [],
|
|
211
215
|
renderers: [jsxRenderer],
|
|
212
216
|
injectedRoutes: [],
|
|
@@ -346,6 +350,15 @@ async function tryLoadConfig(configOptions, flags, root) {
|
|
|
346
350
|
await finallyCleanup();
|
|
347
351
|
}
|
|
348
352
|
}
|
|
353
|
+
function loadTSConfig(cwd) {
|
|
354
|
+
for (const searchName of ["tsconfig.json", "jsconfig.json"]) {
|
|
355
|
+
const config = tsr.tsconfigResolverSync({ cwd, searchName });
|
|
356
|
+
if (config.exists) {
|
|
357
|
+
return config;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return void 0;
|
|
361
|
+
}
|
|
349
362
|
async function loadConfig(configOptions) {
|
|
350
363
|
const root = resolveRoot(configOptions.cwd);
|
|
351
364
|
const flags = resolveFlags(configOptions.flags || {});
|
package/dist/core/dev/index.js
CHANGED
package/dist/core/messages.js
CHANGED
|
@@ -47,7 +47,7 @@ function devStart({
|
|
|
47
47
|
site,
|
|
48
48
|
isRestart = false
|
|
49
49
|
}) {
|
|
50
|
-
const version = "1.2.
|
|
50
|
+
const version = "1.2.5";
|
|
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.
|
|
229
|
+
`v${"1.2.5"}`
|
|
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.
|
|
8
|
+
const ASTRO_VERSION = "1.2.5";
|
|
9
9
|
function isObject(value) {
|
|
10
10
|
return typeof value === "object" && value != null;
|
|
11
11
|
}
|
|
@@ -63,7 +63,10 @@ var _a;
|
|
|
63
63
|
}
|
|
64
64
|
async childrenConnectedCallback() {
|
|
65
65
|
window.addEventListener("astro:hydrate", this.hydrate);
|
|
66
|
-
|
|
66
|
+
let beforeHydrationUrl = this.getAttribute("before-hydration-url");
|
|
67
|
+
if (beforeHydrationUrl) {
|
|
68
|
+
await import(beforeHydrationUrl);
|
|
69
|
+
}
|
|
67
70
|
this.start();
|
|
68
71
|
}
|
|
69
72
|
start() {
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Do not edit this directly, but instead edit that file and rerun the prebuild
|
|
4
4
|
* to generate this file.
|
|
5
5
|
*/
|
|
6
|
-
declare const _default: "var l;{const c={0:t=>t,1:t=>JSON.parse(t,o),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,o)),5:t=>new Set(JSON.parse(t,o)),6:t=>BigInt(t),7:t=>new URL(t)},o=(t,
|
|
6
|
+
declare const _default: "var l;{const c={0:t=>t,1:t=>JSON.parse(t,o),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,o)),5:t=>new Set(JSON.parse(t,o)),6:t=>BigInt(t),7:t=>new URL(t)},o=(t,s)=>{if(t===\"\"||!Array.isArray(s))return s;const[e,n]=s;return e in c?c[e](n):void 0};customElements.get(\"astro-island\")||customElements.define(\"astro-island\",(l=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=()=>{if(!this.hydrator||this.parentElement&&this.parentElement.closest(\"astro-island[ssr]\"))return;const s=this.querySelectorAll(\"astro-slot\"),e={},n=this.querySelectorAll(\"template[data-astro-template]\");for(const r of n){const i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute(\"data-astro-template\")||\"default\"]=r.innerHTML,r.remove())}for(const r of s){const i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute(\"name\")||\"default\"]=r.innerHTML)}const a=this.hasAttribute(\"props\")?JSON.parse(this.getAttribute(\"props\"),o):{};this.hydrator(this)(this.Component,a,e,{client:this.getAttribute(\"client\")}),this.removeAttribute(\"ssr\"),window.removeEventListener(\"astro:hydrate\",this.hydrate),window.dispatchEvent(new CustomEvent(\"astro:hydrate\"))}}connectedCallback(){!this.hasAttribute(\"await-children\")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((s,e)=>{e.disconnect(),this.childrenConnectedCallback()}).observe(this,{childList:!0})}async childrenConnectedCallback(){window.addEventListener(\"astro:hydrate\",this.hydrate);let s=this.getAttribute(\"before-hydration-url\");s&&await import(s),this.start()}start(){const s=JSON.parse(this.getAttribute(\"opts\")),e=this.getAttribute(\"client\");if(Astro[e]===void 0){window.addEventListener(`astro:${e}`,()=>this.start(),{once:!0});return}Astro[e](async()=>{const n=this.getAttribute(\"renderer-url\"),[a,{default:r}]=await Promise.all([import(this.getAttribute(\"component-url\")),n?import(n):()=>()=>{}]),i=this.getAttribute(\"component-export\")||\"default\";if(!i.includes(\".\"))this.Component=a[i];else{this.Component=a;for(const d of i.split(\".\"))this.Component=this.Component[d]}return this.hydrator=r,this.hydrate},s,this)}attributeChangedCallback(){this.hydrator&&this.hydrate()}},l.observedAttributes=[\"props\"],l))}";
|
|
7
7
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var astro_island_prebuilt_default = `var l;{const c={0:t=>t,1:t=>JSON.parse(t,o),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,o)),5:t=>new Set(JSON.parse(t,o)),6:t=>BigInt(t),7:t=>new URL(t)},o=(t,
|
|
1
|
+
var astro_island_prebuilt_default = `var l;{const c={0:t=>t,1:t=>JSON.parse(t,o),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,o)),5:t=>new Set(JSON.parse(t,o)),6:t=>BigInt(t),7:t=>new URL(t)},o=(t,s)=>{if(t===""||!Array.isArray(s))return s;const[e,n]=s;return e in c?c[e](n):void 0};customElements.get("astro-island")||customElements.define("astro-island",(l=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=()=>{if(!this.hydrator||this.parentElement&&this.parentElement.closest("astro-island[ssr]"))return;const s=this.querySelectorAll("astro-slot"),e={},n=this.querySelectorAll("template[data-astro-template]");for(const r of n){const i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(const r of s){const i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute("name")||"default"]=r.innerHTML)}const a=this.hasAttribute("props")?JSON.parse(this.getAttribute("props"),o):{};this.hydrator(this)(this.Component,a,e,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),window.removeEventListener("astro:hydrate",this.hydrate),window.dispatchEvent(new CustomEvent("astro:hydrate"))}}connectedCallback(){!this.hasAttribute("await-children")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((s,e)=>{e.disconnect(),this.childrenConnectedCallback()}).observe(this,{childList:!0})}async childrenConnectedCallback(){window.addEventListener("astro:hydrate",this.hydrate);let s=this.getAttribute("before-hydration-url");s&&await import(s),this.start()}start(){const s=JSON.parse(this.getAttribute("opts")),e=this.getAttribute("client");if(Astro[e]===void 0){window.addEventListener(\`astro:\${e}\`,()=>this.start(),{once:!0});return}Astro[e](async()=>{const n=this.getAttribute("renderer-url"),[a,{default:r}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),i=this.getAttribute("component-export")||"default";if(!i.includes("."))this.Component=a[i];else{this.Component=a;for(const d of i.split("."))this.Component=this.Component[d]}return this.hydrator=r,this.hydrate},s,this)}attributeChangedCallback(){this.hydrator&&this.hydrate()}},l.observedAttributes=["props"],l))}`;
|
|
2
2
|
export {
|
|
3
3
|
astro_island_prebuilt_default as default
|
|
4
4
|
};
|
|
@@ -93,7 +93,10 @@ async function generateHydrateScript(scriptOptions, metadata) {
|
|
|
93
93
|
}
|
|
94
94
|
island.props["ssr"] = "";
|
|
95
95
|
island.props["client"] = hydrate;
|
|
96
|
-
|
|
96
|
+
let beforeHydrationUrl = await result.resolve("astro:scripts/before-hydration.js");
|
|
97
|
+
if (beforeHydrationUrl.length) {
|
|
98
|
+
island.props["before-hydration-url"] = beforeHydrationUrl;
|
|
99
|
+
}
|
|
97
100
|
island.props["opts"] = escapeHTML(
|
|
98
101
|
JSON.stringify({
|
|
99
102
|
name: metadata.displayName,
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import * as path from "path";
|
|
2
|
-
import * as tsr from "tsconfig-resolver";
|
|
3
|
-
import * as url from "url";
|
|
4
2
|
const normalize = (pathname) => String(pathname).split(path.sep).join(path.posix.sep);
|
|
5
|
-
const
|
|
6
|
-
const config =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const getConfigAlias = (cwd) => {
|
|
10
|
-
const config = getExistingConfig("tsconfig.json", cwd) || getExistingConfig("jsconfig.json", cwd);
|
|
11
|
-
if (!config)
|
|
3
|
+
const getConfigAlias = (astroConfig) => {
|
|
4
|
+
const config = astroConfig._ctx.tsConfig;
|
|
5
|
+
const configPath = astroConfig._ctx.tsConfigPath;
|
|
6
|
+
if (!config || !configPath)
|
|
12
7
|
return null;
|
|
13
|
-
const compilerOptions = Object(config.
|
|
8
|
+
const compilerOptions = Object(config.compilerOptions);
|
|
14
9
|
if (!compilerOptions.baseUrl)
|
|
15
10
|
return null;
|
|
16
11
|
const baseUrl = path.posix.resolve(
|
|
17
|
-
path.posix.dirname(normalize(
|
|
12
|
+
path.posix.dirname(normalize(configPath).replace(/^\/?/, "/")),
|
|
18
13
|
normalize(compilerOptions.baseUrl)
|
|
19
14
|
);
|
|
20
15
|
const aliases = [];
|
|
@@ -42,7 +37,7 @@ const getConfigAlias = (cwd) => {
|
|
|
42
37
|
function configAliasVitePlugin({
|
|
43
38
|
config: astroConfig
|
|
44
39
|
}) {
|
|
45
|
-
const configAlias = getConfigAlias(astroConfig
|
|
40
|
+
const configAlias = getConfigAlias(astroConfig);
|
|
46
41
|
if (!configAlias)
|
|
47
42
|
return {};
|
|
48
43
|
return {
|
|
@@ -124,6 +124,7 @@ function jsx({ config, logging }) {
|
|
|
124
124
|
defaultJSXRendererEntry = [...jsxRenderersIntegrationOnly.entries()][0];
|
|
125
125
|
},
|
|
126
126
|
async transform(code, id, opts) {
|
|
127
|
+
var _a;
|
|
127
128
|
const ssr = Boolean(opts == null ? void 0 : opts.ssr);
|
|
128
129
|
if (!JSX_EXTENSIONS.has(path.extname(id))) {
|
|
129
130
|
return null;
|
|
@@ -163,6 +164,10 @@ function jsx({ config, logging }) {
|
|
|
163
164
|
if (!importSource && IMPORT_KEYWORD_REGEX.test(code)) {
|
|
164
165
|
importSource = await detectImportSourceFromImports(code, id, jsxRenderers);
|
|
165
166
|
}
|
|
167
|
+
if (!importSource) {
|
|
168
|
+
const compilerOptions = (_a = config._ctx.tsConfig) == null ? void 0 : _a.compilerOptions;
|
|
169
|
+
importSource = compilerOptions == null ? void 0 : compilerOptions.jsxImportSource;
|
|
170
|
+
}
|
|
166
171
|
if (!importSource && defaultJSXRendererEntry) {
|
|
167
172
|
const [defaultRendererName] = defaultJSXRendererEntry;
|
|
168
173
|
error(
|