🎉 initiate project *astro_rewrite*

This commit is contained in:
sindrekjelsrud 2023-07-19 21:31:30 +02:00
parent ffd4d5e86c
commit 2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions

37
node_modules/astro/dist/assets/utils/emitAsset.js generated vendored Normal file
View file

@ -0,0 +1,37 @@
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
import { prependForwardSlash, slash } from "../../core/path.js";
import { imageMetadata } from "./metadata.js";
async function emitESMImage(id, watchMode, fileEmitter) {
if (!id) {
return void 0;
}
const url = pathToFileURL(id);
const meta = await imageMetadata(url);
if (!meta) {
return void 0;
}
if (!watchMode) {
const pathname = decodeURI(url.pathname);
const filename = path.basename(pathname, path.extname(pathname) + `.${meta.format}`);
const handle = fileEmitter({
name: filename,
source: await fs.promises.readFile(url),
type: "asset"
});
meta.src = `__ASTRO_ASSET_IMAGE__${handle}__`;
} else {
url.searchParams.append("origWidth", meta.width.toString());
url.searchParams.append("origHeight", meta.height.toString());
url.searchParams.append("origFormat", meta.format);
meta.src = `/@fs` + prependForwardSlash(fileURLToNormalizedPath(url));
}
return meta;
}
function fileURLToNormalizedPath(filePath) {
return slash(fileURLToPath(filePath) + filePath.search).replace(/\\/g, "/");
}
export {
emitESMImage
};