cloudcommerce 2.6.3 → 2.6.4

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 (155) hide show
  1. package/.github/workflows/test-apps.yml +1 -1
  2. package/CHANGELOG.md +12 -0
  3. package/README.md +2 -0
  4. package/ecomplus-stores/barradoce/functions/many/package.json +3 -3
  5. package/ecomplus-stores/barradoce/functions/ssr/content/reviews.json +71 -0
  6. package/ecomplus-stores/barradoce/functions/ssr/content/types.d.ts +5 -0
  7. package/ecomplus-stores/barradoce/functions/ssr/package.json +6 -6
  8. package/ecomplus-stores/barradoce/functions/ssr/src/env.d.ts +1 -0
  9. package/ecomplus-stores/barradoce/functions/with-apps/package.json +3 -3
  10. package/ecomplus-stores/barradoce/package.json +2 -2
  11. package/package.json +7 -7
  12. package/packages/api/package.json +1 -1
  13. package/packages/apps/affiliate-program/package.json +1 -1
  14. package/packages/apps/correios/package.json +1 -1
  15. package/packages/apps/custom-payment/package.json +1 -1
  16. package/packages/apps/custom-shipping/package.json +1 -1
  17. package/packages/apps/datafrete/package.json +1 -1
  18. package/packages/apps/discounts/package.json +1 -1
  19. package/packages/apps/emails/package.json +1 -1
  20. package/packages/apps/fb-conversions/package.json +1 -1
  21. package/packages/apps/flash-courier/package.json +1 -1
  22. package/packages/apps/frenet/package.json +1 -1
  23. package/packages/apps/galaxpay/package.json +1 -1
  24. package/packages/apps/google-analytics/package.json +1 -1
  25. package/packages/apps/jadlog/package.json +1 -1
  26. package/packages/apps/loyalty-points/package.json +1 -1
  27. package/packages/apps/mandae/package.json +1 -1
  28. package/packages/apps/melhor-envio/package.json +1 -1
  29. package/packages/apps/mercadopago/package.json +1 -1
  30. package/packages/apps/pagarme/package.json +2 -2
  31. package/packages/apps/pagarme-v5/package.json +1 -1
  32. package/packages/apps/paghiper/package.json +1 -1
  33. package/packages/apps/pix/package.json +1 -1
  34. package/packages/apps/tiny-erp/package.json +1 -1
  35. package/packages/apps/webhooks/package.json +1 -1
  36. package/packages/cli/package.json +2 -2
  37. package/packages/config/package.json +1 -1
  38. package/packages/emails/package.json +2 -2
  39. package/packages/eslint/package.json +6 -6
  40. package/packages/events/package.json +1 -1
  41. package/packages/feeds/package.json +1 -1
  42. package/packages/firebase/package.json +2 -2
  43. package/packages/i18n/package.json +1 -1
  44. package/packages/modules/package.json +1 -1
  45. package/packages/passport/package.json +1 -1
  46. package/packages/ssr/lib/lib/cron-ssr-save-views.js +2 -1
  47. package/packages/ssr/lib/lib/cron-ssr-save-views.js.map +1 -1
  48. package/packages/ssr/package.json +4 -4
  49. package/packages/ssr/src/lib/cron-ssr-save-views.ts +2 -1
  50. package/packages/storefront/dist/client/_astro/AccountPage.B4WZaOzX.js +1 -0
  51. package/packages/storefront/dist/client/_astro/CartSidebar.DAGdpIcU.js +1 -0
  52. package/packages/storefront/dist/client/_astro/HeroSlider.Dq_9kcdU.js +1 -0
  53. package/packages/storefront/dist/client/_astro/PitchBar.BwLlIs6F.js +1 -0
  54. package/packages/storefront/dist/client/_astro/Prices.BgHTq5id.js +1 -0
  55. package/packages/storefront/dist/client/_astro/ProductDetails.CnYNdPl5.js +7 -0
  56. package/packages/storefront/dist/client/_astro/ProductShelf.kfADQTUO.js +1 -0
  57. package/packages/storefront/dist/client/_astro/SearchModal.DcmvABes.js +1 -0
  58. package/packages/storefront/dist/client/_astro/SearchShowcase.C9GWwOnF.js +1 -0
  59. package/packages/storefront/dist/client/_astro/ShippingCalculator.DE01D7dt.js +1 -0
  60. package/packages/storefront/dist/client/_astro/ShopHeader.Cf4t6O6z.js +7 -0
  61. package/packages/storefront/dist/client/_astro/_commonjsHelpers.Cpj98o6Y.js +1 -0
  62. package/packages/storefront/dist/client/_astro/_plugin-vue_export-helper.CBemkWnU.js +5 -0
  63. package/packages/storefront/dist/client/_astro/{_slug_.4W7qhV-L.css → _slug_.DX_OkMX7.css} +1 -1
  64. package/packages/storefront/dist/client/_astro/{afetch.OifQZgwR.js → afetch.DPLba2tr.js} +1 -1
  65. package/packages/storefront/dist/client/_astro/client.CdXC84C5.js +1 -0
  66. package/packages/storefront/dist/client/_astro/customer-session.CNe1heRH.js +7 -0
  67. package/packages/storefront/dist/client/_astro/{firebase-app.iLdzDVjL.js → firebase-app.CBckq0Sj.js} +1 -1
  68. package/packages/storefront/dist/client/_astro/{format-money.1_HtF5S2.js → format-money.DINpWB0x.js} +1 -1
  69. package/packages/storefront/dist/client/_astro/grid-title.D4m7-g3h.js +1 -0
  70. package/packages/storefront/dist/client/_astro/hoisted.B2rH1xwX.js +8 -0
  71. package/packages/storefront/dist/client/_astro/hoisted.DBPXHTEb.js +1 -0
  72. package/packages/storefront/dist/client/_astro/hoisted.EBqhuD5o.js +1 -0
  73. package/packages/storefront/dist/client/_astro/{hoisted.GaT7bmE3.js → hoisted.ut_nNM_H.js} +1 -1
  74. package/packages/storefront/dist/client/_astro/i18n.B3skIOFg.js +1 -0
  75. package/packages/storefront/dist/client/_astro/img-sizes.rFK7so02.js +1 -0
  76. package/packages/storefront/dist/client/_astro/img.D5a6GzeE.js +1 -0
  77. package/packages/storefront/dist/client/_astro/index.CFw6O-Kt.js +1 -0
  78. package/packages/storefront/dist/client/_astro/index.DBfgCyd-.js +1 -0
  79. package/packages/storefront/dist/client/_astro/{modules-info.HP6478mG.js → modules-info.BHKiT6oA.js} +1 -1
  80. package/packages/storefront/dist/client/_astro/name.BZA9xqh-.js +1 -0
  81. package/packages/storefront/dist/client/_astro/photoswipe.esm.C0FT-EY-.js +4 -0
  82. package/packages/storefront/dist/client/_astro/price.CHiL6Z1J.js +1 -0
  83. package/packages/storefront/dist/client/_astro/sf-utils.Cigv01cN.js +13 -0
  84. package/packages/storefront/dist/client/_astro/shopping-cart.D-w8Z-4p.js +1 -0
  85. package/packages/storefront/dist/client/_astro/use-analytics.CQDdNgwF.js +1 -0
  86. package/packages/storefront/dist/client/_astro/use-cms-preview.4Hq7LCmA.js +1 -0
  87. package/packages/storefront/dist/client/_astro/use-product-card.CQRlRsNX.js +1 -0
  88. package/packages/storefront/dist/client/_astro/use-text-value.UjCYLWjm.js +4 -0
  89. package/packages/storefront/dist/client/img/uploads/logo.png +0 -0
  90. package/packages/storefront/dist/server/chunks/{CartSidebar_3_1aFp67.mjs → CartSidebar_BmwcZuxv.mjs} +36 -4
  91. package/packages/storefront/dist/server/chunks/{SearchModal_2azP1u7P.mjs → SearchModal_BvEnUvAx.mjs} +4 -3
  92. package/packages/storefront/dist/server/chunks/_.._DORZHe_Z.mjs +5 -0
  93. package/packages/storefront/dist/server/chunks/{_page__qqIVxbal.mjs → _page__DU3kNewy.mjs} +1 -1
  94. package/packages/storefront/dist/server/chunks/{account_vK6pmJlz.mjs → account_CaTloREf.mjs} +1 -1
  95. package/packages/storefront/dist/server/chunks/astro/{assets-service_631fRtTy.mjs → assets-service_B77Hm2ue.mjs} +2 -2
  96. package/packages/storefront/dist/server/chunks/{astro_u-oSb215.mjs → astro_ISB6VLqs.mjs} +178 -59
  97. package/packages/storefront/dist/server/chunks/index_BTDpenpc.mjs +5 -0
  98. package/packages/storefront/dist/server/chunks/index_D0q4ab_n.mjs +5 -0
  99. package/packages/storefront/dist/server/chunks/{node_zqXXqc-u.mjs → node_C7sdLKL4.mjs} +1 -1
  100. package/packages/storefront/dist/server/chunks/pages/{__ZucPYaOo.mjs → __B4CsSrck.mjs} +1751 -344
  101. package/packages/storefront/dist/server/chunks/pages/{_page__0sN9U0SD.mjs → _page__sb5Idhgp.mjs} +2 -3
  102. package/packages/storefront/dist/server/chunks/pages/{account_OQr_6KN1.mjs → account_iWjHfkwu.mjs} +2 -3
  103. package/packages/storefront/dist/server/chunks/pages/{index_3IjgOEIq.mjs → index_BZlpKBRL.mjs} +41 -4
  104. package/packages/storefront/dist/server/chunks/pages/node_GFu-CQ19.mjs +852 -0
  105. package/packages/storefront/dist/server/chunks/pages/{~fallback_133FK-CP.mjs → ~fallback_C07rzeay.mjs} +2 -3
  106. package/packages/storefront/dist/server/chunks/{index__05fnqFh.mjs → ~fallback_YpJa9BIL.mjs} +1 -1
  107. package/packages/storefront/dist/server/entry.mjs +751 -912
  108. package/packages/storefront/dist/server/manifest_KFjAaJaC.mjs +201 -0
  109. package/packages/storefront/dist/server/renderers.mjs +1 -1
  110. package/packages/storefront/package.json +6 -6
  111. package/packages/storefront/src/lib/content.d.ts +4 -1
  112. package/packages/storefront/src/lib/custom-content.d.ts +9 -0
  113. package/packages/storefront/src/lib/ssr-context.ts +6 -4
  114. package/packages/test-base/package.json +1 -1
  115. package/packages/types/package.json +1 -1
  116. package/packages/storefront/dist/client/_astro/AccountPage.0M6_FdU6.js +0 -1
  117. package/packages/storefront/dist/client/_astro/CartSidebar.L0Vbhsdt.js +0 -1
  118. package/packages/storefront/dist/client/_astro/HeroSlider.ju9TsLrJ.js +0 -1
  119. package/packages/storefront/dist/client/_astro/PitchBar.yqD9ycx5.js +0 -1
  120. package/packages/storefront/dist/client/_astro/Prices.xI1rdM1e.js +0 -1
  121. package/packages/storefront/dist/client/_astro/ProductDetails.FQtM5kpd.js +0 -7
  122. package/packages/storefront/dist/client/_astro/ProductShelf.-4fsYkPB.js +0 -1
  123. package/packages/storefront/dist/client/_astro/ProductShelf.GAAhKdTN.js +0 -1
  124. package/packages/storefront/dist/client/_astro/QuantitySelector.v7L8EYOR.js +0 -1
  125. package/packages/storefront/dist/client/_astro/SearchModal.rasg5jV6.js +0 -1
  126. package/packages/storefront/dist/client/_astro/SearchShowcase.kA6jICYo.js +0 -1
  127. package/packages/storefront/dist/client/_astro/ShopHeader.v_L96Y90.js +0 -7
  128. package/packages/storefront/dist/client/_astro/_plugin-vue_export-helper.xATGHWd9.js +0 -5
  129. package/packages/storefront/dist/client/_astro/client.YJ00ta5M.js +0 -1
  130. package/packages/storefront/dist/client/_astro/customer-session.ZD6tLDQJ.js +0 -7
  131. package/packages/storefront/dist/client/_astro/grid-title.pK2Nn3i-.js +0 -1
  132. package/packages/storefront/dist/client/_astro/hoisted.ICXGWNEA.js +0 -1
  133. package/packages/storefront/dist/client/_astro/hoisted.XOXTrHqn.js +0 -1
  134. package/packages/storefront/dist/client/_astro/i18n.zhlBzJt8.js +0 -1
  135. package/packages/storefront/dist/client/_astro/img-sizes.gxAI9JNh.js +0 -1
  136. package/packages/storefront/dist/client/_astro/img.AnjeGdy_.js +0 -1
  137. package/packages/storefront/dist/client/_astro/index.KfrHdfOH.js +0 -1
  138. package/packages/storefront/dist/client/_astro/index.ShNlAyu1.js +0 -1
  139. package/packages/storefront/dist/client/_astro/name.VA3MEpe0.js +0 -1
  140. package/packages/storefront/dist/client/_astro/photoswipe.esm.Ylh9TGkz.js +0 -4
  141. package/packages/storefront/dist/client/_astro/price.Easct8WC.js +0 -1
  142. package/packages/storefront/dist/client/_astro/sf-utils.c42cbZ9W.js +0 -13
  143. package/packages/storefront/dist/client/_astro/shopping-cart.nSNNOrp9.js +0 -1
  144. package/packages/storefront/dist/client/_astro/use-analytics.wTmoP8B1.js +0 -1
  145. package/packages/storefront/dist/client/_astro/use-product-card.UFr8SCuD.js +0 -1
  146. package/packages/storefront/dist/client/_astro/use-text-value.lKqoIagH.js +0 -4
  147. package/packages/storefront/dist/server/chunks/_.._19fCuQdO.mjs +0 -5
  148. package/packages/storefront/dist/server/chunks/pages/node_OmjWRf8D.mjs +0 -112
  149. package/packages/storefront/dist/server/chunks/~fallback_Wahcp9Wk.mjs +0 -5
  150. package/packages/storefront/dist/server/manifest_9FASPYUE.mjs +0 -202
  151. /package/packages/storefront/dist/client/_astro/{index-bea2a320.eWykogwr.js → index-bea2a320.CHELEM8n.js} +0 -0
  152. /package/packages/storefront/dist/client/_astro/{photoswipe-lightbox.esm.dZBqKD9u.js → photoswipe-lightbox.esm.BbYxSZIB.js} +0 -0
  153. /package/packages/storefront/dist/client/_astro/{photoswipe.0V7m2jWu.js → photoswipe.CNpEZKfy.js} +0 -0
  154. /package/packages/storefront/dist/client/_astro/{server-data.4C60Esyt.js → server-data.CUHTES8a.js} +0 -0
  155. /package/packages/storefront/dist/server/chunks/{photoswipe_IcWDJiwc.mjs → photoswipe_wusPJBJF.mjs} +0 -0
@@ -0,0 +1,852 @@
1
+ import { isRemotePath } from '@astrojs/internal-helpers/path';
2
+ import { readFile } from 'fs/promises';
3
+ import mime from 'mime/lite.js';
4
+ import { A as AstroError, I as InvalidImageService, c as isRemoteAllowed } from '../astro/assets-service_B77Hm2ue.mjs';
5
+ import { f as imageConfig, h as assetsDir } from './__B4CsSrck.mjs';
6
+
7
+ const decoder = new TextDecoder();
8
+ const toUTF8String = (input, start = 0, end = input.length) => decoder.decode(input.slice(start, end));
9
+ const toHexString = (input, start = 0, end = input.length) => input.slice(start, end).reduce((memo, i) => memo + ("0" + i.toString(16)).slice(-2), "");
10
+ const readInt16LE = (input, offset = 0) => {
11
+ const val = input[offset] + input[offset + 1] * 2 ** 8;
12
+ return val | (val & 2 ** 15) * 131070;
13
+ };
14
+ const readUInt16BE = (input, offset = 0) => input[offset] * 2 ** 8 + input[offset + 1];
15
+ const readUInt16LE = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8;
16
+ const readUInt24LE = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8 + input[offset + 2] * 2 ** 16;
17
+ const readInt32LE = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8 + input[offset + 2] * 2 ** 16 + (input[offset + 3] << 24);
18
+ const readUInt32BE = (input, offset = 0) => input[offset] * 2 ** 24 + input[offset + 1] * 2 ** 16 + input[offset + 2] * 2 ** 8 + input[offset + 3];
19
+ const readUInt32LE = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8 + input[offset + 2] * 2 ** 16 + input[offset + 3] * 2 ** 24;
20
+ const methods = {
21
+ readUInt16BE,
22
+ readUInt16LE,
23
+ readUInt32BE,
24
+ readUInt32LE
25
+ };
26
+ function readUInt(input, bits, offset, isBigEndian) {
27
+ offset = offset || 0;
28
+ const endian = isBigEndian ? "BE" : "LE";
29
+ const methodName = "readUInt" + bits + endian;
30
+ return methods[methodName](input, offset);
31
+ }
32
+ function readBox(buffer, offset) {
33
+ if (buffer.length - offset < 4)
34
+ return;
35
+ const boxSize = readUInt32BE(buffer, offset);
36
+ if (buffer.length - offset < boxSize)
37
+ return;
38
+ return {
39
+ name: toUTF8String(buffer, 4 + offset, 8 + offset),
40
+ offset,
41
+ size: boxSize
42
+ };
43
+ }
44
+ function findBox(buffer, boxName, offset) {
45
+ while (offset < buffer.length) {
46
+ const box = readBox(buffer, offset);
47
+ if (!box)
48
+ break;
49
+ if (box.name === boxName)
50
+ return box;
51
+ offset += box.size;
52
+ }
53
+ }
54
+
55
+ const BMP = {
56
+ validate: (input) => toUTF8String(input, 0, 2) === "BM",
57
+ calculate: (input) => ({
58
+ height: Math.abs(readInt32LE(input, 22)),
59
+ width: readUInt32LE(input, 18)
60
+ })
61
+ };
62
+
63
+ const TYPE_ICON = 1;
64
+ const SIZE_HEADER$1 = 2 + 2 + 2;
65
+ const SIZE_IMAGE_ENTRY = 1 + 1 + 1 + 1 + 2 + 2 + 4 + 4;
66
+ function getSizeFromOffset(input, offset) {
67
+ const value = input[offset];
68
+ return value === 0 ? 256 : value;
69
+ }
70
+ function getImageSize$1(input, imageIndex) {
71
+ const offset = SIZE_HEADER$1 + imageIndex * SIZE_IMAGE_ENTRY;
72
+ return {
73
+ height: getSizeFromOffset(input, offset + 1),
74
+ width: getSizeFromOffset(input, offset)
75
+ };
76
+ }
77
+ const ICO = {
78
+ validate(input) {
79
+ const reserved = readUInt16LE(input, 0);
80
+ const imageCount = readUInt16LE(input, 4);
81
+ if (reserved !== 0 || imageCount === 0)
82
+ return false;
83
+ const imageType = readUInt16LE(input, 2);
84
+ return imageType === TYPE_ICON;
85
+ },
86
+ calculate(input) {
87
+ const nbImages = readUInt16LE(input, 4);
88
+ const imageSize = getImageSize$1(input, 0);
89
+ if (nbImages === 1)
90
+ return imageSize;
91
+ const imgs = [imageSize];
92
+ for (let imageIndex = 1; imageIndex < nbImages; imageIndex += 1) {
93
+ imgs.push(getImageSize$1(input, imageIndex));
94
+ }
95
+ return {
96
+ height: imageSize.height,
97
+ images: imgs,
98
+ width: imageSize.width
99
+ };
100
+ }
101
+ };
102
+
103
+ const TYPE_CURSOR = 2;
104
+ const CUR = {
105
+ validate(input) {
106
+ const reserved = readUInt16LE(input, 0);
107
+ const imageCount = readUInt16LE(input, 4);
108
+ if (reserved !== 0 || imageCount === 0)
109
+ return false;
110
+ const imageType = readUInt16LE(input, 2);
111
+ return imageType === TYPE_CURSOR;
112
+ },
113
+ calculate: (input) => ICO.calculate(input)
114
+ };
115
+
116
+ const DDS = {
117
+ validate: (input) => readUInt32LE(input, 0) === 542327876,
118
+ calculate: (input) => ({
119
+ height: readUInt32LE(input, 12),
120
+ width: readUInt32LE(input, 16)
121
+ })
122
+ };
123
+
124
+ const gifRegexp = /^GIF8[79]a/;
125
+ const GIF = {
126
+ validate: (input) => gifRegexp.test(toUTF8String(input, 0, 6)),
127
+ calculate: (input) => ({
128
+ height: readUInt16LE(input, 8),
129
+ width: readUInt16LE(input, 6)
130
+ })
131
+ };
132
+
133
+ const brandMap = {
134
+ avif: "avif",
135
+ mif1: "heif",
136
+ msf1: "heif",
137
+ // hief-sequence
138
+ heic: "heic",
139
+ heix: "heic",
140
+ hevc: "heic",
141
+ // heic-sequence
142
+ hevx: "heic"
143
+ // heic-sequence
144
+ };
145
+ function detectBrands(buffer, start, end) {
146
+ let brandsDetected = {};
147
+ for (let i = start; i <= end; i += 4) {
148
+ const brand = toUTF8String(buffer, i, i + 4);
149
+ if (brand in brandMap) {
150
+ brandsDetected[brand] = 1;
151
+ }
152
+ }
153
+ if ("avif" in brandsDetected) {
154
+ return "avif";
155
+ } else if ("heic" in brandsDetected || "heix" in brandsDetected || "hevc" in brandsDetected || "hevx" in brandsDetected) {
156
+ return "heic";
157
+ } else if ("mif1" in brandsDetected || "msf1" in brandsDetected) {
158
+ return "heif";
159
+ }
160
+ }
161
+ const HEIF = {
162
+ validate(buffer) {
163
+ const ftype = toUTF8String(buffer, 4, 8);
164
+ const brand = toUTF8String(buffer, 8, 12);
165
+ return "ftyp" === ftype && brand in brandMap;
166
+ },
167
+ calculate(buffer) {
168
+ const metaBox = findBox(buffer, "meta", 0);
169
+ const iprpBox = metaBox && findBox(buffer, "iprp", metaBox.offset + 12);
170
+ const ipcoBox = iprpBox && findBox(buffer, "ipco", iprpBox.offset + 8);
171
+ const ispeBox = ipcoBox && findBox(buffer, "ispe", ipcoBox.offset + 8);
172
+ if (ispeBox) {
173
+ return {
174
+ height: readUInt32BE(buffer, ispeBox.offset + 16),
175
+ width: readUInt32BE(buffer, ispeBox.offset + 12),
176
+ type: detectBrands(buffer, 8, metaBox.offset)
177
+ };
178
+ }
179
+ throw new TypeError("Invalid HEIF, no size found");
180
+ }
181
+ };
182
+
183
+ const SIZE_HEADER = 4 + 4;
184
+ const FILE_LENGTH_OFFSET = 4;
185
+ const ENTRY_LENGTH_OFFSET = 4;
186
+ const ICON_TYPE_SIZE = {
187
+ ICON: 32,
188
+ "ICN#": 32,
189
+ // m => 16 x 16
190
+ "icm#": 16,
191
+ icm4: 16,
192
+ icm8: 16,
193
+ // s => 16 x 16
194
+ "ics#": 16,
195
+ ics4: 16,
196
+ ics8: 16,
197
+ is32: 16,
198
+ s8mk: 16,
199
+ icp4: 16,
200
+ // l => 32 x 32
201
+ icl4: 32,
202
+ icl8: 32,
203
+ il32: 32,
204
+ l8mk: 32,
205
+ icp5: 32,
206
+ ic11: 32,
207
+ // h => 48 x 48
208
+ ich4: 48,
209
+ ich8: 48,
210
+ ih32: 48,
211
+ h8mk: 48,
212
+ // . => 64 x 64
213
+ icp6: 64,
214
+ ic12: 32,
215
+ // t => 128 x 128
216
+ it32: 128,
217
+ t8mk: 128,
218
+ ic07: 128,
219
+ // . => 256 x 256
220
+ ic08: 256,
221
+ ic13: 256,
222
+ // . => 512 x 512
223
+ ic09: 512,
224
+ ic14: 512,
225
+ // . => 1024 x 1024
226
+ ic10: 1024
227
+ };
228
+ function readImageHeader(input, imageOffset) {
229
+ const imageLengthOffset = imageOffset + ENTRY_LENGTH_OFFSET;
230
+ return [
231
+ toUTF8String(input, imageOffset, imageLengthOffset),
232
+ readUInt32BE(input, imageLengthOffset)
233
+ ];
234
+ }
235
+ function getImageSize(type) {
236
+ const size = ICON_TYPE_SIZE[type];
237
+ return { width: size, height: size, type };
238
+ }
239
+ const ICNS = {
240
+ validate: (input) => toUTF8String(input, 0, 4) === "icns",
241
+ calculate(input) {
242
+ const inputLength = input.length;
243
+ const fileLength = readUInt32BE(input, FILE_LENGTH_OFFSET);
244
+ let imageOffset = SIZE_HEADER;
245
+ let imageHeader = readImageHeader(input, imageOffset);
246
+ let imageSize = getImageSize(imageHeader[0]);
247
+ imageOffset += imageHeader[1];
248
+ if (imageOffset === fileLength)
249
+ return imageSize;
250
+ const result = {
251
+ height: imageSize.height,
252
+ images: [imageSize],
253
+ width: imageSize.width
254
+ };
255
+ while (imageOffset < fileLength && imageOffset < inputLength) {
256
+ imageHeader = readImageHeader(input, imageOffset);
257
+ imageSize = getImageSize(imageHeader[0]);
258
+ imageOffset += imageHeader[1];
259
+ result.images.push(imageSize);
260
+ }
261
+ return result;
262
+ }
263
+ };
264
+
265
+ const J2C = {
266
+ // TODO: this doesn't seem right. SIZ marker doesn't have to be right after the SOC
267
+ validate: (input) => toHexString(input, 0, 4) === "ff4fff51",
268
+ calculate: (input) => ({
269
+ height: readUInt32BE(input, 12),
270
+ width: readUInt32BE(input, 8)
271
+ })
272
+ };
273
+
274
+ const JP2 = {
275
+ validate(input) {
276
+ if (readUInt32BE(input, 4) !== 1783636e3 || readUInt32BE(input, 0) < 1)
277
+ return false;
278
+ const ftypBox = findBox(input, "ftyp", 0);
279
+ if (!ftypBox)
280
+ return false;
281
+ return readUInt32BE(input, ftypBox.offset + 4) === 1718909296;
282
+ },
283
+ calculate(input) {
284
+ const jp2hBox = findBox(input, "jp2h", 0);
285
+ const ihdrBox = jp2hBox && findBox(input, "ihdr", jp2hBox.offset + 8);
286
+ if (ihdrBox) {
287
+ return {
288
+ height: readUInt32BE(input, ihdrBox.offset + 8),
289
+ width: readUInt32BE(input, ihdrBox.offset + 12)
290
+ };
291
+ }
292
+ throw new TypeError("Unsupported JPEG 2000 format");
293
+ }
294
+ };
295
+
296
+ const EXIF_MARKER = "45786966";
297
+ const APP1_DATA_SIZE_BYTES = 2;
298
+ const EXIF_HEADER_BYTES = 6;
299
+ const TIFF_BYTE_ALIGN_BYTES = 2;
300
+ const BIG_ENDIAN_BYTE_ALIGN = "4d4d";
301
+ const LITTLE_ENDIAN_BYTE_ALIGN = "4949";
302
+ const IDF_ENTRY_BYTES = 12;
303
+ const NUM_DIRECTORY_ENTRIES_BYTES = 2;
304
+ function isEXIF(input) {
305
+ return toHexString(input, 2, 6) === EXIF_MARKER;
306
+ }
307
+ function extractSize(input, index) {
308
+ return {
309
+ height: readUInt16BE(input, index),
310
+ width: readUInt16BE(input, index + 2)
311
+ };
312
+ }
313
+ function extractOrientation(exifBlock, isBigEndian) {
314
+ const idfOffset = 8;
315
+ const offset = EXIF_HEADER_BYTES + idfOffset;
316
+ const idfDirectoryEntries = readUInt(exifBlock, 16, offset, isBigEndian);
317
+ for (let directoryEntryNumber = 0; directoryEntryNumber < idfDirectoryEntries; directoryEntryNumber++) {
318
+ const start = offset + NUM_DIRECTORY_ENTRIES_BYTES + directoryEntryNumber * IDF_ENTRY_BYTES;
319
+ const end = start + IDF_ENTRY_BYTES;
320
+ if (start > exifBlock.length) {
321
+ return;
322
+ }
323
+ const block = exifBlock.slice(start, end);
324
+ const tagNumber = readUInt(block, 16, 0, isBigEndian);
325
+ if (tagNumber === 274) {
326
+ const dataFormat = readUInt(block, 16, 2, isBigEndian);
327
+ if (dataFormat !== 3) {
328
+ return;
329
+ }
330
+ const numberOfComponents = readUInt(block, 32, 4, isBigEndian);
331
+ if (numberOfComponents !== 1) {
332
+ return;
333
+ }
334
+ return readUInt(block, 16, 8, isBigEndian);
335
+ }
336
+ }
337
+ }
338
+ function validateExifBlock(input, index) {
339
+ const exifBlock = input.slice(APP1_DATA_SIZE_BYTES, index);
340
+ const byteAlign = toHexString(
341
+ exifBlock,
342
+ EXIF_HEADER_BYTES,
343
+ EXIF_HEADER_BYTES + TIFF_BYTE_ALIGN_BYTES
344
+ );
345
+ const isBigEndian = byteAlign === BIG_ENDIAN_BYTE_ALIGN;
346
+ const isLittleEndian = byteAlign === LITTLE_ENDIAN_BYTE_ALIGN;
347
+ if (isBigEndian || isLittleEndian) {
348
+ return extractOrientation(exifBlock, isBigEndian);
349
+ }
350
+ }
351
+ function validateInput(input, index) {
352
+ if (index > input.length) {
353
+ throw new TypeError("Corrupt JPG, exceeded buffer limits");
354
+ }
355
+ }
356
+ const JPG = {
357
+ validate: (input) => toHexString(input, 0, 2) === "ffd8",
358
+ calculate(input) {
359
+ input = input.slice(4);
360
+ let orientation;
361
+ let next;
362
+ while (input.length) {
363
+ const i = readUInt16BE(input, 0);
364
+ if (input[i] !== 255) {
365
+ input = input.slice(1);
366
+ continue;
367
+ }
368
+ if (isEXIF(input)) {
369
+ orientation = validateExifBlock(input, i);
370
+ }
371
+ validateInput(input, i);
372
+ next = input[i + 1];
373
+ if (next === 192 || next === 193 || next === 194) {
374
+ const size = extractSize(input, i + 5);
375
+ if (!orientation) {
376
+ return size;
377
+ }
378
+ return {
379
+ height: size.height,
380
+ orientation,
381
+ width: size.width
382
+ };
383
+ }
384
+ input = input.slice(i + 2);
385
+ }
386
+ throw new TypeError("Invalid JPG, no size found");
387
+ }
388
+ };
389
+
390
+ const KTX = {
391
+ validate: (input) => {
392
+ const signature = toUTF8String(input, 1, 7);
393
+ return ["KTX 11", "KTX 20"].includes(signature);
394
+ },
395
+ calculate: (input) => {
396
+ const type = input[5] === 49 ? "ktx" : "ktx2";
397
+ const offset = type === "ktx" ? 36 : 20;
398
+ return {
399
+ height: readUInt32LE(input, offset + 4),
400
+ width: readUInt32LE(input, offset),
401
+ type
402
+ };
403
+ }
404
+ };
405
+
406
+ const pngSignature = "PNG\r\n\n";
407
+ const pngImageHeaderChunkName = "IHDR";
408
+ const pngFriedChunkName = "CgBI";
409
+ const PNG = {
410
+ validate(input) {
411
+ if (pngSignature === toUTF8String(input, 1, 8)) {
412
+ let chunkName = toUTF8String(input, 12, 16);
413
+ if (chunkName === pngFriedChunkName) {
414
+ chunkName = toUTF8String(input, 28, 32);
415
+ }
416
+ if (chunkName !== pngImageHeaderChunkName) {
417
+ throw new TypeError("Invalid PNG");
418
+ }
419
+ return true;
420
+ }
421
+ return false;
422
+ },
423
+ calculate(input) {
424
+ if (toUTF8String(input, 12, 16) === pngFriedChunkName) {
425
+ return {
426
+ height: readUInt32BE(input, 36),
427
+ width: readUInt32BE(input, 32)
428
+ };
429
+ }
430
+ return {
431
+ height: readUInt32BE(input, 20),
432
+ width: readUInt32BE(input, 16)
433
+ };
434
+ }
435
+ };
436
+
437
+ const PNMTypes = {
438
+ P1: "pbm/ascii",
439
+ P2: "pgm/ascii",
440
+ P3: "ppm/ascii",
441
+ P4: "pbm",
442
+ P5: "pgm",
443
+ P6: "ppm",
444
+ P7: "pam",
445
+ PF: "pfm"
446
+ };
447
+ const handlers = {
448
+ default: (lines) => {
449
+ let dimensions = [];
450
+ while (lines.length > 0) {
451
+ const line = lines.shift();
452
+ if (line[0] === "#") {
453
+ continue;
454
+ }
455
+ dimensions = line.split(" ");
456
+ break;
457
+ }
458
+ if (dimensions.length === 2) {
459
+ return {
460
+ height: parseInt(dimensions[1], 10),
461
+ width: parseInt(dimensions[0], 10)
462
+ };
463
+ } else {
464
+ throw new TypeError("Invalid PNM");
465
+ }
466
+ },
467
+ pam: (lines) => {
468
+ const size = {};
469
+ while (lines.length > 0) {
470
+ const line = lines.shift();
471
+ if (line.length > 16 || line.charCodeAt(0) > 128) {
472
+ continue;
473
+ }
474
+ const [key, value] = line.split(" ");
475
+ if (key && value) {
476
+ size[key.toLowerCase()] = parseInt(value, 10);
477
+ }
478
+ if (size.height && size.width) {
479
+ break;
480
+ }
481
+ }
482
+ if (size.height && size.width) {
483
+ return {
484
+ height: size.height,
485
+ width: size.width
486
+ };
487
+ } else {
488
+ throw new TypeError("Invalid PAM");
489
+ }
490
+ }
491
+ };
492
+ const PNM = {
493
+ validate: (input) => toUTF8String(input, 0, 2) in PNMTypes,
494
+ calculate(input) {
495
+ const signature = toUTF8String(input, 0, 2);
496
+ const type = PNMTypes[signature];
497
+ const lines = toUTF8String(input, 3).split(/[\r\n]+/);
498
+ const handler = handlers[type] || handlers.default;
499
+ return handler(lines);
500
+ }
501
+ };
502
+
503
+ const PSD = {
504
+ validate: (input) => toUTF8String(input, 0, 4) === "8BPS",
505
+ calculate: (input) => ({
506
+ height: readUInt32BE(input, 14),
507
+ width: readUInt32BE(input, 18)
508
+ })
509
+ };
510
+
511
+ const svgReg = /<svg\s([^>"']|"[^"]*"|'[^']*')*>/;
512
+ const extractorRegExps = {
513
+ height: /\sheight=(['"])([^%]+?)\1/,
514
+ root: svgReg,
515
+ viewbox: /\sviewBox=(['"])(.+?)\1/i,
516
+ width: /\swidth=(['"])([^%]+?)\1/
517
+ };
518
+ const INCH_CM = 2.54;
519
+ const units = {
520
+ in: 96,
521
+ cm: 96 / INCH_CM,
522
+ em: 16,
523
+ ex: 8,
524
+ m: 96 / INCH_CM * 100,
525
+ mm: 96 / INCH_CM / 10,
526
+ pc: 96 / 72 / 12,
527
+ pt: 96 / 72,
528
+ px: 1
529
+ };
530
+ const unitsReg = new RegExp(
531
+ // eslint-disable-next-line regexp/prefer-d
532
+ `^([0-9.]+(?:e\\d+)?)(${Object.keys(units).join("|")})?$`
533
+ );
534
+ function parseLength(len) {
535
+ const m = unitsReg.exec(len);
536
+ if (!m) {
537
+ return void 0;
538
+ }
539
+ return Math.round(Number(m[1]) * (units[m[2]] || 1));
540
+ }
541
+ function parseViewbox(viewbox) {
542
+ const bounds = viewbox.split(" ");
543
+ return {
544
+ height: parseLength(bounds[3]),
545
+ width: parseLength(bounds[2])
546
+ };
547
+ }
548
+ function parseAttributes(root) {
549
+ const width = root.match(extractorRegExps.width);
550
+ const height = root.match(extractorRegExps.height);
551
+ const viewbox = root.match(extractorRegExps.viewbox);
552
+ return {
553
+ height: height && parseLength(height[2]),
554
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
555
+ viewbox: viewbox && parseViewbox(viewbox[2]),
556
+ width: width && parseLength(width[2])
557
+ };
558
+ }
559
+ function calculateByDimensions(attrs) {
560
+ return {
561
+ height: attrs.height,
562
+ width: attrs.width
563
+ };
564
+ }
565
+ function calculateByViewbox(attrs, viewbox) {
566
+ const ratio = viewbox.width / viewbox.height;
567
+ if (attrs.width) {
568
+ return {
569
+ height: Math.floor(attrs.width / ratio),
570
+ width: attrs.width
571
+ };
572
+ }
573
+ if (attrs.height) {
574
+ return {
575
+ height: attrs.height,
576
+ width: Math.floor(attrs.height * ratio)
577
+ };
578
+ }
579
+ return {
580
+ height: viewbox.height,
581
+ width: viewbox.width
582
+ };
583
+ }
584
+ const SVG = {
585
+ // Scan only the first kilo-byte to speed up the check on larger files
586
+ validate: (input) => svgReg.test(toUTF8String(input, 0, 1e3)),
587
+ calculate(input) {
588
+ const root = toUTF8String(input).match(extractorRegExps.root);
589
+ if (root) {
590
+ const attrs = parseAttributes(root[0]);
591
+ if (attrs.width && attrs.height) {
592
+ return calculateByDimensions(attrs);
593
+ }
594
+ if (attrs.viewbox) {
595
+ return calculateByViewbox(attrs, attrs.viewbox);
596
+ }
597
+ }
598
+ throw new TypeError("Invalid SVG");
599
+ }
600
+ };
601
+
602
+ const TGA = {
603
+ validate(input) {
604
+ return readUInt16LE(input, 0) === 0 && readUInt16LE(input, 4) === 0;
605
+ },
606
+ calculate(input) {
607
+ return {
608
+ height: readUInt16LE(input, 14),
609
+ width: readUInt16LE(input, 12)
610
+ };
611
+ }
612
+ };
613
+
614
+ function readIFD(input, isBigEndian) {
615
+ const ifdOffset = readUInt(input, 32, 4, isBigEndian);
616
+ return input.slice(ifdOffset + 2);
617
+ }
618
+ function readValue(input, isBigEndian) {
619
+ const low = readUInt(input, 16, 8, isBigEndian);
620
+ const high = readUInt(input, 16, 10, isBigEndian);
621
+ return (high << 16) + low;
622
+ }
623
+ function nextTag(input) {
624
+ if (input.length > 24) {
625
+ return input.slice(12);
626
+ }
627
+ }
628
+ function extractTags(input, isBigEndian) {
629
+ const tags = {};
630
+ let temp = input;
631
+ while (temp && temp.length) {
632
+ const code = readUInt(temp, 16, 0, isBigEndian);
633
+ const type = readUInt(temp, 16, 2, isBigEndian);
634
+ const length = readUInt(temp, 32, 4, isBigEndian);
635
+ if (code === 0) {
636
+ break;
637
+ } else {
638
+ if (length === 1 && (type === 3 || type === 4)) {
639
+ tags[code] = readValue(temp, isBigEndian);
640
+ }
641
+ temp = nextTag(temp);
642
+ }
643
+ }
644
+ return tags;
645
+ }
646
+ function determineEndianness(input) {
647
+ const signature = toUTF8String(input, 0, 2);
648
+ if ("II" === signature) {
649
+ return "LE";
650
+ } else if ("MM" === signature) {
651
+ return "BE";
652
+ }
653
+ }
654
+ const signatures = [
655
+ // '492049', // currently not supported
656
+ "49492a00",
657
+ // Little endian
658
+ "4d4d002a"
659
+ // Big Endian
660
+ // '4d4d002a', // BigTIFF > 4GB. currently not supported
661
+ ];
662
+ const TIFF = {
663
+ validate: (input) => signatures.includes(toHexString(input, 0, 4)),
664
+ calculate(input) {
665
+ const isBigEndian = determineEndianness(input) === "BE";
666
+ const ifdBuffer = readIFD(input, isBigEndian);
667
+ const tags = extractTags(ifdBuffer, isBigEndian);
668
+ const width = tags[256];
669
+ const height = tags[257];
670
+ if (!width || !height) {
671
+ throw new TypeError("Invalid Tiff. Missing tags");
672
+ }
673
+ return { height, width };
674
+ }
675
+ };
676
+
677
+ function calculateExtended(input) {
678
+ return {
679
+ height: 1 + readUInt24LE(input, 7),
680
+ width: 1 + readUInt24LE(input, 4)
681
+ };
682
+ }
683
+ function calculateLossless(input) {
684
+ return {
685
+ height: 1 + ((input[4] & 15) << 10 | input[3] << 2 | (input[2] & 192) >> 6),
686
+ width: 1 + ((input[2] & 63) << 8 | input[1])
687
+ };
688
+ }
689
+ function calculateLossy(input) {
690
+ return {
691
+ height: readInt16LE(input, 8) & 16383,
692
+ width: readInt16LE(input, 6) & 16383
693
+ };
694
+ }
695
+ const WEBP = {
696
+ validate(input) {
697
+ const riffHeader = "RIFF" === toUTF8String(input, 0, 4);
698
+ const webpHeader = "WEBP" === toUTF8String(input, 8, 12);
699
+ const vp8Header = "VP8" === toUTF8String(input, 12, 15);
700
+ return riffHeader && webpHeader && vp8Header;
701
+ },
702
+ calculate(input) {
703
+ const chunkHeader = toUTF8String(input, 12, 16);
704
+ input = input.slice(20, 30);
705
+ if (chunkHeader === "VP8X") {
706
+ const extendedHeader = input[0];
707
+ const validStart = (extendedHeader & 192) === 0;
708
+ const validEnd = (extendedHeader & 1) === 0;
709
+ if (validStart && validEnd) {
710
+ return calculateExtended(input);
711
+ } else {
712
+ throw new TypeError("Invalid WebP");
713
+ }
714
+ }
715
+ if (chunkHeader === "VP8 " && input[0] !== 47) {
716
+ return calculateLossy(input);
717
+ }
718
+ const signature = toHexString(input, 3, 6);
719
+ if (chunkHeader === "VP8L" && signature !== "9d012a") {
720
+ return calculateLossless(input);
721
+ }
722
+ throw new TypeError("Invalid WebP");
723
+ }
724
+ };
725
+
726
+ const typeHandlers = /* @__PURE__ */ new Map([
727
+ ["bmp", BMP],
728
+ ["cur", CUR],
729
+ ["dds", DDS],
730
+ ["gif", GIF],
731
+ ["heif", HEIF],
732
+ ["icns", ICNS],
733
+ ["ico", ICO],
734
+ ["j2c", J2C],
735
+ ["jp2", JP2],
736
+ ["jpg", JPG],
737
+ ["ktx", KTX],
738
+ ["png", PNG],
739
+ ["pnm", PNM],
740
+ ["psd", PSD],
741
+ ["svg", SVG],
742
+ ["tga", TGA],
743
+ ["tiff", TIFF],
744
+ ["webp", WEBP]
745
+ ]);
746
+ Array.from(typeHandlers.keys());
747
+
748
+ async function getConfiguredImageService() {
749
+ if (!globalThis?.astroAsset?.imageService) {
750
+ const { default: service } = await import(
751
+ // @ts-expect-error
752
+ '../astro/assets-service_B77Hm2ue.mjs'
753
+ ).then(n => n.s).catch((e) => {
754
+ const error = new AstroError(InvalidImageService);
755
+ error.cause = e;
756
+ throw error;
757
+ });
758
+ if (!globalThis.astroAsset)
759
+ globalThis.astroAsset = {};
760
+ globalThis.astroAsset.imageService = service;
761
+ return service;
762
+ }
763
+ return globalThis.astroAsset.imageService;
764
+ }
765
+
766
+ const fnv1a52 = (str) => {
767
+ const len = str.length;
768
+ let i = 0, t0 = 0, v0 = 8997, t1 = 0, v1 = 33826, t2 = 0, v2 = 40164, t3 = 0, v3 = 52210;
769
+ while (i < len) {
770
+ v0 ^= str.charCodeAt(i++);
771
+ t0 = v0 * 435;
772
+ t1 = v1 * 435;
773
+ t2 = v2 * 435;
774
+ t3 = v3 * 435;
775
+ t2 += v0 << 8;
776
+ t3 += v1 << 8;
777
+ t1 += t0 >>> 16;
778
+ v0 = t0 & 65535;
779
+ t2 += t1 >>> 16;
780
+ v1 = t1 & 65535;
781
+ v3 = t3 + (t2 >>> 16) & 65535;
782
+ v2 = t2 & 65535;
783
+ }
784
+ return (v3 & 15) * 281474976710656 + v2 * 4294967296 + v1 * 65536 + (v0 ^ v3 >> 4);
785
+ };
786
+ const etag = (payload, weak = false) => {
787
+ const prefix = weak ? 'W/"' : '"';
788
+ return prefix + fnv1a52(payload).toString(36) + payload.length.toString(36) + '"';
789
+ };
790
+
791
+ async function loadLocalImage(src, url) {
792
+ const filePath = new URL("." + src, assetsDir);
793
+ let buffer = void 0;
794
+ try {
795
+ buffer = await readFile(filePath);
796
+ } catch (e) {
797
+ const sourceUrl = new URL(src, url.origin);
798
+ buffer = await loadRemoteImage(sourceUrl);
799
+ }
800
+ return buffer;
801
+ }
802
+ async function loadRemoteImage(src) {
803
+ try {
804
+ const res = await fetch(src);
805
+ if (!res.ok) {
806
+ return void 0;
807
+ }
808
+ return Buffer.from(await res.arrayBuffer());
809
+ } catch (err) {
810
+ return void 0;
811
+ }
812
+ }
813
+ const GET = async ({ request }) => {
814
+ try {
815
+ const imageService = await getConfiguredImageService();
816
+ if (!("transform" in imageService)) {
817
+ throw new Error("Configured image service is not a local service");
818
+ }
819
+ const url = new URL(request.url);
820
+ const transform = await imageService.parseURL(url, imageConfig);
821
+ if (!transform?.src) {
822
+ throw new Error("Incorrect transform returned by `parseURL`");
823
+ }
824
+ let inputBuffer = void 0;
825
+ if (isRemotePath(transform.src)) {
826
+ if (isRemoteAllowed(transform.src, imageConfig) === false) {
827
+ return new Response("Forbidden", { status: 403 });
828
+ }
829
+ inputBuffer = await loadRemoteImage(new URL(transform.src));
830
+ } else {
831
+ inputBuffer = await loadLocalImage(transform.src, url);
832
+ }
833
+ if (!inputBuffer) {
834
+ return new Response("Not Found", { status: 404 });
835
+ }
836
+ const { data, format } = await imageService.transform(inputBuffer, transform, imageConfig);
837
+ return new Response(data, {
838
+ status: 200,
839
+ headers: {
840
+ "Content-Type": mime.getType(format) ?? `image/${format}`,
841
+ "Cache-Control": "public, max-age=31536000",
842
+ ETag: etag(data.toString()),
843
+ Date: (/* @__PURE__ */ new Date()).toUTCString()
844
+ }
845
+ });
846
+ } catch (err) {
847
+ console.error("Could not process image request:", err);
848
+ return new Response(`Server Error: ${err}`, { status: 500 });
849
+ }
850
+ };
851
+
852
+ export { GET };