Files
website/node_modules/astro/dist/assets/utils/proxy.js
2024-05-06 17:15:30 -04:00

21 lines
556 B
JavaScript

function getProxyCode(options, isSSR) {
const stringifiedFSPath = JSON.stringify(options.fsPath);
return `
new Proxy(${JSON.stringify(options)}, {
get(target, name, receiver) {
if (name === 'clone') {
return structuredClone(target);
}
if (name === 'fsPath') {
return ${stringifiedFSPath};
}
${!isSSR ? `if (target[name] !== undefined) globalThis.astroAsset.referencedImages.add(${stringifiedFSPath});` : ""}
return target[name];
}
})
`;
}
export {
getProxyCode
};