@kyro-cms/admin 0.1.2 → 0.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.
- package/package.json +17 -6
- package/src/components/Admin.tsx +50 -1
- package/src/components/LoginPage.tsx +223 -0
- package/src/components/layout/Sidebar.tsx +35 -0
- package/src/index.ts +35 -0
- package/src/middleware.ts +2 -0
- package/src/pages/api/auth/register.ts +133 -0
- package/src/styles/main.css +148 -0
- package/.astro/content.d.ts +0 -154
- package/.astro/settings.json +0 -5
- package/.astro/types.d.ts +0 -2
- package/astro.config.mjs +0 -28
- package/bun.lock +0 -1374
- package/dist/client/_astro/AdminLayout.DkDpng53.css +0 -1
- package/dist/client/_astro/AutoForm.3eJCmCJp.js +0 -1
- package/dist/client/_astro/client.DyczpTbx.js +0 -9
- package/dist/client/_astro/index.B02hbnpo.js +0 -1
- package/dist/client/fonts/Serotiva-Black.woff2 +0 -0
- package/dist/client/fonts/Serotiva-Bold.woff2 +0 -0
- package/dist/client/fonts/Serotiva-Medium.woff2 +0 -0
- package/dist/client/fonts/Serotiva-Regular.woff2 +0 -0
- package/dist/client/fonts/Serotiva-SemiBold.woff2 +0 -0
- package/dist/server/chunks/AdminLayout_D-_JeUqC.mjs +0 -26
- package/dist/server/chunks/_id__BzI_o0qT.mjs +0 -50
- package/dist/server/chunks/_id__Cd-jOuY3.mjs +0 -238
- package/dist/server/chunks/_id__DvbD--iR.mjs +0 -992
- package/dist/server/chunks/_id__vpVaEo16.mjs +0 -128
- package/dist/server/chunks/_virtual_astro_server-island-manifest_CQQ1F5PF.mjs +0 -7
- package/dist/server/chunks/_virtual_astro_session-driver_Bk3Q189E.mjs +0 -4
- package/dist/server/chunks/astro-component_Dbx3T2Nh.mjs +0 -37
- package/dist/server/chunks/audit-logs_DrnUMRvY.mjs +0 -74
- package/dist/server/chunks/config_CPXslElD.mjs +0 -4221
- package/dist/server/chunks/dataStore_Dl7cA2Qp.mjs +0 -89
- package/dist/server/chunks/index_CVqOkerS.mjs +0 -2960
- package/dist/server/chunks/index_CX8SQ4BF.mjs +0 -55
- package/dist/server/chunks/index_CYofDU51.mjs +0 -58
- package/dist/server/chunks/index_DdNRhuaM.mjs +0 -55
- package/dist/server/chunks/index_DupPvtIF.mjs +0 -42
- package/dist/server/chunks/index_YTS_M-B9.mjs +0 -263
- package/dist/server/chunks/index_YeCzuVps.mjs +0 -53
- package/dist/server/chunks/login_DLyqMRO8.mjs +0 -93
- package/dist/server/chunks/logout_CSbt5wea.mjs +0 -50
- package/dist/server/chunks/me_C04jlYhH.mjs +0 -41
- package/dist/server/chunks/new_BbQ9b55M.mjs +0 -92
- package/dist/server/chunks/node_9bvTewss.mjs +0 -1014
- package/dist/server/chunks/noop-entrypoint_BOlrdqWF.mjs +0 -3
- package/dist/server/chunks/sequence_9cl7AJy-.mjs +0 -2503
- package/dist/server/chunks/server_peBx9VXG.mjs +0 -8117
- package/dist/server/chunks/sharp_pmJ7nHES.mjs +0 -142
- package/dist/server/chunks/users_Dzddy_YR.mjs +0 -137
- package/dist/server/entry.mjs +0 -5
- package/dist/server/virtual_astro_middleware.mjs +0 -48
- package/public/fonts/Serotiva-Black.woff2 +0 -0
- package/public/fonts/Serotiva-Bold.woff2 +0 -0
- package/public/fonts/Serotiva-Medium.woff2 +0 -0
- package/public/fonts/Serotiva-Regular.woff2 +0 -0
- package/public/fonts/Serotiva-SemiBold.woff2 +0 -0
- package/tsconfig.json +0 -12
|
@@ -1,1014 +0,0 @@
|
|
|
1
|
-
import { A as AstroError, aV as NoImageMetadata, aW as FailedToFetchRemoteImageDimensions, aX as RemoteImageNotAllowed, aH as joinPaths, aY as ExpectedImage, aZ as isRemotePath, a_ as LocalImageUsedWrongly, a$ as MissingImageDimension, b0 as UnsupportedImageFormat, b1 as IncompatibleDescriptorOptions, b2 as UnsupportedImageConversion, b3 as InvalidImageService, b4 as ExpectedImageOptions, b5 as ExpectedNotESMImage, b6 as ImageMissingAlt, B as maybeRenderHead, a3 as addAttribute, Q as renderTemplate, b7 as FontFamilyNotFound, b8 as unescapeHTML, b9 as removeQueryString, ba as isParentDirectory } from './sequence_9cl7AJy-.mjs';
|
|
2
|
-
import { t as typeHandlers, a as types, i as isRemoteAllowed, s as spreadAttributes } from './server_peBx9VXG.mjs';
|
|
3
|
-
import { c as createComponent } from './astro-component_Dbx3T2Nh.mjs';
|
|
4
|
-
import 'clsx';
|
|
5
|
-
import * as mime from 'mrmime';
|
|
6
|
-
import 'piccolore';
|
|
7
|
-
import { readFile } from 'node:fs/promises';
|
|
8
|
-
import path from 'node:path';
|
|
9
|
-
import { fileURLToPath } from 'node:url';
|
|
10
|
-
|
|
11
|
-
function isESMImportedImage(src) {
|
|
12
|
-
return typeof src === "object" || typeof src === "function" && "src" in src;
|
|
13
|
-
}
|
|
14
|
-
function isRemoteImage(src) {
|
|
15
|
-
return typeof src === "string";
|
|
16
|
-
}
|
|
17
|
-
async function resolveSrc(src) {
|
|
18
|
-
if (typeof src === "object" && "then" in src) {
|
|
19
|
-
const resource = await src;
|
|
20
|
-
return resource.default ?? resource;
|
|
21
|
-
}
|
|
22
|
-
return src;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const firstBytes = /* @__PURE__ */ new Map([
|
|
26
|
-
[0, "heif"],
|
|
27
|
-
[56, "psd"],
|
|
28
|
-
[66, "bmp"],
|
|
29
|
-
[68, "dds"],
|
|
30
|
-
[71, "gif"],
|
|
31
|
-
[73, "tiff"],
|
|
32
|
-
[77, "tiff"],
|
|
33
|
-
[82, "webp"],
|
|
34
|
-
[105, "icns"],
|
|
35
|
-
[137, "png"],
|
|
36
|
-
[255, "jpg"]
|
|
37
|
-
]);
|
|
38
|
-
function detector(input) {
|
|
39
|
-
const byte = input[0];
|
|
40
|
-
const type = firstBytes.get(byte);
|
|
41
|
-
if (type && typeHandlers.get(type).validate(input)) {
|
|
42
|
-
return type;
|
|
43
|
-
}
|
|
44
|
-
return types.find((imageType) => typeHandlers.get(imageType).validate(input));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function lookup(input) {
|
|
48
|
-
const type = detector(input);
|
|
49
|
-
if (typeof type !== "undefined") {
|
|
50
|
-
const size = typeHandlers.get(type).calculate(input);
|
|
51
|
-
if (size !== void 0) {
|
|
52
|
-
size.type = size.type ?? type;
|
|
53
|
-
return size;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
throw new TypeError("unsupported file type: " + type);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async function imageMetadata(data, src) {
|
|
60
|
-
let result;
|
|
61
|
-
try {
|
|
62
|
-
result = lookup(data);
|
|
63
|
-
} catch {
|
|
64
|
-
throw new AstroError({
|
|
65
|
-
...NoImageMetadata,
|
|
66
|
-
message: NoImageMetadata.message(src)
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
if (!result.height || !result.width || !result.type) {
|
|
70
|
-
throw new AstroError({
|
|
71
|
-
...NoImageMetadata,
|
|
72
|
-
message: NoImageMetadata.message(src)
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
const { width, height, type, orientation } = result;
|
|
76
|
-
const isPortrait = (orientation || 0) >= 5;
|
|
77
|
-
return {
|
|
78
|
-
width: isPortrait ? height : width,
|
|
79
|
-
height: isPortrait ? width : height,
|
|
80
|
-
format: type,
|
|
81
|
-
orientation
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
async function inferRemoteSize(url, imageConfig) {
|
|
86
|
-
if (!URL.canParse(url)) {
|
|
87
|
-
throw new AstroError({
|
|
88
|
-
...FailedToFetchRemoteImageDimensions,
|
|
89
|
-
message: FailedToFetchRemoteImageDimensions.message(url)
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
const allowlistConfig = imageConfig ? {
|
|
93
|
-
domains: imageConfig.domains ?? [],
|
|
94
|
-
remotePatterns: imageConfig.remotePatterns ?? []
|
|
95
|
-
} : void 0;
|
|
96
|
-
if (!allowlistConfig) {
|
|
97
|
-
const parsedUrl = new URL(url);
|
|
98
|
-
if (!["http:", "https:"].includes(parsedUrl.protocol)) {
|
|
99
|
-
throw new AstroError({
|
|
100
|
-
...FailedToFetchRemoteImageDimensions,
|
|
101
|
-
message: FailedToFetchRemoteImageDimensions.message(url)
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (allowlistConfig && !isRemoteAllowed(url, allowlistConfig)) {
|
|
106
|
-
throw new AstroError({
|
|
107
|
-
...RemoteImageNotAllowed,
|
|
108
|
-
message: RemoteImageNotAllowed.message(url)
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
const response = await fetch(url, { redirect: "manual" });
|
|
112
|
-
if (response.status >= 300 && response.status < 400) {
|
|
113
|
-
throw new AstroError({
|
|
114
|
-
...FailedToFetchRemoteImageDimensions,
|
|
115
|
-
message: FailedToFetchRemoteImageDimensions.message(url)
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
if (!response.body || !response.ok) {
|
|
119
|
-
throw new AstroError({
|
|
120
|
-
...FailedToFetchRemoteImageDimensions,
|
|
121
|
-
message: FailedToFetchRemoteImageDimensions.message(url)
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
const reader = response.body.getReader();
|
|
125
|
-
let done, value;
|
|
126
|
-
let accumulatedChunks = new Uint8Array();
|
|
127
|
-
while (!done) {
|
|
128
|
-
const readResult = await reader.read();
|
|
129
|
-
done = readResult.done;
|
|
130
|
-
if (done) break;
|
|
131
|
-
if (readResult.value) {
|
|
132
|
-
value = readResult.value;
|
|
133
|
-
let tmp = new Uint8Array(accumulatedChunks.length + value.length);
|
|
134
|
-
tmp.set(accumulatedChunks, 0);
|
|
135
|
-
tmp.set(value, accumulatedChunks.length);
|
|
136
|
-
accumulatedChunks = tmp;
|
|
137
|
-
try {
|
|
138
|
-
const dimensions = await imageMetadata(accumulatedChunks, url);
|
|
139
|
-
if (dimensions) {
|
|
140
|
-
await reader.cancel();
|
|
141
|
-
return dimensions;
|
|
142
|
-
}
|
|
143
|
-
} catch {
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
throw new AstroError({
|
|
148
|
-
...NoImageMetadata,
|
|
149
|
-
message: NoImageMetadata.message(url)
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const VALID_SUPPORTED_FORMATS = [
|
|
154
|
-
"jpeg",
|
|
155
|
-
"jpg",
|
|
156
|
-
"png",
|
|
157
|
-
"tiff",
|
|
158
|
-
"webp",
|
|
159
|
-
"gif",
|
|
160
|
-
"svg",
|
|
161
|
-
"avif"
|
|
162
|
-
];
|
|
163
|
-
const DEFAULT_OUTPUT_FORMAT = "webp";
|
|
164
|
-
const DEFAULT_HASH_PROPS = [
|
|
165
|
-
"src",
|
|
166
|
-
"width",
|
|
167
|
-
"height",
|
|
168
|
-
"format",
|
|
169
|
-
"quality",
|
|
170
|
-
"fit",
|
|
171
|
-
"position",
|
|
172
|
-
"background"
|
|
173
|
-
];
|
|
174
|
-
|
|
175
|
-
const DEFAULT_RESOLUTIONS = [
|
|
176
|
-
640,
|
|
177
|
-
// older and lower-end phones
|
|
178
|
-
750,
|
|
179
|
-
// iPhone 6-8
|
|
180
|
-
828,
|
|
181
|
-
// iPhone XR/11
|
|
182
|
-
960,
|
|
183
|
-
// older horizontal phones
|
|
184
|
-
1080,
|
|
185
|
-
// iPhone 6-8 Plus
|
|
186
|
-
1280,
|
|
187
|
-
// 720p
|
|
188
|
-
1668,
|
|
189
|
-
// Various iPads
|
|
190
|
-
1920,
|
|
191
|
-
// 1080p
|
|
192
|
-
2048,
|
|
193
|
-
// QXGA
|
|
194
|
-
2560,
|
|
195
|
-
// WQXGA
|
|
196
|
-
3200,
|
|
197
|
-
// QHD+
|
|
198
|
-
3840,
|
|
199
|
-
// 4K
|
|
200
|
-
4480,
|
|
201
|
-
// 4.5K
|
|
202
|
-
5120,
|
|
203
|
-
// 5K
|
|
204
|
-
6016
|
|
205
|
-
// 6K
|
|
206
|
-
];
|
|
207
|
-
const LIMITED_RESOLUTIONS = [
|
|
208
|
-
640,
|
|
209
|
-
// older and lower-end phones
|
|
210
|
-
750,
|
|
211
|
-
// iPhone 6-8
|
|
212
|
-
828,
|
|
213
|
-
// iPhone XR/11
|
|
214
|
-
1080,
|
|
215
|
-
// iPhone 6-8 Plus
|
|
216
|
-
1280,
|
|
217
|
-
// 720p
|
|
218
|
-
1668,
|
|
219
|
-
// Various iPads
|
|
220
|
-
2048,
|
|
221
|
-
// QXGA
|
|
222
|
-
2560
|
|
223
|
-
// WQXGA
|
|
224
|
-
];
|
|
225
|
-
const getWidths = ({
|
|
226
|
-
width,
|
|
227
|
-
layout,
|
|
228
|
-
breakpoints = DEFAULT_RESOLUTIONS,
|
|
229
|
-
originalWidth
|
|
230
|
-
}) => {
|
|
231
|
-
const smallerThanOriginal = (w) => !originalWidth || w <= originalWidth;
|
|
232
|
-
if (layout === "full-width") {
|
|
233
|
-
return breakpoints.filter(smallerThanOriginal);
|
|
234
|
-
}
|
|
235
|
-
if (!width) {
|
|
236
|
-
return [];
|
|
237
|
-
}
|
|
238
|
-
const doubleWidth = width * 2;
|
|
239
|
-
const maxSize = originalWidth ? Math.min(doubleWidth, originalWidth) : doubleWidth;
|
|
240
|
-
if (layout === "fixed") {
|
|
241
|
-
return originalWidth && width > originalWidth ? [originalWidth] : [width, maxSize];
|
|
242
|
-
}
|
|
243
|
-
if (layout === "constrained") {
|
|
244
|
-
return [
|
|
245
|
-
// Always include the image at 1x and 2x the specified width
|
|
246
|
-
width,
|
|
247
|
-
doubleWidth,
|
|
248
|
-
...breakpoints
|
|
249
|
-
].filter((w) => w <= maxSize).sort((a, b) => a - b);
|
|
250
|
-
}
|
|
251
|
-
return [];
|
|
252
|
-
};
|
|
253
|
-
const getSizesAttribute = ({
|
|
254
|
-
width,
|
|
255
|
-
layout
|
|
256
|
-
}) => {
|
|
257
|
-
if (!width || !layout) {
|
|
258
|
-
return void 0;
|
|
259
|
-
}
|
|
260
|
-
switch (layout) {
|
|
261
|
-
// If screen is wider than the max size then image width is the max size,
|
|
262
|
-
// otherwise it's the width of the screen
|
|
263
|
-
case "constrained":
|
|
264
|
-
return `(min-width: ${width}px) ${width}px, 100vw`;
|
|
265
|
-
// Image is always the same width, whatever the size of the screen
|
|
266
|
-
case "fixed":
|
|
267
|
-
return `${width}px`;
|
|
268
|
-
// Image is always the width of the screen
|
|
269
|
-
case "full-width":
|
|
270
|
-
return `100vw`;
|
|
271
|
-
case "none":
|
|
272
|
-
default:
|
|
273
|
-
return void 0;
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
function isLocalService(service) {
|
|
278
|
-
if (!service) {
|
|
279
|
-
return false;
|
|
280
|
-
}
|
|
281
|
-
return "transform" in service;
|
|
282
|
-
}
|
|
283
|
-
function parseQuality(quality) {
|
|
284
|
-
let result = Number.parseInt(quality);
|
|
285
|
-
if (Number.isNaN(result)) {
|
|
286
|
-
return quality;
|
|
287
|
-
}
|
|
288
|
-
return result;
|
|
289
|
-
}
|
|
290
|
-
const sortNumeric = (a, b) => a - b;
|
|
291
|
-
function verifyOptions(options) {
|
|
292
|
-
if (!options.src || !isRemoteImage(options.src) && !isESMImportedImage(options.src)) {
|
|
293
|
-
throw new AstroError({
|
|
294
|
-
...ExpectedImage,
|
|
295
|
-
message: ExpectedImage.message(
|
|
296
|
-
JSON.stringify(options.src),
|
|
297
|
-
typeof options.src,
|
|
298
|
-
JSON.stringify(options, (_, v) => v === void 0 ? null : v)
|
|
299
|
-
)
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
if (!isESMImportedImage(options.src)) {
|
|
303
|
-
if (options.src.startsWith("/@fs/") || !isRemotePath(options.src) && !options.src.startsWith("/")) {
|
|
304
|
-
throw new AstroError({
|
|
305
|
-
...LocalImageUsedWrongly,
|
|
306
|
-
message: LocalImageUsedWrongly.message(options.src)
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
let missingDimension;
|
|
310
|
-
if (!options.width && !options.height) {
|
|
311
|
-
missingDimension = "both";
|
|
312
|
-
} else if (!options.width && options.height) {
|
|
313
|
-
missingDimension = "width";
|
|
314
|
-
} else if (options.width && !options.height) {
|
|
315
|
-
missingDimension = "height";
|
|
316
|
-
}
|
|
317
|
-
if (missingDimension) {
|
|
318
|
-
throw new AstroError({
|
|
319
|
-
...MissingImageDimension,
|
|
320
|
-
message: MissingImageDimension.message(missingDimension, options.src)
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
} else {
|
|
324
|
-
if (!VALID_SUPPORTED_FORMATS.includes(options.src.format)) {
|
|
325
|
-
throw new AstroError({
|
|
326
|
-
...UnsupportedImageFormat,
|
|
327
|
-
message: UnsupportedImageFormat.message(
|
|
328
|
-
options.src.format,
|
|
329
|
-
options.src.src,
|
|
330
|
-
VALID_SUPPORTED_FORMATS
|
|
331
|
-
)
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
if (options.widths && options.densities) {
|
|
335
|
-
throw new AstroError(IncompatibleDescriptorOptions);
|
|
336
|
-
}
|
|
337
|
-
if (options.src.format !== "svg" && options.format === "svg") {
|
|
338
|
-
throw new AstroError(UnsupportedImageConversion);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
const baseService = {
|
|
343
|
-
validateOptions(options) {
|
|
344
|
-
verifyOptions(options);
|
|
345
|
-
if (!options.format) {
|
|
346
|
-
if (isESMImportedImage(options.src) && options.src.format === "svg") {
|
|
347
|
-
options.format = "svg";
|
|
348
|
-
} else {
|
|
349
|
-
options.format = DEFAULT_OUTPUT_FORMAT;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
if (options.width) options.width = Math.round(options.width);
|
|
353
|
-
if (options.height) options.height = Math.round(options.height);
|
|
354
|
-
if (options.layout) {
|
|
355
|
-
delete options.layout;
|
|
356
|
-
}
|
|
357
|
-
if (options.fit === "none") {
|
|
358
|
-
delete options.fit;
|
|
359
|
-
}
|
|
360
|
-
return options;
|
|
361
|
-
},
|
|
362
|
-
getHTMLAttributes(options) {
|
|
363
|
-
const { targetWidth, targetHeight } = getTargetDimensions(options);
|
|
364
|
-
const {
|
|
365
|
-
src,
|
|
366
|
-
width,
|
|
367
|
-
height,
|
|
368
|
-
format,
|
|
369
|
-
quality,
|
|
370
|
-
densities,
|
|
371
|
-
widths,
|
|
372
|
-
formats,
|
|
373
|
-
layout,
|
|
374
|
-
priority,
|
|
375
|
-
fit,
|
|
376
|
-
position,
|
|
377
|
-
background,
|
|
378
|
-
...attributes
|
|
379
|
-
} = options;
|
|
380
|
-
return {
|
|
381
|
-
...attributes,
|
|
382
|
-
width: targetWidth,
|
|
383
|
-
height: targetHeight,
|
|
384
|
-
loading: attributes.loading ?? "lazy",
|
|
385
|
-
decoding: attributes.decoding ?? "async"
|
|
386
|
-
};
|
|
387
|
-
},
|
|
388
|
-
getSrcSet(options) {
|
|
389
|
-
const { targetWidth, targetHeight } = getTargetDimensions(options);
|
|
390
|
-
const aspectRatio = targetWidth / targetHeight;
|
|
391
|
-
const { widths, densities } = options;
|
|
392
|
-
const targetFormat = options.format ?? DEFAULT_OUTPUT_FORMAT;
|
|
393
|
-
let transformedWidths = (widths ?? []).sort(sortNumeric);
|
|
394
|
-
let imageWidth = options.width;
|
|
395
|
-
let maxWidth = Number.POSITIVE_INFINITY;
|
|
396
|
-
if (isESMImportedImage(options.src)) {
|
|
397
|
-
imageWidth = options.src.width;
|
|
398
|
-
maxWidth = imageWidth;
|
|
399
|
-
if (transformedWidths.length > 0 && transformedWidths.at(-1) > maxWidth) {
|
|
400
|
-
transformedWidths = transformedWidths.filter((width) => width <= maxWidth);
|
|
401
|
-
transformedWidths.push(maxWidth);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
transformedWidths = Array.from(new Set(transformedWidths));
|
|
405
|
-
const {
|
|
406
|
-
width: transformWidth,
|
|
407
|
-
height: transformHeight,
|
|
408
|
-
...transformWithoutDimensions
|
|
409
|
-
} = options;
|
|
410
|
-
let allWidths = [];
|
|
411
|
-
if (densities) {
|
|
412
|
-
const densityValues = densities.map((density) => {
|
|
413
|
-
if (typeof density === "number") {
|
|
414
|
-
return density;
|
|
415
|
-
} else {
|
|
416
|
-
return Number.parseFloat(density);
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
|
-
const densityWidths = densityValues.sort(sortNumeric).map((density) => Math.round(targetWidth * density));
|
|
420
|
-
allWidths = densityWidths.map((width, index) => ({
|
|
421
|
-
width,
|
|
422
|
-
descriptor: `${densityValues[index]}x`
|
|
423
|
-
}));
|
|
424
|
-
} else if (transformedWidths.length > 0) {
|
|
425
|
-
allWidths = transformedWidths.map((width) => ({
|
|
426
|
-
width,
|
|
427
|
-
descriptor: `${width}w`
|
|
428
|
-
}));
|
|
429
|
-
}
|
|
430
|
-
return allWidths.map(({ width, descriptor }) => {
|
|
431
|
-
const height = Math.round(width / aspectRatio);
|
|
432
|
-
const transform = { ...transformWithoutDimensions, width, height };
|
|
433
|
-
return {
|
|
434
|
-
transform,
|
|
435
|
-
descriptor,
|
|
436
|
-
attributes: {
|
|
437
|
-
type: `image/${targetFormat}`
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
});
|
|
441
|
-
},
|
|
442
|
-
getURL(options, imageConfig) {
|
|
443
|
-
const searchParams = new URLSearchParams();
|
|
444
|
-
if (isESMImportedImage(options.src)) {
|
|
445
|
-
searchParams.append("href", options.src.src);
|
|
446
|
-
} else if (isRemoteAllowed(options.src, imageConfig)) {
|
|
447
|
-
searchParams.append("href", options.src);
|
|
448
|
-
} else {
|
|
449
|
-
return options.src;
|
|
450
|
-
}
|
|
451
|
-
const params = {
|
|
452
|
-
w: "width",
|
|
453
|
-
h: "height",
|
|
454
|
-
q: "quality",
|
|
455
|
-
f: "format",
|
|
456
|
-
fit: "fit",
|
|
457
|
-
position: "position",
|
|
458
|
-
background: "background"
|
|
459
|
-
};
|
|
460
|
-
Object.entries(params).forEach(([param, key]) => {
|
|
461
|
-
options[key] && searchParams.append(param, options[key].toString());
|
|
462
|
-
});
|
|
463
|
-
const imageEndpoint = joinPaths("/", imageConfig.endpoint.route);
|
|
464
|
-
let url = `${imageEndpoint}?${searchParams}`;
|
|
465
|
-
if (imageConfig.assetQueryParams) {
|
|
466
|
-
const assetQueryString = imageConfig.assetQueryParams.toString();
|
|
467
|
-
if (assetQueryString) {
|
|
468
|
-
url += "&" + assetQueryString;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
return url;
|
|
472
|
-
},
|
|
473
|
-
parseURL(url) {
|
|
474
|
-
const params = url.searchParams;
|
|
475
|
-
if (!params.has("href")) {
|
|
476
|
-
return void 0;
|
|
477
|
-
}
|
|
478
|
-
const transform = {
|
|
479
|
-
src: params.get("href"),
|
|
480
|
-
width: params.has("w") ? Number.parseInt(params.get("w")) : void 0,
|
|
481
|
-
height: params.has("h") ? Number.parseInt(params.get("h")) : void 0,
|
|
482
|
-
format: params.get("f"),
|
|
483
|
-
quality: params.get("q"),
|
|
484
|
-
fit: params.get("fit"),
|
|
485
|
-
position: params.get("position") ?? void 0,
|
|
486
|
-
background: params.get("background") ?? void 0
|
|
487
|
-
};
|
|
488
|
-
return transform;
|
|
489
|
-
},
|
|
490
|
-
getRemoteSize(url, imageConfig) {
|
|
491
|
-
return inferRemoteSize(url, imageConfig);
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
function getTargetDimensions(options) {
|
|
495
|
-
let targetWidth = options.width;
|
|
496
|
-
let targetHeight = options.height;
|
|
497
|
-
if (isESMImportedImage(options.src)) {
|
|
498
|
-
const aspectRatio = options.src.width / options.src.height;
|
|
499
|
-
if (targetHeight && !targetWidth) {
|
|
500
|
-
targetWidth = Math.round(targetHeight * aspectRatio);
|
|
501
|
-
} else if (targetWidth && !targetHeight) {
|
|
502
|
-
targetHeight = Math.round(targetWidth / aspectRatio);
|
|
503
|
-
} else if (!targetWidth && !targetHeight) {
|
|
504
|
-
targetWidth = options.src.width;
|
|
505
|
-
targetHeight = options.src.height;
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
return {
|
|
509
|
-
targetWidth,
|
|
510
|
-
targetHeight
|
|
511
|
-
};
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
function isImageMetadata(src) {
|
|
515
|
-
return src.fsPath && !("fsPath" in src);
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
const PLACEHOLDER_BASE = "astro://placeholder";
|
|
519
|
-
function createPlaceholderURL(pathOrUrl) {
|
|
520
|
-
return new URL(pathOrUrl, PLACEHOLDER_BASE);
|
|
521
|
-
}
|
|
522
|
-
function stringifyPlaceholderURL(url) {
|
|
523
|
-
return url.href.replace(PLACEHOLDER_BASE, "");
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
const cssFitValues = ["fill", "contain", "cover", "scale-down"];
|
|
527
|
-
async function getConfiguredImageService() {
|
|
528
|
-
if (!globalThis?.astroAsset?.imageService) {
|
|
529
|
-
const { default: service } = await import(
|
|
530
|
-
// @ts-expect-error
|
|
531
|
-
'./sharp_pmJ7nHES.mjs'
|
|
532
|
-
).catch((e) => {
|
|
533
|
-
const error = new AstroError(InvalidImageService);
|
|
534
|
-
error.cause = e;
|
|
535
|
-
throw error;
|
|
536
|
-
});
|
|
537
|
-
if (!globalThis.astroAsset) globalThis.astroAsset = {};
|
|
538
|
-
globalThis.astroAsset.imageService = service;
|
|
539
|
-
return service;
|
|
540
|
-
}
|
|
541
|
-
return globalThis.astroAsset.imageService;
|
|
542
|
-
}
|
|
543
|
-
async function getImage$1(options, imageConfig) {
|
|
544
|
-
if (!options || typeof options !== "object") {
|
|
545
|
-
throw new AstroError({
|
|
546
|
-
...ExpectedImageOptions,
|
|
547
|
-
message: ExpectedImageOptions.message(JSON.stringify(options))
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
if (typeof options.src === "undefined") {
|
|
551
|
-
throw new AstroError({
|
|
552
|
-
...ExpectedImage,
|
|
553
|
-
message: ExpectedImage.message(
|
|
554
|
-
options.src,
|
|
555
|
-
"undefined",
|
|
556
|
-
JSON.stringify(options)
|
|
557
|
-
)
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
if (isImageMetadata(options)) {
|
|
561
|
-
throw new AstroError(ExpectedNotESMImage);
|
|
562
|
-
}
|
|
563
|
-
const service = await getConfiguredImageService();
|
|
564
|
-
const resolvedOptions = {
|
|
565
|
-
...options,
|
|
566
|
-
src: await resolveSrc(options.src)
|
|
567
|
-
};
|
|
568
|
-
let originalWidth;
|
|
569
|
-
let originalHeight;
|
|
570
|
-
if (resolvedOptions.inferSize) {
|
|
571
|
-
delete resolvedOptions.inferSize;
|
|
572
|
-
if (isRemoteImage(resolvedOptions.src) && isRemotePath(resolvedOptions.src)) {
|
|
573
|
-
if (!isRemoteAllowed(resolvedOptions.src, imageConfig)) {
|
|
574
|
-
throw new AstroError({
|
|
575
|
-
...RemoteImageNotAllowed,
|
|
576
|
-
message: RemoteImageNotAllowed.message(resolvedOptions.src)
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
const getRemoteSize = (url) => service.getRemoteSize?.(url, imageConfig) ?? inferRemoteSize(url, imageConfig);
|
|
580
|
-
const result = await getRemoteSize(resolvedOptions.src);
|
|
581
|
-
resolvedOptions.width ??= result.width;
|
|
582
|
-
resolvedOptions.height ??= result.height;
|
|
583
|
-
originalWidth = result.width;
|
|
584
|
-
originalHeight = result.height;
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
const originalFilePath = isESMImportedImage(resolvedOptions.src) ? resolvedOptions.src.fsPath : void 0;
|
|
588
|
-
const clonedSrc = isESMImportedImage(resolvedOptions.src) ? (
|
|
589
|
-
// @ts-expect-error - clone is a private, hidden prop
|
|
590
|
-
resolvedOptions.src.clone ?? resolvedOptions.src
|
|
591
|
-
) : resolvedOptions.src;
|
|
592
|
-
if (isESMImportedImage(clonedSrc)) {
|
|
593
|
-
originalWidth = clonedSrc.width;
|
|
594
|
-
originalHeight = clonedSrc.height;
|
|
595
|
-
}
|
|
596
|
-
if (originalWidth && originalHeight) {
|
|
597
|
-
const aspectRatio = originalWidth / originalHeight;
|
|
598
|
-
if (resolvedOptions.height && !resolvedOptions.width) {
|
|
599
|
-
resolvedOptions.width = Math.round(resolvedOptions.height * aspectRatio);
|
|
600
|
-
} else if (resolvedOptions.width && !resolvedOptions.height) {
|
|
601
|
-
resolvedOptions.height = Math.round(resolvedOptions.width / aspectRatio);
|
|
602
|
-
} else if (!resolvedOptions.width && !resolvedOptions.height) {
|
|
603
|
-
resolvedOptions.width = originalWidth;
|
|
604
|
-
resolvedOptions.height = originalHeight;
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
resolvedOptions.src = clonedSrc;
|
|
608
|
-
const layout = options.layout ?? imageConfig.layout ?? "none";
|
|
609
|
-
if (resolvedOptions.priority) {
|
|
610
|
-
resolvedOptions.loading ??= "eager";
|
|
611
|
-
resolvedOptions.decoding ??= "sync";
|
|
612
|
-
resolvedOptions.fetchpriority ??= "high";
|
|
613
|
-
delete resolvedOptions.priority;
|
|
614
|
-
} else {
|
|
615
|
-
resolvedOptions.loading ??= "lazy";
|
|
616
|
-
resolvedOptions.decoding ??= "async";
|
|
617
|
-
resolvedOptions.fetchpriority ??= void 0;
|
|
618
|
-
}
|
|
619
|
-
if (layout !== "none") {
|
|
620
|
-
resolvedOptions.widths ||= getWidths({
|
|
621
|
-
width: resolvedOptions.width,
|
|
622
|
-
layout,
|
|
623
|
-
originalWidth,
|
|
624
|
-
breakpoints: imageConfig.breakpoints?.length ? imageConfig.breakpoints : isLocalService(service) ? LIMITED_RESOLUTIONS : DEFAULT_RESOLUTIONS
|
|
625
|
-
});
|
|
626
|
-
resolvedOptions.sizes ||= getSizesAttribute({ width: resolvedOptions.width, layout });
|
|
627
|
-
delete resolvedOptions.densities;
|
|
628
|
-
resolvedOptions["data-astro-image"] = layout;
|
|
629
|
-
if (resolvedOptions.fit && cssFitValues.includes(resolvedOptions.fit)) {
|
|
630
|
-
resolvedOptions["data-astro-image-fit"] = resolvedOptions.fit;
|
|
631
|
-
}
|
|
632
|
-
if (resolvedOptions.position) {
|
|
633
|
-
resolvedOptions["data-astro-image-pos"] = resolvedOptions.position.replace(/\s+/g, "-");
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
const validatedOptions = service.validateOptions ? await service.validateOptions(resolvedOptions, imageConfig) : resolvedOptions;
|
|
637
|
-
const srcSetTransforms = service.getSrcSet ? await service.getSrcSet(validatedOptions, imageConfig) : [];
|
|
638
|
-
const lazyImageURLFactory = (getValue) => {
|
|
639
|
-
let cached = null;
|
|
640
|
-
return () => cached ??= getValue();
|
|
641
|
-
};
|
|
642
|
-
const initialImageURL = await service.getURL(validatedOptions, imageConfig);
|
|
643
|
-
let lazyImageURL = lazyImageURLFactory(() => initialImageURL);
|
|
644
|
-
const matchesValidatedTransform = (transform) => transform.width === validatedOptions.width && transform.height === validatedOptions.height && transform.format === validatedOptions.format;
|
|
645
|
-
let srcSets = await Promise.all(
|
|
646
|
-
srcSetTransforms.map(async (srcSet) => {
|
|
647
|
-
return {
|
|
648
|
-
transform: srcSet.transform,
|
|
649
|
-
url: matchesValidatedTransform(srcSet.transform) ? initialImageURL : await service.getURL(srcSet.transform, imageConfig),
|
|
650
|
-
descriptor: srcSet.descriptor,
|
|
651
|
-
attributes: srcSet.attributes
|
|
652
|
-
};
|
|
653
|
-
})
|
|
654
|
-
);
|
|
655
|
-
if (isLocalService(service) && globalThis.astroAsset.addStaticImage && !(isRemoteImage(validatedOptions.src) && initialImageURL === validatedOptions.src)) {
|
|
656
|
-
const propsToHash = service.propertiesToHash ?? DEFAULT_HASH_PROPS;
|
|
657
|
-
lazyImageURL = lazyImageURLFactory(
|
|
658
|
-
() => globalThis.astroAsset.addStaticImage(validatedOptions, propsToHash, originalFilePath)
|
|
659
|
-
);
|
|
660
|
-
srcSets = srcSetTransforms.map((srcSet) => {
|
|
661
|
-
return {
|
|
662
|
-
transform: srcSet.transform,
|
|
663
|
-
url: matchesValidatedTransform(srcSet.transform) ? lazyImageURL() : globalThis.astroAsset.addStaticImage(srcSet.transform, propsToHash, originalFilePath),
|
|
664
|
-
descriptor: srcSet.descriptor,
|
|
665
|
-
attributes: srcSet.attributes
|
|
666
|
-
};
|
|
667
|
-
});
|
|
668
|
-
} else if (imageConfig.assetQueryParams) {
|
|
669
|
-
const imageURLObj = createPlaceholderURL(initialImageURL);
|
|
670
|
-
imageConfig.assetQueryParams.forEach((value, key) => {
|
|
671
|
-
imageURLObj.searchParams.set(key, value);
|
|
672
|
-
});
|
|
673
|
-
lazyImageURL = lazyImageURLFactory(() => stringifyPlaceholderURL(imageURLObj));
|
|
674
|
-
srcSets = srcSets.map((srcSet) => {
|
|
675
|
-
const urlObj = createPlaceholderURL(srcSet.url);
|
|
676
|
-
imageConfig.assetQueryParams.forEach((value, key) => {
|
|
677
|
-
urlObj.searchParams.set(key, value);
|
|
678
|
-
});
|
|
679
|
-
return {
|
|
680
|
-
...srcSet,
|
|
681
|
-
url: stringifyPlaceholderURL(urlObj)
|
|
682
|
-
};
|
|
683
|
-
});
|
|
684
|
-
}
|
|
685
|
-
return {
|
|
686
|
-
rawOptions: resolvedOptions,
|
|
687
|
-
options: validatedOptions,
|
|
688
|
-
get src() {
|
|
689
|
-
return lazyImageURL();
|
|
690
|
-
},
|
|
691
|
-
srcSet: {
|
|
692
|
-
values: srcSets,
|
|
693
|
-
attribute: srcSets.map((srcSet) => `${srcSet.url} ${srcSet.descriptor}`).join(", ")
|
|
694
|
-
},
|
|
695
|
-
attributes: service.getHTMLAttributes !== void 0 ? await service.getHTMLAttributes(validatedOptions, imageConfig) : {}
|
|
696
|
-
};
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
Function.prototype.toString.call(Object);
|
|
700
|
-
|
|
701
|
-
const $$Image = createComponent(async ($$result, $$props, $$slots) => {
|
|
702
|
-
const Astro2 = $$result.createAstro($$props, $$slots);
|
|
703
|
-
Astro2.self = $$Image;
|
|
704
|
-
const props = Astro2.props;
|
|
705
|
-
if (props.alt === void 0 || props.alt === null) {
|
|
706
|
-
throw new AstroError(ImageMissingAlt);
|
|
707
|
-
}
|
|
708
|
-
if (typeof props.width === "string") {
|
|
709
|
-
props.width = Number.parseInt(props.width);
|
|
710
|
-
}
|
|
711
|
-
if (typeof props.height === "string") {
|
|
712
|
-
props.height = Number.parseInt(props.height);
|
|
713
|
-
}
|
|
714
|
-
const layout = props.layout ?? imageConfig.layout ?? "none";
|
|
715
|
-
if (layout !== "none") {
|
|
716
|
-
props.layout ??= imageConfig.layout;
|
|
717
|
-
props.fit ??= imageConfig.objectFit ?? "cover";
|
|
718
|
-
props.position ??= imageConfig.objectPosition ?? "center";
|
|
719
|
-
} else if (imageConfig.objectFit || imageConfig.objectPosition) {
|
|
720
|
-
props.fit ??= imageConfig.objectFit;
|
|
721
|
-
props.position ??= imageConfig.objectPosition;
|
|
722
|
-
}
|
|
723
|
-
const image = await getImage(props);
|
|
724
|
-
const additionalAttributes = {};
|
|
725
|
-
if (image.srcSet.values.length > 0) {
|
|
726
|
-
additionalAttributes.srcset = image.srcSet.attribute;
|
|
727
|
-
}
|
|
728
|
-
const { class: className, ...attributes } = { ...additionalAttributes, ...image.attributes };
|
|
729
|
-
return renderTemplate`${maybeRenderHead()}<img${addAttribute(image.src, "src")}${spreadAttributes(attributes)}${addAttribute(className, "class")}>`;
|
|
730
|
-
}, "/Users/macbook/Dev/Web/Astro/kyro-cms/admin/node_modules/astro/components/Image.astro", void 0);
|
|
731
|
-
|
|
732
|
-
const $$Picture = createComponent(async ($$result, $$props, $$slots) => {
|
|
733
|
-
const Astro2 = $$result.createAstro($$props, $$slots);
|
|
734
|
-
Astro2.self = $$Picture;
|
|
735
|
-
const defaultFormats = ["webp"];
|
|
736
|
-
const defaultFallbackFormat = "png";
|
|
737
|
-
const specialFormatsFallback = ["gif", "svg", "jpg", "jpeg"];
|
|
738
|
-
const { formats = defaultFormats, pictureAttributes = {}, fallbackFormat, ...props } = Astro2.props;
|
|
739
|
-
if (props.alt === void 0 || props.alt === null) {
|
|
740
|
-
throw new AstroError(ImageMissingAlt);
|
|
741
|
-
}
|
|
742
|
-
const scopedStyleClass = props.class?.match(/\bastro-\w{8}\b/)?.[0];
|
|
743
|
-
if (scopedStyleClass) {
|
|
744
|
-
if (pictureAttributes.class) {
|
|
745
|
-
pictureAttributes.class = `${pictureAttributes.class} ${scopedStyleClass}`;
|
|
746
|
-
} else {
|
|
747
|
-
pictureAttributes.class = scopedStyleClass;
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
const layout = props.layout ?? imageConfig.layout ?? "none";
|
|
751
|
-
const useResponsive = layout !== "none";
|
|
752
|
-
if (useResponsive) {
|
|
753
|
-
props.layout ??= imageConfig.layout;
|
|
754
|
-
props.fit ??= imageConfig.objectFit ?? "cover";
|
|
755
|
-
props.position ??= imageConfig.objectPosition ?? "center";
|
|
756
|
-
} else if (imageConfig.objectFit || imageConfig.objectPosition) {
|
|
757
|
-
props.fit ??= imageConfig.objectFit;
|
|
758
|
-
props.position ??= imageConfig.objectPosition;
|
|
759
|
-
}
|
|
760
|
-
for (const key in props) {
|
|
761
|
-
if (key.startsWith("data-astro-cid")) {
|
|
762
|
-
pictureAttributes[key] = props[key];
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
const originalSrc = await resolveSrc(props.src);
|
|
766
|
-
const optimizedImages = await Promise.all(
|
|
767
|
-
formats.map(
|
|
768
|
-
async (format) => await getImage({
|
|
769
|
-
...props,
|
|
770
|
-
src: originalSrc,
|
|
771
|
-
format,
|
|
772
|
-
widths: props.widths,
|
|
773
|
-
densities: props.densities
|
|
774
|
-
})
|
|
775
|
-
)
|
|
776
|
-
);
|
|
777
|
-
const clonedSrc = isESMImportedImage(originalSrc) ? (
|
|
778
|
-
// @ts-expect-error - clone is a private, hidden prop
|
|
779
|
-
originalSrc.clone ?? originalSrc
|
|
780
|
-
) : originalSrc;
|
|
781
|
-
let resultFallbackFormat = fallbackFormat ?? defaultFallbackFormat;
|
|
782
|
-
if (!fallbackFormat && isESMImportedImage(clonedSrc) && specialFormatsFallback.includes(clonedSrc.format)) {
|
|
783
|
-
resultFallbackFormat = clonedSrc.format;
|
|
784
|
-
}
|
|
785
|
-
const fallbackImage = await getImage({
|
|
786
|
-
...props,
|
|
787
|
-
format: resultFallbackFormat,
|
|
788
|
-
widths: props.widths,
|
|
789
|
-
densities: props.densities
|
|
790
|
-
});
|
|
791
|
-
const imgAdditionalAttributes = {};
|
|
792
|
-
const sourceAdditionalAttributes = {};
|
|
793
|
-
if (props.sizes) {
|
|
794
|
-
sourceAdditionalAttributes.sizes = props.sizes;
|
|
795
|
-
}
|
|
796
|
-
if (fallbackImage.srcSet.values.length > 0) {
|
|
797
|
-
imgAdditionalAttributes.srcset = fallbackImage.srcSet.attribute;
|
|
798
|
-
}
|
|
799
|
-
const { class: className, ...attributes } = {
|
|
800
|
-
...imgAdditionalAttributes,
|
|
801
|
-
...fallbackImage.attributes
|
|
802
|
-
};
|
|
803
|
-
return renderTemplate`${maybeRenderHead()}<picture${spreadAttributes(pictureAttributes)}> ${Object.entries(optimizedImages).map(([_, image]) => {
|
|
804
|
-
const srcsetAttribute = props.densities || !props.densities && !props.widths && !useResponsive ? `${image.src}${image.srcSet.values.length > 0 ? ", " + image.srcSet.attribute : ""}` : image.srcSet.attribute;
|
|
805
|
-
return renderTemplate`<source${addAttribute(srcsetAttribute, "srcset")}${addAttribute(mime.lookup(image.options.format ?? image.src) ?? `image/${image.options.format}`, "type")}${spreadAttributes(sourceAdditionalAttributes)}>`;
|
|
806
|
-
})} <img${addAttribute(fallbackImage.src, "src")}${spreadAttributes(attributes)}${addAttribute(className, "class")}> </picture>`;
|
|
807
|
-
}, "/Users/macbook/Dev/Web/Astro/kyro-cms/admin/node_modules/astro/components/Picture.astro", void 0);
|
|
808
|
-
|
|
809
|
-
const componentDataByCssVariable = new Map([]);
|
|
810
|
-
|
|
811
|
-
function filterPreloads(data, preload) {
|
|
812
|
-
if (!preload) {
|
|
813
|
-
return null;
|
|
814
|
-
}
|
|
815
|
-
if (preload === true) {
|
|
816
|
-
return data;
|
|
817
|
-
}
|
|
818
|
-
return data.filter(
|
|
819
|
-
({ weight, style, subset }) => preload.some((p) => {
|
|
820
|
-
if (p.weight !== void 0 && weight !== void 0 && !checkWeight(p.weight.toString(), weight)) {
|
|
821
|
-
return false;
|
|
822
|
-
}
|
|
823
|
-
if (p.style !== void 0 && p.style !== style) {
|
|
824
|
-
return false;
|
|
825
|
-
}
|
|
826
|
-
if (p.subset !== void 0 && p.subset !== subset) {
|
|
827
|
-
return false;
|
|
828
|
-
}
|
|
829
|
-
return true;
|
|
830
|
-
})
|
|
831
|
-
);
|
|
832
|
-
}
|
|
833
|
-
function checkWeight(input, target) {
|
|
834
|
-
const trimmedInput = input.trim();
|
|
835
|
-
if (trimmedInput.includes(" ")) {
|
|
836
|
-
return trimmedInput === target;
|
|
837
|
-
}
|
|
838
|
-
if (target.includes(" ")) {
|
|
839
|
-
const [a, b] = target.split(" ");
|
|
840
|
-
const parsedInput = Number.parseInt(input);
|
|
841
|
-
return parsedInput >= Number.parseInt(a) && parsedInput <= Number.parseInt(b);
|
|
842
|
-
}
|
|
843
|
-
return input === target;
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
const $$Font = createComponent(($$result, $$props, $$slots) => {
|
|
847
|
-
const Astro2 = $$result.createAstro($$props, $$slots);
|
|
848
|
-
Astro2.self = $$Font;
|
|
849
|
-
const { cssVariable, preload = false } = Astro2.props;
|
|
850
|
-
const data = componentDataByCssVariable.get(cssVariable);
|
|
851
|
-
if (!data) {
|
|
852
|
-
throw new AstroError({
|
|
853
|
-
...FontFamilyNotFound,
|
|
854
|
-
message: FontFamilyNotFound.message(cssVariable)
|
|
855
|
-
});
|
|
856
|
-
}
|
|
857
|
-
const filteredPreloadData = filterPreloads(data.preloads, preload);
|
|
858
|
-
return renderTemplate`<style>${unescapeHTML(data.css)}</style>${filteredPreloadData?.map(({ url, type }) => renderTemplate`<link rel="preload"${addAttribute(url, "href")} as="font"${addAttribute(`font/${type}`, "type")} crossorigin>`)}`;
|
|
859
|
-
}, "/Users/macbook/Dev/Web/Astro/kyro-cms/admin/node_modules/astro/components/Font.astro", void 0);
|
|
860
|
-
|
|
861
|
-
const assetQueryParams = undefined;
|
|
862
|
-
const imageConfig = {"endpoint":{"route":"/_image","entrypoint":"astro/assets/endpoint/node"},"service":{"entrypoint":"astro/assets/services/sharp","config":{}},"domains":[],"remotePatterns":[],"responsiveStyles":false};
|
|
863
|
-
Object.defineProperty(imageConfig, 'assetQueryParams', {
|
|
864
|
-
value: assetQueryParams,
|
|
865
|
-
enumerable: false,
|
|
866
|
-
configurable: true,
|
|
867
|
-
});
|
|
868
|
-
// This is used by the @astrojs/node integration to locate images.
|
|
869
|
-
// It's unused on other platforms, but on some platforms like Netlify (and presumably also Vercel)
|
|
870
|
-
// new URL("dist/...") is interpreted by the bundler as a signal to include that directory
|
|
871
|
-
// in the Lambda bundle, which would bloat the bundle with images.
|
|
872
|
-
// To prevent this, we mark the URL construction as pure,
|
|
873
|
-
// so that it's tree-shaken away for all platforms that don't need it.
|
|
874
|
-
const outDir = /* #__PURE__ */ new URL("file:///Users/macbook/Dev/Web/Astro/kyro-cms/admin/dist/client/");
|
|
875
|
-
const serverDir = /* #__PURE__ */ new URL("file:///Users/macbook/Dev/Web/Astro/kyro-cms/admin/dist/server/");
|
|
876
|
-
const getImage = async (options) => await getImage$1(options, imageConfig);
|
|
877
|
-
|
|
878
|
-
const fnv1a52 = (str) => {
|
|
879
|
-
const len = str.length;
|
|
880
|
-
let i = 0, t0 = 0, v0 = 8997, t1 = 0, v1 = 33826, t2 = 0, v2 = 40164, t3 = 0, v3 = 52210;
|
|
881
|
-
while (i < len) {
|
|
882
|
-
v0 ^= str.charCodeAt(i++);
|
|
883
|
-
t0 = v0 * 435;
|
|
884
|
-
t1 = v1 * 435;
|
|
885
|
-
t2 = v2 * 435;
|
|
886
|
-
t3 = v3 * 435;
|
|
887
|
-
t2 += v0 << 8;
|
|
888
|
-
t3 += v1 << 8;
|
|
889
|
-
t1 += t0 >>> 16;
|
|
890
|
-
v0 = t0 & 65535;
|
|
891
|
-
t2 += t1 >>> 16;
|
|
892
|
-
v1 = t1 & 65535;
|
|
893
|
-
v3 = t3 + (t2 >>> 16) & 65535;
|
|
894
|
-
v2 = t2 & 65535;
|
|
895
|
-
}
|
|
896
|
-
return (v3 & 15) * 281474976710656 + v2 * 4294967296 + v1 * 65536 + (v0 ^ v3 >> 4);
|
|
897
|
-
};
|
|
898
|
-
const etag = (payload, weak = false) => {
|
|
899
|
-
const prefix = weak ? 'W/"' : '"';
|
|
900
|
-
return prefix + fnv1a52(payload).toString(36) + payload.length.toString(36) + '"';
|
|
901
|
-
};
|
|
902
|
-
|
|
903
|
-
async function loadRemoteImage(src) {
|
|
904
|
-
try {
|
|
905
|
-
const res = await fetch(src, { redirect: "manual" });
|
|
906
|
-
if (res.status >= 300 && res.status < 400) {
|
|
907
|
-
return void 0;
|
|
908
|
-
}
|
|
909
|
-
if (!res.ok) {
|
|
910
|
-
return void 0;
|
|
911
|
-
}
|
|
912
|
-
return Buffer.from(await res.arrayBuffer());
|
|
913
|
-
} catch {
|
|
914
|
-
return void 0;
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
const handleImageRequest = async ({
|
|
918
|
-
request,
|
|
919
|
-
loadLocalImage
|
|
920
|
-
}) => {
|
|
921
|
-
const imageService = await getConfiguredImageService();
|
|
922
|
-
if (!("transform" in imageService)) {
|
|
923
|
-
throw new Error("Configured image service is not a local service");
|
|
924
|
-
}
|
|
925
|
-
const url = new URL(request.url);
|
|
926
|
-
const transform = await imageService.parseURL(url, imageConfig);
|
|
927
|
-
if (!transform?.src) {
|
|
928
|
-
return new Response("Invalid request", { status: 400 });
|
|
929
|
-
}
|
|
930
|
-
let inputBuffer = void 0;
|
|
931
|
-
if (isRemotePath(transform.src)) {
|
|
932
|
-
if (!isRemoteAllowed(transform.src, imageConfig)) {
|
|
933
|
-
return new Response("Forbidden", { status: 403 });
|
|
934
|
-
}
|
|
935
|
-
inputBuffer = await loadRemoteImage(new URL(transform.src));
|
|
936
|
-
} else {
|
|
937
|
-
inputBuffer = await loadLocalImage(removeQueryString(transform.src), url);
|
|
938
|
-
}
|
|
939
|
-
if (!inputBuffer) {
|
|
940
|
-
return new Response("Internal Server Error", { status: 500 });
|
|
941
|
-
}
|
|
942
|
-
const { data, format } = await imageService.transform(inputBuffer, transform, imageConfig);
|
|
943
|
-
return new Response(data, {
|
|
944
|
-
status: 200,
|
|
945
|
-
headers: {
|
|
946
|
-
"Content-Type": mime.lookup(format) ?? `image/${format}`,
|
|
947
|
-
"Cache-Control": "public, max-age=31536000",
|
|
948
|
-
ETag: etag(data.toString()),
|
|
949
|
-
Date: (/* @__PURE__ */ new Date()).toUTCString()
|
|
950
|
-
}
|
|
951
|
-
});
|
|
952
|
-
};
|
|
953
|
-
|
|
954
|
-
async function loadLocalImage(src, url) {
|
|
955
|
-
const outDirURL = resolveOutDir();
|
|
956
|
-
const idx = url.pathname.indexOf("/_image");
|
|
957
|
-
if (idx > 0) {
|
|
958
|
-
src = src.slice(idx);
|
|
959
|
-
}
|
|
960
|
-
if (!URL.canParse("." + src, outDirURL)) {
|
|
961
|
-
return void 0;
|
|
962
|
-
}
|
|
963
|
-
const fileUrl = new URL("." + src, outDirURL);
|
|
964
|
-
if (fileUrl.protocol !== "file:") {
|
|
965
|
-
return void 0;
|
|
966
|
-
}
|
|
967
|
-
if (!isParentDirectory(fileURLToPath(outDirURL), fileURLToPath(fileUrl))) {
|
|
968
|
-
return void 0;
|
|
969
|
-
}
|
|
970
|
-
try {
|
|
971
|
-
return await readFile(fileUrl);
|
|
972
|
-
} catch {
|
|
973
|
-
return void 0;
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
const GET = async ({ request }) => {
|
|
977
|
-
try {
|
|
978
|
-
return await handleImageRequest({ request, loadLocalImage });
|
|
979
|
-
} catch (err) {
|
|
980
|
-
console.error("Could not process image request:", err);
|
|
981
|
-
return new Response("Internal Server Error", {
|
|
982
|
-
status: 500
|
|
983
|
-
});
|
|
984
|
-
}
|
|
985
|
-
};
|
|
986
|
-
function resolveOutDir() {
|
|
987
|
-
const serverDirPath = fileURLToPath(serverDir);
|
|
988
|
-
const rel = path.relative(serverDirPath, fileURLToPath(outDir));
|
|
989
|
-
const serverFolder = path.basename(serverDirPath);
|
|
990
|
-
let serverEntryFolderURL = path.dirname(import.meta.url);
|
|
991
|
-
while (!serverEntryFolderURL.endsWith(serverFolder)) {
|
|
992
|
-
serverEntryFolderURL = path.dirname(serverEntryFolderURL);
|
|
993
|
-
}
|
|
994
|
-
const serverEntryURL = serverEntryFolderURL + "/entry.mjs";
|
|
995
|
-
const outDirURL = new URL(appendForwardSlash(rel), serverEntryURL);
|
|
996
|
-
return outDirURL;
|
|
997
|
-
}
|
|
998
|
-
function appendForwardSlash(pth) {
|
|
999
|
-
return pth.endsWith("/") ? pth : pth + "/";
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
const _page = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
1003
|
-
__proto__: null,
|
|
1004
|
-
GET
|
|
1005
|
-
}, Symbol.toStringTag, { value: 'Module' }));
|
|
1006
|
-
|
|
1007
|
-
const page = () => _page;
|
|
1008
|
-
|
|
1009
|
-
const node___js = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
1010
|
-
__proto__: null,
|
|
1011
|
-
page
|
|
1012
|
-
}, Symbol.toStringTag, { value: 'Module' }));
|
|
1013
|
-
|
|
1014
|
-
export { baseService as b, node___js as n, parseQuality as p };
|