UNPKG

cloudinary-video-player

Version:
92 lines (88 loc) 3.04 kB
const LEGACY_CONDITIONAL_OPERATORS = { "=": 'eq', "!=": 'ne', "<": 'lt', ">": 'gt', "<=": 'lte', ">=": 'gte', "&&": 'and', "||": 'or', "*": "mul", "/": "div", "+": "add", "-": "sub", "^": "pow" }; const OLD_AKAMAI_SHARED_CDN = "cloudinary-a.akamaihd.net"; const AKAMAI_SHARED_CDN = "res.cloudinary.com"; const SHARED_CDN = AKAMAI_SHARED_CDN; const LEGACY_PREDEFINED_VARS = { "aspect_ratio": "ar", "aspectRatio": "ar", "current_page": "cp", "currentPage": "cp", "duration": "du", "face_count": "fc", "faceCount": "fc", "height": "h", "initial_aspect_ratio": "iar", "initial_height": "ih", "initial_width": "iw", "initialAspectRatio": "iar", "initialHeight": "ih", "initialWidth": "iw", "initial_duration": "idu", "initialDuration": "idu", "page_count": "pc", "page_x": "px", "page_y": "py", "pageCount": "pc", "pageX": "px", "pageY": "py", "tags": "tags", "width": "w" }; const NUMBER_PATTERN = "([0-9]*)\\.([0-9]+)|([0-9]+)"; const OFFSET_ANY_PATTERN = `(${NUMBER_PATTERN})([%pP])?`; const RANGE_VALUE_RE = RegExp(`^${OFFSET_ANY_PATTERN}$`); const OFFSET_ANY_PATTERN_RE = RegExp(`(${OFFSET_ANY_PATTERN})\\.\\.(${OFFSET_ANY_PATTERN})`); const LAYER_KEYWORD_PARAMS = { font_weight: "normal", font_style: "normal", text_decoration: "none", text_align: '', stroke: "none" }; function unsigned_url_prefix(source, cloud_name, private_cdn, cdn_subdomain, secure_cdn_subdomain, cname, secure, secure_distribution) { let prefix; if (cloud_name.indexOf("/") === 0) { return '/res' + cloud_name; } let shared_domain = !private_cdn; if (secure) { if ((secure_distribution == null) || secure_distribution === OLD_AKAMAI_SHARED_CDN) { secure_distribution = private_cdn ? cloud_name + "-res.cloudinary.com" : SHARED_CDN; } if (shared_domain == null) { shared_domain = secure_distribution === SHARED_CDN; } prefix = 'https://' + secure_distribution; } else if (cname) { // let subdomain = cdn_subdomain ? 'a' + ((crc32(source) % 5) + 1) + '.' : ''; prefix = 'http://' + cname; } else { let cdn_part = private_cdn ? cloud_name + '-' : ''; let host = [cdn_part, 'res', '.cloudinary.com'].join(''); prefix = 'http://' + host; } if (shared_domain) { prefix += '/' + cloud_name; } return prefix; } const getCloudinaryUrlPrefix = cloudinaryConfig => { return unsigned_url_prefix(null, cloudinaryConfig.cloud_name, cloudinaryConfig.private_cdn, cloudinaryConfig.cdn_subdomain, cloudinaryConfig.secure_cdn_subdomain, cloudinaryConfig.cname, cloudinaryConfig.secure ?? true, cloudinaryConfig.secure_distribution); }; export { LAYER_KEYWORD_PARAMS as L, OFFSET_ANY_PATTERN_RE as O, RANGE_VALUE_RE as R, LEGACY_CONDITIONAL_OPERATORS as a, LEGACY_PREDEFINED_VARS as b, getCloudinaryUrlPrefix as g, unsigned_url_prefix as u };