fangguo-component 1.2.3 → 1.2.5

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 (52) hide show
  1. package/dist/{ErrorImage-CFVt1ht_.js → ErrorImage-Ao9kEEUg.js} +2 -2
  2. package/dist/FgCascader.css +2 -14
  3. package/dist/{FgCascader.vue_vue_type_style_index_0_lang-CstlYwHs.js → FgCascader.vue_vue_type_style_index_0_lang-CtUPO8fk.js} +20 -26
  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-CLRjYOUN.js +556 -0
  12. package/dist/ViewImg.css +60 -35
  13. package/dist/ViewImgPopover-BtFnYval.js +463 -0
  14. package/dist/ViewImgPopover.css +28 -26
  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 +44 -19
  29. package/dist/components/viewImg/ViewImgErrorFallback.vue.d.ts +17 -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 +207 -99
  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-Qkq7I01c.js → index-DsfY1yqo.js} +6 -1
  39. package/dist/{index-Ce_edAQB.js → index-wDrpgKQT.js} +17 -13
  40. package/dist/index.d.ts +8 -3
  41. package/dist/index.js +58 -49
  42. package/dist/montageImgUrl-B9ZmJ7TF.js +464 -0
  43. package/dist/tools/ImageParserUtils/index.d.ts +1 -1
  44. package/dist/tools/imgUrl/imageUrl.d.ts +246 -0
  45. package/dist/tools/imgUrl/index.d.ts +2 -0
  46. package/dist/tools/imgUrl/index.js +13 -8
  47. package/dist/tools/imgUrl/montageImgUrl.d.ts +11 -5
  48. package/dist/tools/index.js +19 -14
  49. package/package.json +2 -2
  50. package/dist/ViewImg-DXhF20SL.js +0 -254
  51. package/dist/ViewImgPopover-QblZG0z5.js +0 -343
  52. package/dist/montageImgUrl-CwgYnB2h.js +0 -204
@@ -0,0 +1,464 @@
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
+ base = base.replace(/_thumbnail\.(webp|png|jpg|jpeg)/gi, "_thumbnail_fullx.$1");
165
+ base = base.replace(/_square_thumbnail\.(webp|png|jpg|jpeg)/gi, "_square_thumbnail_fullx.$1");
166
+ return base;
167
+ }
168
+ function getAmazonOriginalImageUrl(url) {
169
+ const parsed = parseHttpUrl(url);
170
+ const isAmazonImageHost = parsed && (/(^|\.)media-amazon\.com$/i.test(parsed.hostname) || /(^|\.)ssl-images-amazon\.com$/i.test(parsed.hostname) || /(^|\.)amazon\./i.test(parsed.hostname));
171
+ if (!isAmazonImageHost) return url;
172
+ const base = removeImageUrlQuery(url);
173
+ const marker = "._AC_";
174
+ const i = base.indexOf(marker);
175
+ if (i === -1) return base;
176
+ const prefix = base.slice(0, i + marker.length);
177
+ let rest = base.slice(i + marker.length);
178
+ const reLead = new RegExp(`^(${AMAZON_DIM_TOKEN})(\\d+)(?:,(\\d+))?`);
179
+ rest = rest.replace(
180
+ reLead,
181
+ (_m, tag, _n1, n2) => n2 != null && n2 !== "" ? `${tag}full,full` : `${tag}full`
182
+ );
183
+ const reChain = new RegExp(`_(${AMAZON_DIM_TOKEN})(\\d+)(?:,(\\d+))?`, "g");
184
+ rest = rest.replace(
185
+ reChain,
186
+ (_m, tag, _n1, n2) => n2 != null && n2 !== "" ? `_${tag}full,full` : `_${tag}full`
187
+ );
188
+ return prefix + rest;
189
+ }
190
+ function getEtsyOriginalImageUrl(url) {
191
+ const parsed = parseHttpUrl(url);
192
+ const isEtsyImageHost = parsed && (/(^|\.)etsystatic\.com$/i.test(parsed.hostname) || /(^|\.)etsy\./i.test(parsed.hostname));
193
+ if (!isEtsyImageHost) return url;
194
+ return removeImageUrlQuery(url).replace(/il_\d+x\d+\./i, "il_fullxfull.");
195
+ }
196
+ function buildTemuImageResizeUrl(url, options = {}) {
197
+ const parsed = parseHttpUrl(url);
198
+ if (!parsed || !/(^|\.)kwcdn\.com$/i.test(parsed.hostname)) return url;
199
+ const width = toPositiveInteger(options.width);
200
+ if (!width) return url;
201
+ const base = removeImageUrlQuery(url);
202
+ return `${base}?imageView2/2/w/${width}/q/50/format/avif%7CimageVqr/2`;
203
+ }
204
+ function buildSheinImageResizeUrl(url, options = {}) {
205
+ const parsed = parseHttpUrl(url);
206
+ if (!parsed || !/(^|\.)ltwebstatic\.com$/i.test(parsed.hostname)) return url;
207
+ const width = toPositiveInteger(options.width) || toPositiveInteger(options.height);
208
+ const height = toPositiveInteger(options.height) || toPositiveInteger(options.width);
209
+ if (!width || !height) return url;
210
+ const base = removeImageUrlQuery(url);
211
+ const next = base.replace(
212
+ /_((?:square_)?thumbnail)(?:_\d+x\d*|_fullx)?\.(webp|png|jpg|jpeg)/gi,
213
+ `_$1_${width}x${height}.$2`
214
+ );
215
+ return next === base ? url : next;
216
+ }
217
+ function buildAmazonImageResizeUrl(url, options = {}) {
218
+ const parsed = parseHttpUrl(url);
219
+ const isAmazonImageHost = parsed && (/(^|\.)media-amazon\.com$/i.test(parsed.hostname) || /(^|\.)ssl-images-amazon\.com$/i.test(parsed.hostname) || /(^|\.)amazon\./i.test(parsed.hostname));
220
+ if (!isAmazonImageHost) return url;
221
+ const width = toPositiveInteger(options.width);
222
+ const height = toPositiveInteger(options.height);
223
+ if (!width && !height) return url;
224
+ const single = String(width || height);
225
+ const pairW = String(width || height);
226
+ const pairH = String(height || width);
227
+ const base = removeImageUrlQuery(url);
228
+ const marker = "._AC_";
229
+ const i = base.indexOf(marker);
230
+ if (i === -1) return url;
231
+ const prefix = base.slice(0, i + marker.length);
232
+ let rest = base.slice(i + marker.length);
233
+ const reLead = new RegExp(`^(${AMAZON_DIM_TOKEN})(\\d+|full)(?:,(\\d+|full))?`, "i");
234
+ rest = rest.replace(
235
+ reLead,
236
+ (_m, tag, _n1, n2) => n2 != null && n2 !== "" ? `${tag}${pairW},${pairH}` : `${tag}${single}`
237
+ );
238
+ const reChain = new RegExp(`_(${AMAZON_DIM_TOKEN})(\\d+|full)(?:,(\\d+|full))?`, "gi");
239
+ rest = rest.replace(
240
+ reChain,
241
+ (_m, tag, _n1, n2) => n2 != null && n2 !== "" ? `_${tag}${pairW},${pairH}` : `_${tag}${single}`
242
+ );
243
+ return prefix + rest;
244
+ }
245
+ function buildEtsyImageResizeUrl(url, options = {}) {
246
+ const parsed = parseHttpUrl(url);
247
+ const isEtsyImageHost = parsed && (/(^|\.)etsystatic\.com$/i.test(parsed.hostname) || /(^|\.)etsy\./i.test(parsed.hostname));
248
+ if (!isEtsyImageHost) return url;
249
+ const width = toPositiveInteger(options.width) || toPositiveInteger(options.height);
250
+ const height = toPositiveInteger(options.height) || toPositiveInteger(options.width);
251
+ if (!width || !height) return url;
252
+ const base = removeImageUrlQuery(url);
253
+ const next = base.replace(/il_(?:\d+|full)x(?:\d+|full)\./i, `il_${width}x${height}.`);
254
+ return next === base ? url : next;
255
+ }
256
+ function resolveOssLinks(options = {}) {
257
+ var _a;
258
+ return (_a = options.ossLinks) != null ? _a : getOssLinks();
259
+ }
260
+ function hasOssProcessParam(url) {
261
+ return url.includes("x-oss-process=");
262
+ }
263
+ function isOssImageUrl(url, options = {}) {
264
+ const ossLinks2 = resolveOssLinks(options);
265
+ if (!ossLinks2.length) return false;
266
+ return ossLinks2.some((domain) => url.includes(domain));
267
+ }
268
+ function buildOssImageResizeUrl(url, options = {}) {
269
+ var _a;
270
+ const hasProcess = hasOssProcessParam(url);
271
+ if (!hasProcess && !isOssImageUrl(url, options)) return url;
272
+ const width = toPositiveInteger(options.width);
273
+ const height = toPositiveInteger(options.height);
274
+ const qualityVal = (_a = options.Q) != null ? _a : options.q;
275
+ const format = options.format || "";
276
+ const formatPart = format ? `/format,${format}` : "";
277
+ const useAbsoluteQuality = options.Q != null;
278
+ let finalUrl = url;
279
+ if (hasProcess) {
280
+ if (height) finalUrl = finalUrl.replace(/h_\d+/, `h_${height}`);
281
+ if (width) finalUrl = finalUrl.replace(/w_\d+/, `w_${width}`);
282
+ if (qualityVal) {
283
+ finalUrl = finalUrl.replace(
284
+ /quality,[Qq]_\d+/,
285
+ `quality,${useAbsoluteQuality ? "Q" : "q"}_${qualityVal}`
286
+ );
287
+ }
288
+ if (format) {
289
+ if (finalUrl.includes("/format,")) {
290
+ finalUrl = finalUrl.replace(/\/format,\w+/, formatPart);
291
+ } else {
292
+ finalUrl += formatPart;
293
+ }
294
+ }
295
+ return finalUrl;
296
+ }
297
+ let resizeStr = "resize,";
298
+ if (width) resizeStr += `w_${width}`;
299
+ else if (height) resizeStr += `h_${height}`;
300
+ else resizeStr += "l_120";
301
+ const qualityPart = qualityVal && qualityVal >= 1 && qualityVal <= 100 ? `/quality,${useAbsoluteQuality ? "Q" : "q"}_${qualityVal}` : "";
302
+ const connector = url.includes("?") ? "&" : "?";
303
+ return `${url}${connector}x-oss-process=image/${resizeStr}${qualityPart}${formatPart}`;
304
+ }
305
+ const IMAGE_RESIZE_RULES = [
306
+ {
307
+ name: "temu-kwcdn",
308
+ match: (url) => /(^|\.)kwcdn\.com$/i.test(url.hostname),
309
+ build: buildTemuImageResizeUrl
310
+ },
311
+ {
312
+ name: "shein-ltwebstatic",
313
+ match: (url) => /(^|\.)ltwebstatic\.com$/i.test(url.hostname),
314
+ build: buildSheinImageResizeUrl
315
+ },
316
+ {
317
+ name: "amazon",
318
+ match: (url) => /(^|\.)media-amazon\.com$/i.test(url.hostname) || /(^|\.)ssl-images-amazon\.com$/i.test(url.hostname) || /(^|\.)amazon\./i.test(url.hostname),
319
+ build: buildAmazonImageResizeUrl
320
+ },
321
+ {
322
+ name: "etsy",
323
+ match: (url) => /(^|\.)etsystatic\.com$/i.test(url.hostname) || /(^|\.)etsy\./i.test(url.hostname),
324
+ build: buildEtsyImageResizeUrl
325
+ },
326
+ {
327
+ name: "oss",
328
+ // 白名单命中,或 URL 已带 x-oss-process(业务侧已拼参、悬停需改尺寸)
329
+ match: (url, options) => isOssImageUrl(url.href, options) || hasOssProcessParam(url.href),
330
+ build: buildOssImageResizeUrl
331
+ }
332
+ ];
333
+ const IMAGE_ORIGINAL_RULES = [
334
+ {
335
+ name: "temu-kwcdn",
336
+ match: (url) => /(^|\.)kwcdn\.com$/i.test(url.hostname),
337
+ build: getTemuOriginalImageUrl
338
+ },
339
+ {
340
+ name: "shein-ltwebstatic",
341
+ match: (url) => /(^|\.)ltwebstatic\.com$/i.test(url.hostname),
342
+ build: getSheinOriginalImageUrl
343
+ },
344
+ {
345
+ name: "amazon",
346
+ match: (url) => /(^|\.)media-amazon\.com$/i.test(url.hostname) || /(^|\.)ssl-images-amazon\.com$/i.test(url.hostname) || /(^|\.)amazon\./i.test(url.hostname),
347
+ build: getAmazonOriginalImageUrl
348
+ },
349
+ {
350
+ name: "etsy",
351
+ match: (url) => /(^|\.)etsystatic\.com$/i.test(url.hostname) || /(^|\.)etsy\./i.test(url.hostname),
352
+ build: getEtsyOriginalImageUrl
353
+ }
354
+ ];
355
+ function buildPlatformImageResizeUrl(url, options = {}) {
356
+ const raw = (url || "").trim();
357
+ if (!raw) return "";
358
+ const parsed = parseHttpUrl(raw);
359
+ if (!parsed) return url;
360
+ const rule = IMAGE_RESIZE_RULES.find((item) => item.match(parsed, options));
361
+ if (!rule) return url;
362
+ return rule.build(raw, options);
363
+ }
364
+ function hasPlatformImageResizeParams(url) {
365
+ const raw = (url || "").trim();
366
+ if (!raw) return false;
367
+ if (hasOssProcessParam(raw)) return true;
368
+ if (/[?&]imageView2\//i.test(raw) || /[?&]imageMogr2\//i.test(raw) || raw.includes("imageView2/")) {
369
+ return true;
370
+ }
371
+ const path = removeImageUrlQuery(raw);
372
+ if (/_(?:square_)?thumbnail(?:_\d+x\d*|_fullx)?\./i.test(path)) {
373
+ return true;
374
+ }
375
+ if (/\._AC_(?:UL|SR|SL|SX|SY|SF|SC)/i.test(path)) return true;
376
+ if (/il_(?:\d+|full)x(?:\d+|full)\./i.test(path)) return true;
377
+ return false;
378
+ }
379
+ function getPlatformOriginalImageUrl(url) {
380
+ const raw = (url || "").trim();
381
+ if (!raw) return "";
382
+ const parsed = parseHttpUrl(raw);
383
+ if (!parsed) return url;
384
+ const rule = IMAGE_ORIGINAL_RULES.find((item) => item.match(parsed));
385
+ if (!rule) return url;
386
+ return rule.build(raw);
387
+ }
388
+ function getImageResizeRuleName(url) {
389
+ var _a;
390
+ const parsed = parseHttpUrl(url);
391
+ if (!parsed) return "";
392
+ return ((_a = IMAGE_RESIZE_RULES.find((item) => item.match(parsed))) == null ? void 0 : _a.name) || "";
393
+ }
394
+ const notSupportedImgTypes = ["tif", "tiff", "psd"];
395
+ function isUnsupportedImg(url) {
396
+ const pathname = url.split(/[?#]/)[0];
397
+ const filename = pathname.slice(pathname.lastIndexOf("/") + 1);
398
+ const dot = filename.lastIndexOf(".");
399
+ if (dot === -1) return false;
400
+ return notSupportedImgTypes.includes(filename.slice(dot + 1).toLowerCase());
401
+ }
402
+ function replaceUnsupportedImg(url = "") {
403
+ if (!url) return url;
404
+ return isUnsupportedImg(url) ? getImgFasten().notSupported : url;
405
+ }
406
+ function temuThumbUrl(url, imgSize) {
407
+ var _a, _b;
408
+ return buildPlatformImageResizeUrl(url, {
409
+ width: (_b = (_a = imgSize == null ? void 0 : imgSize.w) != null ? _a : imgSize == null ? void 0 : imgSize.h) != null ? _b : 200,
410
+ height: imgSize == null ? void 0 : imgSize.h
411
+ });
412
+ }
413
+ function toPlatformResizeOptions(imgSize, ossLinks2) {
414
+ var _a, _b;
415
+ const width = (_a = imgSize == null ? void 0 : imgSize.w) != null ? _a : imgSize == null ? void 0 : imgSize.h;
416
+ const height = (_b = imgSize == null ? void 0 : imgSize.h) != null ? _b : imgSize == null ? void 0 : imgSize.w;
417
+ return {
418
+ width,
419
+ height,
420
+ Q: imgSize == null ? void 0 : imgSize.Q,
421
+ q: imgSize == null ? void 0 : imgSize.q,
422
+ format: typeof (imgSize == null ? void 0 : imgSize.format) === "string" ? imgSize.format : void 0,
423
+ ossLinks: ossLinks2
424
+ };
425
+ }
426
+ function montageImgUrl(url = "", imgSize, options = {}) {
427
+ var _a;
428
+ const imgFasten2 = getImgFasten();
429
+ if (!url) return imgFasten2.empty;
430
+ if (isUnsupportedImg(url)) return imgFasten2.notSupported;
431
+ const ruleName = getImageResizeRuleName(url);
432
+ const ossLinks2 = (_a = options.ossLinks) != null ? _a : getOssLinks();
433
+ const hitOssByLinks = ossLinks2.some((domain) => url.includes(domain));
434
+ const hasOssProcess = url.includes("x-oss-process=");
435
+ if (ruleName === "oss" || !ruleName && hitOssByLinks || !ruleName && hasOssProcess) {
436
+ if (!hitOssByLinks && !hasOssProcess) return url;
437
+ const networkOpts = getNetworkAdaptiveOptions(imgSize || { h: 260, Q: 92 });
438
+ return buildPlatformImageResizeUrl(url, toPlatformResizeOptions(__spreadValues(__spreadValues({}, imgSize), networkOpts), ossLinks2));
439
+ }
440
+ if (ruleName) {
441
+ return buildPlatformImageResizeUrl(url, toPlatformResizeOptions(imgSize));
442
+ }
443
+ return url;
444
+ }
445
+ export {
446
+ DEFAULT_IMG_FASTEN as D,
447
+ getImgFasten as a,
448
+ buildPlatformImageResizeUrl as b,
449
+ configureImgUrl as c,
450
+ getNetworkAdaptiveOptions as d,
451
+ getOssLinks as e,
452
+ getPlatformOriginalImageUrl as f,
453
+ getImageResizeRuleName as g,
454
+ hasPlatformImageResizeParams as h,
455
+ imgUrlConfigKey as i,
456
+ initNetworkListener as j,
457
+ isUnsupportedImg as k,
458
+ notSupportedImgTypes as l,
459
+ montageImgUrl as m,
460
+ networkKey as n,
461
+ replaceUnsupportedImg as o,
462
+ removeImageUrlQuery as r,
463
+ temuThumbUrl as t
464
+ };
@@ -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';