@patternfly/patternfly-doc-core 1.9.1 → 1.11.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.
Files changed (118) hide show
  1. package/astro.config.mjs +3 -4
  2. package/cli/cli.ts +60 -19
  3. package/cli/convertToMDX.ts +77 -22
  4. package/dist/.assetsignore +2 -0
  5. package/dist/_astro/ClientRouter.astro_astro_type_script_index_0_lang.CtSceO8m.js +1 -0
  6. package/dist/{client/_astro/LiveExample.DZkxbJA_.js → _astro/LiveExample.DjPiO80i.js} +1 -1
  7. package/dist/_astro/client.DN8ES6L5.js +1 -0
  8. package/dist/_routes.json +20 -0
  9. package/dist/_worker.js/_@astrojs-ssr-adapter.mjs +2 -0
  10. package/dist/_worker.js/_astro-internal_middleware.mjs +21 -0
  11. package/dist/_worker.js/_noop-actions.mjs +4 -0
  12. package/dist/{server/chunks/AutoLinkHeader_C2GD0g-K.mjs → _worker.js/chunks/AutoLinkHeader_xh_mBOfs.mjs} +13 -14
  13. package/dist/{server/chunks/Button_BKhHR-ak.mjs → _worker.js/chunks/Button_ByndGYyw.mjs} +83 -13
  14. package/dist/{server/chunks/CSSTable_B8tlH3gz.mjs → _worker.js/chunks/CSSTable_DAbso55e.mjs} +3 -3
  15. package/dist/_worker.js/chunks/PropsTables_BZngJp47.mjs +6628 -0
  16. package/dist/_worker.js/chunks/_@astrojs-ssr-adapter_C9Nk07-M.mjs +1082 -0
  17. package/dist/_worker.js/chunks/angle-down-icon_yt3z9cvI.mjs +3686 -0
  18. package/dist/_worker.js/chunks/astro/server_BpfPtTmt.mjs +7278 -0
  19. package/dist/_worker.js/chunks/astro-designed-error-pages_4xWqsa9_.mjs +928 -0
  20. package/dist/_worker.js/chunks/cloudflare-kv-binding_DMly_2Gl.mjs +107 -0
  21. package/dist/_worker.js/chunks/index_Dc2aKkl4.mjs +57 -0
  22. package/dist/{server/chunks/_@astrojs-ssr-adapter_CbICuCdt.mjs → _worker.js/chunks/index_DlGha6WC.mjs} +1295 -1817
  23. package/dist/_worker.js/chunks/noop-middleware_Ct44Kk5Y.mjs +10 -0
  24. package/dist/_worker.js/chunks/parse_EttCPxrw.mjs +271 -0
  25. package/dist/{server/chunks/path_Cvt6sEOY.mjs → _worker.js/chunks/path_C-ZOwaTP.mjs} +2 -1
  26. package/dist/{server/entry.mjs → _worker.js/index.js} +12 -19
  27. package/dist/_worker.js/manifest_DcBPbZXQ.mjs +100 -0
  28. package/dist/_worker.js/pages/_image.astro.mjs +24 -0
  29. package/dist/_worker.js/pages/_section_/_page_/_---tab_.astro.mjs +1 -0
  30. package/dist/_worker.js/pages/index.astro.mjs +1 -0
  31. package/dist/{server → _worker.js}/pages/props.astro.mjs +3 -2
  32. package/dist/_worker.js/renderers.mjs +484 -0
  33. package/dist/cli/cli.js +46 -12
  34. package/dist/cli/convertToMDX.js +53 -16
  35. package/dist/components/accordion/index.html +60 -0
  36. package/dist/components/accordion/react/index.html +60 -0
  37. package/dist/components/all-components/index.html +47 -0
  38. package/dist/design-foundations/typography/index.html +198 -0
  39. package/dist/{client/design-foundations → design-foundations}/usage-and-behavior/index.html +4 -54
  40. package/dist/get-started/contribute/index.html +94 -0
  41. package/dist/index.html +43 -0
  42. package/package.json +12 -8
  43. package/public/.assetsignore +2 -0
  44. package/src/components/LiveExample.astro +2 -2
  45. package/src/components/LiveExample.tsx +38 -9
  46. package/src/pages/props.ts +2 -2
  47. package/wrangler.jsonc +14 -0
  48. package/dist/client/_astro/ClientRouter.astro_astro_type_script_index_0_lang.Cainpjm5.js +0 -1
  49. package/dist/client/_astro/client.zs76E0tG.js +0 -1
  50. package/dist/client/components/accordion/index.html +0 -110
  51. package/dist/client/components/accordion/react/index.html +0 -110
  52. package/dist/client/components/all-components/index.html +0 -97
  53. package/dist/client/design-foundations/typography/index.html +0 -248
  54. package/dist/client/get-started/contribute/index.html +0 -144
  55. package/dist/client/index.html +0 -43
  56. package/dist/server/_@astrojs-ssr-adapter.mjs +0 -1
  57. package/dist/server/_noop-middleware.mjs +0 -3
  58. package/dist/server/chunks/PropsTables_PVzRHJNB.mjs +0 -1750
  59. package/dist/server/chunks/_astro_assets_DaYumpRZ.mjs +0 -1507
  60. package/dist/server/chunks/angle-down-icon_BO1Ed-9Z.mjs +0 -3288
  61. package/dist/server/chunks/astro/server_Cl9jPh4p.mjs +0 -2859
  62. package/dist/server/chunks/astro-designed-error-pages_BFveJFnQ.mjs +0 -282
  63. package/dist/server/chunks/consts_BmVDRGlB.mjs +0 -32
  64. package/dist/server/chunks/sharp_CbOL3WDk.mjs +0 -88
  65. package/dist/server/manifest_DxJLmW-j.mjs +0 -102
  66. package/dist/server/pages/_image.astro.mjs +0 -132
  67. package/dist/server/renderers.mjs +0 -308
  68. /package/dist/{client/PF-HorizontalLogo-Color.svg → PF-HorizontalLogo-Color.svg} +0 -0
  69. /package/dist/{client/PF-HorizontalLogo-Reverse.svg → PF-HorizontalLogo-Reverse.svg} +0 -0
  70. /package/dist/{client/_astro → _astro}/Button.BQCwQ5pE.js +0 -0
  71. /package/dist/{client/_astro → _astro}/CSSTable.DC79W1Ct.js +0 -0
  72. /package/dist/{client/_astro → _astro}/Content.B4M2qzJY.js +0 -0
  73. /package/dist/{client/_astro → _astro}/DropdownList.cxp03sS4.js +0 -0
  74. /package/dist/{client/_astro → _astro}/LiveExample.CxJsMvEq.css +0 -0
  75. /package/dist/{client/_astro → _astro}/Navigation.kbLxctIo.js +0 -0
  76. /package/dist/{client/_astro → _astro}/PageContext.miTsIqVo.js +0 -0
  77. /package/dist/{client/_astro → _astro}/PageSidebarBody.B0AJe8Hg.js +0 -0
  78. /package/dist/{client/_astro → _astro}/PageToggle.CMZ3C1v1.js +0 -0
  79. /package/dist/{client/_astro → _astro}/RedHatDisplayVF-Italic.CRpusWc8.woff2 +0 -0
  80. /package/dist/{client/_astro → _astro}/RedHatDisplayVF.CYDHf1NI.woff2 +0 -0
  81. /package/dist/{client/_astro → _astro}/RedHatMonoVF-Italic.DGQo2ogW.woff2 +0 -0
  82. /package/dist/{client/_astro → _astro}/RedHatMonoVF.C4fMH6Vz.woff2 +0 -0
  83. /package/dist/{client/_astro → _astro}/RedHatTextVF-Italic.Dkj_WqbA.woff2 +0 -0
  84. /package/dist/{client/_astro → _astro}/RedHatTextVF.wYvZ7prR.woff2 +0 -0
  85. /package/dist/{client/_astro → _astro}/SearchInput.DhHo7yPx.js +0 -0
  86. /package/dist/{client/_astro → _astro}/SectionGallery.3ABpQwE4.js +0 -0
  87. /package/dist/{client/_astro → _astro}/Toolbar.CroDQcyv.js +0 -0
  88. /package/dist/{client/_astro → _astro}/ToolbarContent.UH3ZRlHp.js +0 -0
  89. /package/dist/{client/_astro → _astro}/_page_.Chv_bGyU.css +0 -0
  90. /package/dist/{client/_astro → _astro}/_page_.CtheD08_.css +0 -0
  91. /package/dist/{client/_astro → _astro}/_page_.D1z73Byz.css +0 -0
  92. /package/dist/{client/_astro → _astro}/_page_.DxJDkZPc.css +0 -0
  93. /package/dist/{client/_astro → _astro}/angle-left-icon.teo8GC0v.js +0 -0
  94. /package/dist/{client/_astro → _astro}/bars-icon.Dk6ua1rr.js +0 -0
  95. /package/dist/{client/_astro → _astro}/divider.tlrBPkzg.js +0 -0
  96. /package/dist/{client/_astro → _astro}/fa-solid-900.DguXoeIz.woff2 +0 -0
  97. /package/dist/{client/_astro → _astro}/github-icon.ByC5XEPt.js +0 -0
  98. /package/dist/{client/_astro → _astro}/index.BQFV5hT1.js +0 -0
  99. /package/dist/{client/_astro → _astro}/index.CAChmxYj.js +0 -0
  100. /package/dist/{client/_astro → _astro}/index.DYVB4vTo.js +0 -0
  101. /package/dist/{client/_astro → _astro}/index.eCxJ45ll.js +0 -0
  102. /package/dist/{client/_astro → _astro}/link-icon.BNHnRn73.js +0 -0
  103. /package/dist/{client/_astro → _astro}/page.BTC3Kf3x.js +0 -0
  104. /package/dist/{client/_astro → _astro}/pf-v6-pficon.Dy6oiu9u.woff2 +0 -0
  105. /package/dist/{server/chunks/Accordion_BJka4Qvb.mjs → _worker.js/chunks/Accordion_BNafbla6.mjs} +0 -0
  106. /package/dist/{server/chunks/Accordion_BQIphkaZ.mjs → _worker.js/chunks/Accordion_CZsuyu9E.mjs} +0 -0
  107. /package/dist/{server/chunks/AllComponents_CRhgTsiT.mjs → _worker.js/chunks/AllComponents_BrL9IHSc.mjs} +0 -0
  108. /package/dist/{server/chunks/AllComponents_CjOtwUH6.mjs → _worker.js/chunks/AllComponents_CI7S6uwA.mjs} +0 -0
  109. /package/dist/{server/chunks/_astro_data-layer-content_D4Ib_RjR.mjs → _worker.js/chunks/_astro_assets_vBCb4v6U.mjs} +0 -0
  110. /package/dist/{server/chunks/content-assets_DleWbedO.mjs → _worker.js/chunks/_astro_data-layer-content_CgXoS6Mm.mjs} +0 -0
  111. /package/dist/{server/chunks/content-modules_fX1c2JRG.mjs → _worker.js/chunks/content-assets_XqCgPAV2.mjs} +0 -0
  112. /package/dist/{server/pages/_section_/_---page_.astro.mjs → _worker.js/chunks/content-modules_CKq2j9RQ.mjs} +0 -0
  113. /package/dist/{server/pages/_section_/_page_/_---tab_.astro.mjs → _worker.js/chunks/sharp_CNjr3bU4.mjs} +0 -0
  114. /package/dist/{server/pages/index.astro.mjs → _worker.js/pages/_section_/_---page_.astro.mjs} +0 -0
  115. /package/dist/{client/avatarImg.svg → avatarImg.svg} +0 -0
  116. /package/dist/{client/avatarImgDark.svg → avatarImgDark.svg} +0 -0
  117. /package/dist/{client/content → content}/typography/line-height.png +0 -0
  118. /package/dist/{client/favicon.svg → favicon.svg} +0 -0
@@ -1,1507 +0,0 @@
1
- import { j as joinPaths, i as isRemotePath } from './path_Cvt6sEOY.mjs';
2
- import { A as AstroError, ac as ExpectedImage, ad as LocalImageUsedWrongly, ae as MissingImageDimension, af as UnsupportedImageFormat, ag as IncompatibleDescriptorOptions, ah as UnsupportedImageConversion, ai as toStyleString, aj as NoImageMetadata, ak as FailedToFetchRemoteImageDimensions, al as ExpectedImageOptions, am as ExpectedNotESMImage, an as InvalidImageService, c as createComponent, a as createAstro, ao as ImageMissingAlt, m as maybeRenderHead, d as addAttribute, ap as spreadAttributes, b as renderTemplate } from './astro/server_Cl9jPh4p.mjs';
3
- import { D as DEFAULT_OUTPUT_FORMAT, a as VALID_SUPPORTED_FORMATS, b as DEFAULT_HASH_PROPS } from './consts_BmVDRGlB.mjs';
4
- import * as mime from 'mrmime';
5
- import 'clsx';
6
-
7
- const DEFAULT_RESOLUTIONS = [
8
- 640,
9
- // older and lower-end phones
10
- 750,
11
- // iPhone 6-8
12
- 828,
13
- // iPhone XR/11
14
- 960,
15
- // older horizontal phones
16
- 1080,
17
- // iPhone 6-8 Plus
18
- 1280,
19
- // 720p
20
- 1668,
21
- // Various iPads
22
- 1920,
23
- // 1080p
24
- 2048,
25
- // QXGA
26
- 2560,
27
- // WQXGA
28
- 3200,
29
- // QHD+
30
- 3840,
31
- // 4K
32
- 4480,
33
- // 4.5K
34
- 5120,
35
- // 5K
36
- 6016
37
- // 6K
38
- ];
39
- const LIMITED_RESOLUTIONS = [
40
- 640,
41
- // older and lower-end phones
42
- 750,
43
- // iPhone 6-8
44
- 828,
45
- // iPhone XR/11
46
- 1080,
47
- // iPhone 6-8 Plus
48
- 1280,
49
- // 720p
50
- 1668,
51
- // Various iPads
52
- 2048,
53
- // QXGA
54
- 2560
55
- // WQXGA
56
- ];
57
- const getWidths = ({
58
- width,
59
- layout,
60
- breakpoints = DEFAULT_RESOLUTIONS,
61
- originalWidth
62
- }) => {
63
- const smallerThanOriginal = (w) => !originalWidth || w <= originalWidth;
64
- if (layout === "full-width") {
65
- return breakpoints.filter(smallerThanOriginal);
66
- }
67
- if (!width) {
68
- return [];
69
- }
70
- const doubleWidth = width * 2;
71
- const maxSize = originalWidth ? Math.min(doubleWidth, originalWidth) : doubleWidth;
72
- if (layout === "fixed") {
73
- return originalWidth && width > originalWidth ? [originalWidth] : [width, maxSize];
74
- }
75
- if (layout === "responsive") {
76
- return [
77
- // Always include the image at 1x and 2x the specified width
78
- width,
79
- doubleWidth,
80
- ...breakpoints
81
- ].filter((w) => w <= maxSize).sort((a, b) => a - b);
82
- }
83
- return [];
84
- };
85
- const getSizesAttribute = ({
86
- width,
87
- layout
88
- }) => {
89
- if (!width || !layout) {
90
- return void 0;
91
- }
92
- switch (layout) {
93
- // If screen is wider than the max size then image width is the max size,
94
- // otherwise it's the width of the screen
95
- case `responsive`:
96
- return `(min-width: ${width}px) ${width}px, 100vw`;
97
- // Image is always the same width, whatever the size of the screen
98
- case `fixed`:
99
- return `${width}px`;
100
- // Image is always the width of the screen
101
- case `full-width`:
102
- return `100vw`;
103
- case "none":
104
- default:
105
- return void 0;
106
- }
107
- };
108
-
109
- function matchPattern(url, remotePattern) {
110
- return matchProtocol(url, remotePattern.protocol) && matchHostname(url, remotePattern.hostname, true) && matchPort(url, remotePattern.port) && matchPathname(url, remotePattern.pathname);
111
- }
112
- function matchPort(url, port) {
113
- return !port || port === url.port;
114
- }
115
- function matchProtocol(url, protocol) {
116
- return !protocol || protocol === url.protocol.slice(0, -1);
117
- }
118
- function matchHostname(url, hostname, allowWildcard) {
119
- if (!hostname) {
120
- return true;
121
- } else if (!allowWildcard || !hostname.startsWith("*")) {
122
- return hostname === url.hostname;
123
- } else if (hostname.startsWith("**.")) {
124
- const slicedHostname = hostname.slice(2);
125
- return slicedHostname !== url.hostname && url.hostname.endsWith(slicedHostname);
126
- } else if (hostname.startsWith("*.")) {
127
- const slicedHostname = hostname.slice(1);
128
- const additionalSubdomains = url.hostname.replace(slicedHostname, "").split(".").filter(Boolean);
129
- return additionalSubdomains.length === 1;
130
- }
131
- return false;
132
- }
133
- function matchPathname(url, pathname, allowWildcard) {
134
- if (!pathname) {
135
- return true;
136
- } else if (!pathname.endsWith("*")) {
137
- return pathname === url.pathname;
138
- } else if (pathname.endsWith("/**")) {
139
- const slicedPathname = pathname.slice(0, -2);
140
- return slicedPathname !== url.pathname && url.pathname.startsWith(slicedPathname);
141
- } else if (pathname.endsWith("/*")) {
142
- const slicedPathname = pathname.slice(0, -1);
143
- const additionalPathChunks = url.pathname.replace(slicedPathname, "").split("/").filter(Boolean);
144
- return additionalPathChunks.length === 1;
145
- }
146
- return false;
147
- }
148
- function isRemoteAllowed(src, {
149
- domains,
150
- remotePatterns
151
- }) {
152
- if (!URL.canParse(src)) {
153
- return false;
154
- }
155
- const url = new URL(src);
156
- return domains.some((domain) => matchHostname(url, domain)) || remotePatterns.some((remotePattern) => matchPattern(url, remotePattern));
157
- }
158
-
159
- function isESMImportedImage(src) {
160
- return typeof src === "object" || typeof src === "function" && "src" in src;
161
- }
162
- function isRemoteImage(src) {
163
- return typeof src === "string";
164
- }
165
- async function resolveSrc(src) {
166
- return typeof src === "object" && "then" in src ? (await src).default ?? await src : src;
167
- }
168
-
169
- function isLocalService(service) {
170
- if (!service) {
171
- return false;
172
- }
173
- return "transform" in service;
174
- }
175
- function parseQuality(quality) {
176
- let result = parseInt(quality);
177
- if (Number.isNaN(result)) {
178
- return quality;
179
- }
180
- return result;
181
- }
182
- const sortNumeric = (a, b) => a - b;
183
- const baseService = {
184
- validateOptions(options) {
185
- if (!options.src || !isRemoteImage(options.src) && !isESMImportedImage(options.src)) {
186
- throw new AstroError({
187
- ...ExpectedImage,
188
- message: ExpectedImage.message(
189
- JSON.stringify(options.src),
190
- typeof options.src,
191
- JSON.stringify(options, (_, v) => v === void 0 ? null : v)
192
- )
193
- });
194
- }
195
- if (!isESMImportedImage(options.src)) {
196
- if (options.src.startsWith("/@fs/") || !isRemotePath(options.src) && !options.src.startsWith("/")) {
197
- throw new AstroError({
198
- ...LocalImageUsedWrongly,
199
- message: LocalImageUsedWrongly.message(options.src)
200
- });
201
- }
202
- let missingDimension;
203
- if (!options.width && !options.height) {
204
- missingDimension = "both";
205
- } else if (!options.width && options.height) {
206
- missingDimension = "width";
207
- } else if (options.width && !options.height) {
208
- missingDimension = "height";
209
- }
210
- if (missingDimension) {
211
- throw new AstroError({
212
- ...MissingImageDimension,
213
- message: MissingImageDimension.message(missingDimension, options.src)
214
- });
215
- }
216
- } else {
217
- if (!VALID_SUPPORTED_FORMATS.includes(options.src.format)) {
218
- throw new AstroError({
219
- ...UnsupportedImageFormat,
220
- message: UnsupportedImageFormat.message(
221
- options.src.format,
222
- options.src.src,
223
- VALID_SUPPORTED_FORMATS
224
- )
225
- });
226
- }
227
- if (options.widths && options.densities) {
228
- throw new AstroError(IncompatibleDescriptorOptions);
229
- }
230
- if (options.src.format === "svg") {
231
- options.format = "svg";
232
- }
233
- if (options.src.format === "svg" && options.format !== "svg" || options.src.format !== "svg" && options.format === "svg") {
234
- throw new AstroError(UnsupportedImageConversion);
235
- }
236
- }
237
- if (!options.format) {
238
- options.format = DEFAULT_OUTPUT_FORMAT;
239
- }
240
- if (options.width) options.width = Math.round(options.width);
241
- if (options.height) options.height = Math.round(options.height);
242
- if (options.layout && options.width && options.height) {
243
- options.fit ??= "cover";
244
- delete options.layout;
245
- }
246
- if (options.fit === "none") {
247
- delete options.fit;
248
- }
249
- return options;
250
- },
251
- getHTMLAttributes(options) {
252
- const { targetWidth, targetHeight } = getTargetDimensions(options);
253
- const {
254
- src,
255
- width,
256
- height,
257
- format,
258
- quality,
259
- densities,
260
- widths,
261
- formats,
262
- layout,
263
- priority,
264
- fit,
265
- position,
266
- ...attributes
267
- } = options;
268
- return {
269
- ...attributes,
270
- width: targetWidth,
271
- height: targetHeight,
272
- loading: attributes.loading ?? "lazy",
273
- decoding: attributes.decoding ?? "async"
274
- };
275
- },
276
- getSrcSet(options) {
277
- const { targetWidth, targetHeight } = getTargetDimensions(options);
278
- const aspectRatio = targetWidth / targetHeight;
279
- const { widths, densities } = options;
280
- const targetFormat = options.format ?? DEFAULT_OUTPUT_FORMAT;
281
- let transformedWidths = (widths ?? []).sort(sortNumeric);
282
- let imageWidth = options.width;
283
- let maxWidth = Infinity;
284
- if (isESMImportedImage(options.src)) {
285
- imageWidth = options.src.width;
286
- maxWidth = imageWidth;
287
- if (transformedWidths.length > 0 && transformedWidths.at(-1) > maxWidth) {
288
- transformedWidths = transformedWidths.filter((width) => width <= maxWidth);
289
- transformedWidths.push(maxWidth);
290
- }
291
- }
292
- transformedWidths = Array.from(new Set(transformedWidths));
293
- const {
294
- width: transformWidth,
295
- height: transformHeight,
296
- ...transformWithoutDimensions
297
- } = options;
298
- let allWidths = [];
299
- if (densities) {
300
- const densityValues = densities.map((density) => {
301
- if (typeof density === "number") {
302
- return density;
303
- } else {
304
- return parseFloat(density);
305
- }
306
- });
307
- const densityWidths = densityValues.sort(sortNumeric).map((density) => Math.round(targetWidth * density));
308
- allWidths = densityWidths.map((width, index) => ({
309
- width,
310
- descriptor: `${densityValues[index]}x`
311
- }));
312
- } else if (transformedWidths.length > 0) {
313
- allWidths = transformedWidths.map((width) => ({
314
- width,
315
- descriptor: `${width}w`
316
- }));
317
- }
318
- return allWidths.map(({ width, descriptor }) => {
319
- const height = Math.round(width / aspectRatio);
320
- const transform = { ...transformWithoutDimensions, width, height };
321
- return {
322
- transform,
323
- descriptor,
324
- attributes: {
325
- type: `image/${targetFormat}`
326
- }
327
- };
328
- });
329
- },
330
- getURL(options, imageConfig) {
331
- const searchParams = new URLSearchParams();
332
- if (isESMImportedImage(options.src)) {
333
- searchParams.append("href", options.src.src);
334
- } else if (isRemoteAllowed(options.src, imageConfig)) {
335
- searchParams.append("href", options.src);
336
- } else {
337
- return options.src;
338
- }
339
- const params = {
340
- w: "width",
341
- h: "height",
342
- q: "quality",
343
- f: "format",
344
- fit: "fit",
345
- position: "position"
346
- };
347
- Object.entries(params).forEach(([param, key]) => {
348
- options[key] && searchParams.append(param, options[key].toString());
349
- });
350
- const imageEndpoint = joinPaths("/", imageConfig.endpoint.route);
351
- return `${imageEndpoint}?${searchParams}`;
352
- },
353
- parseURL(url) {
354
- const params = url.searchParams;
355
- if (!params.has("href")) {
356
- return void 0;
357
- }
358
- const transform = {
359
- src: params.get("href"),
360
- width: params.has("w") ? parseInt(params.get("w")) : void 0,
361
- height: params.has("h") ? parseInt(params.get("h")) : void 0,
362
- format: params.get("f"),
363
- quality: params.get("q"),
364
- fit: params.get("fit"),
365
- position: params.get("position") ?? void 0
366
- };
367
- return transform;
368
- }
369
- };
370
- function getTargetDimensions(options) {
371
- let targetWidth = options.width;
372
- let targetHeight = options.height;
373
- if (isESMImportedImage(options.src)) {
374
- const aspectRatio = options.src.width / options.src.height;
375
- if (targetHeight && !targetWidth) {
376
- targetWidth = Math.round(targetHeight * aspectRatio);
377
- } else if (targetWidth && !targetHeight) {
378
- targetHeight = Math.round(targetWidth / aspectRatio);
379
- } else if (!targetWidth && !targetHeight) {
380
- targetWidth = options.src.width;
381
- targetHeight = options.src.height;
382
- }
383
- }
384
- return {
385
- targetWidth,
386
- targetHeight
387
- };
388
- }
389
-
390
- function isImageMetadata(src) {
391
- return src.fsPath && !("fsPath" in src);
392
- }
393
-
394
- const cssFitValues = ["fill", "contain", "cover", "scale-down"];
395
- function addCSSVarsToStyle(vars, styles) {
396
- const cssVars = Object.entries(vars).filter(([_, value]) => value !== void 0 && value !== false).map(([key, value]) => `--${key}: ${value};`).join(" ");
397
- if (!styles) {
398
- return cssVars;
399
- }
400
- const style = typeof styles === "string" ? styles : toStyleString(styles);
401
- return `${cssVars} ${style}`;
402
- }
403
-
404
- const decoder = new TextDecoder();
405
- const toUTF8String = (input, start = 0, end = input.length) => decoder.decode(input.slice(start, end));
406
- const toHexString = (input, start = 0, end = input.length) => input.slice(start, end).reduce((memo, i) => memo + ("0" + i.toString(16)).slice(-2), "");
407
- const readInt16LE = (input, offset = 0) => {
408
- const val = input[offset] + input[offset + 1] * 2 ** 8;
409
- return val | (val & 2 ** 15) * 131070;
410
- };
411
- const readUInt16BE = (input, offset = 0) => input[offset] * 2 ** 8 + input[offset + 1];
412
- const readUInt16LE = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8;
413
- const readUInt24LE = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8 + input[offset + 2] * 2 ** 16;
414
- const readInt32LE = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8 + input[offset + 2] * 2 ** 16 + (input[offset + 3] << 24);
415
- const readUInt32BE = (input, offset = 0) => input[offset] * 2 ** 24 + input[offset + 1] * 2 ** 16 + input[offset + 2] * 2 ** 8 + input[offset + 3];
416
- const readUInt32LE = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8 + input[offset + 2] * 2 ** 16 + input[offset + 3] * 2 ** 24;
417
- const methods = {
418
- readUInt16BE,
419
- readUInt16LE,
420
- readUInt32BE,
421
- readUInt32LE
422
- };
423
- function readUInt(input, bits, offset, isBigEndian) {
424
- offset = offset || 0;
425
- const endian = isBigEndian ? "BE" : "LE";
426
- const methodName = "readUInt" + bits + endian;
427
- return methods[methodName](input, offset);
428
- }
429
- function readBox(buffer, offset) {
430
- if (buffer.length - offset < 4) return;
431
- const boxSize = readUInt32BE(buffer, offset);
432
- if (buffer.length - offset < boxSize) return;
433
- return {
434
- name: toUTF8String(buffer, 4 + offset, 8 + offset),
435
- offset,
436
- size: boxSize
437
- };
438
- }
439
- function findBox(buffer, boxName, offset) {
440
- while (offset < buffer.length) {
441
- const box = readBox(buffer, offset);
442
- if (!box) break;
443
- if (box.name === boxName) return box;
444
- offset += box.size;
445
- }
446
- }
447
-
448
- const BMP = {
449
- validate: (input) => toUTF8String(input, 0, 2) === "BM",
450
- calculate: (input) => ({
451
- height: Math.abs(readInt32LE(input, 22)),
452
- width: readUInt32LE(input, 18)
453
- })
454
- };
455
-
456
- const TYPE_ICON = 1;
457
- const SIZE_HEADER$1 = 2 + 2 + 2;
458
- const SIZE_IMAGE_ENTRY = 1 + 1 + 1 + 1 + 2 + 2 + 4 + 4;
459
- function getSizeFromOffset(input, offset) {
460
- const value = input[offset];
461
- return value === 0 ? 256 : value;
462
- }
463
- function getImageSize$1(input, imageIndex) {
464
- const offset = SIZE_HEADER$1 + imageIndex * SIZE_IMAGE_ENTRY;
465
- return {
466
- height: getSizeFromOffset(input, offset + 1),
467
- width: getSizeFromOffset(input, offset)
468
- };
469
- }
470
- const ICO = {
471
- validate(input) {
472
- const reserved = readUInt16LE(input, 0);
473
- const imageCount = readUInt16LE(input, 4);
474
- if (reserved !== 0 || imageCount === 0) return false;
475
- const imageType = readUInt16LE(input, 2);
476
- return imageType === TYPE_ICON;
477
- },
478
- calculate(input) {
479
- const nbImages = readUInt16LE(input, 4);
480
- const imageSize = getImageSize$1(input, 0);
481
- if (nbImages === 1) return imageSize;
482
- const imgs = [imageSize];
483
- for (let imageIndex = 1; imageIndex < nbImages; imageIndex += 1) {
484
- imgs.push(getImageSize$1(input, imageIndex));
485
- }
486
- return {
487
- height: imageSize.height,
488
- images: imgs,
489
- width: imageSize.width
490
- };
491
- }
492
- };
493
-
494
- const TYPE_CURSOR = 2;
495
- const CUR = {
496
- validate(input) {
497
- const reserved = readUInt16LE(input, 0);
498
- const imageCount = readUInt16LE(input, 4);
499
- if (reserved !== 0 || imageCount === 0) return false;
500
- const imageType = readUInt16LE(input, 2);
501
- return imageType === TYPE_CURSOR;
502
- },
503
- calculate: (input) => ICO.calculate(input)
504
- };
505
-
506
- const DDS = {
507
- validate: (input) => readUInt32LE(input, 0) === 542327876,
508
- calculate: (input) => ({
509
- height: readUInt32LE(input, 12),
510
- width: readUInt32LE(input, 16)
511
- })
512
- };
513
-
514
- const gifRegexp = /^GIF8[79]a/;
515
- const GIF = {
516
- validate: (input) => gifRegexp.test(toUTF8String(input, 0, 6)),
517
- calculate: (input) => ({
518
- height: readUInt16LE(input, 8),
519
- width: readUInt16LE(input, 6)
520
- })
521
- };
522
-
523
- const brandMap = {
524
- avif: "avif",
525
- mif1: "heif",
526
- msf1: "heif",
527
- // hief-sequence
528
- heic: "heic",
529
- heix: "heic",
530
- hevc: "heic",
531
- // heic-sequence
532
- hevx: "heic"
533
- // heic-sequence
534
- };
535
- function detectBrands(buffer, start, end) {
536
- let brandsDetected = {};
537
- for (let i = start; i <= end; i += 4) {
538
- const brand = toUTF8String(buffer, i, i + 4);
539
- if (brand in brandMap) {
540
- brandsDetected[brand] = 1;
541
- }
542
- }
543
- if ("avif" in brandsDetected) {
544
- return "avif";
545
- } else if ("heic" in brandsDetected || "heix" in brandsDetected || "hevc" in brandsDetected || "hevx" in brandsDetected) {
546
- return "heic";
547
- } else if ("mif1" in brandsDetected || "msf1" in brandsDetected) {
548
- return "heif";
549
- }
550
- }
551
- const HEIF = {
552
- validate(buffer) {
553
- const ftype = toUTF8String(buffer, 4, 8);
554
- const brand = toUTF8String(buffer, 8, 12);
555
- return "ftyp" === ftype && brand in brandMap;
556
- },
557
- calculate(buffer) {
558
- const metaBox = findBox(buffer, "meta", 0);
559
- const iprpBox = metaBox && findBox(buffer, "iprp", metaBox.offset + 12);
560
- const ipcoBox = iprpBox && findBox(buffer, "ipco", iprpBox.offset + 8);
561
- const ispeBox = ipcoBox && findBox(buffer, "ispe", ipcoBox.offset + 8);
562
- if (ispeBox) {
563
- return {
564
- height: readUInt32BE(buffer, ispeBox.offset + 16),
565
- width: readUInt32BE(buffer, ispeBox.offset + 12),
566
- type: detectBrands(buffer, 8, metaBox.offset)
567
- };
568
- }
569
- throw new TypeError("Invalid HEIF, no size found");
570
- }
571
- };
572
-
573
- const SIZE_HEADER = 4 + 4;
574
- const FILE_LENGTH_OFFSET = 4;
575
- const ENTRY_LENGTH_OFFSET = 4;
576
- const ICON_TYPE_SIZE = {
577
- ICON: 32,
578
- "ICN#": 32,
579
- // m => 16 x 16
580
- "icm#": 16,
581
- icm4: 16,
582
- icm8: 16,
583
- // s => 16 x 16
584
- "ics#": 16,
585
- ics4: 16,
586
- ics8: 16,
587
- is32: 16,
588
- s8mk: 16,
589
- icp4: 16,
590
- // l => 32 x 32
591
- icl4: 32,
592
- icl8: 32,
593
- il32: 32,
594
- l8mk: 32,
595
- icp5: 32,
596
- ic11: 32,
597
- // h => 48 x 48
598
- ich4: 48,
599
- ich8: 48,
600
- ih32: 48,
601
- h8mk: 48,
602
- // . => 64 x 64
603
- icp6: 64,
604
- ic12: 32,
605
- // t => 128 x 128
606
- it32: 128,
607
- t8mk: 128,
608
- ic07: 128,
609
- // . => 256 x 256
610
- ic08: 256,
611
- ic13: 256,
612
- // . => 512 x 512
613
- ic09: 512,
614
- ic14: 512,
615
- // . => 1024 x 1024
616
- ic10: 1024
617
- };
618
- function readImageHeader(input, imageOffset) {
619
- const imageLengthOffset = imageOffset + ENTRY_LENGTH_OFFSET;
620
- return [
621
- toUTF8String(input, imageOffset, imageLengthOffset),
622
- readUInt32BE(input, imageLengthOffset)
623
- ];
624
- }
625
- function getImageSize(type) {
626
- const size = ICON_TYPE_SIZE[type];
627
- return { width: size, height: size, type };
628
- }
629
- const ICNS = {
630
- validate: (input) => toUTF8String(input, 0, 4) === "icns",
631
- calculate(input) {
632
- const inputLength = input.length;
633
- const fileLength = readUInt32BE(input, FILE_LENGTH_OFFSET);
634
- let imageOffset = SIZE_HEADER;
635
- let imageHeader = readImageHeader(input, imageOffset);
636
- let imageSize = getImageSize(imageHeader[0]);
637
- imageOffset += imageHeader[1];
638
- if (imageOffset === fileLength) return imageSize;
639
- const result = {
640
- height: imageSize.height,
641
- images: [imageSize],
642
- width: imageSize.width
643
- };
644
- while (imageOffset < fileLength && imageOffset < inputLength) {
645
- imageHeader = readImageHeader(input, imageOffset);
646
- imageSize = getImageSize(imageHeader[0]);
647
- imageOffset += imageHeader[1];
648
- result.images.push(imageSize);
649
- }
650
- return result;
651
- }
652
- };
653
-
654
- const J2C = {
655
- // TODO: this doesn't seem right. SIZ marker doesn't have to be right after the SOC
656
- validate: (input) => toHexString(input, 0, 4) === "ff4fff51",
657
- calculate: (input) => ({
658
- height: readUInt32BE(input, 12),
659
- width: readUInt32BE(input, 8)
660
- })
661
- };
662
-
663
- const JP2 = {
664
- validate(input) {
665
- if (readUInt32BE(input, 4) !== 1783636e3 || readUInt32BE(input, 0) < 1) return false;
666
- const ftypBox = findBox(input, "ftyp", 0);
667
- if (!ftypBox) return false;
668
- return readUInt32BE(input, ftypBox.offset + 4) === 1718909296;
669
- },
670
- calculate(input) {
671
- const jp2hBox = findBox(input, "jp2h", 0);
672
- const ihdrBox = jp2hBox && findBox(input, "ihdr", jp2hBox.offset + 8);
673
- if (ihdrBox) {
674
- return {
675
- height: readUInt32BE(input, ihdrBox.offset + 8),
676
- width: readUInt32BE(input, ihdrBox.offset + 12)
677
- };
678
- }
679
- throw new TypeError("Unsupported JPEG 2000 format");
680
- }
681
- };
682
-
683
- const EXIF_MARKER = "45786966";
684
- const APP1_DATA_SIZE_BYTES = 2;
685
- const EXIF_HEADER_BYTES = 6;
686
- const TIFF_BYTE_ALIGN_BYTES = 2;
687
- const BIG_ENDIAN_BYTE_ALIGN = "4d4d";
688
- const LITTLE_ENDIAN_BYTE_ALIGN = "4949";
689
- const IDF_ENTRY_BYTES = 12;
690
- const NUM_DIRECTORY_ENTRIES_BYTES = 2;
691
- function isEXIF(input) {
692
- return toHexString(input, 2, 6) === EXIF_MARKER;
693
- }
694
- function extractSize(input, index) {
695
- return {
696
- height: readUInt16BE(input, index),
697
- width: readUInt16BE(input, index + 2)
698
- };
699
- }
700
- function extractOrientation(exifBlock, isBigEndian) {
701
- const idfOffset = 8;
702
- const offset = EXIF_HEADER_BYTES + idfOffset;
703
- const idfDirectoryEntries = readUInt(exifBlock, 16, offset, isBigEndian);
704
- for (let directoryEntryNumber = 0; directoryEntryNumber < idfDirectoryEntries; directoryEntryNumber++) {
705
- const start = offset + NUM_DIRECTORY_ENTRIES_BYTES + directoryEntryNumber * IDF_ENTRY_BYTES;
706
- const end = start + IDF_ENTRY_BYTES;
707
- if (start > exifBlock.length) {
708
- return;
709
- }
710
- const block = exifBlock.slice(start, end);
711
- const tagNumber = readUInt(block, 16, 0, isBigEndian);
712
- if (tagNumber === 274) {
713
- const dataFormat = readUInt(block, 16, 2, isBigEndian);
714
- if (dataFormat !== 3) {
715
- return;
716
- }
717
- const numberOfComponents = readUInt(block, 32, 4, isBigEndian);
718
- if (numberOfComponents !== 1) {
719
- return;
720
- }
721
- return readUInt(block, 16, 8, isBigEndian);
722
- }
723
- }
724
- }
725
- function validateExifBlock(input, index) {
726
- const exifBlock = input.slice(APP1_DATA_SIZE_BYTES, index);
727
- const byteAlign = toHexString(
728
- exifBlock,
729
- EXIF_HEADER_BYTES,
730
- EXIF_HEADER_BYTES + TIFF_BYTE_ALIGN_BYTES
731
- );
732
- const isBigEndian = byteAlign === BIG_ENDIAN_BYTE_ALIGN;
733
- const isLittleEndian = byteAlign === LITTLE_ENDIAN_BYTE_ALIGN;
734
- if (isBigEndian || isLittleEndian) {
735
- return extractOrientation(exifBlock, isBigEndian);
736
- }
737
- }
738
- function validateInput(input, index) {
739
- if (index > input.length) {
740
- throw new TypeError("Corrupt JPG, exceeded buffer limits");
741
- }
742
- }
743
- const JPG = {
744
- validate: (input) => toHexString(input, 0, 2) === "ffd8",
745
- calculate(input) {
746
- input = input.slice(4);
747
- let orientation;
748
- let next;
749
- while (input.length) {
750
- const i = readUInt16BE(input, 0);
751
- if (input[i] !== 255) {
752
- input = input.slice(i);
753
- continue;
754
- }
755
- if (isEXIF(input)) {
756
- orientation = validateExifBlock(input, i);
757
- }
758
- validateInput(input, i);
759
- next = input[i + 1];
760
- if (next === 192 || next === 193 || next === 194) {
761
- const size = extractSize(input, i + 5);
762
- if (!orientation) {
763
- return size;
764
- }
765
- return {
766
- height: size.height,
767
- orientation,
768
- width: size.width
769
- };
770
- }
771
- input = input.slice(i + 2);
772
- }
773
- throw new TypeError("Invalid JPG, no size found");
774
- }
775
- };
776
-
777
- const KTX = {
778
- validate: (input) => {
779
- const signature = toUTF8String(input, 1, 7);
780
- return ["KTX 11", "KTX 20"].includes(signature);
781
- },
782
- calculate: (input) => {
783
- const type = input[5] === 49 ? "ktx" : "ktx2";
784
- const offset = type === "ktx" ? 36 : 20;
785
- return {
786
- height: readUInt32LE(input, offset + 4),
787
- width: readUInt32LE(input, offset),
788
- type
789
- };
790
- }
791
- };
792
-
793
- const pngSignature = "PNG\r\n\n";
794
- const pngImageHeaderChunkName = "IHDR";
795
- const pngFriedChunkName = "CgBI";
796
- const PNG = {
797
- validate(input) {
798
- if (pngSignature === toUTF8String(input, 1, 8)) {
799
- let chunkName = toUTF8String(input, 12, 16);
800
- if (chunkName === pngFriedChunkName) {
801
- chunkName = toUTF8String(input, 28, 32);
802
- }
803
- if (chunkName !== pngImageHeaderChunkName) {
804
- throw new TypeError("Invalid PNG");
805
- }
806
- return true;
807
- }
808
- return false;
809
- },
810
- calculate(input) {
811
- if (toUTF8String(input, 12, 16) === pngFriedChunkName) {
812
- return {
813
- height: readUInt32BE(input, 36),
814
- width: readUInt32BE(input, 32)
815
- };
816
- }
817
- return {
818
- height: readUInt32BE(input, 20),
819
- width: readUInt32BE(input, 16)
820
- };
821
- }
822
- };
823
-
824
- const PNMTypes = {
825
- P1: "pbm/ascii",
826
- P2: "pgm/ascii",
827
- P3: "ppm/ascii",
828
- P4: "pbm",
829
- P5: "pgm",
830
- P6: "ppm",
831
- P7: "pam",
832
- PF: "pfm"
833
- };
834
- const handlers = {
835
- default: (lines) => {
836
- let dimensions = [];
837
- while (lines.length > 0) {
838
- const line = lines.shift();
839
- if (line[0] === "#") {
840
- continue;
841
- }
842
- dimensions = line.split(" ");
843
- break;
844
- }
845
- if (dimensions.length === 2) {
846
- return {
847
- height: parseInt(dimensions[1], 10),
848
- width: parseInt(dimensions[0], 10)
849
- };
850
- } else {
851
- throw new TypeError("Invalid PNM");
852
- }
853
- },
854
- pam: (lines) => {
855
- const size = {};
856
- while (lines.length > 0) {
857
- const line = lines.shift();
858
- if (line.length > 16 || line.charCodeAt(0) > 128) {
859
- continue;
860
- }
861
- const [key, value] = line.split(" ");
862
- if (key && value) {
863
- size[key.toLowerCase()] = parseInt(value, 10);
864
- }
865
- if (size.height && size.width) {
866
- break;
867
- }
868
- }
869
- if (size.height && size.width) {
870
- return {
871
- height: size.height,
872
- width: size.width
873
- };
874
- } else {
875
- throw new TypeError("Invalid PAM");
876
- }
877
- }
878
- };
879
- const PNM = {
880
- validate: (input) => toUTF8String(input, 0, 2) in PNMTypes,
881
- calculate(input) {
882
- const signature = toUTF8String(input, 0, 2);
883
- const type = PNMTypes[signature];
884
- const lines = toUTF8String(input, 3).split(/[\r\n]+/);
885
- const handler = handlers[type] || handlers.default;
886
- return handler(lines);
887
- }
888
- };
889
-
890
- const PSD = {
891
- validate: (input) => toUTF8String(input, 0, 4) === "8BPS",
892
- calculate: (input) => ({
893
- height: readUInt32BE(input, 14),
894
- width: readUInt32BE(input, 18)
895
- })
896
- };
897
-
898
- const svgReg = /<svg\s([^>"']|"[^"]*"|'[^']*')*>/;
899
- const extractorRegExps = {
900
- height: /\sheight=(['"])([^%]+?)\1/,
901
- root: svgReg,
902
- viewbox: /\sviewBox=(['"])(.+?)\1/i,
903
- width: /\swidth=(['"])([^%]+?)\1/
904
- };
905
- const INCH_CM = 2.54;
906
- const units = {
907
- in: 96,
908
- cm: 96 / INCH_CM,
909
- em: 16,
910
- ex: 8,
911
- m: 96 / INCH_CM * 100,
912
- mm: 96 / INCH_CM / 10,
913
- pc: 96 / 72 / 12,
914
- pt: 96 / 72,
915
- px: 1
916
- };
917
- const unitsReg = new RegExp(
918
- `^([0-9.]+(?:e\\d+)?)(${Object.keys(units).join("|")})?$`
919
- );
920
- function parseLength(len) {
921
- const m = unitsReg.exec(len);
922
- if (!m) {
923
- return void 0;
924
- }
925
- return Math.round(Number(m[1]) * (units[m[2]] || 1));
926
- }
927
- function parseViewbox(viewbox) {
928
- const bounds = viewbox.split(" ");
929
- return {
930
- height: parseLength(bounds[3]),
931
- width: parseLength(bounds[2])
932
- };
933
- }
934
- function parseAttributes(root) {
935
- const width = extractorRegExps.width.exec(root);
936
- const height = extractorRegExps.height.exec(root);
937
- const viewbox = extractorRegExps.viewbox.exec(root);
938
- return {
939
- height: height && parseLength(height[2]),
940
- viewbox: viewbox && parseViewbox(viewbox[2]),
941
- width: width && parseLength(width[2])
942
- };
943
- }
944
- function calculateByDimensions(attrs) {
945
- return {
946
- height: attrs.height,
947
- width: attrs.width
948
- };
949
- }
950
- function calculateByViewbox(attrs, viewbox) {
951
- const ratio = viewbox.width / viewbox.height;
952
- if (attrs.width) {
953
- return {
954
- height: Math.floor(attrs.width / ratio),
955
- width: attrs.width
956
- };
957
- }
958
- if (attrs.height) {
959
- return {
960
- height: attrs.height,
961
- width: Math.floor(attrs.height * ratio)
962
- };
963
- }
964
- return {
965
- height: viewbox.height,
966
- width: viewbox.width
967
- };
968
- }
969
- const SVG = {
970
- // Scan only the first kilo-byte to speed up the check on larger files
971
- validate: (input) => svgReg.test(toUTF8String(input, 0, 1e3)),
972
- calculate(input) {
973
- const root = extractorRegExps.root.exec(toUTF8String(input));
974
- if (root) {
975
- const attrs = parseAttributes(root[0]);
976
- if (attrs.width && attrs.height) {
977
- return calculateByDimensions(attrs);
978
- }
979
- if (attrs.viewbox) {
980
- return calculateByViewbox(attrs, attrs.viewbox);
981
- }
982
- }
983
- throw new TypeError("Invalid SVG");
984
- }
985
- };
986
-
987
- const TGA = {
988
- validate(input) {
989
- return readUInt16LE(input, 0) === 0 && readUInt16LE(input, 4) === 0;
990
- },
991
- calculate(input) {
992
- return {
993
- height: readUInt16LE(input, 14),
994
- width: readUInt16LE(input, 12)
995
- };
996
- }
997
- };
998
-
999
- function readIFD(input, isBigEndian) {
1000
- const ifdOffset = readUInt(input, 32, 4, isBigEndian);
1001
- return input.slice(ifdOffset + 2);
1002
- }
1003
- function readValue(input, isBigEndian) {
1004
- const low = readUInt(input, 16, 8, isBigEndian);
1005
- const high = readUInt(input, 16, 10, isBigEndian);
1006
- return (high << 16) + low;
1007
- }
1008
- function nextTag(input) {
1009
- if (input.length > 24) {
1010
- return input.slice(12);
1011
- }
1012
- }
1013
- function extractTags(input, isBigEndian) {
1014
- const tags = {};
1015
- let temp = input;
1016
- while (temp && temp.length) {
1017
- const code = readUInt(temp, 16, 0, isBigEndian);
1018
- const type = readUInt(temp, 16, 2, isBigEndian);
1019
- const length = readUInt(temp, 32, 4, isBigEndian);
1020
- if (code === 0) {
1021
- break;
1022
- } else {
1023
- if (length === 1 && (type === 3 || type === 4)) {
1024
- tags[code] = readValue(temp, isBigEndian);
1025
- }
1026
- temp = nextTag(temp);
1027
- }
1028
- }
1029
- return tags;
1030
- }
1031
- function determineEndianness(input) {
1032
- const signature = toUTF8String(input, 0, 2);
1033
- if ("II" === signature) {
1034
- return "LE";
1035
- } else if ("MM" === signature) {
1036
- return "BE";
1037
- }
1038
- }
1039
- const signatures = [
1040
- // '492049', // currently not supported
1041
- "49492a00",
1042
- // Little endian
1043
- "4d4d002a"
1044
- // Big Endian
1045
- // '4d4d002a', // BigTIFF > 4GB. currently not supported
1046
- ];
1047
- const TIFF = {
1048
- validate: (input) => signatures.includes(toHexString(input, 0, 4)),
1049
- calculate(input) {
1050
- const isBigEndian = determineEndianness(input) === "BE";
1051
- const ifdBuffer = readIFD(input, isBigEndian);
1052
- const tags = extractTags(ifdBuffer, isBigEndian);
1053
- const width = tags[256];
1054
- const height = tags[257];
1055
- if (!width || !height) {
1056
- throw new TypeError("Invalid Tiff. Missing tags");
1057
- }
1058
- return { height, width };
1059
- }
1060
- };
1061
-
1062
- function calculateExtended(input) {
1063
- return {
1064
- height: 1 + readUInt24LE(input, 7),
1065
- width: 1 + readUInt24LE(input, 4)
1066
- };
1067
- }
1068
- function calculateLossless(input) {
1069
- return {
1070
- height: 1 + ((input[4] & 15) << 10 | input[3] << 2 | (input[2] & 192) >> 6),
1071
- width: 1 + ((input[2] & 63) << 8 | input[1])
1072
- };
1073
- }
1074
- function calculateLossy(input) {
1075
- return {
1076
- height: readInt16LE(input, 8) & 16383,
1077
- width: readInt16LE(input, 6) & 16383
1078
- };
1079
- }
1080
- const WEBP = {
1081
- validate(input) {
1082
- const riffHeader = "RIFF" === toUTF8String(input, 0, 4);
1083
- const webpHeader = "WEBP" === toUTF8String(input, 8, 12);
1084
- const vp8Header = "VP8" === toUTF8String(input, 12, 15);
1085
- return riffHeader && webpHeader && vp8Header;
1086
- },
1087
- calculate(input) {
1088
- const chunkHeader = toUTF8String(input, 12, 16);
1089
- input = input.slice(20, 30);
1090
- if (chunkHeader === "VP8X") {
1091
- const extendedHeader = input[0];
1092
- const validStart = (extendedHeader & 192) === 0;
1093
- const validEnd = (extendedHeader & 1) === 0;
1094
- if (validStart && validEnd) {
1095
- return calculateExtended(input);
1096
- } else {
1097
- throw new TypeError("Invalid WebP");
1098
- }
1099
- }
1100
- if (chunkHeader === "VP8 " && input[0] !== 47) {
1101
- return calculateLossy(input);
1102
- }
1103
- const signature = toHexString(input, 3, 6);
1104
- if (chunkHeader === "VP8L" && signature !== "9d012a") {
1105
- return calculateLossless(input);
1106
- }
1107
- throw new TypeError("Invalid WebP");
1108
- }
1109
- };
1110
-
1111
- const typeHandlers = /* @__PURE__ */ new Map([
1112
- ["bmp", BMP],
1113
- ["cur", CUR],
1114
- ["dds", DDS],
1115
- ["gif", GIF],
1116
- ["heif", HEIF],
1117
- ["icns", ICNS],
1118
- ["ico", ICO],
1119
- ["j2c", J2C],
1120
- ["jp2", JP2],
1121
- ["jpg", JPG],
1122
- ["ktx", KTX],
1123
- ["png", PNG],
1124
- ["pnm", PNM],
1125
- ["psd", PSD],
1126
- ["svg", SVG],
1127
- ["tga", TGA],
1128
- ["tiff", TIFF],
1129
- ["webp", WEBP]
1130
- ]);
1131
- const types = Array.from(typeHandlers.keys());
1132
-
1133
- const firstBytes = /* @__PURE__ */ new Map([
1134
- [56, "psd"],
1135
- [66, "bmp"],
1136
- [68, "dds"],
1137
- [71, "gif"],
1138
- [73, "tiff"],
1139
- [77, "tiff"],
1140
- [82, "webp"],
1141
- [105, "icns"],
1142
- [137, "png"],
1143
- [255, "jpg"]
1144
- ]);
1145
- function detector(input) {
1146
- const byte = input[0];
1147
- const type = firstBytes.get(byte);
1148
- if (type && typeHandlers.get(type).validate(input)) {
1149
- return type;
1150
- }
1151
- return types.find((fileType) => typeHandlers.get(fileType).validate(input));
1152
- }
1153
-
1154
- const globalOptions = {
1155
- disabledTypes: []
1156
- };
1157
- function lookup(input) {
1158
- const type = detector(input);
1159
- if (typeof type !== "undefined") {
1160
- if (globalOptions.disabledTypes.includes(type)) {
1161
- throw new TypeError("disabled file type: " + type);
1162
- }
1163
- const size = typeHandlers.get(type).calculate(input);
1164
- if (size !== void 0) {
1165
- size.type = size.type ?? type;
1166
- return size;
1167
- }
1168
- }
1169
- throw new TypeError("unsupported file type: " + type);
1170
- }
1171
-
1172
- async function imageMetadata(data, src) {
1173
- try {
1174
- const result = lookup(data);
1175
- if (!result.height || !result.width || !result.type) {
1176
- throw new AstroError({
1177
- ...NoImageMetadata,
1178
- message: NoImageMetadata.message(src)
1179
- });
1180
- }
1181
- const { width, height, type, orientation } = result;
1182
- const isPortrait = (orientation || 0) >= 5;
1183
- return {
1184
- width: isPortrait ? height : width,
1185
- height: isPortrait ? width : height,
1186
- format: type,
1187
- orientation
1188
- };
1189
- } catch {
1190
- throw new AstroError({
1191
- ...NoImageMetadata,
1192
- message: NoImageMetadata.message(src)
1193
- });
1194
- }
1195
- }
1196
-
1197
- async function inferRemoteSize(url) {
1198
- const response = await fetch(url);
1199
- if (!response.body || !response.ok) {
1200
- throw new AstroError({
1201
- ...FailedToFetchRemoteImageDimensions,
1202
- message: FailedToFetchRemoteImageDimensions.message(url)
1203
- });
1204
- }
1205
- const reader = response.body.getReader();
1206
- let done, value;
1207
- let accumulatedChunks = new Uint8Array();
1208
- while (!done) {
1209
- const readResult = await reader.read();
1210
- done = readResult.done;
1211
- if (done) break;
1212
- if (readResult.value) {
1213
- value = readResult.value;
1214
- let tmp = new Uint8Array(accumulatedChunks.length + value.length);
1215
- tmp.set(accumulatedChunks, 0);
1216
- tmp.set(value, accumulatedChunks.length);
1217
- accumulatedChunks = tmp;
1218
- try {
1219
- const dimensions = await imageMetadata(accumulatedChunks, url);
1220
- if (dimensions) {
1221
- await reader.cancel();
1222
- return dimensions;
1223
- }
1224
- } catch {
1225
- }
1226
- }
1227
- }
1228
- throw new AstroError({
1229
- ...NoImageMetadata,
1230
- message: NoImageMetadata.message(url)
1231
- });
1232
- }
1233
-
1234
- async function getConfiguredImageService() {
1235
- if (!globalThis?.astroAsset?.imageService) {
1236
- const { default: service } = await import(
1237
- // @ts-expect-error
1238
- './sharp_CbOL3WDk.mjs'
1239
- ).catch((e) => {
1240
- const error = new AstroError(InvalidImageService);
1241
- error.cause = e;
1242
- throw error;
1243
- });
1244
- if (!globalThis.astroAsset) globalThis.astroAsset = {};
1245
- globalThis.astroAsset.imageService = service;
1246
- return service;
1247
- }
1248
- return globalThis.astroAsset.imageService;
1249
- }
1250
- async function getImage$1(options, imageConfig) {
1251
- if (!options || typeof options !== "object") {
1252
- throw new AstroError({
1253
- ...ExpectedImageOptions,
1254
- message: ExpectedImageOptions.message(JSON.stringify(options))
1255
- });
1256
- }
1257
- if (typeof options.src === "undefined") {
1258
- throw new AstroError({
1259
- ...ExpectedImage,
1260
- message: ExpectedImage.message(
1261
- options.src,
1262
- "undefined",
1263
- JSON.stringify(options)
1264
- )
1265
- });
1266
- }
1267
- if (isImageMetadata(options)) {
1268
- throw new AstroError(ExpectedNotESMImage);
1269
- }
1270
- const service = await getConfiguredImageService();
1271
- const resolvedOptions = {
1272
- ...options,
1273
- src: await resolveSrc(options.src)
1274
- };
1275
- let originalWidth;
1276
- let originalHeight;
1277
- let originalFormat;
1278
- if (options.inferSize && isRemoteImage(resolvedOptions.src) && isRemotePath(resolvedOptions.src)) {
1279
- const result = await inferRemoteSize(resolvedOptions.src);
1280
- resolvedOptions.width ??= result.width;
1281
- resolvedOptions.height ??= result.height;
1282
- originalWidth = result.width;
1283
- originalHeight = result.height;
1284
- originalFormat = result.format;
1285
- delete resolvedOptions.inferSize;
1286
- }
1287
- const originalFilePath = isESMImportedImage(resolvedOptions.src) ? resolvedOptions.src.fsPath : void 0;
1288
- const clonedSrc = isESMImportedImage(resolvedOptions.src) ? (
1289
- // @ts-expect-error - clone is a private, hidden prop
1290
- resolvedOptions.src.clone ?? resolvedOptions.src
1291
- ) : resolvedOptions.src;
1292
- if (isESMImportedImage(clonedSrc)) {
1293
- originalWidth = clonedSrc.width;
1294
- originalHeight = clonedSrc.height;
1295
- originalFormat = clonedSrc.format;
1296
- }
1297
- if (originalWidth && originalHeight) {
1298
- const aspectRatio = originalWidth / originalHeight;
1299
- if (resolvedOptions.height && !resolvedOptions.width) {
1300
- resolvedOptions.width = Math.round(resolvedOptions.height * aspectRatio);
1301
- } else if (resolvedOptions.width && !resolvedOptions.height) {
1302
- resolvedOptions.height = Math.round(resolvedOptions.width / aspectRatio);
1303
- } else if (!resolvedOptions.width && !resolvedOptions.height) {
1304
- resolvedOptions.width = originalWidth;
1305
- resolvedOptions.height = originalHeight;
1306
- }
1307
- }
1308
- resolvedOptions.src = clonedSrc;
1309
- const layout = options.layout ?? imageConfig.experimentalLayout;
1310
- if (imageConfig.experimentalResponsiveImages && layout) {
1311
- resolvedOptions.widths ||= getWidths({
1312
- width: resolvedOptions.width,
1313
- layout,
1314
- originalWidth,
1315
- breakpoints: imageConfig.experimentalBreakpoints?.length ? imageConfig.experimentalBreakpoints : isLocalService(service) ? LIMITED_RESOLUTIONS : DEFAULT_RESOLUTIONS
1316
- });
1317
- resolvedOptions.sizes ||= getSizesAttribute({ width: resolvedOptions.width, layout });
1318
- if (resolvedOptions.priority) {
1319
- resolvedOptions.loading ??= "eager";
1320
- resolvedOptions.decoding ??= "sync";
1321
- resolvedOptions.fetchpriority ??= "high";
1322
- } else {
1323
- resolvedOptions.loading ??= "lazy";
1324
- resolvedOptions.decoding ??= "async";
1325
- resolvedOptions.fetchpriority ??= "auto";
1326
- }
1327
- delete resolvedOptions.priority;
1328
- delete resolvedOptions.densities;
1329
- if (layout !== "none") {
1330
- resolvedOptions.style = addCSSVarsToStyle(
1331
- {
1332
- w: String(resolvedOptions.width),
1333
- h: String(resolvedOptions.height),
1334
- fit: cssFitValues.includes(resolvedOptions.fit ?? "") && resolvedOptions.fit,
1335
- pos: resolvedOptions.position
1336
- },
1337
- resolvedOptions.style
1338
- );
1339
- resolvedOptions["data-astro-image"] = layout;
1340
- }
1341
- }
1342
- const validatedOptions = service.validateOptions ? await service.validateOptions(resolvedOptions, imageConfig) : resolvedOptions;
1343
- const srcSetTransforms = service.getSrcSet ? await service.getSrcSet(validatedOptions, imageConfig) : [];
1344
- let imageURL = await service.getURL(validatedOptions, imageConfig);
1345
- const matchesOriginal = (transform) => transform.width === originalWidth && transform.height === originalHeight && transform.format === originalFormat;
1346
- let srcSets = await Promise.all(
1347
- srcSetTransforms.map(async (srcSet) => {
1348
- return {
1349
- transform: srcSet.transform,
1350
- url: matchesOriginal(srcSet.transform) ? imageURL : await service.getURL(srcSet.transform, imageConfig),
1351
- descriptor: srcSet.descriptor,
1352
- attributes: srcSet.attributes
1353
- };
1354
- })
1355
- );
1356
- if (isLocalService(service) && globalThis.astroAsset.addStaticImage && !(isRemoteImage(validatedOptions.src) && imageURL === validatedOptions.src)) {
1357
- const propsToHash = service.propertiesToHash ?? DEFAULT_HASH_PROPS;
1358
- imageURL = globalThis.astroAsset.addStaticImage(
1359
- validatedOptions,
1360
- propsToHash,
1361
- originalFilePath
1362
- );
1363
- srcSets = srcSetTransforms.map((srcSet) => {
1364
- return {
1365
- transform: srcSet.transform,
1366
- url: matchesOriginal(srcSet.transform) ? imageURL : globalThis.astroAsset.addStaticImage(srcSet.transform, propsToHash, originalFilePath),
1367
- descriptor: srcSet.descriptor,
1368
- attributes: srcSet.attributes
1369
- };
1370
- });
1371
- }
1372
- return {
1373
- rawOptions: resolvedOptions,
1374
- options: validatedOptions,
1375
- src: imageURL,
1376
- srcSet: {
1377
- values: srcSets,
1378
- attribute: srcSets.map((srcSet) => `${srcSet.url} ${srcSet.descriptor}`).join(", ")
1379
- },
1380
- attributes: service.getHTMLAttributes !== void 0 ? await service.getHTMLAttributes(validatedOptions, imageConfig) : {}
1381
- };
1382
- }
1383
-
1384
- const $$Astro$1 = createAstro();
1385
- const $$Image = createComponent(async ($$result, $$props, $$slots) => {
1386
- const Astro2 = $$result.createAstro($$Astro$1, $$props, $$slots);
1387
- Astro2.self = $$Image;
1388
- const props = Astro2.props;
1389
- if (props.alt === void 0 || props.alt === null) {
1390
- throw new AstroError(ImageMissingAlt);
1391
- }
1392
- if (typeof props.width === "string") {
1393
- props.width = parseInt(props.width);
1394
- }
1395
- if (typeof props.height === "string") {
1396
- props.height = parseInt(props.height);
1397
- }
1398
- const layout = props.layout ?? imageConfig.experimentalLayout ?? "none";
1399
- const useResponsive = imageConfig.experimentalResponsiveImages && layout !== "none";
1400
- if (useResponsive) {
1401
- props.layout ??= imageConfig.experimentalLayout;
1402
- props.fit ??= imageConfig.experimentalObjectFit ?? "cover";
1403
- props.position ??= imageConfig.experimentalObjectPosition ?? "center";
1404
- }
1405
- const image = await getImage(props);
1406
- const additionalAttributes = {};
1407
- if (image.srcSet.values.length > 0) {
1408
- additionalAttributes.srcset = image.srcSet.attribute;
1409
- }
1410
- const { class: className, ...attributes } = { ...additionalAttributes, ...image.attributes };
1411
- return renderTemplate`${maybeRenderHead()}<img${addAttribute(image.src, "src")}${spreadAttributes(attributes)}${addAttribute(className, "class")}>`;
1412
- }, "/home/runner/work/patternfly-doc-core/patternfly-doc-core/node_modules/astro/components/Image.astro", void 0);
1413
-
1414
- const $$Astro = createAstro();
1415
- const $$Picture = createComponent(async ($$result, $$props, $$slots) => {
1416
- const Astro2 = $$result.createAstro($$Astro, $$props, $$slots);
1417
- Astro2.self = $$Picture;
1418
- const defaultFormats = ["webp"];
1419
- const defaultFallbackFormat = "png";
1420
- const specialFormatsFallback = ["gif", "svg", "jpg", "jpeg"];
1421
- const { formats = defaultFormats, pictureAttributes = {}, fallbackFormat, ...props } = Astro2.props;
1422
- if (props.alt === void 0 || props.alt === null) {
1423
- throw new AstroError(ImageMissingAlt);
1424
- }
1425
- const scopedStyleClass = props.class?.match(/\bastro-\w{8}\b/)?.[0];
1426
- if (scopedStyleClass) {
1427
- if (pictureAttributes.class) {
1428
- pictureAttributes.class = `${pictureAttributes.class} ${scopedStyleClass}`;
1429
- } else {
1430
- pictureAttributes.class = scopedStyleClass;
1431
- }
1432
- }
1433
- const layout = props.layout ?? imageConfig.experimentalLayout ?? "none";
1434
- const useResponsive = imageConfig.experimentalResponsiveImages && layout !== "none";
1435
- if (useResponsive) {
1436
- props.layout ??= imageConfig.experimentalLayout;
1437
- props.fit ??= imageConfig.experimentalObjectFit ?? "cover";
1438
- props.position ??= imageConfig.experimentalObjectPosition ?? "center";
1439
- }
1440
- for (const key in props) {
1441
- if (key.startsWith("data-astro-cid")) {
1442
- pictureAttributes[key] = props[key];
1443
- }
1444
- }
1445
- const originalSrc = await resolveSrc(props.src);
1446
- const optimizedImages = await Promise.all(
1447
- formats.map(
1448
- async (format) => await getImage({
1449
- ...props,
1450
- src: originalSrc,
1451
- format,
1452
- widths: props.widths,
1453
- densities: props.densities
1454
- })
1455
- )
1456
- );
1457
- let resultFallbackFormat = fallbackFormat ?? defaultFallbackFormat;
1458
- if (!fallbackFormat && isESMImportedImage(originalSrc) && specialFormatsFallback.includes(originalSrc.format)) {
1459
- resultFallbackFormat = originalSrc.format;
1460
- }
1461
- const fallbackImage = await getImage({
1462
- ...props,
1463
- format: resultFallbackFormat,
1464
- widths: props.widths,
1465
- densities: props.densities
1466
- });
1467
- const imgAdditionalAttributes = {};
1468
- const sourceAdditionalAttributes = {};
1469
- if (props.sizes) {
1470
- sourceAdditionalAttributes.sizes = props.sizes;
1471
- }
1472
- if (fallbackImage.srcSet.values.length > 0) {
1473
- imgAdditionalAttributes.srcset = fallbackImage.srcSet.attribute;
1474
- }
1475
- const { class: className, ...attributes } = {
1476
- ...imgAdditionalAttributes,
1477
- ...fallbackImage.attributes
1478
- };
1479
- return renderTemplate`${maybeRenderHead()}<picture${spreadAttributes(pictureAttributes)}> ${Object.entries(optimizedImages).map(([_, image]) => {
1480
- const srcsetAttribute = props.densities || !props.densities && !props.widths && !useResponsive ? `${image.src}${image.srcSet.values.length > 0 ? ", " + image.srcSet.attribute : ""}` : image.srcSet.attribute;
1481
- return renderTemplate`<source${addAttribute(srcsetAttribute, "srcset")}${addAttribute(mime.lookup(image.options.format ?? image.src) ?? `image/${image.options.format}`, "type")}${spreadAttributes(sourceAdditionalAttributes)}>`;
1482
- })} <img${addAttribute(fallbackImage.src, "src")}${spreadAttributes(attributes)}${addAttribute(className, "class")}> </picture>`;
1483
- }, "/home/runner/work/patternfly-doc-core/patternfly-doc-core/node_modules/astro/components/Picture.astro", void 0);
1484
-
1485
- const imageConfig = {"endpoint":{"route":"/_image","entrypoint":"astro/assets/endpoint/node"},"service":{"entrypoint":"astro/assets/services/sharp","config":{}},"domains":[],"remotePatterns":[],"experimentalResponsiveImages":false};
1486
- // This is used by the @astrojs/node integration to locate images.
1487
- // It's unused on other platforms, but on some platforms like Netlify (and presumably also Vercel)
1488
- // new URL("dist/...") is interpreted by the bundler as a signal to include that directory
1489
- // in the Lambda bundle, which would bloat the bundle with images.
1490
- // To prevent this, we mark the URL construction as pure,
1491
- // so that it's tree-shaken away for all platforms that don't need it.
1492
- const outDir = /* #__PURE__ */ new URL("file:///home/runner/work/patternfly-doc-core/patternfly-doc-core/dist/client/");
1493
- const assetsDir = /* #__PURE__ */ new URL("_astro", outDir);
1494
- const getImage = async (options) => await getImage$1(options, imageConfig);
1495
-
1496
- const _astro_assets = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
1497
- __proto__: null,
1498
- assetsDir,
1499
- getConfiguredImageService,
1500
- getImage,
1501
- imageConfig,
1502
- inferRemoteSize,
1503
- isLocalService,
1504
- outDir
1505
- }, Symbol.toStringTag, { value: 'Module' }));
1506
-
1507
- export { _astro_assets as _, isRemoteAllowed as a, assetsDir as b, baseService as c, getConfiguredImageService as g, imageConfig as i, outDir as o, parseQuality as p };