astro 3.0.12 → 3.1.0
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/README.md +2 -2
- package/astro-jsx.d.ts +28 -1
- package/client.d.ts +8 -4
- package/components/ViewTransitions.astro +77 -24
- package/content-types.template.d.ts +6 -1
- package/dist/@types/astro.d.ts +43 -22
- package/dist/assets/build/generate.d.ts +1 -1
- package/dist/assets/build/remote.d.ts +1 -1
- package/dist/assets/consts.d.ts +2 -2
- package/dist/assets/consts.js +4 -10
- package/dist/assets/internal.js +3 -2
- package/dist/assets/services/service.d.ts +1 -1
- package/dist/assets/services/service.js +7 -3
- package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/codecs.d.ts +4 -4
- package/dist/assets/services/vendor/squoosh/image-pool.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/image.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/image_data.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/impl.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/png/squoosh_oxipng_bg.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/png/squoosh_png_bg.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/resize/squoosh_resize_bg.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/rotate/rotate.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/utils/workerPool.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.wasm.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.wasm.d.ts +1 -1
- package/dist/assets/utils/metadata.d.ts +1 -1
- package/dist/assets/utils/metadata.js +6 -2
- package/dist/assets/vite-plugin-assets.d.ts +1 -1
- package/dist/assets/vite-plugin-assets.js +1 -1
- package/dist/cli/add/babel.d.ts +12 -11
- package/dist/config/index.d.ts +1 -1
- package/dist/config/vite-plugin-content-listen.d.ts +2 -2
- package/dist/content/server-listeners.d.ts +1 -1
- package/dist/content/types-generator.d.ts +2 -2
- package/dist/content/utils.d.ts +1 -1
- package/dist/content/utils.js +1 -1
- package/dist/content/vite-plugin-content-assets.d.ts +1 -1
- package/dist/content/vite-plugin-content-imports.d.ts +1 -1
- package/dist/content/vite-plugin-content-virtual-mod.d.ts +1 -1
- package/dist/core/app/common.d.ts +1 -1
- package/dist/core/app/index.d.ts +1 -1
- package/dist/core/app/node.d.ts +3 -3
- package/dist/core/app/ssrPipeline.d.ts +1 -1
- package/dist/core/app/types.d.ts +2 -2
- package/dist/core/build/buildPipeline.d.ts +4 -4
- package/dist/core/build/common.d.ts +1 -1
- package/dist/core/build/css-asset-name.d.ts +1 -1
- package/dist/core/build/generate.d.ts +2 -2
- package/dist/core/build/generate.js +3 -0
- package/dist/core/build/index.d.ts +1 -1
- package/dist/core/build/internal.d.ts +3 -3
- package/dist/core/build/page-data.d.ts +3 -3
- package/dist/core/build/plugin.d.ts +2 -2
- package/dist/core/build/plugins/index.d.ts +1 -1
- package/dist/core/build/plugins/plugin-css.d.ts +3 -3
- package/dist/core/build/plugins/plugin-hoisted-scripts.d.ts +3 -3
- package/dist/core/build/plugins/plugin-internals.d.ts +1 -1
- package/dist/core/build/plugins/plugin-manifest.d.ts +3 -3
- package/dist/core/build/plugins/plugin-manifest.js +2 -2
- package/dist/core/build/plugins/plugin-middleware.d.ts +3 -3
- package/dist/core/build/plugins/plugin-pages.d.ts +3 -3
- package/dist/core/build/plugins/plugin-prerender.d.ts +1 -1
- package/dist/core/build/plugins/plugin-renderers.d.ts +2 -2
- package/dist/core/build/plugins/plugin-ssr.d.ts +2 -2
- package/dist/core/build/plugins/plugin-ssr.js +2 -2
- package/dist/core/build/static-build.d.ts +2 -2
- package/dist/core/build/types.d.ts +5 -4
- package/dist/core/compile/cache.d.ts +1 -1
- package/dist/core/compile/compile.d.ts +1 -1
- package/dist/core/compile/index.d.ts +2 -2
- package/dist/core/config/config.d.ts +2 -2
- package/dist/core/config/index.d.ts +1 -1
- package/dist/core/config/schema.d.ts +29 -15
- package/dist/core/config/schema.js +1 -0
- package/dist/core/config/settings.d.ts +1 -1
- package/dist/core/config/vite-load.d.ts +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/cookies/response.d.ts +1 -1
- package/dist/core/create-vite.d.ts +3 -3
- package/dist/core/create-vite.js +1 -1
- package/dist/core/dev/container.d.ts +4 -4
- package/dist/core/dev/dev.d.ts +3 -3
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/dev/restart.d.ts +3 -3
- package/dist/core/endpoint/index.d.ts +3 -3
- package/dist/core/errors/dev/utils.js +4 -4
- package/dist/core/errors/errors-data.d.ts +12 -3
- package/dist/core/errors/errors-data.js +7 -4
- package/dist/core/errors/index.d.ts +1 -1
- package/dist/core/errors/overlay.js +2 -2
- package/dist/core/logger/node.d.ts +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/callMiddleware.d.ts +2 -2
- package/dist/core/middleware/index.d.ts +2 -2
- package/dist/core/middleware/loadMiddleware.d.ts +2 -2
- package/dist/core/middleware/sequence.d.ts +1 -1
- package/dist/core/module-loader/loader.d.ts +2 -2
- package/dist/core/module-loader/vite.d.ts +1 -1
- package/dist/core/pipeline.d.ts +1 -1
- package/dist/core/preview/index.d.ts +1 -1
- package/dist/core/preview/static-preview-server.d.ts +3 -3
- package/dist/core/redirects/component.d.ts +2 -2
- package/dist/core/redirects/helpers.d.ts +1 -1
- package/dist/core/render/context.d.ts +2 -2
- package/dist/core/render/core.d.ts +1 -1
- package/dist/core/render/environment.d.ts +1 -1
- package/dist/core/render/index.d.ts +2 -2
- package/dist/core/render/paginate.d.ts +1 -1
- package/dist/core/render/params-and-props.d.ts +1 -1
- package/dist/core/render/renderer.d.ts +1 -1
- package/dist/core/render/result.d.ts +1 -1
- package/dist/core/render/route-cache.d.ts +1 -1
- package/dist/core/render/ssr-element.d.ts +2 -2
- package/dist/core/render/ssr-element.js +1 -3
- package/dist/core/request.d.ts +2 -2
- package/dist/core/routing/manifest/create.d.ts +3 -3
- package/dist/core/routing/manifest/generator.d.ts +1 -1
- package/dist/core/routing/manifest/serialization.d.ts +1 -1
- package/dist/core/routing/match.d.ts +1 -1
- package/dist/core/routing/params.d.ts +1 -1
- package/dist/core/routing/validation.d.ts +2 -2
- package/dist/core/sync/index.d.ts +2 -2
- package/dist/core/util.d.ts +2 -2
- package/dist/events/session.d.ts +1 -1
- package/dist/integrations/astroFeaturesValidation.d.ts +1 -1
- package/dist/integrations/index.d.ts +3 -3
- package/dist/prerender/metadata.d.ts +1 -1
- package/dist/prerender/routing.d.ts +2 -2
- package/dist/prerender/utils.d.ts +1 -1
- package/dist/runtime/client/hmr.js +1 -1
- package/dist/runtime/client/idle.d.ts +1 -1
- package/dist/runtime/client/load.d.ts +1 -1
- package/dist/runtime/client/media.d.ts +1 -1
- package/dist/runtime/client/only.d.ts +1 -1
- package/dist/runtime/client/visible.d.ts +1 -1
- package/dist/runtime/client/visible.prebuilt.d.ts +1 -1
- package/dist/runtime/client/visible.prebuilt.js +1 -1
- package/dist/runtime/server/astro-component.d.ts +1 -1
- package/dist/runtime/server/astro-global.d.ts +1 -1
- package/dist/runtime/server/astro-island.d.ts +1 -4
- package/dist/runtime/server/endpoint.d.ts +2 -2
- package/dist/runtime/server/hydration.d.ts +1 -1
- package/dist/runtime/server/render/astro/factory.d.ts +3 -3
- package/dist/runtime/server/render/astro/head-and-content.d.ts +1 -1
- package/dist/runtime/server/render/astro/index.d.ts +2 -2
- package/dist/runtime/server/render/astro/instance.d.ts +1 -1
- package/dist/runtime/server/render/astro/render.d.ts +1 -1
- package/dist/runtime/server/render/common.d.ts +1 -1
- package/dist/runtime/server/render/component.d.ts +1 -1
- package/dist/runtime/server/render/dom.d.ts +1 -1
- package/dist/runtime/server/render/head.d.ts +1 -1
- package/dist/runtime/server/render/index.d.ts +2 -2
- package/dist/runtime/server/render/page.d.ts +2 -2
- package/dist/runtime/server/render/tags.d.ts +2 -2
- package/dist/runtime/server/render/tags.js +1 -1
- package/dist/runtime/server/render/util.d.ts +1 -1
- package/dist/runtime/server/scripts.d.ts +1 -1
- package/dist/runtime/server/serialize.d.ts +1 -1
- package/dist/runtime/server/transition.d.ts +1 -1
- package/dist/transitions/index.d.ts +1 -1
- package/dist/type-utils.d.ts +4 -0
- package/dist/vite-plugin-astro/hmr.d.ts +1 -1
- package/dist/vite-plugin-astro/index.d.ts +2 -2
- package/dist/vite-plugin-astro/metadata.d.ts +2 -2
- package/dist/vite-plugin-astro/types.d.ts +1 -1
- package/dist/vite-plugin-astro-server/base.d.ts +1 -1
- package/dist/vite-plugin-astro-server/controller.d.ts +2 -2
- package/dist/vite-plugin-astro-server/css.d.ts +1 -1
- package/dist/vite-plugin-astro-server/devPipeline.d.ts +4 -4
- package/dist/vite-plugin-astro-server/index.d.ts +1 -1
- package/dist/vite-plugin-astro-server/metadata.d.ts +2 -2
- package/dist/vite-plugin-astro-server/plugin.d.ts +2 -2
- package/dist/vite-plugin-astro-server/request.d.ts +4 -4
- package/dist/vite-plugin-astro-server/resolve.d.ts +1 -1
- package/dist/vite-plugin-astro-server/response.d.ts +2 -2
- package/dist/vite-plugin-astro-server/route.d.ts +2 -2
- package/dist/vite-plugin-astro-server/route.js +0 -1
- package/dist/vite-plugin-astro-server/scripts.d.ts +2 -2
- package/dist/vite-plugin-astro-server/vite.d.ts +1 -1
- package/dist/vite-plugin-config-alias/index.d.ts +1 -1
- package/dist/vite-plugin-env/index.d.ts +1 -1
- package/dist/vite-plugin-inject-env-ts/index.d.ts +1 -1
- package/dist/vite-plugin-load-fallback/index.d.ts +1 -1
- package/dist/vite-plugin-markdown/index.d.ts +1 -1
- package/dist/vite-plugin-markdown/index.js +20 -20
- package/dist/vite-plugin-mdx/index.d.ts +1 -1
- package/dist/vite-plugin-utils/index.d.ts +1 -1
- package/package.json +4 -2
- package/types.d.ts +6 -1
- package/dist/assets/vendor/image-size/detector.d.ts +0 -3
- package/dist/assets/vendor/image-size/detector.js +0 -28
- package/dist/assets/vendor/image-size/index.d.ts +0 -11
- package/dist/assets/vendor/image-size/index.js +0 -93
- package/dist/assets/vendor/image-size/readUInt.d.ts +0 -4
- package/dist/assets/vendor/image-size/readUInt.js +0 -9
- package/dist/assets/vendor/image-size/types/bmp.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/bmp.js +0 -14
- package/dist/assets/vendor/image-size/types/cur.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/cur.js +0 -16
- package/dist/assets/vendor/image-size/types/dds.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/dds.js +0 -14
- package/dist/assets/vendor/image-size/types/gif.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/gif.js +0 -16
- package/dist/assets/vendor/image-size/types/icns.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/icns.js +0 -87
- package/dist/assets/vendor/image-size/types/ico.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/ico.js +0 -42
- package/dist/assets/vendor/image-size/types/interface.d.ts +0 -14
- package/dist/assets/vendor/image-size/types/interface.js +0 -0
- package/dist/assets/vendor/image-size/types/j2c.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/j2c.js +0 -14
- package/dist/assets/vendor/image-size/types/jp2.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/jp2.js +0 -56
- package/dist/assets/vendor/image-size/types/jpg.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/jpg.js +0 -95
- package/dist/assets/vendor/image-size/types/ktx.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/ktx.js +0 -15
- package/dist/assets/vendor/image-size/types/png.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/png.js +0 -33
- package/dist/assets/vendor/image-size/types/pnm.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/pnm.js +0 -72
- package/dist/assets/vendor/image-size/types/psd.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/psd.js +0 -14
- package/dist/assets/vendor/image-size/types/svg.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/svg.js +0 -91
- package/dist/assets/vendor/image-size/types/tiff.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/tiff.js +0 -81
- package/dist/assets/vendor/image-size/types/webp.d.ts +0 -2
- package/dist/assets/vendor/image-size/types/webp.js +0 -51
- package/dist/assets/vendor/image-size/types.d.ts +0 -19
- package/dist/assets/vendor/image-size/types.js +0 -37
- package/dist/assets/vendor/queue/queue.d.ts +0 -39
- package/dist/assets/vendor/queue/queue.js +0 -187
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import type http from 'node:http';
|
|
3
3
|
import type { ErrorWithMetadata } from '../core/errors/index.js';
|
|
4
|
-
import type { ModuleLoader } from '../core/module-loader/index';
|
|
4
|
+
import type { ModuleLoader } from '../core/module-loader/index.js';
|
|
5
5
|
export declare function handle404Response(origin: string, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
6
6
|
export declare function handle500Response(loader: ModuleLoader, res: http.ServerResponse, err: ErrorWithMetadata): Promise<void>;
|
|
7
7
|
export declare function writeHtmlResponse(res: http.ServerResponse, statusCode: number, html: string): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import type http from 'node:http';
|
|
3
|
-
import type { ComponentInstance, ManifestData, RouteData, SSRManifest } from '../@types/astro';
|
|
3
|
+
import type { ComponentInstance, ManifestData, RouteData, SSRManifest } from '../@types/astro.js';
|
|
4
4
|
import type DevPipeline from './devPipeline.js';
|
|
5
5
|
type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (...args: any) => Promise<infer R> ? R : any;
|
|
6
6
|
export interface MatchedRoute {
|
|
@@ -241,7 +241,6 @@ async function getScriptsAndStyles({ pipeline, filePath }) {
|
|
|
241
241
|
});
|
|
242
242
|
styles.add({
|
|
243
243
|
props: {
|
|
244
|
-
type: "text/css",
|
|
245
244
|
// Track the ID so we can match it to Vite's injected style later
|
|
246
245
|
"data-astro-dev-id": viteID(new URL(`.${url}`, settings.config.root))
|
|
247
246
|
},
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { SSRElement } from '../@types/astro';
|
|
2
|
-
import type { ModuleLoader } from '../core/module-loader';
|
|
1
|
+
import type { SSRElement } from '../@types/astro.js';
|
|
2
|
+
import type { ModuleLoader } from '../core/module-loader/index.js';
|
|
3
3
|
export declare function getScriptsForURL(filePath: URL, root: URL, loader: ModuleLoader): Promise<Set<SSRElement>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ModuleLoader, ModuleNode } from '../core/module-loader/index';
|
|
1
|
+
import type { ModuleLoader, ModuleNode } from '../core/module-loader/index.js';
|
|
2
2
|
/** recursively crawl the module graph to get all style files imported by parent id */
|
|
3
3
|
export declare function crawlGraph(loader: ModuleLoader, _id: string, isRootFile: boolean, scanned?: Set<string>): AsyncGenerator<ModuleNode, void, unknown>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Plugin as VitePlugin } from 'vite';
|
|
2
|
-
import type { AstroSettings } from '../@types/astro';
|
|
2
|
+
import type { AstroSettings } from '../@types/astro.js';
|
|
3
3
|
/** Returns a Vite plugin used to alias paths from tsconfig.json and jsconfig.json. */
|
|
4
4
|
export default function configAliasVitePlugin({ settings, }: {
|
|
5
5
|
settings: AstroSettings;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { renderMarkdown } from "@astrojs/markdown-remark";
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "@astrojs/markdown-remark
|
|
2
|
+
createMarkdownProcessor,
|
|
3
|
+
InvalidAstroDataError
|
|
4
|
+
} from "@astrojs/markdown-remark";
|
|
6
5
|
import matter from "gray-matter";
|
|
7
6
|
import fs from "node:fs";
|
|
8
7
|
import path from "node:path";
|
|
@@ -41,9 +40,13 @@ const astroErrorModulePath = normalizePath(
|
|
|
41
40
|
fileURLToPath(new URL("../core/errors/index.js", import.meta.url))
|
|
42
41
|
);
|
|
43
42
|
function markdown({ settings, logger }) {
|
|
43
|
+
let processor;
|
|
44
44
|
return {
|
|
45
45
|
enforce: "pre",
|
|
46
46
|
name: "astro:markdown",
|
|
47
|
+
async buildStart() {
|
|
48
|
+
processor = await createMarkdownProcessor(settings.config.markdown);
|
|
49
|
+
},
|
|
47
50
|
// Why not the "transform" hook instead of "load" + readFile?
|
|
48
51
|
// A: Vite transforms all "import.meta.env" references to their values before
|
|
49
52
|
// passing to the transform hook. This lets us get the truly raw value
|
|
@@ -53,27 +56,24 @@ function markdown({ settings, logger }) {
|
|
|
53
56
|
const { fileId, fileUrl } = getFileInfo(id, settings.config);
|
|
54
57
|
const rawFile = await fs.promises.readFile(fileId, "utf-8");
|
|
55
58
|
const raw = safeMatter(rawFile, id);
|
|
56
|
-
const renderResult = await
|
|
57
|
-
...settings.config.markdown,
|
|
59
|
+
const renderResult = await processor.render(raw.content, {
|
|
58
60
|
fileURL: new URL(`file://${fileId}`),
|
|
59
61
|
frontmatter: raw.data
|
|
62
|
+
}).catch((err) => {
|
|
63
|
+
if (err instanceof InvalidAstroDataError) {
|
|
64
|
+
throw new AstroError(AstroErrorData.InvalidFrontmatterInjectionError);
|
|
65
|
+
}
|
|
66
|
+
throw err;
|
|
60
67
|
});
|
|
61
68
|
let html = renderResult.code;
|
|
62
|
-
const { headings } = renderResult.metadata;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
const astroData = safelyGetAstroData(renderResult.vfile.data);
|
|
73
|
-
if (astroData instanceof InvalidAstroDataError) {
|
|
74
|
-
throw new AstroError(AstroErrorData.InvalidFrontmatterInjectionError);
|
|
69
|
+
const { headings, imagePaths: rawImagePaths, frontmatter } = renderResult.metadata;
|
|
70
|
+
const imagePaths = [];
|
|
71
|
+
for (const imagePath of rawImagePaths.values()) {
|
|
72
|
+
imagePaths.push({
|
|
73
|
+
raw: imagePath,
|
|
74
|
+
resolved: (await this.resolve(imagePath, id))?.id ?? path.join(path.dirname(id), imagePath)
|
|
75
|
+
});
|
|
75
76
|
}
|
|
76
|
-
const { frontmatter } = astroData;
|
|
77
77
|
const { layout } = frontmatter;
|
|
78
78
|
if (frontmatter.setup) {
|
|
79
79
|
logger.warn(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
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",
|
|
@@ -141,6 +141,7 @@
|
|
|
141
141
|
"p-limit": "^4.0.0",
|
|
142
142
|
"path-to-regexp": "^6.2.1",
|
|
143
143
|
"preferred-pm": "^3.1.2",
|
|
144
|
+
"probe-image-size": "^7.2.3",
|
|
144
145
|
"prompts": "^2.4.2",
|
|
145
146
|
"rehype": "^12.0.1",
|
|
146
147
|
"resolve": "^1.22.4",
|
|
@@ -159,7 +160,7 @@
|
|
|
159
160
|
"yargs-parser": "^21.1.1",
|
|
160
161
|
"zod": "3.21.1",
|
|
161
162
|
"@astrojs/internal-helpers": "0.2.0",
|
|
162
|
-
"@astrojs/markdown-remark": "3.
|
|
163
|
+
"@astrojs/markdown-remark": "3.2.0",
|
|
163
164
|
"@astrojs/telemetry": "3.0.1"
|
|
164
165
|
},
|
|
165
166
|
"optionalDependencies": {
|
|
@@ -184,6 +185,7 @@
|
|
|
184
185
|
"@types/js-yaml": "^4.0.5",
|
|
185
186
|
"@types/mime": "^3.0.1",
|
|
186
187
|
"@types/mocha": "^10.0.1",
|
|
188
|
+
"@types/probe-image-size": "^7.2.0",
|
|
187
189
|
"@types/prompts": "^2.4.4",
|
|
188
190
|
"@types/resolve": "^1.20.2",
|
|
189
191
|
"@types/send": "^0.17.1",
|
package/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './astro-jsx';
|
|
2
|
-
import { AstroBuiltinAttributes } from './dist/@types/astro';
|
|
2
|
+
import { AstroBuiltinAttributes } from './dist/@types/astro.js';
|
|
3
3
|
|
|
4
4
|
/** Any supported HTML or SVG element name, as defined by the HTML specification */
|
|
5
5
|
export type HTMLTag = keyof astroHTML.JSX.DefinedIntrinsicElements;
|
|
@@ -9,6 +9,11 @@ export type HTMLAttributes<Tag extends HTMLTag> = Omit<
|
|
|
9
9
|
keyof Omit<AstroBuiltinAttributes, 'class:list'>
|
|
10
10
|
>;
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* All the CSS properties available, as defined by the CSS specification
|
|
14
|
+
*/
|
|
15
|
+
export type CSSProperty = keyof astroHTML.JSX.KebabCSSDOMProperties;
|
|
16
|
+
|
|
12
17
|
type PolymorphicAttributes<P extends { as: HTMLTag }> = Omit<P & HTMLAttributes<P['as']>, 'as'> & {
|
|
13
18
|
as?: P['as'];
|
|
14
19
|
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { typeHandlers } from "./types.js";
|
|
2
|
-
const keys = Object.keys(typeHandlers);
|
|
3
|
-
const firstBytes = {
|
|
4
|
-
56: "psd",
|
|
5
|
-
66: "bmp",
|
|
6
|
-
68: "dds",
|
|
7
|
-
71: "gif",
|
|
8
|
-
73: "tiff",
|
|
9
|
-
77: "tiff",
|
|
10
|
-
82: "webp",
|
|
11
|
-
105: "icns",
|
|
12
|
-
137: "png",
|
|
13
|
-
255: "jpg"
|
|
14
|
-
};
|
|
15
|
-
function detector(buffer) {
|
|
16
|
-
const byte = buffer[0];
|
|
17
|
-
if (byte in firstBytes) {
|
|
18
|
-
const type = firstBytes[byte];
|
|
19
|
-
if (type && typeHandlers[type].validate(buffer)) {
|
|
20
|
-
return type;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
const finder = (key) => typeHandlers[key].validate(buffer);
|
|
24
|
-
return keys.find(finder);
|
|
25
|
-
}
|
|
26
|
-
export {
|
|
27
|
-
detector
|
|
28
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { type imageType } from "./types.js";
|
|
3
|
-
import type { ISizeCalculationResult } from "./types/interface.js";
|
|
4
|
-
type CallbackFn = (e: Error | null, r?: ISizeCalculationResult) => void;
|
|
5
|
-
export default imageSize;
|
|
6
|
-
export declare function imageSize(input: Buffer | string): ISizeCalculationResult;
|
|
7
|
-
export declare function imageSize(input: string, callback: CallbackFn): void;
|
|
8
|
-
export declare const disableFS: (v: boolean) => void;
|
|
9
|
-
export declare const disableTypes: (types: imageType[]) => void;
|
|
10
|
-
export declare const setConcurrency: (c: number) => void;
|
|
11
|
-
export declare const types: string[];
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import Queue from "../queue/queue.js";
|
|
4
|
-
import { detector } from "./detector.js";
|
|
5
|
-
import { typeHandlers } from "./types.js";
|
|
6
|
-
const MaxBufferSize = 512 * 1024;
|
|
7
|
-
const queue = new Queue({ concurrency: 100, autostart: true });
|
|
8
|
-
const globalOptions = {
|
|
9
|
-
disabledFS: false,
|
|
10
|
-
disabledTypes: []
|
|
11
|
-
};
|
|
12
|
-
function lookup(buffer, filepath) {
|
|
13
|
-
const type = detector(buffer);
|
|
14
|
-
if (typeof type !== "undefined") {
|
|
15
|
-
if (globalOptions.disabledTypes.indexOf(type) > -1) {
|
|
16
|
-
throw new TypeError("disabled file type: " + type);
|
|
17
|
-
}
|
|
18
|
-
if (type in typeHandlers) {
|
|
19
|
-
const size = typeHandlers[type].calculate(buffer, filepath);
|
|
20
|
-
if (size !== void 0) {
|
|
21
|
-
size.type = type;
|
|
22
|
-
return size;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
throw new TypeError(
|
|
27
|
-
"unsupported file type: " + type + " (file: " + filepath + ")"
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
async function asyncFileToBuffer(filepath) {
|
|
31
|
-
const handle = await fs.promises.open(filepath, "r");
|
|
32
|
-
const { size } = await handle.stat();
|
|
33
|
-
if (size <= 0) {
|
|
34
|
-
await handle.close();
|
|
35
|
-
throw new Error("Empty file");
|
|
36
|
-
}
|
|
37
|
-
const bufferSize = Math.min(size, MaxBufferSize);
|
|
38
|
-
const buffer = Buffer.alloc(bufferSize);
|
|
39
|
-
await handle.read(buffer, 0, bufferSize, 0);
|
|
40
|
-
await handle.close();
|
|
41
|
-
return buffer;
|
|
42
|
-
}
|
|
43
|
-
function syncFileToBuffer(filepath) {
|
|
44
|
-
const descriptor = fs.openSync(filepath, "r");
|
|
45
|
-
const { size } = fs.fstatSync(descriptor);
|
|
46
|
-
if (size <= 0) {
|
|
47
|
-
fs.closeSync(descriptor);
|
|
48
|
-
throw new Error("Empty file");
|
|
49
|
-
}
|
|
50
|
-
const bufferSize = Math.min(size, MaxBufferSize);
|
|
51
|
-
const buffer = Buffer.alloc(bufferSize);
|
|
52
|
-
fs.readSync(descriptor, buffer, 0, bufferSize, 0);
|
|
53
|
-
fs.closeSync(descriptor);
|
|
54
|
-
return buffer;
|
|
55
|
-
}
|
|
56
|
-
var image_size_default = imageSize;
|
|
57
|
-
function imageSize(input, callback) {
|
|
58
|
-
if (Buffer.isBuffer(input)) {
|
|
59
|
-
return lookup(input);
|
|
60
|
-
}
|
|
61
|
-
if (typeof input !== "string" || globalOptions.disabledFS) {
|
|
62
|
-
throw new TypeError("invalid invocation. input should be a Buffer");
|
|
63
|
-
}
|
|
64
|
-
const filepath = path.resolve(input);
|
|
65
|
-
if (typeof callback === "function") {
|
|
66
|
-
queue.push(
|
|
67
|
-
() => asyncFileToBuffer(filepath).then(
|
|
68
|
-
(buffer) => process.nextTick(callback, null, lookup(buffer, filepath))
|
|
69
|
-
).catch(callback)
|
|
70
|
-
);
|
|
71
|
-
} else {
|
|
72
|
-
const buffer = syncFileToBuffer(filepath);
|
|
73
|
-
return lookup(buffer, filepath);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
const disableFS = (v) => {
|
|
77
|
-
globalOptions.disabledFS = v;
|
|
78
|
-
};
|
|
79
|
-
const disableTypes = (types2) => {
|
|
80
|
-
globalOptions.disabledTypes = types2;
|
|
81
|
-
};
|
|
82
|
-
const setConcurrency = (c) => {
|
|
83
|
-
queue.concurrency = c;
|
|
84
|
-
};
|
|
85
|
-
const types = Object.keys(typeHandlers);
|
|
86
|
-
export {
|
|
87
|
-
image_size_default as default,
|
|
88
|
-
disableFS,
|
|
89
|
-
disableTypes,
|
|
90
|
-
imageSize,
|
|
91
|
-
setConcurrency,
|
|
92
|
-
types
|
|
93
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ICO } from "./ico.js";
|
|
2
|
-
const TYPE_CURSOR = 2;
|
|
3
|
-
const CUR = {
|
|
4
|
-
validate(buffer) {
|
|
5
|
-
if (buffer.readUInt16LE(0) !== 0) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
return buffer.readUInt16LE(2) === TYPE_CURSOR;
|
|
9
|
-
},
|
|
10
|
-
calculate(buffer) {
|
|
11
|
-
return ICO.calculate(buffer);
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
CUR
|
|
16
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const gifRegexp = /^GIF8[79]a/;
|
|
2
|
-
const GIF = {
|
|
3
|
-
validate(buffer) {
|
|
4
|
-
const signature = buffer.toString("ascii", 0, 6);
|
|
5
|
-
return gifRegexp.test(signature);
|
|
6
|
-
},
|
|
7
|
-
calculate(buffer) {
|
|
8
|
-
return {
|
|
9
|
-
height: buffer.readUInt16LE(8),
|
|
10
|
-
width: buffer.readUInt16LE(6)
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
GIF
|
|
16
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
const SIZE_HEADER = 4 + 4;
|
|
2
|
-
const FILE_LENGTH_OFFSET = 4;
|
|
3
|
-
const ENTRY_LENGTH_OFFSET = 4;
|
|
4
|
-
const ICON_TYPE_SIZE = {
|
|
5
|
-
ICON: 32,
|
|
6
|
-
"ICN#": 32,
|
|
7
|
-
// m => 16 x 16
|
|
8
|
-
"icm#": 16,
|
|
9
|
-
icm4: 16,
|
|
10
|
-
icm8: 16,
|
|
11
|
-
// s => 16 x 16
|
|
12
|
-
"ics#": 16,
|
|
13
|
-
ics4: 16,
|
|
14
|
-
ics8: 16,
|
|
15
|
-
is32: 16,
|
|
16
|
-
s8mk: 16,
|
|
17
|
-
icp4: 16,
|
|
18
|
-
// l => 32 x 32
|
|
19
|
-
icl4: 32,
|
|
20
|
-
icl8: 32,
|
|
21
|
-
il32: 32,
|
|
22
|
-
l8mk: 32,
|
|
23
|
-
icp5: 32,
|
|
24
|
-
ic11: 32,
|
|
25
|
-
// h => 48 x 48
|
|
26
|
-
ich4: 48,
|
|
27
|
-
ich8: 48,
|
|
28
|
-
ih32: 48,
|
|
29
|
-
h8mk: 48,
|
|
30
|
-
// . => 64 x 64
|
|
31
|
-
icp6: 64,
|
|
32
|
-
ic12: 32,
|
|
33
|
-
// t => 128 x 128
|
|
34
|
-
it32: 128,
|
|
35
|
-
t8mk: 128,
|
|
36
|
-
ic07: 128,
|
|
37
|
-
// . => 256 x 256
|
|
38
|
-
ic08: 256,
|
|
39
|
-
ic13: 256,
|
|
40
|
-
// . => 512 x 512
|
|
41
|
-
ic09: 512,
|
|
42
|
-
ic14: 512,
|
|
43
|
-
// . => 1024 x 1024
|
|
44
|
-
ic10: 1024
|
|
45
|
-
};
|
|
46
|
-
function readImageHeader(buffer, imageOffset) {
|
|
47
|
-
const imageLengthOffset = imageOffset + ENTRY_LENGTH_OFFSET;
|
|
48
|
-
return [
|
|
49
|
-
buffer.toString("ascii", imageOffset, imageLengthOffset),
|
|
50
|
-
buffer.readUInt32BE(imageLengthOffset)
|
|
51
|
-
];
|
|
52
|
-
}
|
|
53
|
-
function getImageSize(type) {
|
|
54
|
-
const size = ICON_TYPE_SIZE[type];
|
|
55
|
-
return { width: size, height: size, type };
|
|
56
|
-
}
|
|
57
|
-
const ICNS = {
|
|
58
|
-
validate(buffer) {
|
|
59
|
-
return "icns" === buffer.toString("ascii", 0, 4);
|
|
60
|
-
},
|
|
61
|
-
calculate(buffer) {
|
|
62
|
-
const bufferLength = buffer.length;
|
|
63
|
-
const fileLength = buffer.readUInt32BE(FILE_LENGTH_OFFSET);
|
|
64
|
-
let imageOffset = SIZE_HEADER;
|
|
65
|
-
let imageHeader = readImageHeader(buffer, imageOffset);
|
|
66
|
-
let imageSize = getImageSize(imageHeader[0]);
|
|
67
|
-
imageOffset += imageHeader[1];
|
|
68
|
-
if (imageOffset === fileLength) {
|
|
69
|
-
return imageSize;
|
|
70
|
-
}
|
|
71
|
-
const result = {
|
|
72
|
-
height: imageSize.height,
|
|
73
|
-
images: [imageSize],
|
|
74
|
-
width: imageSize.width
|
|
75
|
-
};
|
|
76
|
-
while (imageOffset < fileLength && imageOffset < bufferLength) {
|
|
77
|
-
imageHeader = readImageHeader(buffer, imageOffset);
|
|
78
|
-
imageSize = getImageSize(imageHeader[0]);
|
|
79
|
-
imageOffset += imageHeader[1];
|
|
80
|
-
result.images.push(imageSize);
|
|
81
|
-
}
|
|
82
|
-
return result;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
export {
|
|
86
|
-
ICNS
|
|
87
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const TYPE_ICON = 1;
|
|
2
|
-
const SIZE_HEADER = 2 + 2 + 2;
|
|
3
|
-
const SIZE_IMAGE_ENTRY = 1 + 1 + 1 + 1 + 2 + 2 + 4 + 4;
|
|
4
|
-
function getSizeFromOffset(buffer, offset) {
|
|
5
|
-
const value = buffer.readUInt8(offset);
|
|
6
|
-
return value === 0 ? 256 : value;
|
|
7
|
-
}
|
|
8
|
-
function getImageSize(buffer, imageIndex) {
|
|
9
|
-
const offset = SIZE_HEADER + imageIndex * SIZE_IMAGE_ENTRY;
|
|
10
|
-
return {
|
|
11
|
-
height: getSizeFromOffset(buffer, offset + 1),
|
|
12
|
-
width: getSizeFromOffset(buffer, offset)
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
const ICO = {
|
|
16
|
-
validate(buffer) {
|
|
17
|
-
if (buffer.readUInt16LE(0) !== 0) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
return buffer.readUInt16LE(2) === TYPE_ICON;
|
|
21
|
-
},
|
|
22
|
-
calculate(buffer) {
|
|
23
|
-
const nbImages = buffer.readUInt16LE(4);
|
|
24
|
-
const imageSize = getImageSize(buffer, 0);
|
|
25
|
-
if (nbImages === 1) {
|
|
26
|
-
return imageSize;
|
|
27
|
-
}
|
|
28
|
-
const imgs = [imageSize];
|
|
29
|
-
for (let imageIndex = 1; imageIndex < nbImages; imageIndex += 1) {
|
|
30
|
-
imgs.push(getImageSize(buffer, imageIndex));
|
|
31
|
-
}
|
|
32
|
-
const result = {
|
|
33
|
-
height: imageSize.height,
|
|
34
|
-
images: imgs,
|
|
35
|
-
width: imageSize.width
|
|
36
|
-
};
|
|
37
|
-
return result;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
export {
|
|
41
|
-
ICO
|
|
42
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
export interface ISize {
|
|
3
|
-
width: number | undefined;
|
|
4
|
-
height: number | undefined;
|
|
5
|
-
orientation?: number;
|
|
6
|
-
type?: string;
|
|
7
|
-
}
|
|
8
|
-
export interface ISizeCalculationResult extends ISize {
|
|
9
|
-
images?: ISize[];
|
|
10
|
-
}
|
|
11
|
-
export interface IImage {
|
|
12
|
-
validate: (buffer: Buffer) => boolean;
|
|
13
|
-
calculate: (buffer: Buffer, filepath?: string) => ISizeCalculationResult;
|
|
14
|
-
}
|
|
File without changes
|