fangguo-component 1.2.2 → 1.2.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 (51) hide show
  1. package/dist/{ErrorImage-CFVt1ht_.js → ErrorImage-Ao9kEEUg.js} +2 -2
  2. package/dist/FgCascader.css +3 -11
  3. package/dist/{FgCascader.vue_vue_type_style_index_0_lang-CstlYwHs.js → FgCascader.vue_vue_type_style_index_0_lang-DzvTfHp4.js} +4 -13
  4. package/dist/{HSelect-DgFjd08Y.js → HSelect-0w2mSrtm.js} +1 -1
  5. package/dist/{HSelectAll.vue_vue_type_script_setup_true_lang-C6qzdQT-.js → HSelectAll.vue_vue_type_script_setup_true_lang-xHFbYs59.js} +1 -1
  6. package/dist/{HSelectSJ-DOFUzTZV.js → HSelectSJ-Cm573j6B.js} +1 -1
  7. package/dist/{ImgViewerHost.vue_vue_type_script_setup_true_lang-DBs42WOq.js → ImgViewerHost.vue_vue_type_script_setup_true_lang-DO9s-b9s.js} +42 -3
  8. package/dist/{LazyPopover-7ebuh-QG.js → LazyPopover-CcvilJ6U.js} +25 -3
  9. package/dist/LazyPopover.css +1 -1
  10. package/dist/{SelectTree-DUH92Iwr.js → SelectTree-BHvvkiQi.js} +1 -1
  11. package/dist/{ViewImg-DXhF20SL.js → ViewImg-CD4QJK4R.js} +137 -34
  12. package/dist/ViewImg.css +31 -35
  13. package/dist/ViewImgPopover-D-1b2nEa.js +497 -0
  14. package/dist/ViewImgPopover.css +35 -12
  15. package/dist/components/cascader/index.js +1 -1
  16. package/dist/components/errorImage/index.js +2 -2
  17. package/dist/components/hSelect/index.js +1 -1
  18. package/dist/components/hSelectAll/index.js +1 -1
  19. package/dist/components/hSelectSJ/index.js +1 -1
  20. package/dist/components/imgViewerHost/ImgViewerHost.vue.d.ts +7 -1
  21. package/dist/components/imgViewerHost/imgViewerAutoHost.d.ts +2 -0
  22. package/dist/components/imgViewerHost/imgViewerHostRegistry.d.ts +5 -0
  23. package/dist/components/imgViewerHost/index.js +2 -2
  24. package/dist/components/index.js +22 -18
  25. package/dist/components/lazyPopover/LazyPopover.vue.d.ts +2 -0
  26. package/dist/components/lazyPopover/index.js +1 -1
  27. package/dist/components/selectTree/index.js +1 -1
  28. package/dist/components/viewImg/ViewImg.vue.d.ts +32 -14
  29. package/dist/components/viewImg/ViewImgErrorFallback.vue.d.ts +14 -0
  30. package/dist/components/viewImg/defaults.d.ts +28 -0
  31. package/dist/components/viewImg/index.d.ts +3 -0
  32. package/dist/components/viewImg/index.js +6 -2
  33. package/dist/components/viewImgPopover/ViewImgPopover.vue.d.ts +158 -66
  34. package/dist/components/viewImgPopover/index.js +1 -1
  35. package/dist/components/viewImgPreview/ViewImgPreview.vue.d.ts +6 -6
  36. package/dist/imgViewerAutoHost-BQVVGop1.js +32 -0
  37. package/dist/{imgViewerStore-DK3zvGf4.js → imgViewerStore-Ajm-L7R5.js} +7 -0
  38. package/dist/{index-Ce_edAQB.js → index-CALlgLrT.js} +17 -13
  39. package/dist/{index-Qkq7I01c.js → index-rEz2pixF.js} +5 -1
  40. package/dist/index.d.ts +7 -3
  41. package/dist/index.js +56 -48
  42. package/dist/montageImgUrl-DP5jMHCX.js +445 -0
  43. package/dist/tools/ImageParserUtils/index.d.ts +1 -1
  44. package/dist/tools/imgUrl/imageUrl.d.ts +209 -0
  45. package/dist/tools/imgUrl/index.d.ts +2 -0
  46. package/dist/tools/imgUrl/index.js +12 -8
  47. package/dist/tools/imgUrl/montageImgUrl.d.ts +11 -5
  48. package/dist/tools/index.js +17 -13
  49. package/package.json +1 -1
  50. package/dist/ViewImgPopover-QblZG0z5.js +0 -343
  51. package/dist/montageImgUrl-CwgYnB2h.js +0 -204
@@ -0,0 +1,445 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ import { ref } from "vue";
18
+ const DEFAULT_IMG_FASTEN = {
19
+ notSupported: "//static.fangguo.com/assets/img/pic-fasten/not-supported.png",
20
+ error: "//static.fangguo.com/assets/img/pic-fasten/error.png",
21
+ empty: "//static.fangguo.com/assets/img/pic-fasten/empty.png"
22
+ };
23
+ let ossLinks = [];
24
+ let imgFasten = __spreadValues({}, DEFAULT_IMG_FASTEN);
25
+ const imgUrlConfigKey = ref(0);
26
+ function getOssLinks() {
27
+ return ossLinks;
28
+ }
29
+ function getImgFasten() {
30
+ return imgFasten;
31
+ }
32
+ function configureImgUrl(config = {}) {
33
+ let changed = false;
34
+ if (config.ossLinks) {
35
+ ossLinks = [...config.ossLinks];
36
+ changed = true;
37
+ }
38
+ if (config.imgFasten) {
39
+ imgFasten = __spreadValues(__spreadValues({}, imgFasten), config.imgFasten);
40
+ changed = true;
41
+ }
42
+ if (changed) {
43
+ imgUrlConfigKey.value++;
44
+ }
45
+ }
46
+ let lastEffectiveType = null;
47
+ let lastSaveData = null;
48
+ let networkListenerInitialized = false;
49
+ const cachedResults = /* @__PURE__ */ new Map();
50
+ const MAX_CACHE_ENTRIES = 500;
51
+ const networkKey = ref(0);
52
+ function normalizeCacheKeyOptions(baseOptions) {
53
+ const o = baseOptions != null ? baseOptions : {};
54
+ const w = typeof o.w === "number" ? o.w : "";
55
+ const h = typeof o.h === "number" ? o.h : "";
56
+ const Q = typeof o.Q === "number" ? o.Q : "";
57
+ const q = typeof o.q === "number" ? o.q : "";
58
+ const format = typeof o.format === "string" ? o.format : "";
59
+ return `w=${w}&h=${h}&Q=${Q}&q=${q}&format=${format}`;
60
+ }
61
+ function lruGet(key) {
62
+ const hit = cachedResults.get(key);
63
+ if (!hit) return null;
64
+ cachedResults.delete(key);
65
+ cachedResults.set(key, hit);
66
+ return hit;
67
+ }
68
+ function lruSet(key, value) {
69
+ if (cachedResults.has(key)) cachedResults.delete(key);
70
+ cachedResults.set(key, value);
71
+ if (cachedResults.size > MAX_CACHE_ENTRIES) {
72
+ const oldestKey = cachedResults.keys().next().value;
73
+ if (oldestKey) cachedResults.delete(oldestKey);
74
+ }
75
+ }
76
+ function getNetworkAdaptiveOptions(baseOptions = { h: 260, Q: 92 }) {
77
+ var _a;
78
+ const conn = navigator.connection;
79
+ const effectiveType = (conn == null ? void 0 : conn.effectiveType) || "4g";
80
+ const saveData = (_a = conn == null ? void 0 : conn.saveData) != null ? _a : false;
81
+ const key = `${effectiveType}|${String(saveData)}|${normalizeCacheKeyOptions(baseOptions)}`;
82
+ if (effectiveType === lastEffectiveType && saveData === lastSaveData) {
83
+ const hit = lruGet(key);
84
+ if (hit) return hit;
85
+ }
86
+ let scale = 1;
87
+ let quality = baseOptions.Q || 92;
88
+ switch (effectiveType) {
89
+ case "slow-2g":
90
+ case "2g":
91
+ scale = saveData ? 0.3 : 0.4;
92
+ quality = saveData ? 40 : 50;
93
+ break;
94
+ case "3g":
95
+ scale = saveData ? 0.5 : 0.7;
96
+ quality = saveData ? 60 : 82;
97
+ break;
98
+ case "4g":
99
+ default:
100
+ scale = saveData ? 0.7 : 1;
101
+ quality = saveData ? 85 : baseOptions.Q || 92;
102
+ break;
103
+ }
104
+ const options = __spreadValues({}, baseOptions);
105
+ if (options.w) options.w = Math.round(options.w * scale);
106
+ if (options.h) options.h = Math.round(options.h * scale);
107
+ options.Q = quality;
108
+ lastEffectiveType = effectiveType;
109
+ lastSaveData = saveData;
110
+ lruSet(key, options);
111
+ return options;
112
+ }
113
+ function initNetworkListener() {
114
+ if (networkListenerInitialized) return;
115
+ networkListenerInitialized = true;
116
+ const conn = navigator.connection;
117
+ if (conn == null ? void 0 : conn.addEventListener) {
118
+ conn.addEventListener("change", () => {
119
+ cachedResults.clear();
120
+ lastEffectiveType = null;
121
+ lastSaveData = null;
122
+ networkKey.value++;
123
+ });
124
+ }
125
+ getNetworkAdaptiveOptions();
126
+ }
127
+ const AMAZON_DIM_TOKEN = "UL|SR|SL|SX|SY|SF|SC";
128
+ function toPositiveInteger(value) {
129
+ if (value === void 0 || value === null || value === "") return 0;
130
+ const n = Number(value);
131
+ if (!Number.isFinite(n) || n <= 0) return 0;
132
+ return Math.round(n);
133
+ }
134
+ function parseHttpUrl(url) {
135
+ const raw = (url || "").trim();
136
+ if (!raw) return null;
137
+ try {
138
+ if (raw.startsWith("//")) return new URL(`https:${raw}`);
139
+ if (/^https?:\/\//i.test(raw)) return new URL(raw);
140
+ } catch (e) {
141
+ return null;
142
+ }
143
+ return null;
144
+ }
145
+ function removeImageUrlQuery(url) {
146
+ const raw = (url || "").trim();
147
+ if (!raw) return "";
148
+ const hashIndex = raw.indexOf("#");
149
+ const beforeHash = hashIndex === -1 ? raw : raw.slice(0, hashIndex);
150
+ const hash = hashIndex === -1 ? "" : raw.slice(hashIndex);
151
+ return beforeHash.split("?")[0] + hash;
152
+ }
153
+ function getTemuOriginalImageUrl(url) {
154
+ const parsed = parseHttpUrl(url);
155
+ if (!parsed || !/(^|\.)kwcdn\.com$/i.test(parsed.hostname)) return url;
156
+ return removeImageUrlQuery(url);
157
+ }
158
+ function getSheinOriginalImageUrl(url) {
159
+ const parsed = parseHttpUrl(url);
160
+ if (!parsed || !/(^|\.)ltwebstatic\.com$/i.test(parsed.hostname)) return url;
161
+ let base = removeImageUrlQuery(url);
162
+ base = base.replace(/_thumbnail_\d+x\d*\.(webp|png|jpg|jpeg)/gi, "_thumbnail_fullx.$1");
163
+ base = base.replace(/_square_thumbnail_\d+x\d*\.(webp|png|jpg|jpeg)/gi, "_square_thumbnail_fullx.$1");
164
+ return base;
165
+ }
166
+ function getAmazonOriginalImageUrl(url) {
167
+ const parsed = parseHttpUrl(url);
168
+ const isAmazonImageHost = parsed && (/(^|\.)media-amazon\.com$/i.test(parsed.hostname) || /(^|\.)ssl-images-amazon\.com$/i.test(parsed.hostname) || /(^|\.)amazon\./i.test(parsed.hostname));
169
+ if (!isAmazonImageHost) return url;
170
+ const base = removeImageUrlQuery(url);
171
+ const marker = "._AC_";
172
+ const i = base.indexOf(marker);
173
+ if (i === -1) return base;
174
+ const prefix = base.slice(0, i + marker.length);
175
+ let rest = base.slice(i + marker.length);
176
+ const reLead = new RegExp(`^(${AMAZON_DIM_TOKEN})(\\d+)(?:,(\\d+))?`);
177
+ rest = rest.replace(
178
+ reLead,
179
+ (_m, tag, _n1, n2) => n2 != null && n2 !== "" ? `${tag}full,full` : `${tag}full`
180
+ );
181
+ const reChain = new RegExp(`_(${AMAZON_DIM_TOKEN})(\\d+)(?:,(\\d+))?`, "g");
182
+ rest = rest.replace(
183
+ reChain,
184
+ (_m, tag, _n1, n2) => n2 != null && n2 !== "" ? `_${tag}full,full` : `_${tag}full`
185
+ );
186
+ return prefix + rest;
187
+ }
188
+ function getEtsyOriginalImageUrl(url) {
189
+ const parsed = parseHttpUrl(url);
190
+ const isEtsyImageHost = parsed && (/(^|\.)etsystatic\.com$/i.test(parsed.hostname) || /(^|\.)etsy\./i.test(parsed.hostname));
191
+ if (!isEtsyImageHost) return url;
192
+ return removeImageUrlQuery(url).replace(/il_\d+x\d+\./i, "il_fullxfull.");
193
+ }
194
+ function buildTemuImageResizeUrl(url, options = {}) {
195
+ const parsed = parseHttpUrl(url);
196
+ if (!parsed || !/(^|\.)kwcdn\.com$/i.test(parsed.hostname)) return url;
197
+ const width = toPositiveInteger(options.width);
198
+ if (!width) return url;
199
+ const base = removeImageUrlQuery(url);
200
+ return `${base}?imageView2/2/w/${width}/q/50/format/avif%7CimageVqr/2`;
201
+ }
202
+ function buildSheinImageResizeUrl(url, options = {}) {
203
+ const parsed = parseHttpUrl(url);
204
+ if (!parsed || !/(^|\.)ltwebstatic\.com$/i.test(parsed.hostname)) return url;
205
+ const width = toPositiveInteger(options.width) || toPositiveInteger(options.height);
206
+ const height = toPositiveInteger(options.height) || toPositiveInteger(options.width);
207
+ if (!width || !height) return url;
208
+ const base = removeImageUrlQuery(url);
209
+ const thumbnailUrl = base.replace(
210
+ /_thumbnail_\d+x\d*\.(webp|png|jpg|jpeg)/gi,
211
+ `_thumbnail_${width}x${height}.$1`
212
+ );
213
+ const next = thumbnailUrl.replace(
214
+ /_square_thumbnail_\d+x\d*\.(webp|png|jpg|jpeg)/gi,
215
+ `_square_thumbnail_${width}x${height}.$1`
216
+ );
217
+ return next === base ? url : next;
218
+ }
219
+ function buildAmazonImageResizeUrl(url, options = {}) {
220
+ const parsed = parseHttpUrl(url);
221
+ const isAmazonImageHost = parsed && (/(^|\.)media-amazon\.com$/i.test(parsed.hostname) || /(^|\.)ssl-images-amazon\.com$/i.test(parsed.hostname) || /(^|\.)amazon\./i.test(parsed.hostname));
222
+ if (!isAmazonImageHost) return url;
223
+ const width = toPositiveInteger(options.width);
224
+ const height = toPositiveInteger(options.height);
225
+ if (!width && !height) return url;
226
+ const single = String(width || height);
227
+ const pairW = String(width || height);
228
+ const pairH = String(height || width);
229
+ const base = removeImageUrlQuery(url);
230
+ const marker = "._AC_";
231
+ const i = base.indexOf(marker);
232
+ if (i === -1) return url;
233
+ const prefix = base.slice(0, i + marker.length);
234
+ let rest = base.slice(i + marker.length);
235
+ const reLead = new RegExp(`^(${AMAZON_DIM_TOKEN})(\\d+|full)(?:,(\\d+|full))?`, "i");
236
+ rest = rest.replace(
237
+ reLead,
238
+ (_m, tag, _n1, n2) => n2 != null && n2 !== "" ? `${tag}${pairW},${pairH}` : `${tag}${single}`
239
+ );
240
+ const reChain = new RegExp(`_(${AMAZON_DIM_TOKEN})(\\d+|full)(?:,(\\d+|full))?`, "gi");
241
+ rest = rest.replace(
242
+ reChain,
243
+ (_m, tag, _n1, n2) => n2 != null && n2 !== "" ? `_${tag}${pairW},${pairH}` : `_${tag}${single}`
244
+ );
245
+ return prefix + rest;
246
+ }
247
+ function buildEtsyImageResizeUrl(url, options = {}) {
248
+ const parsed = parseHttpUrl(url);
249
+ const isEtsyImageHost = parsed && (/(^|\.)etsystatic\.com$/i.test(parsed.hostname) || /(^|\.)etsy\./i.test(parsed.hostname));
250
+ if (!isEtsyImageHost) return url;
251
+ const width = toPositiveInteger(options.width) || toPositiveInteger(options.height);
252
+ const height = toPositiveInteger(options.height) || toPositiveInteger(options.width);
253
+ if (!width || !height) return url;
254
+ const base = removeImageUrlQuery(url);
255
+ const next = base.replace(/il_(?:\d+|full)x(?:\d+|full)\./i, `il_${width}x${height}.`);
256
+ return next === base ? url : next;
257
+ }
258
+ function resolveOssLinks(options = {}) {
259
+ var _a;
260
+ return (_a = options.ossLinks) != null ? _a : getOssLinks();
261
+ }
262
+ function isOssImageUrl(url, options = {}) {
263
+ const ossLinks2 = resolveOssLinks(options);
264
+ if (!ossLinks2.length) return false;
265
+ return ossLinks2.some((domain) => url.includes(domain));
266
+ }
267
+ function buildOssImageResizeUrl(url, options = {}) {
268
+ var _a;
269
+ if (!isOssImageUrl(url, options)) return url;
270
+ const width = toPositiveInteger(options.width);
271
+ const height = toPositiveInteger(options.height);
272
+ const qualityVal = (_a = options.Q) != null ? _a : options.q;
273
+ const format = options.format || "";
274
+ const formatPart = format ? `/format,${format}` : "";
275
+ const useAbsoluteQuality = options.Q != null;
276
+ let finalUrl = url;
277
+ const hasProcess = url.includes("x-oss-process=");
278
+ if (hasProcess) {
279
+ if (height) finalUrl = finalUrl.replace(/h_\d+/, `h_${height}`);
280
+ if (width) finalUrl = finalUrl.replace(/w_\d+/, `w_${width}`);
281
+ if (qualityVal) {
282
+ finalUrl = finalUrl.replace(
283
+ /quality,[Qq]_\d+/,
284
+ `quality,${useAbsoluteQuality ? "Q" : "q"}_${qualityVal}`
285
+ );
286
+ }
287
+ if (format) {
288
+ if (finalUrl.includes("/format,")) {
289
+ finalUrl = finalUrl.replace(/\/format,\w+/, formatPart);
290
+ } else {
291
+ finalUrl += formatPart;
292
+ }
293
+ }
294
+ return finalUrl;
295
+ }
296
+ let resizeStr = "resize,";
297
+ if (width) resizeStr += `w_${width}`;
298
+ else if (height) resizeStr += `h_${height}`;
299
+ else resizeStr += "l_120";
300
+ const qualityPart = qualityVal && qualityVal >= 1 && qualityVal <= 100 ? `/quality,${useAbsoluteQuality ? "Q" : "q"}_${qualityVal}` : "";
301
+ const connector = url.includes("?") ? "&" : "?";
302
+ return `${url}${connector}x-oss-process=image/${resizeStr}${qualityPart}${formatPart}`;
303
+ }
304
+ const IMAGE_RESIZE_RULES = [
305
+ {
306
+ name: "temu-kwcdn",
307
+ match: (url) => /(^|\.)kwcdn\.com$/i.test(url.hostname),
308
+ build: buildTemuImageResizeUrl
309
+ },
310
+ {
311
+ name: "shein-ltwebstatic",
312
+ match: (url) => /(^|\.)ltwebstatic\.com$/i.test(url.hostname),
313
+ build: buildSheinImageResizeUrl
314
+ },
315
+ {
316
+ name: "amazon",
317
+ match: (url) => /(^|\.)media-amazon\.com$/i.test(url.hostname) || /(^|\.)ssl-images-amazon\.com$/i.test(url.hostname) || /(^|\.)amazon\./i.test(url.hostname),
318
+ build: buildAmazonImageResizeUrl
319
+ },
320
+ {
321
+ name: "etsy",
322
+ match: (url) => /(^|\.)etsystatic\.com$/i.test(url.hostname) || /(^|\.)etsy\./i.test(url.hostname),
323
+ build: buildEtsyImageResizeUrl
324
+ },
325
+ {
326
+ name: "oss",
327
+ match: (url, options) => isOssImageUrl(url.href, options),
328
+ build: buildOssImageResizeUrl
329
+ }
330
+ ];
331
+ const IMAGE_ORIGINAL_RULES = [
332
+ {
333
+ name: "temu-kwcdn",
334
+ match: (url) => /(^|\.)kwcdn\.com$/i.test(url.hostname),
335
+ build: getTemuOriginalImageUrl
336
+ },
337
+ {
338
+ name: "shein-ltwebstatic",
339
+ match: (url) => /(^|\.)ltwebstatic\.com$/i.test(url.hostname),
340
+ build: getSheinOriginalImageUrl
341
+ },
342
+ {
343
+ name: "amazon",
344
+ match: (url) => /(^|\.)media-amazon\.com$/i.test(url.hostname) || /(^|\.)ssl-images-amazon\.com$/i.test(url.hostname) || /(^|\.)amazon\./i.test(url.hostname),
345
+ build: getAmazonOriginalImageUrl
346
+ },
347
+ {
348
+ name: "etsy",
349
+ match: (url) => /(^|\.)etsystatic\.com$/i.test(url.hostname) || /(^|\.)etsy\./i.test(url.hostname),
350
+ build: getEtsyOriginalImageUrl
351
+ }
352
+ ];
353
+ function buildPlatformImageResizeUrl(url, options = {}) {
354
+ const raw = (url || "").trim();
355
+ if (!raw) return "";
356
+ const parsed = parseHttpUrl(raw);
357
+ if (!parsed) return url;
358
+ const rule = IMAGE_RESIZE_RULES.find((item) => item.match(parsed, options));
359
+ if (!rule) return url;
360
+ return rule.build(raw, options);
361
+ }
362
+ function getPlatformOriginalImageUrl(url) {
363
+ const raw = (url || "").trim();
364
+ if (!raw) return "";
365
+ const parsed = parseHttpUrl(raw);
366
+ if (!parsed) return url;
367
+ const rule = IMAGE_ORIGINAL_RULES.find((item) => item.match(parsed));
368
+ if (!rule) return url;
369
+ return rule.build(raw);
370
+ }
371
+ function getImageResizeRuleName(url) {
372
+ var _a;
373
+ const parsed = parseHttpUrl(url);
374
+ if (!parsed) return "";
375
+ return ((_a = IMAGE_RESIZE_RULES.find((item) => item.match(parsed))) == null ? void 0 : _a.name) || "";
376
+ }
377
+ const notSupportedImgTypes = ["tif", "tiff", "psd"];
378
+ function isUnsupportedImg(url) {
379
+ const pathname = url.split(/[?#]/)[0];
380
+ const filename = pathname.slice(pathname.lastIndexOf("/") + 1);
381
+ const dot = filename.lastIndexOf(".");
382
+ if (dot === -1) return false;
383
+ return notSupportedImgTypes.includes(filename.slice(dot + 1).toLowerCase());
384
+ }
385
+ function replaceUnsupportedImg(url = "") {
386
+ if (!url) return url;
387
+ return isUnsupportedImg(url) ? getImgFasten().notSupported : url;
388
+ }
389
+ function temuThumbUrl(url, imgSize) {
390
+ var _a, _b;
391
+ return buildPlatformImageResizeUrl(url, {
392
+ width: (_b = (_a = imgSize == null ? void 0 : imgSize.w) != null ? _a : imgSize == null ? void 0 : imgSize.h) != null ? _b : 200,
393
+ height: imgSize == null ? void 0 : imgSize.h
394
+ });
395
+ }
396
+ function toPlatformResizeOptions(imgSize, ossLinks2) {
397
+ var _a, _b;
398
+ const width = (_a = imgSize == null ? void 0 : imgSize.w) != null ? _a : imgSize == null ? void 0 : imgSize.h;
399
+ const height = (_b = imgSize == null ? void 0 : imgSize.h) != null ? _b : imgSize == null ? void 0 : imgSize.w;
400
+ return {
401
+ width,
402
+ height,
403
+ Q: imgSize == null ? void 0 : imgSize.Q,
404
+ q: imgSize == null ? void 0 : imgSize.q,
405
+ format: typeof (imgSize == null ? void 0 : imgSize.format) === "string" ? imgSize.format : void 0,
406
+ ossLinks: ossLinks2
407
+ };
408
+ }
409
+ function montageImgUrl(url = "", imgSize, options = {}) {
410
+ var _a;
411
+ const imgFasten2 = getImgFasten();
412
+ if (!url) return imgFasten2.empty;
413
+ if (isUnsupportedImg(url)) return imgFasten2.notSupported;
414
+ const ruleName = getImageResizeRuleName(url);
415
+ const ossLinks2 = (_a = options.ossLinks) != null ? _a : getOssLinks();
416
+ const hitOssByLinks = ossLinks2.some((domain) => url.includes(domain));
417
+ if (ruleName === "oss" || !ruleName && hitOssByLinks) {
418
+ if (!hitOssByLinks) return url;
419
+ const networkOpts = getNetworkAdaptiveOptions(imgSize || { h: 260, Q: 92 });
420
+ return buildPlatformImageResizeUrl(url, toPlatformResizeOptions(__spreadValues(__spreadValues({}, imgSize), networkOpts), ossLinks2));
421
+ }
422
+ if (ruleName) {
423
+ return buildPlatformImageResizeUrl(url, toPlatformResizeOptions(imgSize));
424
+ }
425
+ return url;
426
+ }
427
+ export {
428
+ DEFAULT_IMG_FASTEN as D,
429
+ getImgFasten as a,
430
+ buildPlatformImageResizeUrl as b,
431
+ configureImgUrl as c,
432
+ getNetworkAdaptiveOptions as d,
433
+ getOssLinks as e,
434
+ getPlatformOriginalImageUrl as f,
435
+ getImageResizeRuleName as g,
436
+ initNetworkListener as h,
437
+ imgUrlConfigKey as i,
438
+ isUnsupportedImg as j,
439
+ notSupportedImgTypes as k,
440
+ replaceUnsupportedImg as l,
441
+ montageImgUrl as m,
442
+ networkKey as n,
443
+ removeImageUrlQuery as r,
444
+ temuThumbUrl as t
445
+ };
@@ -4,4 +4,4 @@
4
4
  export { parsePSD } from './parsePSD';
5
5
  export { parseTIFF } from './parseTIFF';
6
6
  export { parseImage } from './parseImage';
7
- export { parsePSDFile, parseTIFFFile, parseImageFile, detectFileType, formatFileSize, parseFile, parseFiles, type ParsedImageInfo, type ParseOptions } from './common';
7
+ export { parsePSDFile, parseTIFFFile, parseImageFile, detectFileType, formatFileSize, parseFile, parseFiles, type ParsedImageInfo, type ParseOptions, type AgPsdOptions, } from './common';
@@ -0,0 +1,209 @@
1
+ type ImageSizeValue = number | string | null | undefined;
2
+ export type ImageResizeOptions = {
3
+ width?: ImageSizeValue;
4
+ height?: ImageSizeValue;
5
+ /** OSS 绝对质量 Q(1–100) */
6
+ Q?: number;
7
+ /** OSS 相对质量 q(1–100);与 Q 同时存在时优先 Q */
8
+ q?: number;
9
+ /** OSS 输出格式,如 webp */
10
+ format?: string;
11
+ /** 当前调用使用的 OSS 域名白名单;未传时使用 configureImgUrl 注入的全局配置 */
12
+ ossLinks?: string[];
13
+ };
14
+ /**
15
+ * 移除 URL query,保留 hash。
16
+ *
17
+ * @example
18
+ * removeImageUrlQuery('https://a.com/img.jpg?x=1#top')
19
+ * // 'https://a.com/img.jpg#top'
20
+ */
21
+ export declare function removeImageUrlQuery(url: string): string;
22
+ /**
23
+ * Temu / kwcdn 获取原图。
24
+ *
25
+ * 当前采集规则是直接去掉 query 参数。
26
+ *
27
+ * @example
28
+ * getTemuOriginalImageUrl(
29
+ * 'https://img.kwcdn.com/thumbnail/s/a.jpeg?imageView2/2/w/150/q/50/format/avif%7CimageVqr/2'
30
+ * )
31
+ * // 'https://img.kwcdn.com/thumbnail/s/a.jpeg'
32
+ */
33
+ export declare function getTemuOriginalImageUrl(url: string): string;
34
+ /**
35
+ * Shein / ltwebstatic 获取原图。
36
+ *
37
+ * 当前采集规则:
38
+ * - _thumbnail_405x552.jpg -> _thumbnail_fullx.jpg
39
+ * - _square_thumbnail_405x552.jpg -> _square_thumbnail_fullx.jpg
40
+ *
41
+ * @example
42
+ * getSheinOriginalImageUrl(
43
+ * '//img.ltwebstatic.com/v4/j/pi/2025/12/12/22/a_thumbnail_405x552.jpg'
44
+ * )
45
+ * // '//img.ltwebstatic.com/v4/j/pi/2025/12/12/22/a_thumbnail_fullx.jpg'
46
+ */
47
+ export declare function getSheinOriginalImageUrl(url: string): string;
48
+ /**
49
+ * Amazon 获取原图。
50
+ *
51
+ * 当前采集规则是把 ._AC_ 后的尺寸段扩成 full,保留 QL/FMwebp 等非尺寸段。
52
+ *
53
+ * @example
54
+ * getAmazonOriginalImageUrl('https://m.media-amazon.com/images/I/abc._AC_UL450_SR450,320_.jpg')
55
+ * // 'https://m.media-amazon.com/images/I/abc._AC_ULfull_SRfull,full_.jpg'
56
+ */
57
+ export declare function getAmazonOriginalImageUrl(url: string): string;
58
+ /**
59
+ * Etsy 获取原图。
60
+ *
61
+ * 当前采集规则:il_75x75 / il_340x270 等改成 il_fullxfull。
62
+ *
63
+ * @example
64
+ * getEtsyOriginalImageUrl('https://i.etsystatic.com/123/r/il_340x270.456.jpg')
65
+ * // 'https://i.etsystatic.com/123/r/il_fullxfull.456.jpg'
66
+ */
67
+ export declare function getEtsyOriginalImageUrl(url: string): string;
68
+ /**
69
+ * Temu / kwcdn
70
+ *
71
+ * 优先使用 width;未传 width 时回退 height(组件侧常只传 h)。
72
+ * 原链接已有 query(含历史 imageView2 / 非法双 ? + imageMogr2)时,先清掉再统一换成 imageView2。
73
+ *
74
+ * @example
75
+ * buildTemuImageResizeUrl(
76
+ * 'https://img.kwcdn.com/thumbnail/s/a.jpeg?imageView2/2/w/500/q/70/format/avif?imageMogr2/thumbnail/100x',
77
+ * { width: 100 }
78
+ * )
79
+ * // 'https://img.kwcdn.com/thumbnail/s/a.jpeg?imageView2/2/w/100/q/50/format/avif%7CimageVqr/2'
80
+ */
81
+ export declare function buildTemuImageResizeUrl(url: string, options?: ImageResizeOptions): string;
82
+ /**
83
+ * Shein / ltwebstatic
84
+ *
85
+ * Shein 尺寸在文件路径里,不在 query 中;因此通过替换路径里的 thumbnail 尺寸实现。
86
+ * 宽高缺一时用另一个回填。
87
+ *
88
+ * @example
89
+ * buildSheinImageResizeUrl(
90
+ * '//img.ltwebstatic.com/v4/j/pi/2025/12/12/22/a_thumbnail_405x552.jpg',
91
+ * { width: 300, height: 409 }
92
+ * )
93
+ * // '//img.ltwebstatic.com/v4/j/pi/2025/12/12/22/a_thumbnail_300x409.jpg'
94
+ */
95
+ export declare function buildSheinImageResizeUrl(url: string, options?: ImageResizeOptions): string;
96
+ /**
97
+ * Amazon
98
+ *
99
+ * 替换 ._AC_ 后 UL/SR/SX 等尺寸段;单值标签用 width(缺省用 height),
100
+ * 双值标签用 width,height(缺一则用另一个填充)。也支持把 full 改回具体尺寸。
101
+ *
102
+ * @example
103
+ * buildAmazonImageResizeUrl(
104
+ * 'https://m.media-amazon.com/images/I/abc._AC_UL450_SR450,320_.jpg',
105
+ * { width: 200, height: 150 }
106
+ * )
107
+ * // 'https://m.media-amazon.com/images/I/abc._AC_UL200_SR200,150_.jpg'
108
+ */
109
+ export declare function buildAmazonImageResizeUrl(url: string, options?: ImageResizeOptions): string;
110
+ /**
111
+ * Etsy
112
+ *
113
+ * 将路径里的 il_{w}x{h} / il_fullxfull 替换为 il_{width}x{height}。
114
+ * 宽高缺一时用另一个回填(组件侧常只传 w 或 h)。
115
+ *
116
+ * @example
117
+ * buildEtsyImageResizeUrl(
118
+ * 'https://i.etsystatic.com/123/r/il_340x270.456.jpg',
119
+ * { width: 200, height: 200 }
120
+ * )
121
+ * // 'https://i.etsystatic.com/123/r/il_200x200.456.jpg'
122
+ *
123
+ * @example
124
+ * buildEtsyImageResizeUrl(
125
+ * 'https://i.etsystatic.com/123/r/il_fullxfull.456.jpg',
126
+ * { width: 100 }
127
+ * )
128
+ * // 'https://i.etsystatic.com/123/r/il_100x100.456.jpg'
129
+ */
130
+ export declare function buildEtsyImageResizeUrl(url: string, options?: ImageResizeOptions): string;
131
+ /**
132
+ * OSS(阿里云等)图片处理参数拼接。
133
+ *
134
+ * 规则对齐 montageImgUrl:
135
+ * - 命中 ossLinks 白名单才处理
136
+ * - 已有 x-oss-process 时原地替换 w_/h_/quality/format
137
+ * - 否则追加 ?x-oss-process=image/resize,w_{width}|h_{height}
138
+ * - 新建 process 且宽高都缺失时,默认 l_120(与 montageImgUrl 一致)
139
+ *
140
+ * @example
141
+ * buildOssImageResizeUrl(
142
+ * 'https://static.fangguo.com/a.jpg',
143
+ * { width: 200, Q: 90, ossLinks: ['static.fangguo.com'] }
144
+ * )
145
+ * // 'https://static.fangguo.com/a.jpg?x-oss-process=image/resize,w_200/quality,Q_90'
146
+ */
147
+ export declare function buildOssImageResizeUrl(url: string, options?: ImageResizeOptions): string;
148
+ /**
149
+ * 按图片域名/平台拼接对应尺寸参数。
150
+ * 未匹配或参数不足的平台会原链接返回。
151
+ *
152
+ * @example
153
+ * buildPlatformImageResizeUrl(
154
+ * 'https://img.kwcdn.com/thumbnail/s/a.jpeg',
155
+ * { width: 150 }
156
+ * )
157
+ * // 'https://img.kwcdn.com/thumbnail/s/a.jpeg?imageView2/2/w/150/q/50/format/avif%7CimageVqr/2'
158
+ *
159
+ * @example
160
+ * buildPlatformImageResizeUrl(
161
+ * '//img.ltwebstatic.com/v4/j/pi/2025/12/12/22/a_thumbnail_405x552.jpg',
162
+ * { width: 300, height: 409 }
163
+ * )
164
+ * // '//img.ltwebstatic.com/v4/j/pi/2025/12/12/22/a_thumbnail_300x409.jpg'
165
+ *
166
+ * @example
167
+ * buildPlatformImageResizeUrl(
168
+ * 'https://img.fangguo.com/a.jpg',
169
+ * { width: 200, Q: 90, ossLinks: ['img.fangguo.com'] }
170
+ * )
171
+ * // 'https://img.fangguo.com/a.jpg?x-oss-process=image/resize,w_200/quality,Q_90'
172
+ *
173
+ * @example
174
+ * buildPlatformImageResizeUrl('https://example.com/a.jpg', { width: 100 })
175
+ * // 'https://example.com/a.jpg'
176
+ */
177
+ export declare function buildPlatformImageResizeUrl(url: string, options?: ImageResizeOptions): string;
178
+ /**
179
+ * 按当前商品采集规则获取主图/原图。
180
+ * 未匹配的平台会原链接返回。
181
+ *
182
+ * @example
183
+ * getPlatformOriginalImageUrl(
184
+ * 'https://img.kwcdn.com/thumbnail/s/a.jpeg?imageView2/2/w/150/q/50/format/avif%7CimageVqr/2'
185
+ * )
186
+ * // 'https://img.kwcdn.com/thumbnail/s/a.jpeg'
187
+ *
188
+ * @example
189
+ * getPlatformOriginalImageUrl(
190
+ * '//img.ltwebstatic.com/v4/j/pi/2025/12/12/22/a_thumbnail_405x552.jpg'
191
+ * )
192
+ * // '//img.ltwebstatic.com/v4/j/pi/2025/12/12/22/a_thumbnail_fullx.jpg'
193
+ */
194
+ export declare function getPlatformOriginalImageUrl(url: string): string;
195
+ /**
196
+ * 获取当前图片地址命中的规则名,便于调试或埋点。
197
+ * OSS 规则依赖 configureImgUrl 注入的全局 ossLinks。
198
+ *
199
+ * @example
200
+ * getImageResizeRuleName('https://img.kwcdn.com/thumbnail/s/a.jpeg')
201
+ * // 'temu-kwcdn'
202
+ *
203
+ * @example
204
+ * // configureImgUrl({ ossLinks: ['img.fangguo.com'] }) 之后
205
+ * getImageResizeRuleName('https://img.fangguo.com/a.jpg')
206
+ * // 'oss'
207
+ */
208
+ export declare function getImageResizeRuleName(url: string): string;
209
+ export {};
@@ -1,4 +1,6 @@
1
1
  export { configureImgUrl, DEFAULT_IMG_FASTEN, getImgFasten, getOssLinks, imgUrlConfigKey } from './config';
2
2
  export { getNetworkAdaptiveOptions, initNetworkListener, networkKey } from './networkAdaptive';
3
3
  export { isUnsupportedImg, montageImgUrl, notSupportedImgTypes, replaceUnsupportedImg, temuThumbUrl, } from './montageImgUrl';
4
+ export { buildPlatformImageResizeUrl, getImageResizeRuleName, getPlatformOriginalImageUrl, removeImageUrlQuery, } from './imageUrl';
5
+ export type { ImageResizeOptions } from './imageUrl';
4
6
  export type { ImgFastenConfig, ImgSizeOptions, ImgUrlConfig, MontageImgUrlOptions } from './types';