651ae1bd479e28c41404c456627484da01bdebf7933b10fa1a3f31c6715f2a14.json 16 KB

1
  1. {"ast":null,"code":"import { request, urlSafeBase64Encode } from '../utils';\nfunction getImageUrl(key, domain) {\n key = encodeURIComponent(key);\n if (domain.slice(domain.length - 1) !== '/') {\n domain += '/';\n }\n return domain + key;\n}\nexport function imageView2(op, key, domain) {\n if (!/^\\d$/.test(String(op.mode))) {\n throw 'mode should be number in imageView2';\n }\n var mode = op.mode,\n w = op.w,\n h = op.h,\n q = op.q,\n format = op.format;\n if (!w && !h) {\n throw 'param w and h is empty in imageView2';\n }\n var imageUrl = 'imageView2/' + encodeURIComponent(mode);\n imageUrl += w ? '/w/' + encodeURIComponent(w) : '';\n imageUrl += h ? '/h/' + encodeURIComponent(h) : '';\n imageUrl += q ? '/q/' + encodeURIComponent(q) : '';\n imageUrl += format ? '/format/' + encodeURIComponent(format) : '';\n if (key && domain) {\n imageUrl = getImageUrl(key, domain) + '?' + imageUrl;\n }\n return imageUrl;\n}\n// invoke the imageMogr2 api of Qiniu\nexport function imageMogr2(op, key, domain) {\n var autoOrient = op['auto-orient'];\n var thumbnail = op.thumbnail,\n strip = op.strip,\n gravity = op.gravity,\n crop = op.crop,\n quality = op.quality,\n rotate = op.rotate,\n format = op.format,\n blur = op.blur;\n var imageUrl = 'imageMogr2';\n imageUrl += autoOrient ? '/auto-orient' : '';\n imageUrl += thumbnail ? '/thumbnail/' + encodeURIComponent(thumbnail) : '';\n imageUrl += strip ? '/strip' : '';\n imageUrl += gravity ? '/gravity/' + encodeURIComponent(gravity) : '';\n imageUrl += quality ? '/quality/' + encodeURIComponent(quality) : '';\n imageUrl += crop ? '/crop/' + encodeURIComponent(crop) : '';\n imageUrl += rotate ? '/rotate/' + encodeURIComponent(rotate) : '';\n imageUrl += format ? '/format/' + encodeURIComponent(format) : '';\n imageUrl += blur ? '/blur/' + encodeURIComponent(blur) : '';\n if (key && domain) {\n imageUrl = getImageUrl(key, domain) + '?' + imageUrl;\n }\n return imageUrl;\n}\n// invoke the watermark api of Qiniu\nexport function watermark(op, key, domain) {\n var mode = op.mode;\n if (!mode) {\n throw \"mode can't be empty in watermark\";\n }\n var imageUrl = 'watermark/' + mode;\n if (mode !== 1 && mode !== 2) {\n throw 'mode is wrong';\n }\n if (mode === 1) {\n var image = op.image;\n if (!image) {\n throw \"image can't be empty in watermark\";\n }\n imageUrl += image ? '/image/' + urlSafeBase64Encode(image) : '';\n }\n if (mode === 2) {\n var text = op.text,\n font = op.font,\n fontsize = op.fontsize,\n fill = op.fill;\n if (!text) {\n throw \"text can't be empty in watermark\";\n }\n imageUrl += text ? '/text/' + urlSafeBase64Encode(text) : '';\n imageUrl += font ? '/font/' + urlSafeBase64Encode(font) : '';\n imageUrl += fontsize ? '/fontsize/' + fontsize : '';\n imageUrl += fill ? '/fill/' + urlSafeBase64Encode(fill) : '';\n }\n var dissolve = op.dissolve,\n gravity = op.gravity,\n dx = op.dx,\n dy = op.dy;\n imageUrl += dissolve ? '/dissolve/' + encodeURIComponent(dissolve) : '';\n imageUrl += gravity ? '/gravity/' + encodeURIComponent(gravity) : '';\n imageUrl += dx ? '/dx/' + encodeURIComponent(dx) : '';\n imageUrl += dy ? '/dy/' + encodeURIComponent(dy) : '';\n if (key && domain) {\n imageUrl = getImageUrl(key, domain) + '?' + imageUrl;\n }\n return imageUrl;\n}\n// invoke the imageInfo api of Qiniu\nexport function imageInfo(key, domain) {\n var url = getImageUrl(key, domain) + '?imageInfo';\n return request(url, {\n method: 'GET'\n });\n}\n// invoke the exif api of Qiniu\nexport function exif(key, domain) {\n var url = getImageUrl(key, domain) + '?exif';\n return request(url, {\n method: 'GET'\n });\n}\nexport function pipeline(arr, key, domain) {\n var isArray = Object.prototype.toString.call(arr) === '[object Array]';\n var option;\n var errOp = false;\n var imageUrl = '';\n if (isArray) {\n for (var i = 0, len = arr.length; i < len; i++) {\n option = arr[i];\n if (!option.fop) {\n throw \"fop can't be empty in pipeline\";\n }\n switch (option.fop) {\n case 'watermark':\n imageUrl += watermark(option) + '|';\n break;\n case 'imageView2':\n imageUrl += imageView2(option) + '|';\n break;\n case 'imageMogr2':\n imageUrl += imageMogr2(option) + '|';\n break;\n default:\n errOp = true;\n break;\n }\n if (errOp) {\n throw 'fop is wrong in pipeline';\n }\n }\n if (key && domain) {\n imageUrl = getImageUrl(key, domain) + '?' + imageUrl;\n var length_1 = imageUrl.length;\n if (imageUrl.slice(length_1 - 1) === '|') {\n imageUrl = imageUrl.slice(0, length_1 - 1);\n }\n }\n return imageUrl;\n }\n throw \"pipeline's first param should be array\";\n}","map":{"version":3,"names":["request","urlSafeBase64Encode","getImageUrl","key","domain","encodeURIComponent","slice","length","imageView2","op","test","String","mode","w","h","q","format","imageUrl","imageMogr2","autoOrient","thumbnail","strip","gravity","crop","quality","rotate","blur","watermark","image","text","font","fontsize","fill","dissolve","dx","dy","imageInfo","url","method","exif","pipeline","arr","isArray","Object","prototype","toString","call","option","errOp","i","len","fop","length_1"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/qiniu-js/esm/image/index.js"],"sourcesContent":["import { request, urlSafeBase64Encode } from '../utils';\nfunction getImageUrl(key, domain) {\n key = encodeURIComponent(key);\n if (domain.slice(domain.length - 1) !== '/') {\n domain += '/';\n }\n return domain + key;\n}\nexport function imageView2(op, key, domain) {\n if (!/^\\d$/.test(String(op.mode))) {\n throw 'mode should be number in imageView2';\n }\n var mode = op.mode, w = op.w, h = op.h, q = op.q, format = op.format;\n if (!w && !h) {\n throw 'param w and h is empty in imageView2';\n }\n var imageUrl = 'imageView2/' + encodeURIComponent(mode);\n imageUrl += w ? '/w/' + encodeURIComponent(w) : '';\n imageUrl += h ? '/h/' + encodeURIComponent(h) : '';\n imageUrl += q ? '/q/' + encodeURIComponent(q) : '';\n imageUrl += format ? '/format/' + encodeURIComponent(format) : '';\n if (key && domain) {\n imageUrl = getImageUrl(key, domain) + '?' + imageUrl;\n }\n return imageUrl;\n}\n// invoke the imageMogr2 api of Qiniu\nexport function imageMogr2(op, key, domain) {\n var autoOrient = op['auto-orient'];\n var thumbnail = op.thumbnail, strip = op.strip, gravity = op.gravity, crop = op.crop, quality = op.quality, rotate = op.rotate, format = op.format, blur = op.blur;\n var imageUrl = 'imageMogr2';\n imageUrl += autoOrient ? '/auto-orient' : '';\n imageUrl += thumbnail ? '/thumbnail/' + encodeURIComponent(thumbnail) : '';\n imageUrl += strip ? '/strip' : '';\n imageUrl += gravity ? '/gravity/' + encodeURIComponent(gravity) : '';\n imageUrl += quality ? '/quality/' + encodeURIComponent(quality) : '';\n imageUrl += crop ? '/crop/' + encodeURIComponent(crop) : '';\n imageUrl += rotate ? '/rotate/' + encodeURIComponent(rotate) : '';\n imageUrl += format ? '/format/' + encodeURIComponent(format) : '';\n imageUrl += blur ? '/blur/' + encodeURIComponent(blur) : '';\n if (key && domain) {\n imageUrl = getImageUrl(key, domain) + '?' + imageUrl;\n }\n return imageUrl;\n}\n// invoke the watermark api of Qiniu\nexport function watermark(op, key, domain) {\n var mode = op.mode;\n if (!mode) {\n throw \"mode can't be empty in watermark\";\n }\n var imageUrl = 'watermark/' + mode;\n if (mode !== 1 && mode !== 2) {\n throw 'mode is wrong';\n }\n if (mode === 1) {\n var image = op.image;\n if (!image) {\n throw \"image can't be empty in watermark\";\n }\n imageUrl += image ? '/image/' + urlSafeBase64Encode(image) : '';\n }\n if (mode === 2) {\n var text = op.text, font = op.font, fontsize = op.fontsize, fill = op.fill;\n if (!text) {\n throw \"text can't be empty in watermark\";\n }\n imageUrl += text ? '/text/' + urlSafeBase64Encode(text) : '';\n imageUrl += font ? '/font/' + urlSafeBase64Encode(font) : '';\n imageUrl += fontsize ? '/fontsize/' + fontsize : '';\n imageUrl += fill ? '/fill/' + urlSafeBase64Encode(fill) : '';\n }\n var dissolve = op.dissolve, gravity = op.gravity, dx = op.dx, dy = op.dy;\n imageUrl += dissolve ? '/dissolve/' + encodeURIComponent(dissolve) : '';\n imageUrl += gravity ? '/gravity/' + encodeURIComponent(gravity) : '';\n imageUrl += dx ? '/dx/' + encodeURIComponent(dx) : '';\n imageUrl += dy ? '/dy/' + encodeURIComponent(dy) : '';\n if (key && domain) {\n imageUrl = getImageUrl(key, domain) + '?' + imageUrl;\n }\n return imageUrl;\n}\n// invoke the imageInfo api of Qiniu\nexport function imageInfo(key, domain) {\n var url = getImageUrl(key, domain) + '?imageInfo';\n return request(url, { method: 'GET' });\n}\n// invoke the exif api of Qiniu\nexport function exif(key, domain) {\n var url = getImageUrl(key, domain) + '?exif';\n return request(url, { method: 'GET' });\n}\nexport function pipeline(arr, key, domain) {\n var isArray = Object.prototype.toString.call(arr) === '[object Array]';\n var option;\n var errOp = false;\n var imageUrl = '';\n if (isArray) {\n for (var i = 0, len = arr.length; i < len; i++) {\n option = arr[i];\n if (!option.fop) {\n throw \"fop can't be empty in pipeline\";\n }\n switch (option.fop) {\n case 'watermark':\n imageUrl += watermark(option) + '|';\n break;\n case 'imageView2':\n imageUrl += imageView2(option) + '|';\n break;\n case 'imageMogr2':\n imageUrl += imageMogr2(option) + '|';\n break;\n default:\n errOp = true;\n break;\n }\n if (errOp) {\n throw 'fop is wrong in pipeline';\n }\n }\n if (key && domain) {\n imageUrl = getImageUrl(key, domain) + '?' + imageUrl;\n var length_1 = imageUrl.length;\n if (imageUrl.slice(length_1 - 1) === '|') {\n imageUrl = imageUrl.slice(0, length_1 - 1);\n }\n }\n return imageUrl;\n }\n throw \"pipeline's first param should be array\";\n}\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,mBAAmB,QAAQ,UAAU;AACvD,SAASC,WAAWA,CAACC,GAAG,EAAEC,MAAM,EAAE;EAC9BD,GAAG,GAAGE,kBAAkB,CAACF,GAAG,CAAC;EAC7B,IAAIC,MAAM,CAACE,KAAK,CAACF,MAAM,CAACG,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;IACzCH,MAAM,IAAI,GAAG;EACjB;EACA,OAAOA,MAAM,GAAGD,GAAG;AACvB;AACA,OAAO,SAASK,UAAUA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