astro 4.5.16 → 4.5.18

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/astro-jsx.d.ts CHANGED
@@ -873,6 +873,8 @@ declare namespace astroHTML.JSX {
873
873
  playsinline?: boolean | string | undefined | null;
874
874
  preload?: string | undefined | null;
875
875
  src?: string | undefined | null;
876
+ // https://www.w3.org/TR/remote-playback/#the-disableremoteplayback-attribute
877
+ disableRemotePlayback?: boolean | string | undefined | null;
876
878
  }
877
879
 
878
880
  interface MetaHTMLAttributes extends HTMLAttributes {
@@ -2330,9 +2330,9 @@ export interface AstroRenderer {
2330
2330
  clientEntrypoint?: string;
2331
2331
  /** Import entrypoint for the server/build/ssr renderer. */
2332
2332
  serverEntrypoint: string;
2333
- /** JSX identifier (e.g. 'react' or 'solid-js') */
2333
+ /** @deprecated Vite plugins should transform the JSX instead */
2334
2334
  jsxImportSource?: string;
2335
- /** Babel transform options */
2335
+ /** @deprecated Vite plugins should transform the JSX instead */
2336
2336
  jsxTransformOptions?: JSXTransformFn;
2337
2337
  }
2338
2338
  export interface SSRLoadedRenderer extends AstroRenderer {
@@ -11,7 +11,7 @@ export declare const visit: {
11
11
  node: (node: traverse.Node, opts: traverse.TraverseOptions<traverse.Node>, scope?: traverse.Scope | undefined, state?: any, path?: traverse.NodePath<traverse.Node> | undefined, skipKeys?: Record<string, boolean> | undefined) => void;
12
12
  clearNode: (node: traverse.Node, opts?: traverse.RemovePropertiesOptions | undefined) => void;
13
13
  removeProperties: (tree: traverse.Node, opts?: traverse.RemovePropertiesOptions | undefined) => traverse.Node;
14
- hasType: (tree: traverse.Node, type: "CatchClause" | "ClassBody" | "Identifier" | "Program" | "SpreadElement" | "Super" | "SwitchCase" | "TemplateElement" | "VariableDeclarator" | "ArrayExpression" | "ArrowFunctionExpression" | "AssignmentExpression" | "AwaitExpression" | "BinaryExpression" | "CallExpression" | "ClassExpression" | "ConditionalExpression" | "FunctionExpression" | "ImportExpression" | "LogicalExpression" | "MemberExpression" | "MetaProperty" | "NewExpression" | "ObjectExpression" | "SequenceExpression" | "TaggedTemplateExpression" | "TemplateLiteral" | "ThisExpression" | "UnaryExpression" | "UpdateExpression" | "YieldExpression" | "ClassDeclaration" | "FunctionDeclaration" | "ImportDeclaration" | "ExportNamedDeclaration" | "ExportDefaultDeclaration" | "ExportAllDeclaration" | "ImportSpecifier" | "ImportDefaultSpecifier" | "ImportNamespaceSpecifier" | "ExportSpecifier" | "ObjectPattern" | "ArrayPattern" | "RestElement" | "AssignmentPattern" | "ExpressionStatement" | "BlockStatement" | "StaticBlock" | "EmptyStatement" | "DebuggerStatement" | "WithStatement" | "ReturnStatement" | "LabeledStatement" | "BreakStatement" | "ContinueStatement" | "IfStatement" | "SwitchStatement" | "ThrowStatement" | "TryStatement" | "WhileStatement" | "DoWhileStatement" | "ForStatement" | "ForInStatement" | "ForOfStatement" | "VariableDeclaration" | "File" | "AnyTypeAnnotation" | "ArgumentPlaceholder" | "ArrayTypeAnnotation" | "BigIntLiteral" | "BindExpression" | "BooleanLiteral" | "BooleanLiteralTypeAnnotation" | "BooleanTypeAnnotation" | "ClassAccessorProperty" | "ClassImplements" | "ClassMethod" | "ClassPrivateMethod" | "ClassPrivateProperty" | "ClassProperty" | "DecimalLiteral" | "DeclareClass" | "DeclareExportAllDeclaration" | "DeclareExportDeclaration" | "DeclareFunction" | "DeclareInterface" | "DeclareModule" | "DeclareModuleExports" | "DeclareOpaqueType" | "DeclareTypeAlias" | "DeclareVariable" | "DeclaredPredicate" | "Decorator" | "Directive" | "DirectiveLiteral" | "DoExpression" | "EmptyTypeAnnotation" | "EnumBooleanBody" | "EnumBooleanMember" | "EnumDeclaration" | "EnumDefaultedMember" | "EnumNumberBody" | "EnumNumberMember" | "EnumStringBody" | "EnumStringMember" | "EnumSymbolBody" | "ExistsTypeAnnotation" | "ExportDefaultSpecifier" | "ExportNamespaceSpecifier" | "FunctionTypeAnnotation" | "FunctionTypeParam" | "GenericTypeAnnotation" | "Import" | "ImportAttribute" | "IndexedAccessType" | "InferredPredicate" | "InterfaceDeclaration" | "InterfaceExtends" | "InterfaceTypeAnnotation" | "InterpreterDirective" | "IntersectionTypeAnnotation" | "JSXAttribute" | "JSXClosingElement" | "JSXClosingFragment" | "JSXElement" | "JSXEmptyExpression" | "JSXExpressionContainer" | "JSXFragment" | "JSXIdentifier" | "JSXMemberExpression" | "JSXNamespacedName" | "JSXOpeningElement" | "JSXOpeningFragment" | "JSXSpreadAttribute" | "JSXSpreadChild" | "JSXText" | "MixedTypeAnnotation" | "ModuleExpression" | "Noop" | "NullLiteral" | "NullLiteralTypeAnnotation" | "NullableTypeAnnotation" | "NumberLiteral" | "NumberLiteralTypeAnnotation" | "NumberTypeAnnotation" | "NumericLiteral" | "ObjectMethod" | "ObjectProperty" | "ObjectTypeAnnotation" | "ObjectTypeCallProperty" | "ObjectTypeIndexer" | "ObjectTypeInternalSlot" | "ObjectTypeProperty" | "ObjectTypeSpreadProperty" | "OpaqueType" | "OptionalCallExpression" | "OptionalIndexedAccessType" | "OptionalMemberExpression" | "ParenthesizedExpression" | "PipelineBareFunction" | "PipelinePrimaryTopicReference" | "PipelineTopicExpression" | "Placeholder" | "PrivateName" | "QualifiedTypeIdentifier" | "RecordExpression" | "RegExpLiteral" | "RegexLiteral" | "RestProperty" | "SpreadProperty" | "StringLiteral" | "StringLiteralTypeAnnotation" | "StringTypeAnnotation" | "SymbolTypeAnnotation" | "TSAnyKeyword" | "TSArrayType" | "TSAsExpression" | "TSBigIntKeyword" | "TSBooleanKeyword" | "TSCallSignatureDeclaration" | "TSConditionalType" | "TSConstructSignatureDeclaration" | "TSConstructorType" | "TSDeclareFunction" | "TSDeclareMethod" | "TSEnumDeclaration" | "TSEnumMember" | "TSExportAssignment" | "TSExpressionWithTypeArguments" | "TSExternalModuleReference" | "TSFunctionType" | "TSImportEqualsDeclaration" | "TSImportType" | "TSIndexSignature" | "TSIndexedAccessType" | "TSInferType" | "TSInstantiationExpression" | "TSInterfaceBody" | "TSInterfaceDeclaration" | "TSIntersectionType" | "TSIntrinsicKeyword" | "TSLiteralType" | "TSMappedType" | "TSMethodSignature" | "TSModuleBlock" | "TSModuleDeclaration" | "TSNamedTupleMember" | "TSNamespaceExportDeclaration" | "TSNeverKeyword" | "TSNonNullExpression" | "TSNullKeyword" | "TSNumberKeyword" | "TSObjectKeyword" | "TSOptionalType" | "TSParameterProperty" | "TSParenthesizedType" | "TSPropertySignature" | "TSQualifiedName" | "TSRestType" | "TSSatisfiesExpression" | "TSStringKeyword" | "TSSymbolKeyword" | "TSThisType" | "TSTupleType" | "TSTypeAliasDeclaration" | "TSTypeAnnotation" | "TSTypeAssertion" | "TSTypeLiteral" | "TSTypeOperator" | "TSTypeParameter" | "TSTypeParameterDeclaration" | "TSTypeParameterInstantiation" | "TSTypePredicate" | "TSTypeQuery" | "TSTypeReference" | "TSUndefinedKeyword" | "TSUnionType" | "TSUnknownKeyword" | "TSVoidKeyword" | "ThisTypeAnnotation" | "TopicReference" | "TupleExpression" | "TupleTypeAnnotation" | "TypeAlias" | "TypeAnnotation" | "TypeCastExpression" | "TypeParameter" | "TypeParameterDeclaration" | "TypeParameterInstantiation" | "TypeofTypeAnnotation" | "UnionTypeAnnotation" | "V8IntrinsicIdentifier" | "Variance" | "VoidTypeAnnotation", denylistTypes?: string[] | undefined) => boolean;
14
+ hasType: (tree: traverse.Node, type: "CatchClause" | "ClassBody" | "Identifier" | "Program" | "SpreadElement" | "Super" | "SwitchCase" | "TemplateElement" | "VariableDeclarator" | "ArrayExpression" | "ArrowFunctionExpression" | "AssignmentExpression" | "AwaitExpression" | "BinaryExpression" | "CallExpression" | "ClassExpression" | "ConditionalExpression" | "FunctionExpression" | "ImportExpression" | "LogicalExpression" | "MemberExpression" | "MetaProperty" | "NewExpression" | "ObjectExpression" | "SequenceExpression" | "TaggedTemplateExpression" | "TemplateLiteral" | "ThisExpression" | "UnaryExpression" | "UpdateExpression" | "YieldExpression" | "ClassDeclaration" | "FunctionDeclaration" | "ImportDeclaration" | "ExportNamedDeclaration" | "ExportDefaultDeclaration" | "ExportAllDeclaration" | "ImportSpecifier" | "ImportDefaultSpecifier" | "ImportNamespaceSpecifier" | "ExportSpecifier" | "ObjectPattern" | "ArrayPattern" | "RestElement" | "AssignmentPattern" | "ExpressionStatement" | "BlockStatement" | "StaticBlock" | "EmptyStatement" | "DebuggerStatement" | "WithStatement" | "ReturnStatement" | "LabeledStatement" | "BreakStatement" | "ContinueStatement" | "IfStatement" | "SwitchStatement" | "ThrowStatement" | "TryStatement" | "WhileStatement" | "DoWhileStatement" | "ForStatement" | "ForInStatement" | "ForOfStatement" | "VariableDeclaration" | "File" | "JSXAttribute" | "JSXSpreadAttribute" | "JSXIdentifier" | "JSXNamespacedName" | "JSXElement" | "JSXOpeningElement" | "JSXMemberExpression" | "AnyTypeAnnotation" | "ArgumentPlaceholder" | "ArrayTypeAnnotation" | "BigIntLiteral" | "BindExpression" | "BooleanLiteral" | "BooleanLiteralTypeAnnotation" | "BooleanTypeAnnotation" | "ClassAccessorProperty" | "ClassImplements" | "ClassMethod" | "ClassPrivateMethod" | "ClassPrivateProperty" | "ClassProperty" | "DecimalLiteral" | "DeclareClass" | "DeclareExportAllDeclaration" | "DeclareExportDeclaration" | "DeclareFunction" | "DeclareInterface" | "DeclareModule" | "DeclareModuleExports" | "DeclareOpaqueType" | "DeclareTypeAlias" | "DeclareVariable" | "DeclaredPredicate" | "Decorator" | "Directive" | "DirectiveLiteral" | "DoExpression" | "EmptyTypeAnnotation" | "EnumBooleanBody" | "EnumBooleanMember" | "EnumDeclaration" | "EnumDefaultedMember" | "EnumNumberBody" | "EnumNumberMember" | "EnumStringBody" | "EnumStringMember" | "EnumSymbolBody" | "ExistsTypeAnnotation" | "ExportDefaultSpecifier" | "ExportNamespaceSpecifier" | "FunctionTypeAnnotation" | "FunctionTypeParam" | "GenericTypeAnnotation" | "Import" | "ImportAttribute" | "IndexedAccessType" | "InferredPredicate" | "InterfaceDeclaration" | "InterfaceExtends" | "InterfaceTypeAnnotation" | "InterpreterDirective" | "IntersectionTypeAnnotation" | "JSXClosingElement" | "JSXClosingFragment" | "JSXEmptyExpression" | "JSXExpressionContainer" | "JSXFragment" | "JSXOpeningFragment" | "JSXSpreadChild" | "JSXText" | "MixedTypeAnnotation" | "ModuleExpression" | "Noop" | "NullLiteral" | "NullLiteralTypeAnnotation" | "NullableTypeAnnotation" | "NumberLiteral" | "NumberLiteralTypeAnnotation" | "NumberTypeAnnotation" | "NumericLiteral" | "ObjectMethod" | "ObjectProperty" | "ObjectTypeAnnotation" | "ObjectTypeCallProperty" | "ObjectTypeIndexer" | "ObjectTypeInternalSlot" | "ObjectTypeProperty" | "ObjectTypeSpreadProperty" | "OpaqueType" | "OptionalCallExpression" | "OptionalIndexedAccessType" | "OptionalMemberExpression" | "ParenthesizedExpression" | "PipelineBareFunction" | "PipelinePrimaryTopicReference" | "PipelineTopicExpression" | "Placeholder" | "PrivateName" | "QualifiedTypeIdentifier" | "RecordExpression" | "RegExpLiteral" | "RegexLiteral" | "RestProperty" | "SpreadProperty" | "StringLiteral" | "StringLiteralTypeAnnotation" | "StringTypeAnnotation" | "SymbolTypeAnnotation" | "TSAnyKeyword" | "TSArrayType" | "TSAsExpression" | "TSBigIntKeyword" | "TSBooleanKeyword" | "TSCallSignatureDeclaration" | "TSConditionalType" | "TSConstructSignatureDeclaration" | "TSConstructorType" | "TSDeclareFunction" | "TSDeclareMethod" | "TSEnumDeclaration" | "TSEnumMember" | "TSExportAssignment" | "TSExpressionWithTypeArguments" | "TSExternalModuleReference" | "TSFunctionType" | "TSImportEqualsDeclaration" | "TSImportType" | "TSIndexSignature" | "TSIndexedAccessType" | "TSInferType" | "TSInstantiationExpression" | "TSInterfaceBody" | "TSInterfaceDeclaration" | "TSIntersectionType" | "TSIntrinsicKeyword" | "TSLiteralType" | "TSMappedType" | "TSMethodSignature" | "TSModuleBlock" | "TSModuleDeclaration" | "TSNamedTupleMember" | "TSNamespaceExportDeclaration" | "TSNeverKeyword" | "TSNonNullExpression" | "TSNullKeyword" | "TSNumberKeyword" | "TSObjectKeyword" | "TSOptionalType" | "TSParameterProperty" | "TSParenthesizedType" | "TSPropertySignature" | "TSQualifiedName" | "TSRestType" | "TSSatisfiesExpression" | "TSStringKeyword" | "TSSymbolKeyword" | "TSThisType" | "TSTupleType" | "TSTypeAliasDeclaration" | "TSTypeAnnotation" | "TSTypeAssertion" | "TSTypeLiteral" | "TSTypeOperator" | "TSTypeParameter" | "TSTypeParameterDeclaration" | "TSTypeParameterInstantiation" | "TSTypePredicate" | "TSTypeQuery" | "TSTypeReference" | "TSUndefinedKeyword" | "TSUnionType" | "TSUnknownKeyword" | "TSVoidKeyword" | "ThisTypeAnnotation" | "TopicReference" | "TupleExpression" | "TupleTypeAnnotation" | "TypeAlias" | "TypeAnnotation" | "TypeCastExpression" | "TypeParameter" | "TypeParameterDeclaration" | "TypeParameterInstantiation" | "TypeofTypeAnnotation" | "UnionTypeAnnotation" | "V8IntrinsicIdentifier" | "Variance" | "VoidTypeAnnotation", denylistTypes?: string[] | undefined) => boolean;
15
15
  cache: typeof traverse.cache;
16
16
  };
17
17
  export { t };
@@ -250,7 +250,7 @@ async function getPathsForRoute(route, mod, pipeline, builtPaths) {
250
250
  logger,
251
251
  ssr: serverLike
252
252
  }).catch((err) => {
253
- logger.debug("build", `\u251C\u2500\u2500 ${bold(red("\u2717"))} ${route.component}`);
253
+ logger.error("build", `Failed to call getStaticPaths for ${route.component}`);
254
254
  throw err;
255
255
  });
256
256
  const label = staticPaths.length === 1 ? "page" : "pages";
@@ -40,7 +40,6 @@ function vitePluginPrerender(opts, internals) {
40
40
  }
41
41
  }
42
42
  }
43
- opts.allPages;
44
43
  pageInfo.hasSharedModules = hasSharedModules;
45
44
  pageInfo.route.prerender = true;
46
45
  return "prerender";
@@ -54,6 +53,9 @@ function vitePluginPrerender(opts, internals) {
54
53
  };
55
54
  }
56
55
  function pluginPrerender(opts, internals) {
56
+ if (opts.settings.config.output === "static") {
57
+ return { targets: ["server"] };
58
+ }
57
59
  return {
58
60
  targets: ["server"],
59
61
  hooks: {
@@ -7,10 +7,19 @@ function vitePluginScripts(internals) {
7
7
  assetInlineLimit = config.build.assetsInlineLimit;
8
8
  },
9
9
  async generateBundle(_options, bundle) {
10
- for (const [id, output] of Object.entries(bundle)) {
11
- if (output.type === "chunk" && output.facadeModuleId && internals.discoveredScripts.has(output.facadeModuleId) && output.imports.length === 0 && output.dynamicImports.length === 0 && shouldInlineAsset(output.code, output.fileName, assetInlineLimit)) {
10
+ const outputs = Object.values(bundle);
11
+ const importedIds = /* @__PURE__ */ new Set();
12
+ for (const output of outputs) {
13
+ if (output.type === "chunk") {
14
+ for (const id of output.imports) {
15
+ importedIds.add(id);
16
+ }
17
+ }
18
+ }
19
+ for (const output of outputs) {
20
+ if (output.type === "chunk" && output.facadeModuleId && internals.discoveredScripts.has(output.facadeModuleId) && !importedIds.has(output.fileName) && output.imports.length === 0 && output.dynamicImports.length === 0 && shouldInlineAsset(output.code, output.fileName, assetInlineLimit)) {
12
21
  internals.inlinedScripts.set(output.facadeModuleId, output.code.trim());
13
- delete bundle[id];
22
+ delete bundle[output.fileName];
14
23
  }
15
24
  }
16
25
  }
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "4.5.16";
1
+ const ASTRO_VERSION = "4.5.18";
2
2
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
3
3
  const ROUTE_TYPE_HEADER = "X-Astro-Route-Type";
4
4
  const DEFAULT_404_COMPONENT = "astro-default-404";
@@ -112,7 +112,7 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
112
112
  envVitePlugin({ settings }),
113
113
  markdownVitePlugin({ settings, logger }),
114
114
  htmlVitePlugin(),
115
- mdxVitePlugin({ settings, logger }),
115
+ mdxVitePlugin(),
116
116
  astroPostprocessVitePlugin(),
117
117
  astroIntegrationsContainerPlugin({ settings, logger }),
118
118
  astroScriptsPageSSRPlugin({ settings }),
@@ -23,7 +23,7 @@ async function dev(inlineConfig) {
23
23
  base: restart.container.settings.config.base
24
24
  })
25
25
  );
26
- const currentVersion = "4.5.16";
26
+ const currentVersion = "4.5.18";
27
27
  if (currentVersion.includes("-")) {
28
28
  logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
29
29
  }
@@ -36,7 +36,7 @@ function serverStart({
36
36
  host,
37
37
  base
38
38
  }) {
39
- const version = "4.5.16";
39
+ const version = "4.5.18";
40
40
  const localPrefix = `${dim("\u2503")} Local `;
41
41
  const networkPrefix = `${dim("\u2503")} Network `;
42
42
  const emptyPrefix = " ".repeat(11);
@@ -261,7 +261,7 @@ function printHelp({
261
261
  message.push(
262
262
  linebreak(),
263
263
  ` ${bgGreen(black(` ${commandName} `))} ${green(
264
- `v${"4.5.16"}`
264
+ `v${"4.5.18"}`
265
265
  )} ${headline}`
266
266
  );
267
267
  }
@@ -1,9 +1,3 @@
1
- declare const renderer: {
2
- name: string;
3
- serverEntrypoint: string;
4
- jsxImportSource: string;
5
- jsxTransformOptions: () => Promise<{
6
- plugins: any[];
7
- }>;
8
- };
1
+ import type { AstroRenderer } from '../@types/astro.js';
2
+ declare const renderer: AstroRenderer;
9
3
  export default renderer;
@@ -1,18 +1,9 @@
1
+ import { jsxTransformOptions } from "./transform-options.js";
1
2
  const renderer = {
2
3
  name: "astro:jsx",
3
4
  serverEntrypoint: "astro/jsx/server.js",
4
5
  jsxImportSource: "astro",
5
- jsxTransformOptions: async () => {
6
- const plugin = await import("@babel/plugin-transform-react-jsx");
7
- const jsx = plugin.default?.default ?? plugin.default;
8
- const { default: astroJSX } = await import("./babel.js");
9
- return {
10
- plugins: [
11
- astroJSX(),
12
- jsx({}, { throwIfNamespace: false, runtime: "automatic", importSource: "astro" })
13
- ]
14
- };
15
- }
6
+ jsxTransformOptions
16
7
  };
17
8
  var renderer_default = renderer;
18
9
  export {
@@ -0,0 +1,2 @@
1
+ import type { JSXTransformConfig } from '../@types/astro.js';
2
+ export declare function jsxTransformOptions(): Promise<JSXTransformConfig>;
@@ -0,0 +1,14 @@
1
+ async function jsxTransformOptions() {
2
+ const plugin = await import("@babel/plugin-transform-react-jsx");
3
+ const jsx = plugin.default?.default ?? plugin.default;
4
+ const { default: astroJSX } = await import("./babel.js");
5
+ return {
6
+ plugins: [
7
+ astroJSX(),
8
+ jsx({}, { throwIfNamespace: false, runtime: "automatic", importSource: "astro" })
9
+ ]
10
+ };
11
+ }
12
+ export {
13
+ jsxTransformOptions
14
+ };
@@ -96,6 +96,7 @@ const aria_non_interactive_roles = [
96
96
  "toolbar",
97
97
  "tooltip"
98
98
  ];
99
+ const roleless_elements = ["div", "span"];
99
100
  const a11y_required_content = [
100
101
  // anchor-has-content
101
102
  "a",
@@ -422,6 +423,8 @@ const a11y = [
422
423
  return false;
423
424
  if (!ariaRoles.has(role))
424
425
  return false;
426
+ if (roleless_elements.includes(element.localName))
427
+ return false;
425
428
  if (aria_non_interactive_roles.includes(role))
426
429
  return true;
427
430
  }
@@ -442,6 +445,8 @@ const a11y = [
442
445
  const exceptions = a11y_non_interactive_element_to_interactive_role_exceptions[element.localName];
443
446
  if (exceptions?.includes(role))
444
447
  return false;
448
+ if (roleless_elements.includes(element.localName))
449
+ return false;
445
450
  if (!aria_non_interactive_roles.includes(role))
446
451
  return true;
447
452
  }
@@ -53,9 +53,9 @@ document.addEventListener("DOMContentLoaded", async () => {
53
53
  overlay = document.createElement("astro-dev-toolbar");
54
54
  const notificationLevels = ["error", "warning", "info"];
55
55
  const notificationSVGs = {
56
- error: '<svg viewBox="0 0 10 10"><rect width="9" height="9" x=".5" y=".5" fill="#B33E66" stroke="#13151A" rx="4.5"/></svg>',
57
- warning: '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="10" fill="none"><path fill="#B58A2D" stroke="#13151A" d="M7.29904 1.25c-.57735-1-2.02073-1-2.59808 0l-3.4641 6C.65951 8.25 1.3812 9.5 2.5359 9.5h6.9282c1.1547 0 1.8764-1.25 1.299-2.25l-3.46406-6Z"/></svg>',
58
- info: '<svg viewBox="0 0 10 10"><rect width="9" height="9" x=".5" y=".5" fill="#3645D9" stroke="#13151A" rx="1.5"/></svg>'
56
+ error: '<svg viewBox="0 0 10 10" style="--fill:var(--fill-default);--fill-default:#B33E66;--fill-hover:#E3AFC1;"><rect width="9" height="9" x=".5" y=".5" fill="var(--fill)" stroke="#13151A" stroke-width="2" rx="4.5"/></svg>',
57
+ warning: '<svg width="12" height="10" fill="none" style="--fill:var(--fill-default);--fill-default:#B58A2D;--fill-hover:#D5B776;"><path fill="var(--fill)" stroke="#13151A" stroke-width="2" d="M7.29904 1.25c-.57735-1-2.02073-1-2.59808 0l-3.4641 6C.65951 8.25 1.3812 9.5 2.5359 9.5h6.9282c1.1547 0 1.8764-1.25 1.299-2.25l-3.46406-6Z"/></svg>',
58
+ info: '<svg viewBox="0 0 10 10" style="--fill:var(--fill-default);--fill-default:#3645D9;--fill-hover:#BDC3FF;"><rect width="9" height="9" x=".5" y=".5" fill="var(--fill)" stroke="#13151A" stroke-width="2" rx="1.5"/></svg>'
59
59
  };
60
60
  const prepareApp = (appDefinition, builtIn) => {
61
61
  const eventTarget = new EventTarget();
@@ -171,8 +171,14 @@ class AstroDevToolbar extends HTMLElement {
171
171
  }
172
172
  }
173
173
 
174
+ #dev-bar #bar-container .item:hover .notification rect, #dev-bar #bar-container .item:hover .notification path {
175
+ stroke: #38393D;
176
+ --fill: var(--fill-hover);
177
+ }
178
+
174
179
  #dev-bar #bar-container .item.active .notification rect, #dev-bar #bar-container .item.active .notification path {
175
- stroke: rgba(71, 78, 94, 1);
180
+ stroke: #454C5C;
181
+ --fill: var(--fill-hover);
176
182
  }
177
183
 
178
184
  #dev-bar .item .icon {
@@ -70,7 +70,7 @@ Make sure to use the static attribute syntax (\`${key}={value}\`) instead of the
70
70
  if (key === "className") {
71
71
  return markHTMLString(` class="${toAttributeString(value, shouldEscape)}"`);
72
72
  }
73
- if (typeof value === "string" && value.includes("&") && urlCanParse(value)) {
73
+ if (typeof value === "string" && value.includes("&") && isHttpUrl(value)) {
74
74
  return markHTMLString(` ${key}="${toAttributeString(value, false)}"`);
75
75
  }
76
76
  if (value === true && (key.startsWith("data-") || htmlBooleanAttributes.test(key))) {
@@ -146,10 +146,11 @@ function promiseWithResolvers() {
146
146
  reject
147
147
  };
148
148
  }
149
- function urlCanParse(url) {
149
+ const VALID_PROTOCOLS = ["http:", "https:"];
150
+ function isHttpUrl(url) {
150
151
  try {
151
- new URL(url);
152
- return true;
152
+ const parsedUrl = new URL(url);
153
+ return VALID_PROTOCOLS.includes(parsedUrl.protocol);
153
154
  } catch {
154
155
  return false;
155
156
  }
@@ -224,7 +224,7 @@ async function handleRoute({
224
224
  }
225
225
  if (response.status === 404 && response.headers.get(REROUTE_DIRECTIVE_HEADER) !== "no") {
226
226
  const fourOhFourRoute = await matchRoute("/404", manifestData, pipeline);
227
- if (options)
227
+ if (options && options.route !== fourOhFourRoute?.route)
228
228
  return handleRoute({
229
229
  ...options,
230
230
  matchedRoute: fourOhFourRoute,
@@ -1,10 +1,2 @@
1
1
  import { type Plugin } from 'vite';
2
- import type { AstroSettings } from '../@types/astro.js';
3
- import type { Logger } from '../core/logger/core.js';
4
- interface AstroPluginJSXOptions {
5
- settings: AstroSettings;
6
- logger: Logger;
7
- }
8
- /** Use Astro config to allow for alternate or multiple JSX renderers (by default Vite will assume React) */
9
- export default function mdxVitePlugin({ settings }: AstroPluginJSXOptions): Plugin;
10
- export {};
2
+ export default function mdxVitePlugin(): Plugin;
@@ -1,71 +1,16 @@
1
1
  import { transformWithEsbuild } from "vite";
2
- import babel from "@babel/core";
3
2
  import { CONTENT_FLAG, PROPAGATED_ASSET_FLAG } from "../content/index.js";
4
3
  import { astroEntryPrefix } from "../core/build/plugins/plugin-component-entry.js";
5
4
  import { removeQueryString } from "../core/path.js";
6
- import tagExportsPlugin from "./tag.js";
7
- async function transformJSX({
8
- code,
9
- mode,
10
- id,
11
- ssr,
12
- renderer,
13
- root
14
- }) {
15
- const { jsxTransformOptions } = renderer;
16
- const options = await jsxTransformOptions({ mode, ssr });
17
- const plugins = [...options.plugins || []];
18
- if (ssr) {
19
- plugins.push(await tagExportsPlugin({ rendererName: renderer.name, root }));
20
- }
21
- const result = await babel.transformAsync(code, {
22
- presets: options.presets,
23
- plugins,
24
- cwd: process.cwd(),
25
- filename: id,
26
- ast: false,
27
- compact: false,
28
- sourceMaps: true,
29
- configFile: false,
30
- babelrc: false,
31
- inputSourceMap: options.inputSourceMap
32
- });
33
- if (!result)
34
- return null;
35
- if (renderer.name === "astro:jsx") {
36
- const { astro } = result.metadata;
37
- return {
38
- code: result.code || "",
39
- map: result.map,
40
- meta: {
41
- astro,
42
- vite: {
43
- // Setting this vite metadata to `ts` causes Vite to resolve .js
44
- // extensions to .ts files.
45
- lang: "ts"
46
- }
47
- }
48
- };
49
- }
50
- return {
51
- code: result.code || "",
52
- map: result.map
53
- };
54
- }
5
+ import { transformJSX } from "./transform-jsx.js";
55
6
  const SPECIAL_QUERY_REGEX = new RegExp(
56
7
  `[?&](?:worker|sharedworker|raw|url|${CONTENT_FLAG}|${PROPAGATED_ASSET_FLAG})\\b`
57
8
  );
58
- function mdxVitePlugin({ settings }) {
59
- let viteConfig;
60
- let astroJSXRenderer;
9
+ function mdxVitePlugin() {
61
10
  return {
62
11
  name: "astro:jsx",
63
12
  enforce: "pre",
64
13
  // run transforms before other plugins
65
- async configResolved(resolvedConfig) {
66
- viteConfig = resolvedConfig;
67
- astroJSXRenderer = settings.renderers.find((r) => r.jsxImportSource === "astro");
68
- },
69
14
  async transform(code, id, opts) {
70
15
  if (SPECIAL_QUERY_REGEX.test(id) || id.startsWith(astroEntryPrefix)) {
71
16
  return null;
@@ -86,14 +31,7 @@ function mdxVitePlugin({ settings }) {
86
31
  }
87
32
  }
88
33
  });
89
- return transformJSX({
90
- code: jsxCode,
91
- id,
92
- renderer: astroJSXRenderer,
93
- mode: viteConfig.mode,
94
- ssr: Boolean(opts?.ssr),
95
- root: settings.config.root
96
- });
34
+ return await transformJSX(jsxCode, id, opts?.ssr);
97
35
  }
98
36
  };
99
37
  }
@@ -7,7 +7,4 @@ import type { PluginObj } from '@babel/core';
7
7
  * This plugin crawls each export in the file and "tags" each export with a given `rendererName`.
8
8
  * This allows us to automatically match a component to a renderer and skip the usual `check()` calls.
9
9
  */
10
- export default function tagExportsWithRenderer({ rendererName, }: {
11
- rendererName: string;
12
- root: URL;
13
- }): Promise<PluginObj>;
10
+ export declare const tagExportsPlugin: PluginObj;
@@ -1,107 +1,103 @@
1
1
  import * as t from "@babel/types";
2
- async function tagExportsWithRenderer({
3
- rendererName
4
- }) {
5
- return {
6
- visitor: {
7
- Program: {
8
- // Inject `import { __astro_tag_component__ } from 'astro/runtime/server/index.js'`
9
- enter(path) {
10
- path.node.body.splice(
11
- 0,
12
- 0,
13
- t.importDeclaration(
14
- [
15
- t.importSpecifier(
16
- t.identifier("__astro_tag_component__"),
17
- t.identifier("__astro_tag_component__")
18
- )
19
- ],
20
- t.stringLiteral("astro/runtime/server/index.js")
21
- )
22
- );
23
- },
24
- // For each export we found, inject `__astro_tag_component__(exportName, rendererName)`
25
- exit(path, state) {
26
- const exportedIds = state.get("astro:tags");
27
- if (exportedIds) {
28
- for (const id of exportedIds) {
29
- path.node.body.push(
30
- t.expressionStatement(
31
- t.callExpression(t.identifier("__astro_tag_component__"), [
32
- t.identifier(id),
33
- t.stringLiteral(rendererName)
34
- ])
35
- )
36
- );
37
- }
38
- }
39
- }
2
+ import astroJsxRenderer from "../jsx/renderer.js";
3
+ const rendererName = astroJsxRenderer.name;
4
+ const tagExportsPlugin = {
5
+ visitor: {
6
+ Program: {
7
+ // Inject `import { __astro_tag_component__ } from 'astro/runtime/server/index.js'`
8
+ enter(path) {
9
+ path.node.body.splice(
10
+ 0,
11
+ 0,
12
+ t.importDeclaration(
13
+ [
14
+ t.importSpecifier(
15
+ t.identifier("__astro_tag_component__"),
16
+ t.identifier("__astro_tag_component__")
17
+ )
18
+ ],
19
+ t.stringLiteral("astro/runtime/server/index.js")
20
+ )
21
+ );
40
22
  },
41
- ExportDeclaration: {
42
- /**
43
- * For default anonymous function export, we need to give them a unique name
44
- * @param path
45
- * @returns
46
- */
47
- enter(path) {
48
- const node = path.node;
49
- if (!t.isExportDefaultDeclaration(node))
50
- return;
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);
54
- path.insertBefore(
55
- t.variableDeclaration("const", [
56
- t.variableDeclarator(uidIdentifier, node.declaration)
57
- ])
23
+ // For each export we found, inject `__astro_tag_component__(exportName, rendererName)`
24
+ exit(path, state) {
25
+ const exportedIds = state.get("astro:tags");
26
+ if (exportedIds) {
27
+ for (const id of exportedIds) {
28
+ path.node.body.push(
29
+ t.expressionStatement(
30
+ t.callExpression(t.identifier("__astro_tag_component__"), [
31
+ t.identifier(id),
32
+ t.stringLiteral(rendererName)
33
+ ])
34
+ )
58
35
  );
59
- node.declaration = uidIdentifier;
60
- } else if (t.isFunctionDeclaration(node.declaration) && !node.declaration.id?.name) {
61
- const uidIdentifier = path.scope.generateUidIdentifier("_function");
62
- node.declaration.id = uidIdentifier;
63
36
  }
64
- },
65
- exit(path, state) {
66
- const node = path.node;
67
- if (node.exportKind === "type")
68
- return;
69
- if (t.isExportAllDeclaration(node))
70
- return;
71
- const addTag = (id) => {
72
- const tags = state.get("astro:tags") ?? [];
73
- state.set("astro:tags", [...tags, id]);
74
- };
75
- if (t.isExportNamedDeclaration(node) || t.isExportDefaultDeclaration(node)) {
76
- if (t.isIdentifier(node.declaration)) {
77
- addTag(node.declaration.name);
78
- } else if (t.isFunctionDeclaration(node.declaration) && node.declaration.id?.name) {
79
- addTag(node.declaration.id.name);
80
- } else if (t.isVariableDeclaration(node.declaration)) {
81
- node.declaration.declarations?.forEach((declaration) => {
82
- if (t.isArrowFunctionExpression(declaration.init) && t.isIdentifier(declaration.id)) {
83
- addTag(declaration.id.name);
84
- }
85
- });
86
- } else if (t.isObjectExpression(node.declaration)) {
87
- node.declaration.properties?.forEach((property) => {
88
- if (t.isProperty(property) && t.isIdentifier(property.key)) {
89
- addTag(property.key.name);
90
- }
91
- });
92
- } else if (t.isExportNamedDeclaration(node) && !node.source) {
93
- node.specifiers.forEach((specifier) => {
94
- if (t.isExportSpecifier(specifier) && t.isIdentifier(specifier.exported)) {
95
- addTag(specifier.local.name);
96
- }
97
- });
98
- }
37
+ }
38
+ }
39
+ },
40
+ ExportDeclaration: {
41
+ /**
42
+ * For default anonymous function export, we need to give them a unique name
43
+ * @param path
44
+ * @returns
45
+ */
46
+ enter(path) {
47
+ const node = path.node;
48
+ if (!t.isExportDefaultDeclaration(node))
49
+ return;
50
+ if (t.isArrowFunctionExpression(node.declaration) || t.isCallExpression(node.declaration)) {
51
+ const varName = t.isArrowFunctionExpression(node.declaration) ? "_arrow_function" : "_hoc_function";
52
+ const uidIdentifier = path.scope.generateUidIdentifier(varName);
53
+ path.insertBefore(
54
+ t.variableDeclaration("const", [t.variableDeclarator(uidIdentifier, node.declaration)])
55
+ );
56
+ node.declaration = uidIdentifier;
57
+ } else if (t.isFunctionDeclaration(node.declaration) && !node.declaration.id?.name) {
58
+ const uidIdentifier = path.scope.generateUidIdentifier("_function");
59
+ node.declaration.id = uidIdentifier;
60
+ }
61
+ },
62
+ exit(path, state) {
63
+ const node = path.node;
64
+ if (node.exportKind === "type")
65
+ return;
66
+ if (t.isExportAllDeclaration(node))
67
+ return;
68
+ const addTag = (id) => {
69
+ const tags = state.get("astro:tags") ?? [];
70
+ state.set("astro:tags", [...tags, id]);
71
+ };
72
+ if (t.isExportNamedDeclaration(node) || t.isExportDefaultDeclaration(node)) {
73
+ if (t.isIdentifier(node.declaration)) {
74
+ addTag(node.declaration.name);
75
+ } else if (t.isFunctionDeclaration(node.declaration) && node.declaration.id?.name) {
76
+ addTag(node.declaration.id.name);
77
+ } else if (t.isVariableDeclaration(node.declaration)) {
78
+ node.declaration.declarations?.forEach((declaration) => {
79
+ if (t.isArrowFunctionExpression(declaration.init) && t.isIdentifier(declaration.id)) {
80
+ addTag(declaration.id.name);
81
+ }
82
+ });
83
+ } else if (t.isObjectExpression(node.declaration)) {
84
+ node.declaration.properties?.forEach((property) => {
85
+ if (t.isProperty(property) && t.isIdentifier(property.key)) {
86
+ addTag(property.key.name);
87
+ }
88
+ });
89
+ } else if (t.isExportNamedDeclaration(node) && !node.source) {
90
+ node.specifiers.forEach((specifier) => {
91
+ if (t.isExportSpecifier(specifier) && t.isIdentifier(specifier.exported)) {
92
+ addTag(specifier.local.name);
93
+ }
94
+ });
99
95
  }
100
96
  }
101
97
  }
102
98
  }
103
- };
104
- }
99
+ }
100
+ };
105
101
  export {
106
- tagExportsWithRenderer as default
102
+ tagExportsPlugin
107
103
  };
@@ -0,0 +1,2 @@
1
+ import type { TransformResult } from 'rollup';
2
+ export declare function transformJSX(code: string, id: string, ssr?: boolean): Promise<TransformResult>;
@@ -0,0 +1,50 @@
1
+ import babel from "@babel/core";
2
+ import { jsxTransformOptions } from "../jsx/transform-options.js";
3
+ import { tagExportsPlugin } from "./tag.js";
4
+ async function transformJSX(code, id, ssr) {
5
+ const options = await getJsxTransformOptions();
6
+ const plugins = ssr ? [...options.plugins ?? [], tagExportsPlugin] : options.plugins;
7
+ const result = await babel.transformAsync(code, {
8
+ presets: options.presets,
9
+ plugins,
10
+ cwd: process.cwd(),
11
+ filename: id,
12
+ ast: false,
13
+ compact: false,
14
+ sourceMaps: true,
15
+ configFile: false,
16
+ babelrc: false,
17
+ browserslistConfigFile: false,
18
+ inputSourceMap: options.inputSourceMap
19
+ });
20
+ if (!result)
21
+ return null;
22
+ const { astro } = result.metadata;
23
+ return {
24
+ code: result.code || "",
25
+ map: result.map,
26
+ meta: {
27
+ astro,
28
+ vite: {
29
+ // Setting this vite metadata to `ts` causes Vite to resolve .js
30
+ // extensions to .ts files.
31
+ lang: "ts"
32
+ }
33
+ }
34
+ };
35
+ }
36
+ let cachedJsxTransformOptions;
37
+ async function getJsxTransformOptions() {
38
+ if (cachedJsxTransformOptions) {
39
+ return cachedJsxTransformOptions;
40
+ }
41
+ const options = jsxTransformOptions();
42
+ cachedJsxTransformOptions = options;
43
+ options.then((resolvedOptions) => {
44
+ cachedJsxTransformOptions = resolvedOptions;
45
+ });
46
+ return options;
47
+ }
48
+ export {
49
+ transformJSX
50
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "4.5.16",
3
+ "version": "4.5.18",
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",
@@ -162,8 +162,8 @@
162
162
  "zod": "^3.22.4",
163
163
  "zod-to-json-schema": "^3.22.4",
164
164
  "@astrojs/internal-helpers": "0.4.0",
165
- "@astrojs/markdown-remark": "5.0.0",
166
- "@astrojs/telemetry": "3.0.4"
165
+ "@astrojs/telemetry": "3.0.4",
166
+ "@astrojs/markdown-remark": "5.0.0"
167
167
  },
168
168
  "optionalDependencies": {
169
169
  "sharp": "^0.32.6"