astro 2.1.2 → 2.1.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.
Files changed (86) hide show
  1. package/client-base.d.ts +2 -1
  2. package/client-image.d.ts +7 -14
  3. package/dist/@types/astro.d.ts +2 -2
  4. package/dist/assets/consts.d.ts +5 -1
  5. package/dist/assets/consts.js +0 -3
  6. package/dist/assets/internal.d.ts +1 -1
  7. package/dist/assets/services/service.d.ts +5 -3
  8. package/dist/assets/types.d.ts +3 -3
  9. package/dist/assets/utils/emitAsset.d.ts +2 -0
  10. package/dist/assets/utils/emitAsset.js +31 -0
  11. package/dist/assets/utils/metadata.d.ts +1 -1
  12. package/dist/assets/utils/metadata.js +4 -3
  13. package/dist/assets/utils/queryParams.d.ts +1 -1
  14. package/dist/assets/utils/transformToPath.d.ts +1 -1
  15. package/dist/assets/vite-plugin-assets.d.ts +1 -1
  16. package/dist/assets/vite-plugin-assets.js +25 -25
  17. package/dist/content/error-map.d.ts +2 -0
  18. package/dist/content/error-map.js +75 -0
  19. package/dist/content/index.d.ts +1 -0
  20. package/dist/content/index.js +2 -0
  21. package/dist/content/runtime-assets.d.ts +8 -0
  22. package/dist/content/runtime-assets.js +24 -0
  23. package/dist/content/{internal.d.ts → runtime.d.ts} +1 -19
  24. package/dist/content/{internal.js → runtime.js} +28 -43
  25. package/dist/content/template/virtual-mod-assets.d.mts +1 -0
  26. package/dist/content/template/virtual-mod.d.mts +0 -1
  27. package/dist/content/utils.d.ts +7 -2
  28. package/dist/content/utils.js +18 -26
  29. package/dist/content/vite-plugin-content-assets.d.ts +2 -2
  30. package/dist/content/vite-plugin-content-imports.d.ts +1 -1
  31. package/dist/content/vite-plugin-content-imports.js +4 -10
  32. package/dist/content/vite-plugin-content-virtual-mod.js +4 -2
  33. package/dist/core/add/index.js +15 -0
  34. package/dist/core/app/node.d.ts +1 -1
  35. package/dist/core/build/add-rollup-input.d.ts +1 -1
  36. package/dist/core/build/css-asset-name.d.ts +1 -1
  37. package/dist/core/build/index.d.ts +1 -1
  38. package/dist/core/build/internal.d.ts +16 -6
  39. package/dist/core/build/internal.js +2 -2
  40. package/dist/core/build/plugins/index.js +2 -0
  41. package/dist/core/build/plugins/plugin-alias-resolve.d.ts +1 -1
  42. package/dist/core/build/plugins/plugin-analyzer.js +12 -2
  43. package/dist/core/build/plugins/plugin-component-entry.d.ts +11 -0
  44. package/dist/core/build/plugins/plugin-component-entry.js +74 -0
  45. package/dist/core/build/plugins/plugin-hoisted-scripts.d.ts +2 -2
  46. package/dist/core/build/plugins/plugin-internals.js +2 -1
  47. package/dist/core/build/plugins/plugin-ssr.d.ts +1 -1
  48. package/dist/core/build/static-build.js +2 -2
  49. package/dist/core/config/config.d.ts +1 -1
  50. package/dist/core/config/schema.d.ts +1 -1
  51. package/dist/core/constants.js +1 -1
  52. package/dist/core/create-vite.js +5 -1
  53. package/dist/core/dev/container.d.ts +2 -2
  54. package/dist/core/dev/dev.d.ts +2 -2
  55. package/dist/core/dev/dev.js +1 -1
  56. package/dist/core/errors/errors-data.js +3 -1
  57. package/dist/core/errors/errors.d.ts +1 -1
  58. package/dist/core/errors/utils.d.ts +1 -1
  59. package/dist/core/messages.d.ts +2 -2
  60. package/dist/core/messages.js +2 -2
  61. package/dist/core/preview/static-preview-server.d.ts +1 -1
  62. package/dist/core/preview/vite-plugin-astro-preview.d.ts +2 -2
  63. package/dist/core/render/dev/css.d.ts +1 -1
  64. package/dist/core/render/paginate.d.ts +1 -1
  65. package/dist/core/sync/index.js +1 -0
  66. package/dist/events/error.d.ts +1 -1
  67. package/dist/integrations/index.d.ts +1 -1
  68. package/dist/runtime/server/jsx.d.ts +1 -1
  69. package/dist/runtime/server/render/tags.d.ts +1 -1
  70. package/dist/vite-plugin-astro/compile.d.ts +1 -1
  71. package/dist/vite-plugin-astro-server/plugin.d.ts +1 -1
  72. package/dist/vite-plugin-astro-server/route.d.ts +1 -1
  73. package/dist/vite-plugin-head-propagation/index.d.ts +1 -1
  74. package/dist/vite-plugin-html/transform/slots.d.ts +1 -1
  75. package/dist/vite-plugin-html/transform/utils.d.ts +1 -1
  76. package/dist/vite-plugin-inject-env-ts/index.js +3 -1
  77. package/dist/vite-plugin-integrations-container/index.d.ts +3 -3
  78. package/dist/vite-plugin-jsx/import-source.d.ts +2 -2
  79. package/dist/vite-plugin-markdown/content-entry-type.d.ts +1 -1
  80. package/dist/vite-plugin-scanner/index.d.ts +1 -1
  81. package/dist/vite-plugin-scanner/scan.d.ts +1 -1
  82. package/dist/vite-plugin-scripts/index.d.ts +2 -2
  83. package/dist/vite-plugin-scripts/page-ssr.d.ts +1 -1
  84. package/package.json +4 -2
  85. package/src/content/template/virtual-mod-assets.mjs +7 -0
  86. package/src/content/template/virtual-mod.mjs +1 -7
@@ -1,3 +1,3 @@
1
- import { Plugin } from 'vite';
2
- import { AstroSettings } from '../../@types/astro.js';
1
+ import type { Plugin } from 'vite';
2
+ import type { AstroSettings } from '../../@types/astro.js';
3
3
  export declare function vitePluginAstroPreview(settings: AstroSettings): Plugin;
@@ -1,5 +1,5 @@
1
1
  import type { ModuleLoader } from '../../module-loader/index';
2
- import { RuntimeMode } from '../../../@types/astro.js';
2
+ import type { RuntimeMode } from '../../../@types/astro.js';
3
3
  /** Given a filePath URL, crawl Vite’s module graph to find all style imports. */
4
4
  export declare function getStylesForURL(filePath: URL, loader: ModuleLoader, mode: RuntimeMode): Promise<{
5
5
  urls: Set<string>;
@@ -1,2 +1,2 @@
1
- import { PaginateFunction, RouteData } from '../../@types/astro';
1
+ import type { PaginateFunction, RouteData } from '../../@types/astro';
2
2
  export declare function generatePaginateFunction(routeMatch: RouteData): PaginateFunction;
@@ -36,6 +36,7 @@ async function sync(settings, { logging, fs }) {
36
36
  {
37
37
  server: { middlewareMode: true, hmr: false },
38
38
  optimizeDeps: { entries: [] },
39
+ ssr: { external: ["image-size"] },
39
40
  logLevel: "silent"
40
41
  },
41
42
  { settings, logging, mode: "build", command: "build", fs }
@@ -1,4 +1,4 @@
1
- import { ZodError } from 'zod';
1
+ import type { ZodError } from 'zod';
2
2
  import { ErrorWithMetadata } from '../core/errors/index.js';
3
3
  interface ErrorEventPayload {
4
4
  code: number | undefined;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import type { AddressInfo } from 'net';
3
3
  import type { InlineConfig, ViteDevServer } from 'vite';
4
- import { AstroConfig, AstroSettings, BuildConfig, RouteData } from '../@types/astro.js';
4
+ import type { AstroConfig, AstroSettings, BuildConfig, RouteData } from '../@types/astro.js';
5
5
  import type { SerializedSSRManifest } from '../core/app/types';
6
6
  import type { PageBuildData } from '../core/build/types';
7
7
  import { LogOptions } from '../core/logger/core.js';
@@ -1,2 +1,2 @@
1
- import { SSRResult } from '../../@types/astro.js';
1
+ import type { SSRResult } from '../../@types/astro.js';
2
2
  export declare function renderJSX(result: SSRResult, vnode: any): Promise<any>;
@@ -1,4 +1,4 @@
1
- import { SSRElement, SSRResult } from '../../../@types/astro';
1
+ import type { SSRElement, SSRResult } from '../../../@types/astro';
2
2
  export declare function renderStyleElement(children: string): string;
3
3
  export declare function renderScriptElement({ props, children }: SSRElement): string;
4
4
  export declare function renderStylesheet({ href }: {
@@ -1,6 +1,6 @@
1
1
  import { ESBuildTransformResult } from 'vite';
2
2
  import { CompileProps, CompileResult } from '../core/compile/index.js';
3
- import { LogOptions } from '../core/logger/core.js';
3
+ import type { LogOptions } from '../core/logger/core.js';
4
4
  interface CachedFullCompilation {
5
5
  compileProps: CompileProps;
6
6
  logging: LogOptions;
@@ -2,7 +2,7 @@
2
2
  import type * as vite from 'vite';
3
3
  import type { AstroSettings } from '../@types/astro';
4
4
  import type fs from 'fs';
5
- import { LogOptions } from '../core/logger/core.js';
5
+ import type { LogOptions } from '../core/logger/core.js';
6
6
  export interface AstroPluginOptions {
7
7
  settings: AstroSettings;
8
8
  logging: LogOptions;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import type http from 'http';
3
3
  import type { ComponentInstance, ManifestData, RouteData } from '../@types/astro';
4
- import { ComponentPreload, DevelopmentEnvironment } from '../core/render/dev/index';
4
+ import type { ComponentPreload, DevelopmentEnvironment } from '../core/render/dev/index';
5
5
  type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (...args: any) => Promise<infer R> ? R : any;
6
6
  interface MatchedRoute {
7
7
  route: RouteData;
@@ -2,7 +2,7 @@ import type { AstroSettings } from '../@types/astro';
2
2
  import type { BuildInternals } from '../core/build/internal.js';
3
3
  import type { AstroBuildPlugin } from '../core/build/plugin.js';
4
4
  import type { StaticBuildOptions } from '../core/build/types';
5
- import * as vite from 'vite';
5
+ import type * as vite from 'vite';
6
6
  /**
7
7
  * If any component is marked as doing head injection, walk up the tree
8
8
  * and mark parent Astro components as having head injection in the tree.
@@ -1,6 +1,6 @@
1
1
  import type { Root } from 'hast';
2
2
  import type { Plugin } from 'unified';
3
- import MagicString from 'magic-string';
3
+ import type MagicString from 'magic-string';
4
4
  declare const rehypeSlots: Plugin<[{
5
5
  s: MagicString;
6
6
  }], Root>;
@@ -1,5 +1,5 @@
1
1
  import type { Element } from 'hast';
2
- import MagicString from 'magic-string';
2
+ import type MagicString from 'magic-string';
3
3
  export declare function replaceAttribute(s: MagicString, node: Element, key: string, newValue: string): void;
4
4
  export declare function needsEscape(value: any): value is string;
5
5
  export declare function escape(value: string): string;
@@ -39,12 +39,14 @@ async function setUpEnvTs({
39
39
  'types="astro/client-image"'
40
40
  );
41
41
  await fs.promises.writeFile(envTsPath, typesEnvContents, "utf-8");
42
- } else if (typesEnvContents.includes('types="astro/client-image"')) {
42
+ info(logging, "assets", `Added ${bold(envTsPathRelativetoRoot)} types`);
43
+ } else if (!settings.config.experimental.assets && typesEnvContents.includes('types="astro/client-image"')) {
43
44
  typesEnvContents = typesEnvContents.replace(
44
45
  'types="astro/client-image"',
45
46
  'types="astro/client"'
46
47
  );
47
48
  await fs.promises.writeFile(envTsPath, typesEnvContents, "utf-8");
49
+ info(logging, "assets", `Removed ${bold(envTsPathRelativetoRoot)} types`);
48
50
  }
49
51
  if (!fs.existsSync(dotAstroDir))
50
52
  return;
@@ -1,6 +1,6 @@
1
- import { Plugin as VitePlugin } from 'vite';
2
- import { AstroSettings } from '../@types/astro.js';
3
- import { LogOptions } from '../core/logger/core.js';
1
+ import type { Plugin as VitePlugin } from 'vite';
2
+ import type { AstroSettings } from '../@types/astro.js';
3
+ import type { LogOptions } from '../core/logger/core.js';
4
4
  /** Connect Astro integrations into Vite, as needed. */
5
5
  export default function astroIntegrationsContainerPlugin({ settings, logging, }: {
6
6
  settings: AstroSettings;
@@ -1,3 +1,3 @@
1
- import { TsConfigJson } from 'tsconfig-resolver';
2
- import { AstroRenderer } from '../@types/astro';
1
+ import type { TsConfigJson } from 'tsconfig-resolver';
2
+ import type { AstroRenderer } from '../@types/astro';
3
3
  export declare function detectImportSource(code: string, jsxRenderers: Map<string, AstroRenderer>, tsConfig?: TsConfigJson): Promise<string | undefined>;
@@ -1,4 +1,4 @@
1
- import { ContentEntryType } from '../@types/astro.js';
1
+ import type { ContentEntryType } from '../@types/astro.js';
2
2
  export declare const markdownContentEntryType: ContentEntryType;
3
3
  /**
4
4
  * MDX content type for compatibility with older `@astrojs/mdx` versions
@@ -1,5 +1,5 @@
1
1
  import { Plugin as VitePlugin } from 'vite';
2
- import { AstroSettings } from '../@types/astro.js';
2
+ import type { AstroSettings } from '../@types/astro.js';
3
3
  export default function astroScannerPlugin({ settings }: {
4
4
  settings: AstroSettings;
5
5
  }): VitePlugin;
@@ -1,2 +1,2 @@
1
- import { PageOptions } from '../vite-plugin-astro/types.js';
1
+ import type { PageOptions } from '../vite-plugin-astro/types.js';
2
2
  export declare function scan(code: string, id: string): Promise<PageOptions>;
@@ -1,5 +1,5 @@
1
- import { Plugin as VitePlugin } from 'vite';
2
- import { AstroSettings } from '../@types/astro.js';
1
+ import type { Plugin as VitePlugin } from 'vite';
2
+ import type { AstroSettings } from '../@types/astro.js';
3
3
  export declare const BEFORE_HYDRATION_SCRIPT_ID: string;
4
4
  export declare const PAGE_SCRIPT_ID: string;
5
5
  export declare const PAGE_SSR_SCRIPT_ID: string;
@@ -1,5 +1,5 @@
1
1
  import { Plugin as VitePlugin } from 'vite';
2
- import { AstroSettings } from '../@types/astro.js';
2
+ import type { AstroSettings } from '../@types/astro.js';
3
3
  export default function astroScriptsPostPlugin({ settings, }: {
4
4
  settings: AstroSettings;
5
5
  }): VitePlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "2.1.2",
3
+ "version": "2.1.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",
@@ -53,6 +53,8 @@
53
53
  "./assets/services/sharp": "./dist/assets/services/sharp.js",
54
54
  "./assets/services/squoosh": "./dist/assets/services/squoosh.js",
55
55
  "./content/internal": "./dist/content/internal.js",
56
+ "./content/runtime": "./dist/content/runtime.js",
57
+ "./content/runtime-assets": "./dist/content/runtime-assets.js",
56
58
  "./debug": "./components/Debug.astro",
57
59
  "./internal/*": "./dist/runtime/server/*",
58
60
  "./package.json": "./package.json",
@@ -202,7 +204,7 @@
202
204
  "scripts": {
203
205
  "prebuild": "astro-scripts prebuild --to-string \"src/runtime/server/astro-island.ts\" \"src/runtime/client/{idle,load,media,only,visible}.ts\"",
204
206
  "build": "pnpm run prebuild && astro-scripts build \"src/**/*.ts\" && tsc && pnpm run postbuild",
205
- "build:ci": "pnpm run prebuild && astro-scripts build \"src/**/*.ts\"",
207
+ "build:ci": "pnpm run prebuild && astro-scripts build \"src/**/*.ts\" && pnpm run postbuild",
206
208
  "dev": "astro-scripts dev --copy-wasm --prebuild \"src/runtime/server/astro-island.ts\" --prebuild \"src/runtime/client/{idle,load,media,only,visible}.ts\" \"src/**/*.ts\"",
207
209
  "postbuild": "astro-scripts copy \"src/**/*.astro\" && astro-scripts copy \"src/**/*.wasm\"",
208
210
  "test:unit": "mocha --exit --timeout 30000 ./test/units/**/*.test.js",
@@ -0,0 +1,7 @@
1
+ import { createImage } from 'astro/content/runtime-assets';
2
+
3
+ const assetsDir = '@@ASSETS_DIR@@';
4
+
5
+ export const image = createImage({
6
+ assetsDir,
7
+ });
@@ -3,8 +3,7 @@ import {
3
3
  createCollectionToGlobResultMap,
4
4
  createGetCollection,
5
5
  createGetEntryBySlug,
6
- createImage,
7
- } from 'astro/content/internal';
6
+ } from 'astro/content/runtime';
8
7
 
9
8
  export { z } from 'astro/zod';
10
9
 
@@ -13,7 +12,6 @@ export function defineCollection(config) {
13
12
  }
14
13
 
15
14
  const contentDir = '@@CONTENT_DIR@@';
16
- const assetsDir = '@@ASSETS_DIR@@';
17
15
 
18
16
  const entryGlob = import.meta.glob('@@ENTRY_GLOB_PATH@@', {
19
17
  query: { astroContent: true },
@@ -40,7 +38,3 @@ export const getEntryBySlug = createGetEntryBySlug({
40
38
  getCollection,
41
39
  collectionToRenderEntryMap,
42
40
  });
43
-
44
- export const image = createImage({
45
- assetsDir,
46
- });