Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hap-toolkit/compiler

Package Overview
Dependencies
Maintainers
6
Versions
169
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hap-toolkit/compiler - npm Package Compare versions

Comparing version 1.9.9 to 1.9.10-beta

2

lib/style/process.js

@@ -1,2 +0,2 @@

"use strict";var _fs=_interopRequireDefault(require("fs")),_path=_interopRequireDefault(require("path")),_css=_interopRequireDefault(require("css")),_cssWhat=_interopRequireDefault(require("css-what")),_compilationConfig=require("@hap-toolkit/shared-utils/compilation-config"),_validator=require("./validator"),_compress=require("./compress"),_mediaquery=require("./mediaquery"),_utils=require("../utils");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const VALID_IMPORT_FLAG="__VALID_IMPORT__",IMPORT_REG=new RegExp("@import\\s+__VALID_IMPORT__((?:['\"]([^()]+?)['\"])|(?:(?:url\\(([^()]+?)\\))))((?:\\s*)|(?:\\s+[^;]+))__VALID_IMPORT__;","g"),IMPORT_URL_REG=new RegExp("__VALID_IMPORT__(?:(?:['\"]([^()]+?)['\"])|(?:(?:url\\(([^()]+?)\\))))(\\s+[^;]+)?__VALID_IMPORT__;");function shouldAddToDependency(e,s){return(0,_validator.mightReferlocalResource)(e)&&!/^(data:|http)/.test(s)&&"string"==typeof s}function signValidCssImport(e){let s=!0;const t=_css.default.parse(e);if(t&&"stylesheet"===t.type&&t.stylesheet&&t.stylesheet.rules&&t.stylesheet.rules.length){t.stylesheet.rules.forEach((e=>{const t=e.type;"import"!==t&&"comment"!==t&&(s=!1),"import"===t&&s&&(e.import=VALID_IMPORT_FLAG+e.import+VALID_IMPORT_FLAG)})),e=_css.default.stringify(t)}return e}function processImport(e,s,t,o){let i=signValidCssImport(e);const r=i.match(IMPORT_REG);return r&&r.length>0&&(s?r.forEach((e=>{const r=e.match(IMPORT_URL_REG);if(r.length>1){const n=r[3],a=_path.default.resolve(s,r[1]||r[2]),l=_fs.default.readFileSync(a);if(l){const s=_path.default.dirname(a);let r=processImport(l.toString(),s,t,o);n&&(r=(0,_mediaquery.wrapMediaCode)(r,n)),i=i.replace(e,"\n"+r+"\n"),o.push(a)}else t.push({line:1,column:1,reason:"ERROR: 找不到文件 `"+e+"` , 导入失败"})}})):t.push({line:1,column:1,reason:"ERROR: 找不到资源路径, 无法处理@import"})),i}function processSingleClass(e,s,t,o,i,r){e.declarations.forEach((function(e){if("declaration"!==e.type)return;const s=e.property,n=e.value,a=(0,_utils.hyphenedToCamelCase)(s),l=(0,_validator.validate)(a,n,{filePath:i});l.value.forEach((e=>{(0,_utils.isValidValue)(e.v)&&(t[e.n]=e.v,shouldAddToDependency(e.n,e.v)&&r.push(e.v))})),l.log&&o.push({line:e.position.start.line,column:e.position.start.column,reason:l.log.reason})}));const n=/^[.#]?[A-Za-z0-9_\-:]+$/,a=/^([.#]?[A-Za-z0-9_-]+(\s+|\s*>\s*))+([.#]?[A-Za-z0-9_\-:]+)$/;e.selectors.forEach((function(i){const r={key:i,val:t};if(i.match(n)||i.match(a)){if(!processPseudoClass(r,o,e))return;if(!_compilationConfig.compileOptionsObject.optimizeDescMeta&&i.match(a))try{r.val=Object.assign({},r.val),r.val._meta={},r.val._meta.ruleDef=(0,_compress.compressDescSelector)((0,_cssWhat.default)(r.key))}catch(s){return void o.push({line:e.position.start.line,column:e.position.start.column,reason:"ERROR: 选择器 `"+r.key+"` 不支持"})}s[r.key]=(0,_utils.extend)({},s[r.key]||{},r.val)}else o.push({line:e.position.start.line,column:e.position.start.column,reason:"ERROR: 选择器 `"+i+"` 非法"})}))}function processMediaQueryCss(e,s,t,o,i,r){const n=(0,_mediaquery.validateMediaCondition)(e.media),a=n.value,l=n.reason;if(l&&l.length>0&&n.reason.forEach((s=>{t.push({line:e.position.start.line,column:e.position.start.column,reason:s})})),!a)return;const c=i?`${i} and ${a}`:a;e.rules.forEach((e=>{if("rule"===e.type){if(e.declarations&&e.declarations.length){let i=(0,_mediaquery.findMediaClassByCondition)(s,c);const n=!i;n&&(i={condition:c}),processSingleClass(e,i,{},t,o,r),n&&s.push(i)}}else"media"===e.type&&processMediaQueryCss(e,s,t,o,c,r)}))}function processPseudoClass(e,s,t){const o=e.key.indexOf(":");if(o>-1){const i=e.key.slice(o);if(!(0,_validator.validatePseudoClass)(i))return s.push({line:t.position.start.line,column:t.position.start.column,reason:"ERROR: 不支持伪类选择器`"+i+"`"}),!1;e.key=e.key.slice(0,o);const r={};Object.keys(e.val).forEach((function(s){r[s+i]=e.val[s]})),e.val=r}return!0}module.exports={processImport:processImport,processSingleClass:processSingleClass,processMediaQueryCss:processMediaQueryCss,shouldAddToDependency:shouldAddToDependency};
"use strict";var _fs=_interopRequireDefault(require("fs")),_path=_interopRequireDefault(require("path")),_css=_interopRequireDefault(require("css")),_cssWhat=_interopRequireDefault(require("css-what")),_compilationConfig=require("@hap-toolkit/shared-utils/compilation-config"),_validator=require("./validator"),_compress=require("./compress"),_mediaquery=require("./mediaquery"),_utils=require("../utils");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const VALID_IMPORT_FLAG="__VALID_IMPORT__",IMPORT_REG=new RegExp("@import\\s+__VALID_IMPORT__((?:['\"]([^()]+?)['\"])|(?:(?:url\\(([^()]+?)\\))))((?:\\s*)|(?:\\s+[^;]+))__VALID_IMPORT__;","g"),IMPORT_URL_REG=new RegExp("__VALID_IMPORT__(?:(?:['\"]([^()]+?)['\"])|(?:(?:url\\(([^()]+?)\\))))(\\s+[^;]+)?__VALID_IMPORT__;");function shouldAddToDependency(e,s){return(0,_validator.mightReferlocalResource)(e)&&!/^(data:|http)/.test(s)&&"string"==typeof s}function signValidCssImport(e){let s=!0;const t=_css.default.parse(e);if(t&&"stylesheet"===t.type&&t.stylesheet&&t.stylesheet.rules&&t.stylesheet.rules.length){t.stylesheet.rules.forEach((e=>{const t=e.type;"import"!==t&&"comment"!==t&&(s=!1),"import"===t&&s&&(e.import=VALID_IMPORT_FLAG+e.import+VALID_IMPORT_FLAG)})),e=_css.default.stringify(t)}return e}function processImport(e,s,t,o){let i=signValidCssImport(e);const n=i.match(IMPORT_REG);return n&&n.length>0&&(s?n.forEach((e=>{const n=e.match(IMPORT_URL_REG);if(n.length>1){const r=n[3],a=_path.default.resolve(s,n[1]||n[2]),l=_fs.default.readFileSync(a);if(l){const s=_path.default.dirname(a);let n=processImport(l.toString(),s,t,o);r&&(n=(0,_mediaquery.wrapMediaCode)(n,r)),i=i.replace(e,"\n"+n+"\n"),o.push(a)}else t.push({line:1,column:1,reason:"ERROR: 找不到文件 `"+e+"` , 导入失败"})}})):t.push({line:1,column:1,reason:"ERROR: 找不到资源路径, 无法处理@import"})),i}function processSingleClass(e,s,t,o,i,n){e.declarations.forEach((function(e){if("declaration"!==e.type)return;const s=e.property,r=e.value,a=(0,_utils.hyphenedToCamelCase)(s),l=(0,_validator.validate)(a,r,{filePath:i});l.value.forEach((e=>{(0,_utils.isValidValue)(e.v)&&(t[e.n]=e.v,shouldAddToDependency(e.n,e.v)&&n.push(e.v))})),l.log&&o.push({line:e.position.start.line,column:e.position.start.column,reason:l.log.reason})}));const r=/^[.#]?[A-Za-z0-9_\-:]+$/,a=/^([.#]?[A-Za-z0-9_\-:]+(\s+|\s*>\s*))+([.#]?[A-Za-z0-9_\-:]+)+$/;e.selectors.forEach((function(i){const n={key:i,val:t};if(i.match(r)||i.match(a)){if(!processPseudoClass(n,o,e))return;if(!_compilationConfig.compileOptionsObject.optimizeDescMeta&&i.match(a))try{n.val=Object.assign({},n.val),n.val._meta={},n.val._meta.ruleDef=(0,_compress.compressDescSelector)((0,_cssWhat.default)(n.key))}catch(s){return void o.push({line:e.position.start.line,column:e.position.start.column,reason:"ERROR: 选择器 `"+n.key+"` 不支持"})}s[n.key]=(0,_utils.extend)({},s[n.key]||{},n.val)}else o.push({line:e.position.start.line,column:e.position.start.column,reason:"ERROR: 选择器 `"+i+"` 非法"})}))}function processMediaQueryCss(e,s,t,o,i,n){const r=(0,_mediaquery.validateMediaCondition)(e.media),a=r.value,l=r.reason;if(l&&l.length>0&&r.reason.forEach((s=>{t.push({line:e.position.start.line,column:e.position.start.column,reason:s})})),!a)return;const c=i?`${i} and ${a}`:a;e.rules.forEach((e=>{if("rule"===e.type){if(e.declarations&&e.declarations.length){let i=(0,_mediaquery.findMediaClassByCondition)(s,c);const r=!i;r&&(i={condition:c}),processSingleClass(e,i,{},t,o,n),r&&s.push(i)}}else"media"===e.type&&processMediaQueryCss(e,s,t,o,c,n)}))}function processPseudoClass(e,s,t){const o=e.key.indexOf(":"),i=e.key.match(/(:[A-Za-z]+)+/g);if(i&&i.length){const n=i.filter((e=>!(0,_validator.validatePseudoClass)(e)));if(n.length)return s.push({line:t.position.start.line,column:t.position.start.column,reason:"ERROR: 不支持伪类选择器`"+n.toString()+"`"}),!1;if(1===i.length&&o+i[0].length===e.key.length){e.key=e.key.slice(0,o);const s={};Object.keys(e.val).forEach((function(t){s[t+i[0]]=e.val[t]})),e.val=s}}return!0}module.exports={processImport:processImport,processSingleClass:processSingleClass,processMediaQueryCss:processMediaQueryCss,shouldAddToDependency:shouldAddToDependency};
//# sourceMappingURL=process.js.map

@@ -1,2 +0,2 @@

"use strict";var _utils=require("../utils");const colorNames={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",green:"#008000",greenyellow:"#ADFF2F",grey:"#808080",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"},cssPseudoClasses=["disabled","checked","focus","active","visited","autoplay","selected"],cssPseudoElements=["before","after","first-line","first-letter"],cssLengthUnits=["px","%","dp"],cssAngleUnits=["deg"],cssTimeUnits=["ms","s"],logTypes=["NOTE","WARNING","ERROR"],cssUseLocalResource=["mylocation","mylocationIconPath","backgroundImage","starForeground","starSecondary","starBackground","fontSrc"],REGEXP_LENGTH=/^[-+]?[0-9]*\.?[0-9]+(.*)$/,REGEXP_COLOR_LONG=/^#[0-9a-fA-F]{6}$/,REGEXP_COLOR_SHORT=/^#[0-9a-fA-F]{3}$/,REGEXP_COLOR_RGB=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/,REGEXP_COLOR_RGBA=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d*\.?\d+)\s*\)$/,REGEXP_COLOR_HSL=/^hsl\(\s*(\d+)\s*,\s*(\d+%)\s*,\s*(\d+%)\s*\)$/,REGEXP_COLOR_HSLA=/^hsla\(\s*(\d+)\s*,\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d*\.?\d+)\s*\)$/,REGEXP_ARRAYCOLORSTOP=/(rgba|rgb)\([0-9,.\spx%]+\)\s?[0-9-+pxdp%]*|[#]?\w+\s?[0-9+-\spxdp%]*/gi,REGEXP_ARRAYCOLOR=/(?:.+?\s(?=[#a-zA-Z]))|.+/g,REGEXP_INT=/^[-+]?[0-9]+$/,REGEXP_URL=/^url\(\s*(['"]?)\s*([^'"()]+?)\s*\1\s*\)$/,REGEXP_LOCAL=/^local\(\s*(['"]?)\s*([^'"()]+?)\s*\1\s*\)$/,REGEXP_NAME=/^([a-zA-Z_]+[a-zA-Z0-9]*\s*,\s*)*[a-zA-Z_]+[a-zA-Z0-9]*$/,REGEXP_TIME=/^[-+]?[0-9]*\.?[0-9]+(.*)$/,REGEXP_PROPERTY_NAME=/^[a-zA-Z-]+[a-zA-Z0-9-]*/,REGEXP_TIME_DURATION=/^[0-9]+\.?[0-9]*m?s/,REGEXP_TRANSFORM_ITEM=/^([0-9a-zA-Z]+)\((.*)\)$/,REGEXP_GRADIENT_DIRECTION=/^\s*(to|bottom|right|left|top)|[-+]?[0-9]*\.?[0-9]+(.*)/,REGEXP_ANGLE=/^\s*[-+]?[0-9]*\.?[0-9]+(.*)/,REGEXP_NUMBER=/^[-+]?[0-9]*\.?[0-9]+$/,REGEXP_POSITION=/^(center|left|right|top|bottom)$/,REGEXP_FONT_WEIGHT=/^(normal|bold|lighter|bolder)$/,REGEXP_INT_ABS=/^[1-9]\d*$/,REGEXP_CARET=/^(auto|transparent|currentColor)$/,REGEXP_CUBIC_BEZIER=/cubic-bezier\(\s*(0|1|0.\d+),\s*(\d+|\d+\.\d+),\s*(0|1|0.\d+),\s*(\d+|\d+\.\d+)\s*\)/,REGEXP_STEPS=/steps\(\s*(\d+)\s*(?:,\s*(jump-start|jump-end|jump-none|jump-both|start|end))?\)/;function toCamelCase(e){return e.replace(/-(\w)/g,(function(e,t){return t.toUpperCase()}))}const timingFunctions=["linear","ease","ease-in","ease-out","ease-in-out","cubic-bezier","step-start","step-end","jump-start","jump-end","jump-none","jump-both","start","end"],validateTimingFunction=function(e){const t=timingFunctions;if(t.indexOf(e)>=0)return{value:e};if(e.startsWith("cubic-bezier")){return e.match(REGEXP_CUBIC_BEZIER)?{value:e}:{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 须符合 cubic-bezier(<x1>,<y1>,<x2>,<y2>) 格式,详情请查阅文档"}}}if(e.startsWith("steps")){const t=e.match(REGEXP_STEPS);if(!t)return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 须符合 steps(<number>,direction) 格式,详情请查阅文档"}};const a=t[2]||"end";return{value:`steps(${t[1]}, ${a})`}}return{value:null,reason:function(e,a){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+a+"` 无效 ` (有效枚举值为: `"+t.join("`|`")+"`)"}}},validateTime=function(e){const t=(e=(e||"").toString()).match(REGEXP_TIME);if(t){const a=t[1];if(a){if(cssTimeUnits.indexOf(a.toLowerCase())>=0)return{value:e};return{value:parseFloat(e)+cssTimeUnits[0],reason:function(e){return"ERROR: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 不支持单位 `"+a+"`, 目前仅支持 `"+JSON.stringify(cssTimeUnits)+"`"}}}return{value:parseFloat(e)+cssTimeUnits[0],reason:function(e){return"WARN: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 没有指定单位,默认为 `"+cssTimeUnits[0]+"`"}}}return{value:null,reason:function(e,t){return"ERROR: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 的值不正确 `"+t+"` (仅支持数值)"}}},validator={transition:function(e){const t=e.replace(/;$/,"").split(",").filter(Boolean);let a=[{n:"transitionProperty",v:""},{n:"transitionTimingFunction",v:""},{n:"transitionDuration",v:""},{n:"transitionDelay",v:""}],n=!1;return t.forEach((e=>{e=e.toString().split(" ").filter(Boolean);let t=!0,l=!0;const r={transitionProperty:"all",transitionTimingFunction:"ease",transitionDuration:"0s",transitionDelay:"0s"};e.forEach((e=>timingFunctions.filter((t=>e.startsWith(t))).length?r.transitionTimingFunction=e:e.match(REGEXP_TIME_DURATION)&&t?(t=!1,r.transitionDuration=e):e.match(REGEXP_TIME_DURATION)&&!t?r.transitionDelay=e:e.match(REGEXP_PROPERTY_NAME)&&l?(l=!1,r.transitionProperty=e):void 0)),Object.keys(r).forEach((e=>{switch(e){case"transitionProperty":"none"===r[e].trim()&&(n=!0),a[0].v=(a[0].v+`,${toCamelCase(r[e])}`).trim().replace(/^,/,"");break;case"transitionTimingFunction":a[1].v=(a[1].v+`,${r[e]}`).trim().replace(/^,/,"");break;case"transitionDuration":a[2].v=(a[2].v+`,${r[e]}`).trim().replace(/^,/,"");break;default:a[3].v=(a[3].v+`,${r[e]}`).trim().replace(/^,/,"")}}))})),n?(a=[],{value:a}):{value:a}},transitionProperty:function(e){return{value:toCamelCase(e).trim()||["all"]}},transitionDelay:validateTime,transitionDuration:validateTime,transitionTimingFunction:validateTimingFunction,length:function(e,t,a){const n=(e=(e||"").toString().trim()).match(REGEXP_LENGTH);if(t||(t=cssLengthUnits),n){const l=n[1];if(0!=+e||l){if(l){if(t.indexOf(l.toLowerCase())>=0)return{value:e};return{value:a||parseFloat(e)+t[0],reason:function(e){return"ERROR: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 不支持单位 `"+l+"`, 目前仅支持 `"+JSON.stringify(t)+"`"}}}return{value:parseFloat(e)+t[0],reason:function(e){return"WARN: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 没有指定单位,默认为 `"+t[0]+"`"}}}return{value:+e+t[0]}}return{value:null,reason:function(e,t){return"ERROR: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 不正确(仅支持数值)"}}},color:function(e){if((e=(e||"").toString().trim()).match(REGEXP_COLOR_LONG))return{value:e};if(e.match(REGEXP_COLOR_SHORT))return{value:"#"+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]};if(colorNames[e])return{value:colorNames[e]};let t,a,n,l,r,o,i,s;return REGEXP_COLOR_RGB.exec(e)&&(t=REGEXP_COLOR_RGB.exec(e),a=parseInt(t[1]),n=parseInt(t[2]),l=parseInt(t[3]),a>=0&&a<=255&&n>=0&&n<=255&&l>=0&&l<=255)?{value:"rgb("+[a,n,l].join(",")+")"}:REGEXP_COLOR_RGBA.exec(e)&&(t=REGEXP_COLOR_RGBA.exec(e),a=parseInt(t[1]),n=parseInt(t[2]),l=parseInt(t[3]),r=parseFloat(t[4]),a>=0&&a<=255&&n>=0&&n<=255&&l>=0&&l<=255&&r>=0&&r<=1)?{value:"rgba("+[a,n,l,r].join(",")+")"}:(t=REGEXP_COLOR_HSL.exec(e)||REGEXP_COLOR_HSLA.exec(e),t&&(o=parseInt(t[1]),i=parseInt(t[2]),s=parseInt(t[3]),r=parseFloat(t[4]),o>=0&&o<=360&&i>=0&&i<=100&&s>=0&&s<=100)?r>=0&&r<=1?{value:`hsla(${o},${i}%,${s}%,${r})`}:{value:`hsl(${o},${i}%,${s}%)`}:"transparent"===e?{value:"rgba(0,0,0,0)"}:{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的颜色值 `"+t+"` 无效`"}})},number:function(e){const t=(e=(e||"").toString().trim()).match(REGEXP_NUMBER);return t&&!t[1]?{value:parseFloat(e)}:{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 无效 ` (仅支持数值)"}}},arraynumber:function(e,t){const a=(t=(t||"").toString().trim()).split(/[,\s]+/);if(a&&a.length<=e.length){const t=[];let n;const l=[];let r=0;return a.forEach(((e,a)=>{if(n=validator.number(e),(0,_utils.isValidValue)(n.value)&&t.push(n.value),n.reason){let t=n.reason(a.toString(),e,n.value);const o=t.match(/^([A-Z]+):/);if(o){const e=logTypes.indexOf(o[1]);r<logTypes.indexOf(o[1])&&(r=e),t=t.replace(o[0],"").trim()}l.push(t)}})),{value:r<2?(0,_utils.splitAttr)(e,t):null,reason:l.length>0?function(e,t){return logTypes[r]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+l.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},integer:function(e){return(e=(e||"").toString()).match(REGEXP_INT)?{value:parseInt(e,10)}:{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 无效 ` (仅支持整数)"}}},iterationcount:function(e){return(e=(e||"").toString().trim()).match(REGEXP_INT)?{value:parseInt(e,10)}:/^infinite$/.test(e)?{value:-1}:{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 无效 ` (仅支持整数)"}}},url:function(e,t){if((e=(e||"").toString().trim()).match(/^none$/i))return{value:"none"};const a=REGEXP_URL.exec(e);if(a&&a[2].trim()){let e=a[2];return/^data:/.test(e)||/^http(s)?:/.test(e)||(e=(0,_utils.resolvePath)(e,t.filePath)),{value:e}}return{value:null,reason:function(e,t){return"WARN: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 必须是 none 或者 url(...)"}}},fontSrc:function(e,t){const a=(e=(e||"").toString().trim()).split(",");if(a&&a.length>0){const e=[],n=[];let l=0;return a.forEach((function(a,r){a=a.trim();let o={};if(/^local/.test(a)){const e=REGEXP_LOCAL.exec(a);let t;e&&e[2].trim()&&(t="local://"+e[2]),o={value:t,reason:t?null:function(e,t){return"WARN: @font-face中属性src`"+(0,_utils.camelCaseToHyphened)(e)+"`的值`"+t+"` 存在问题"}}}else o=validator.url(a,t);if((0,_utils.isValidValue)(o.value)&&e.push(o.value),o.reason){let e=o.reason(r.toString(),a,o.value);const t=e.match(/^([A-Z]+):/);if(t){const a=logTypes.indexOf(t[1]);l<logTypes.indexOf(t[1])&&(l=a),e=e.replace(t[0],"").trim()}n.push(e)}})),{value:l<2?e:null,reason:n.length>0?function(e,t){return logTypes[l]+": @font-face中属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+n.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: @font-face中属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题"}}},fontFamily:function(e){return(e=(e||"").toString().replace(/['"]+/g,""))?{value:e}:{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题"}}},position:function(e,t){e=(e||"").toString(),t||(t=cssLengthUnits);const a=e.split(/\s+|,/);if(a&&a.length>1){const e=[];let n;const l=[];let r=0;return a.length>3&&(r=1,l.push("属性数目最多为3个, 忽略多余属性")),a.forEach(((a,o)=>{if(n=validator.length(a,t),(0,_utils.isValidValue)(n.value)&&e.push(n.value),n.reason){let e=n.reason(o.toString(),a,n.value);const t=e.match(/^([A-Z]+):/);if(t){const a=logTypes.indexOf(t[1]);r<logTypes.indexOf(t[1])&&(r=a),e=e.replace(t[0],"").trim()}l.push(e)}})),{value:r<2?e.join(" "):null,reason:l.length>0?function(e,t){return logTypes[r]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+l.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},name:function(e){return(e=(e||"").toString()).match(REGEXP_NAME)?{value:e}:{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},multipleAttributesValidator:function(e,t){const a=(e=(e||"").toString().trim()).replace(/\)\s+/g,")|").split("|");if(a&&a.length){const e={};let n;const l=[];let r=0;return a.forEach(((a,o)=>{const i=a.match(REGEXP_TRANSFORM_ITEM);if(i){let a=i[2];const o=i[1],s=t[o];if("function"==typeof s){if("translate"!==o||/[,\s]+/.test(a.trim())||(a+=",0px"),n=s(a),n.value instanceof Array?n.value.forEach((t=>{(0,_utils.isValidValue)(t.v)&&(e[t.n]=t.v)})):(0,_utils.isValidValue)(n.value)&&(e[o]=n.value),n.reason){let e=n.reason(o,a,n.value);const t=e.match(/^([A-Z]+):/);if(t){const a=logTypes.indexOf(t[1]);r<logTypes.indexOf(t[1])&&(r=a),e=e.replace(t[0],"").trim()}l.push(e)}}else l.push("属性 `"+o+"` 不支持")}else r=2,l.push("属性 `"+o+"` 的值格式不正确")})),{value:(0,_utils.isEmptyObject)(e)?null:JSON.stringify(e),reason:l.length>0?function(e,t){return logTypes[r]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+l.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},background:function(e){let t=(e=(e||"").toString().trim()).split();if(e.indexOf("-gradient")>0){const a=/(repeating-linear|linear)[\s\S]*?(?=\s*(repeating|linear)|$)/g;t=e.match(a)}const a={values:[]};if(t&&t.length){const e=[];let n=0;return t.forEach((t=>{let l,r;if(t.indexOf("-gradient")>=0&&(l=t.indexOf("repeating")>=0?"repeatingLinearGradient":"linearGradient",r=backgroundValidatorMap[l]),"function"==typeof r){const o=r(t);if((0,_utils.isValidValue)(o.value)){const e=JSON.parse(o.value);a.values.push(e)}if(o.reason){let a=o.reason(l,t,o.value);const r=a.match(/^([A-Z]+):/);if(r){const e=logTypes.indexOf(r[1]);n<logTypes.indexOf(r[1])&&(n=e),a=a.replace(r[0],"").trim()}e.push(a)}}else n=2,e.push("背景类型 `"+t+"`暂不支持")})),{value:n<2?JSON.stringify(a):null,reason:e.length>0?function(t,a){return logTypes[n]+": 属性`"+(0,_utils.camelCaseToHyphened)(t)+"` 的值 `"+a+"` 存在问题: \n "+e.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},backgroundSize:function(e,t){let a,n;e=(e||"").toString().trim(),t||(t=cssLengthUnits);let l=0;const r=e.split(/\s+/);if(1===r.length){if(["cover","contain","auto"].indexOf(r[0])>-1)return{value:r[0]};if(n=validator.length(r[0],t),n.reason){a=n.reason("0",r[0],n.value);const e=a.match(/^([A-Z]+):/);e&&(l=logTypes.indexOf(e[1]),a=a.replace(e[0],"").trim())}return{value:(0,_utils.isValidValue)(n.value)?n.value:null,reason:a?function(e,t){return logTypes[l]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+a}:null}}if(2===r.length){const e=[],o=[];return r.forEach(((r,i)=>{if("auto"!==r){if(n=validator.length(r,t),(0,_utils.isValidValue)(n.value)&&e.push(n.value),n.reason){a=n.reason(i.toString(),r,n.value);const e=a.match(/^([A-Z]+):/);if(e){const t=logTypes.indexOf(e[1]);l<t&&(l=t),a=a.replace(e[0],"").trim()}o.push(a)}}else e.push(r)})),{value:l<2?e.join(" "):null,reason:o.length>0?function(e,t){return logTypes[l]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+o.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},backgroundPosition:function(e,t){let a,n;e=(e||"").toString().trim(),t||(t=cssLengthUnits);let l=0,r=[];const o=[],i=e.split(/\s+/);if(1===i.length){if(REGEXP_POSITION.test(i[0]))return{value:i[0]};if(n=validator.length(i[0],t),n.reason){a=n.reason("0",i[0],n.value);const e=a.match(/^([A-Z]+):/);e&&(l=logTypes.indexOf(e[1]),a=a.replace(e[0],"").trim())}return{value:(0,_utils.isValidValue)(n.value)?n.value:null,reason:a?function(e,t){return logTypes[l]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+a}:null}}if(2===i.length){const e=i[0],s=i[1];if("center"===e){if(REGEXP_POSITION.test(s))r=i;else if(n=validator.length(s,t),(0,_utils.isValidValue)(n.value)&&(r=i),n.reason){a=n.reason("1",s,n.value);const e=a.match(/^([A-Z]+):/);if(e){const t=logTypes.indexOf(e[1]);l<t&&(l=t),a=a.replace(e[0],"").trim()}o.push(a)}}else if(["top","bottom"].indexOf(e)>-1&&["left","right","center"].indexOf(s)>-1)r=i;else if(n=validator.length(e,t),["left","right"].indexOf(e)>-1||(0,_utils.isValidValue)(n.value))if(["top","bottom","center"].indexOf(s)>-1)r=i;else if(n=validator.length(s,t),(0,_utils.isValidValue)(n.value)&&(r=i),n.reason){a=n.reason("1",s,n.value);const e=a.match(/^([A-Z]+):/);if(e){const t=logTypes.indexOf(e[1]);l<t&&(l=t),a=a.replace(e[0],"").trim()}o.push(a)}return r.length||(l=2,o.length||o.push("属性值格式不正确")),{value:l<2?r.join(" "):null,reason:o.length>0?function(e,t){return logTypes[l]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+o.join("\n ")}:null}}if(3===i.length){const e=i[0],a=i[1],n=i[2];return REGEXP_POSITION.test(e)&&(REGEXP_POSITION.test(a)&&(0,_utils.isValidValue)(validator.length(n,t).value)||REGEXP_POSITION.test(n)&&(0,_utils.isValidValue)(validator.length(a,t).value))&&(r=i),r.length||(l=2,o.length||o.push("属性值格式不正确")),{value:l<2?r.join(" "):null,reason:o.length>0?function(e,t){return logTypes[l]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+o.join("\n ")}:null}}if(4===i.length){const e=i[0],a=i[1],n=i[2],s=i[3];return REGEXP_POSITION.test(e)&&REGEXP_POSITION.test(n)&&(0,_utils.isValidValue)(validator.length(a,t).value)&&(0,_utils.isValidValue)(validator.length(s,t).value)&&(r=i),r.length||(l=2,o.length||o.push("属性值格式不正确")),{value:l<2?r.join(" "):null,reason:o.length>0?function(e,t){return logTypes[l]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+o.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},fontWeight:function(e,t){return e=(e||"").toString().trim(),REGEXP_FONT_WEIGHT.test(e)||REGEXP_INT_ABS.test(e)?{value:e}:{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确,仅支持normal,bold,lighter,bolder或正整数"}}},linearGradient:function(e){e=(e||"").toString().trim();const t={type:"",directions:["to","bottom"],values:[]};let a={},n={};const l=[];let r=0;const o=e.match(/^([0-9a-zA-Z-]+)\(([\s\S]*)\)/);if(o){const i=(0,_utils.hyphenedToCamelCase)(o[1]);t.type=i;const s=o[2].split(/,/);if(REGEXP_GRADIENT_DIRECTION.test(s[0])){let e;if(/(to|bottom|right|left|top)/.test(s[0])?e=backgroundValidatorMap.linearGradientDirection:s[0].match(REGEXP_ANGLE)&&(e=backgroundValidatorMap.linearGradientAngle),"function"==typeof e&&(n=e(s[0]),s.splice(0,1),(0,_utils.isValidValue)(n.value)&&(t.directions=n.value.split(/\s+/)),n.reason)){let e=n.reason(i,s[0],n.value);if(e){const t=e.match(/^([A-Z]+):/);if(t){const a=logTypes.indexOf(t[1]);r<logTypes.indexOf(t[1])&&(r=a),e=e.replace(t[0],"").trim()}l.push(e)}}}if(s.length>0){if(a=(0,backgroundValidatorMap.linearGradientColor)(s),(0,_utils.isValidValue)(a.value)&&(t.values=JSON.parse(a.value)),a.reason){let e=a.reason(i,s,a.value);if(e){const t=e.match(/^([A-Z]+):/);if(t){const a=logTypes.indexOf(t[1]);r<logTypes.indexOf(t[1])&&(r=a),e=e.replace(t[0],"").trim()}l.push(e)}}}else r=2,l.push("参数 `"+e+"`缺少过渡颜色");return{value:r<2?JSON.stringify(t):null,reason:l.length>0?function(e,t){return logTypes[r]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+l.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},time:validateTime,angle:function(e){const t=(e=(e||"").toString().trim()).match(REGEXP_ANGLE);if(t){const a=t[1];if(a){if(cssAngleUnits.indexOf(a.toLowerCase())>=0)return{value:e};{let t=parseFloat(e);return"rad"===a.toLowerCase()?(t=Math.round(180*t/Math.PI),{value:t+cssAngleUnits[0],reason:function(e){return"WARN: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 不支持单位 `"+a+"`, 自动转换为 `"+cssAngleUnits[0]+"`"}}):{value:t+cssAngleUnits[0],reason:function(e){return"ERROR: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 不支持单位 `"+a+"`, 目前仅支持 `"+JSON.stringify(cssAngleUnits)+"`"}}}}return{value:parseFloat(e)+cssAngleUnits[0],reason:function(e){return"WARN: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 没有指定单位,默认为 `"+cssAngleUnits[0]+"`"}}}return{value:null,reason:function(e,t){return"ERROR: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 的值不正确 `"+t+"` (仅支持数值)"}}},enum:function(e,t){const a=e.indexOf(t);return a>0?{value:t}:0===a?{value:t,reason:!1}:{value:null,reason:function(t,a){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(t)+"` 的值 `"+a+"` 无效 ` (有效枚举值为: `"+e.join("`|`")+"`)"}}},animationTimingFunction:validateTimingFunction,gradientdirection:function(e){const t=(e=(e||"").toString().trim()).split(/\s+/);let a=[];const n=[];return t.forEach((e=>{"to"===e?n.push(0):"top"===e|"bottom"===e?n.push(1):"left"===e|"right"===e?n.push(2):a.push(e)})),0===a.length&&n.length>1&&n.length<4&&0===n[0]&&0!==n[1]?n[2]&&n[1]+n[2]!==3&&(a=t):a=t,{value:a.length>0?null:t.join(" "),reason:a.length>0?function(e){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的属性值 `"+a.join(" ")+"` 格式不正确 `)"}:null}},multipleLength:function(e,t){return"auto"===(e=(e||"").toString().trim())?{value:e}:/^[-+]?[0-9]+.*/.test(e)?validator.length(e,t):{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 的值不正确"}}},arraylength:function(e,t,a){const n=(t=(t||"").toString().trim()).split(/[,\s]+/);if(n&&n.length<=e.length){const l=[];let r;const o=[];let i=0;const s=/^margin.*/.test(e[0]);return n.forEach(((e,t)=>{if(r=s?validator.multipleLength(e,a):validator.length(e,a),(0,_utils.isValidValue)(r.value)&&l.push(r.value),r.reason){let a=r.reason(t.toString(),e,r.value);const n=a.match(/^([A-Z]+):/);if(n){const e=logTypes.indexOf(n[1]);i<logTypes.indexOf(n[1])&&(i=e),a=a.replace(n[0],"").trim()}o.push(a)}})),{value:i<2?(0,_utils.splitAttr)(e,l):null,reason:o.length>0?function(e){return logTypes[i]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+o.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},arraycolor:function(e,t){const a=(t=(t||"").toString()).match(REGEXP_ARRAYCOLOR);if(a&&a.length<=4){const t=[];let n;const l=[];let r=0;return a.forEach(((e,a)=>{if(n=validator.color(e),(0,_utils.isValidValue)(n.value)&&t.push(n.value),n.reason){let t=n.reason(a.toString(),e,n.value);const o=t.match(/^([A-Z]+):/);if(o){const e=logTypes.indexOf(o[1]);r<logTypes.indexOf(o[1])&&(r=e),t=t.replace(o[0],"").trim()}l.push(t)}})),{value:r<2?(0,_utils.splitAttr)(e,t):null,reason:l.length>0?function(e,t){return logTypes[r]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+l.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},arraycolorstop:function(e){const t=(e=(e||"").toString().trim()).match(REGEXP_ARRAYCOLORSTOP);if(t&&t.length>1){const a=[],n=[];let l=0;return t.forEach(((t,r)=>{const o=t.match(/[\s]+[-+0-9]+(px|%|dp)?$/),i=[];if(o){const e=validator.length(o[0]),a=t.indexOf(o[0]);if(t=t.substring(0,a),(0,_utils.isValidValue)(e.value)&&i.push(e.value),e.reason){let t=e.reason(r.toString(),o[0],e.value);const a=t.match(/^([A-Z]+):/);if(a){const e=logTypes.indexOf(a[1]);l<logTypes.indexOf(a[1])&&(l=e),t=t.replace(a[0],"").trim()}n.push(t)}}if(t){const e=validator.color(t);if((0,_utils.isValidValue)(e.value)&&i.unshift(e.value),a.push(i.join(" ")),e.reason){let a=e.reason(r.toString(),t,e.value);const o=a.match(/^([A-Z]+):/);if(o){const e=logTypes.indexOf(o[1]);l<logTypes.indexOf(o[1])&&(l=e),a=a.replace(o[0],"").trim()}n.push(a)}}else l=2,n.push("参数 `"+e+"` 格式不正确")})),{value:l<2?JSON.stringify(a):null,reason:n.length>0?function(e,t){return logTypes[l]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+n.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确,至少指定两种颜色"}}},mylocation:function(e,t){const a=(e=(e||"").toString()).split(/\s+/);if(a&&a.length<=3){const e=[];let n;const l=[];let r=0;const o=[];let i=-1;return a.forEach(((a,i)=>{if((0,_utils.isValidValue)(validator.color(a).value)?(o.push(i),0===i?(n=validatorMap.mylocationFillColor(a),e.push({n:"mylocationFillColor",v:n.value})):1===i&&(n=validatorMap.mylocationStrokeColor(a),e.push({n:"mylocationStrokeColor",v:n.value}))):(0,_utils.isValidValue)(validator.url(a,t).value)?(o.push(2),n=validatorMap.mylocationIconPath(a,t),e.push({n:"mylocationIconPath",v:n.value})):(n={},r=2,l.push("属性`"+i+"` 的值 `"+a+"` 存在问题: \n 不满足fillColor、strokeColor和iconPath的检验标准")),n&&n.reason){let e=n.reason(i.toString(),a,n.value);const t=e.match(/^([A-Z]+):/);if(t){const a=logTypes.indexOf(t[1]);r<logTypes.indexOf(t[1])&&(r=a),e=e.replace(t[0],"").trim()}l.push(e)}})),o.forEach((e=>{e>i?i=e:(r=2,l.push("必须按顺序设置属性fillColor、strokeColor和iconPath"))})),{value:r<2?e:null,reason:l.length>0?function(e,t){return logTypes[r]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+l.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},border:function(e,t,a){e=(e=(e||"").toString()).replace(/\s*,\s*/g,","),a=(a||"").toString();const n=e.split(/\s+/);if(n&&n.length<=3){let e,l=[];const r=[];let o=0;const i=[];let s=-1;return n.forEach(((n,s)=>{if((0,_utils.isValidValue)(validator.length(n,t).value)){i.push(0);const t="border"+a+"Width";e=validatorMap[t](n),e.value instanceof Array?l=l.concat(e.value):a&&(0,_utils.isValidValue)(e.value)&&l.push({n:t,v:e.value})}else if((0,_utils.isValidValue)(validatorMap.borderStyle(n).value))i.push(1),e=validatorMap.borderStyle(n),l.push({n:"border"+a+"Style",v:n});else if((0,_utils.isValidValue)(validator.color(n).value)){i.push(2);const t="border"+a+"Color";e=validatorMap[t](n),e.value instanceof Array?l=l.concat(e.value):a&&(0,_utils.isValidValue)(e.value)&&l.push({n:t,v:e.value})}else e={},o=2,r.push("属性`"+s+"` 的值 `"+n+"` 存在问题: \n 不满足width、style和color的检验标准");if(e&&e.reason){let t=e.reason(s.toString(),n,e.value);const a=t.match(/^([A-Z]+):/);if(a){const e=logTypes.indexOf(a[1]);o<logTypes.indexOf(a[1])&&(o=e),t=t.replace(a[0],"").trim()}r.push(t)}})),i.forEach((e=>{e>s?s=e:(o=2,r.push("必须按顺序设置属性width style color"))})),{value:o<2?l:null,reason:r.length>0?function(e,t){return logTypes[o]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+r.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},borderLeft:function(e,t){return validator.border(e,t,"Left")},borderRight:function(e,t){return validator.border(e,t,"Right")},borderTop:function(e,t){return validator.border(e,t,"Top")},borderBottom:function(e,t){return validator.border(e,t,"Bottom")},display:function(e){e=(e||"").toString();const t=["flex","none"],a=t.indexOf(e);return a>0?{value:e}:"block"===e?{value:"flex",reason:function(e,a){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+a+"` 需修改为flex ` (有效枚举值为: `"+t.join("`|`")+"`)"}}:0===a?{value:e,reason:!1}:{value:null,reason:function(e,a){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+a+"` 无效 ` (有效枚举值为: `"+t.join("`|`")+"`)"}}},caretColor:function(e,t){return e=(e||"").toString().trim(),REGEXP_CARET.test(e)||(0,_utils.isValidValue)(validator.color(e).value)?{value:e}:{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确,仅支持auto,currentColor,transparent或<color>"}}}};function _lengthValidator(e,t,a){return validator.length(a,e,t)}function makeLengthValidator(e,t){return _lengthValidator.bind(null,e,t)}function _multipleAttributesValidator(e,t){return validator.multipleAttributesValidator(t,e)}function makeMultipleAttributesValidator(e){return _multipleAttributesValidator.bind(null,e)}function makeEnumValidator(e){return validator.enum.bind(null,e)}function makeAbbrAttrValidator(e,t){return validator[e].bind(null,t)}const backgroundValidatorMap={linearGradient:validator.linearGradient,repeatingLinearGradient:validator.linearGradient,linearGradientColor:validator.arraycolorstop,linearGradientAngle:validator.angle,linearGradientDirection:validator.gradientdirection},transformValidatorMap={translate:makeAbbrAttrValidator("arraylength",["translateX","translateY"]),translateX:validator.length,translateY:validator.length,scale:makeAbbrAttrValidator("arraynumber",["scaleX","scaleY"]),scaleX:validator.number,scaleY:validator.number,rotate:validator.angle,rotateX:validator.angle,rotateY:validator.angle},filterValidatorMap={blur:makeLengthValidator(["px","dp"],"0px")},validatorMap={transition:validator.transition,transitionProperty:validator.transitionProperty,transitionDelay:validator.transitionDelay,transitionDuration:validator.transitionDuration,transitionTimingFunction:validateTimingFunction,width:validator.length,height:validator.length,minHeight:validator.length,minWidth:validator.length,maxHeight:validator.length,maxWidth:validator.length,padding:makeAbbrAttrValidator("arraylength",["paddingTop","paddingRight","paddingBottom","paddingLeft"]),paddingLeft:validator.length,paddingRight:validator.length,paddingTop:validator.length,paddingBottom:validator.length,margin:makeAbbrAttrValidator("arraylength",["marginTop","marginRight","marginBottom","marginLeft"]),marginLeft:validator.multipleLength,marginRight:validator.multipleLength,marginTop:validator.multipleLength,marginBottom:validator.multipleLength,border:validator.border,borderLeft:validator.borderLeft,borderRight:validator.borderRight,borderTop:validator.borderTop,borderBottom:validator.borderBottom,borderWidth:makeAbbrAttrValidator("arraylength",["borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth"]),borderLeftWidth:validator.length,borderTopWidth:validator.length,borderRightWidth:validator.length,borderBottomWidth:validator.length,borderColor:makeAbbrAttrValidator("arraycolor",["borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),borderLeftColor:validator.color,borderTopColor:validator.color,borderRightColor:validator.color,borderBottomColor:validator.color,borderStyle:makeEnumValidator(["solid","dotted","dashed"]),borderRadius:validator.length,borderBottomLeftRadius:validator.length,borderBottomRightRadius:validator.length,borderTopLeftRadius:validator.length,borderTopRightRadius:validator.length,indicatorSize:validator.length,indicatorTop:validator.length,indicatorRight:validator.length,indicatorBottom:validator.length,indicatorLeft:validator.length,filter:makeMultipleAttributesValidator(filterValidatorMap),overflow:makeEnumValidator(["hidden","visible"]),flex:validator.number,flexGrow:validator.number,flexShrink:validator.number,flexBasis:validator.length,flexDirection:makeEnumValidator(["row","column","row-reverse","column-reverse"]),flexWrap:makeEnumValidator(["nowrap","wrap","wrap-reverse"]),justifyContent:makeEnumValidator(["flex-start","flex-end","center","space-between","space-around"]),alignItems:makeEnumValidator(["stretch","flex-start","flex-end","center"]),alignContent:makeEnumValidator(["stretch","flex-start","flex-end","center","space-between","space-around"]),alignSelf:makeEnumValidator(["auto","flex-start","flex-end","center","baseline","stretch"]),position:makeEnumValidator(["static","fixed","relative","absolute"]),top:validator.length,bottom:validator.length,left:validator.length,right:validator.length,zIndex:validator.integer,opacity:validator.number,background:validator.background,backgroundColor:validator.color,backgroundImage:validator.url,backgroundSize:validator.backgroundSize,backgroundRepeat:makeEnumValidator(["no-repeat","repeat","repeat-x","repeat-y"]),backgroundPosition:validator.backgroundPosition,display:validator.display,visibility:makeEnumValidator(["visible","hidden"]),objectFit:makeEnumValidator(["fill","contain","cover","none","scale-down"]),altObjectFit:makeEnumValidator(["fill","contain","cover","none","scale-down"]),lines:validator.integer,color:validator.color,fontSize:validator.length,fontStyle:makeEnumValidator(["normal","italic"]),fontWeight:validator.fontWeight,textDecoration:makeEnumValidator(["none","underline","line-through"]),textAlign:makeEnumValidator(["left","center","right"]),lineHeight:validator.length,textOverflow:makeEnumValidator(["clip","ellipsis"]),textIndent:makeLengthValidator(["px","dp","cm","%","em"]),transform:makeMultipleAttributesValidator(transformValidatorMap),transformOrigin:validator.position,animationName:validator.name,animationDuration:validator.time,animationTimingFunction:validateTimingFunction,pageAnimationName:validator.name,pageTransformOrigin:validator.position,animationDelay:validator.time,animationIterationCount:validator.iterationcount,animationFillMode:makeEnumValidator(["none","forwards"]),animationDirection:makeEnumValidator(["normal","reverse","alternate","alternate-reverse"]),placeholderColor:validator.color,selectedColor:validator.color,textColor:validator.color,timeColor:validator.color,textHighlightColor:validator.color,strokeWidth:validator.length,progressColor:validator.color,indicatorColor:validator.color,indicatorSelectedColor:validator.color,slideWidth:validator.length,slideMargin:validator.length,resizeMode:makeEnumValidator(["cover","contain","stretch","center"]),columns:validator.number,columnSpan:validator.number,maskColor:validator.color,blockColor:validator.color,mylocation:validator.mylocation,mylocationFillColor:validator.color,mylocationStrokeColor:validator.color,mylocationIconPath:validator.url,caretColor:validator.caretColor,thumbColor:validator.color,trackColor:validator.color,layerColor:validator.color,layoutType:makeEnumValidator(["grid","stagger"]),starBackground:validator.url,starForeground:validator.url,starSecondary:validator.url,fontSrc:validator.fontSrc,fontFamily:validator.fontFamily};function validate(e,t,a){let n,l;const r=validatorMap[e];return"function"==typeof r?(n="function"!=typeof t?mightReferlocalResource(e)?r(t,a):r(t):{value:t},n.reason&&(l={reason:n.reason(e,t,n.value)})):(n={value:t},l={reason:"WARN: 样式名`"+(0,_utils.camelCaseToHyphened)(e)+"`不支持"}),{value:n.value instanceof Array?n.value:[{n:e,v:n.value}],log:l}}function mightReferlocalResource(e){return cssUseLocalResource.indexOf(e)>-1}function validatePseudoClass(e){return e=e.replace(/^(:)/,""),cssPseudoClasses.indexOf(e.toLowerCase())>=0}function validatePseudoElement(e){return e=e.replace(/^(:)/,""),cssPseudoElements.indexOf(e.toLowerCase())>=0}module.exports={colorNames:colorNames,validatorMap:validatorMap,validator:validator,validate:validate,validatePseudoClass:validatePseudoClass,validatePseudoElement:validatePseudoElement,enumValidatorFactory:makeEnumValidator,mightReferlocalResource:mightReferlocalResource};
"use strict";var _utils=require("../utils");const colorNames={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",green:"#008000",greenyellow:"#ADFF2F",grey:"#808080",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"},cssPseudoClasses=["disabled","checked","focus","active","visited","autoplay","selected","blur","quick-blur","quick-focus"],cssPseudoElements=["before","after","first-line","first-letter"],cssLengthUnits=["px","%","dp"],cssAngleUnits=["deg"],cssTimeUnits=["ms","s"],logTypes=["NOTE","WARNING","ERROR"],cssUseLocalResource=["mylocation","mylocationIconPath","backgroundImage","starForeground","starSecondary","starBackground","fontSrc"],REGEXP_LENGTH=/^[-+]?[0-9]*\.?[0-9]+(.*)$/,REGEXP_COLOR_LONG=/^#[0-9a-fA-F]{6}$/,REGEXP_COLOR_SHORT=/^#[0-9a-fA-F]{3}$/,REGEXP_COLOR_ALPHA_LONG=/^#[0-9a-fA-F]{8}$/,REGEXP_COLOR_ALPHA_SHORT=/^#[0-9a-fA-F]{4}$/,REGEXP_COLOR_RGB=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/,REGEXP_COLOR_RGBA=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d*\.?\d+)\s*\)$/,REGEXP_COLOR_HSL=/^hsl\(\s*(\d+)\s*,\s*(\d+%)\s*,\s*(\d+%)\s*\)$/,REGEXP_COLOR_HSLA=/^hsla\(\s*(\d+)\s*,\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d*\.?\d+)\s*\)$/,REGEXP_ARRAYCOLORSTOP=/(rgba|rgb)\([0-9,.\spx%]+\)\s?[0-9-+pxdp%]*|[#]?\w+\s?[0-9+-\spxdp%]*/gi,REGEXP_ARRAYCOLOR=/(?:.+?\s(?=[#a-zA-Z]))|.+/g,REGEXP_INT=/^[-+]?[0-9]+$/,REGEXP_URL=/^url\(\s*(['"]?)\s*([^'"()]+?)\s*\1\s*\)$/,REGEXP_LOCAL=/^local\(\s*(['"]?)\s*([^'"()]+?)\s*\1\s*\)$/,REGEXP_NAME=/^([a-zA-Z_]+[a-zA-Z0-9]*\s*,\s*)*[a-zA-Z_]+[a-zA-Z0-9]*$/,REGEXP_TIME=/^[-+]?[0-9]*\.?[0-9]+(.*)$/,REGEXP_PROPERTY_NAME=/^[a-zA-Z-]+[a-zA-Z0-9-]*/,REGEXP_TIME_DURATION=/^[0-9]+\.?[0-9]*m?s/,REGEXP_TRANSFORM_ITEM=/^([0-9a-zA-Z]+)\((.*)\)$/,REGEXP_GRADIENT_DIRECTION=/^\s*(to|bottom|right|left|top)|[-+]?[0-9]*\.?[0-9]+(.*)/,REGEXP_ANGLE=/^\s*[-+]?[0-9]*\.?[0-9]+(.*)/,REGEXP_NUMBER=/^[-+]?[0-9]*\.?[0-9]+$/,REGEXP_POSITION=/^(center|left|right|top|bottom)$/,REGEXP_FONT_WEIGHT=/^(normal|bold|lighter|bolder)$/,REGEXP_INT_ABS=/^[1-9]\d*$/,REGEXP_CARET=/^(auto|transparent|currentColor)$/,REGEXP_CUBIC_BEZIER=/cubic-bezier\(\s*(0|1|0.\d+),\s*(\d+|\d+\.\d+),\s*(0|1|0.\d+),\s*(\d+|\d+\.\d+)\s*\)/,REGEXP_STEPS=/steps\(\s*(\d+)\s*(?:,\s*(jump-start|jump-end|jump-none|jump-both|start|end))?\)/;function toCamelCase(e){return e.replace(/-(\w)/g,(function(e,t){return t.toUpperCase()}))}const timingFunctions=["linear","ease","ease-in","ease-out","ease-in-out","cubic-bezier","step-start","step-end","jump-start","jump-end","jump-none","jump-both","start","end"],validateTimingFunction=function(e){const t=timingFunctions;if(t.indexOf(e)>=0)return{value:e};if(e.startsWith("cubic-bezier")){return e.match(REGEXP_CUBIC_BEZIER)?{value:e}:{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 须符合 cubic-bezier(<x1>,<y1>,<x2>,<y2>) 格式,详情请查阅文档"}}}if(e.startsWith("steps")){const t=e.match(REGEXP_STEPS);if(!t)return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 须符合 steps(<number>,direction) 格式,详情请查阅文档"}};const a=t[2]||"end";return{value:`steps(${t[1]}, ${a})`}}return{value:null,reason:function(e,a){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+a+"` 无效 ` (有效枚举值为: `"+t.join("`|`")+"`)"}}},validateTime=function(e){const t=(e=(e||"").toString()).match(REGEXP_TIME);if(t){const a=t[1];if(a){if(cssTimeUnits.indexOf(a.toLowerCase())>=0)return{value:e};return{value:parseFloat(e)+cssTimeUnits[0],reason:function(e){return"ERROR: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 不支持单位 `"+a+"`, 目前仅支持 `"+JSON.stringify(cssTimeUnits)+"`"}}}return{value:parseFloat(e)+cssTimeUnits[0],reason:function(e){return"WARN: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 没有指定单位,默认为 `"+cssTimeUnits[0]+"`"}}}return{value:null,reason:function(e,t){return"ERROR: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 的值不正确 `"+t+"` (仅支持数值)"}}},validator={transition:function(e){const t=e.replace(/;$/,"").split(",").filter(Boolean);let a=[{n:"transitionProperty",v:""},{n:"transitionTimingFunction",v:""},{n:"transitionDuration",v:""},{n:"transitionDelay",v:""}],n=!1;return t.forEach((e=>{e=e.toString().split(" ").filter(Boolean);let t=!0,l=!0;const r={transitionProperty:"all",transitionTimingFunction:"ease",transitionDuration:"0s",transitionDelay:"0s"};e.forEach((e=>timingFunctions.filter((t=>e.startsWith(t))).length?r.transitionTimingFunction=e:e.match(REGEXP_TIME_DURATION)&&t?(t=!1,r.transitionDuration=e):e.match(REGEXP_TIME_DURATION)&&!t?r.transitionDelay=e:e.match(REGEXP_PROPERTY_NAME)&&l?(l=!1,r.transitionProperty=e):void 0)),Object.keys(r).forEach((e=>{switch(e){case"transitionProperty":"none"===r[e].trim()&&(n=!0),a[0].v=(a[0].v+`,${toCamelCase(r[e])}`).trim().replace(/^,/,"");break;case"transitionTimingFunction":a[1].v=(a[1].v+`,${r[e]}`).trim().replace(/^,/,"");break;case"transitionDuration":a[2].v=(a[2].v+`,${r[e]}`).trim().replace(/^,/,"");break;default:a[3].v=(a[3].v+`,${r[e]}`).trim().replace(/^,/,"")}}))})),n?(a=[],{value:a}):{value:a}},transitionProperty:function(e){return{value:toCamelCase(e).trim()||["all"]}},transitionDelay:validateTime,transitionDuration:validateTime,transitionTimingFunction:validateTimingFunction,length:function(e,t,a){const n=(e=(e||"").toString().trim()).match(REGEXP_LENGTH);if(t||(t=cssLengthUnits),n){const l=n[1];if(0!=+e||l){if(l){if(t.indexOf(l.toLowerCase())>=0)return{value:e};return{value:a||parseFloat(e)+t[0],reason:function(e){return"ERROR: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 不支持单位 `"+l+"`, 目前仅支持 `"+JSON.stringify(t)+"`"}}}return{value:parseFloat(e)+t[0],reason:function(e){return"WARN: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 没有指定单位,默认为 `"+t[0]+"`"}}}return{value:+e+t[0]}}return{value:null,reason:function(e,t){return"ERROR: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 不正确(仅支持数值)"}}},color:function(e){if((e=(e||"").toString().trim()).match(REGEXP_COLOR_LONG)||e.match(REGEXP_COLOR_ALPHA_LONG)||e.match(REGEXP_COLOR_ALPHA_SHORT))return{value:e};if(e.match(REGEXP_COLOR_SHORT))return{value:"#"+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]};if(colorNames[e])return{value:colorNames[e]};let t,a,n,l,r,o,i,s;return REGEXP_COLOR_RGB.exec(e)&&(t=REGEXP_COLOR_RGB.exec(e),a=parseInt(t[1]),n=parseInt(t[2]),l=parseInt(t[3]),a>=0&&a<=255&&n>=0&&n<=255&&l>=0&&l<=255)?{value:"rgb("+[a,n,l].join(",")+")"}:REGEXP_COLOR_RGBA.exec(e)&&(t=REGEXP_COLOR_RGBA.exec(e),a=parseInt(t[1]),n=parseInt(t[2]),l=parseInt(t[3]),r=parseFloat(t[4]),a>=0&&a<=255&&n>=0&&n<=255&&l>=0&&l<=255&&r>=0&&r<=1)?{value:"rgba("+[a,n,l,r].join(",")+")"}:(t=REGEXP_COLOR_HSL.exec(e)||REGEXP_COLOR_HSLA.exec(e),t&&(o=parseInt(t[1]),i=parseInt(t[2]),s=parseInt(t[3]),r=parseFloat(t[4]),o>=0&&o<=360&&i>=0&&i<=100&&s>=0&&s<=100)?r>=0&&r<=1?{value:`hsla(${o},${i}%,${s}%,${r})`}:{value:`hsl(${o},${i}%,${s}%)`}:"transparent"===e?{value:"rgba(0,0,0,0)"}:{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的颜色值 `"+t+"` 无效`"}})},number:function(e){const t=(e=(e||"").toString().trim()).match(REGEXP_NUMBER);return t&&!t[1]?{value:parseFloat(e)}:{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 无效 ` (仅支持数值)"}}},arraynumber:function(e,t){const a=(t=(t||"").toString().trim()).split(/[,\s]+/);if(a&&a.length<=e.length){const t=[];let n;const l=[];let r=0;return a.forEach(((e,a)=>{if(n=validator.number(e),(0,_utils.isValidValue)(n.value)&&t.push(n.value),n.reason){let t=n.reason(a.toString(),e,n.value);const o=t.match(/^([A-Z]+):/);if(o){const e=logTypes.indexOf(o[1]);r<logTypes.indexOf(o[1])&&(r=e),t=t.replace(o[0],"").trim()}l.push(t)}})),{value:r<2?(0,_utils.splitAttr)(e,t):null,reason:l.length>0?function(e,t){return logTypes[r]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+l.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},integer:function(e){return(e=(e||"").toString()).match(REGEXP_INT)?{value:parseInt(e,10)}:{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 无效 ` (仅支持整数)"}}},iterationcount:function(e){return(e=(e||"").toString().trim()).match(REGEXP_INT)?{value:parseInt(e,10)}:/^infinite$/.test(e)?{value:-1}:{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 无效 ` (仅支持整数)"}}},url:function(e,t){if((e=(e||"").toString().trim()).match(/^none$/i))return{value:"none"};const a=REGEXP_URL.exec(e);if(a&&a[2].trim()){let e=a[2];return/^data:/.test(e)||/^http(s)?:/.test(e)||(e=(0,_utils.resolvePath)(e,t.filePath)),{value:e}}return{value:null,reason:function(e,t){return"WARN: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 必须是 none 或者 url(...)"}}},fontSrc:function(e,t){const a=(e=(e||"").toString().trim()).split(",");if(a&&a.length>0){const e=[],n=[];let l=0;return a.forEach((function(a,r){a=a.trim();let o={};if(/^local/.test(a)){const e=REGEXP_LOCAL.exec(a);let t;e&&e[2].trim()&&(t="local://"+e[2]),o={value:t,reason:t?null:function(e,t){return"WARN: @font-face中属性src`"+(0,_utils.camelCaseToHyphened)(e)+"`的值`"+t+"` 存在问题"}}}else o=validator.url(a,t);if((0,_utils.isValidValue)(o.value)&&e.push(o.value),o.reason){let e=o.reason(r.toString(),a,o.value);const t=e.match(/^([A-Z]+):/);if(t){const a=logTypes.indexOf(t[1]);l<logTypes.indexOf(t[1])&&(l=a),e=e.replace(t[0],"").trim()}n.push(e)}})),{value:l<2?e:null,reason:n.length>0?function(e,t){return logTypes[l]+": @font-face中属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+n.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: @font-face中属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题"}}},fontFamily:function(e){return(e=(e||"").toString().replace(/['"]+/g,""))?{value:e}:{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题"}}},position:function(e,t){e=(e||"").toString(),t||(t=cssLengthUnits);const a=e.split(/\s+|,/);if(a&&a.length>1){const e=[];let n;const l=[];let r=0;return a.length>3&&(r=1,l.push("属性数目最多为3个, 忽略多余属性")),a.forEach(((a,o)=>{if(n=validator.length(a,t),(0,_utils.isValidValue)(n.value)&&e.push(n.value),n.reason){let e=n.reason(o.toString(),a,n.value);const t=e.match(/^([A-Z]+):/);if(t){const a=logTypes.indexOf(t[1]);r<logTypes.indexOf(t[1])&&(r=a),e=e.replace(t[0],"").trim()}l.push(e)}})),{value:r<2?e.join(" "):null,reason:l.length>0?function(e,t){return logTypes[r]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+l.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},name:function(e){return(e=(e||"").toString()).match(REGEXP_NAME)?{value:e}:{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},multipleAttributesValidator:function(e,t){const a=(e=(e||"").toString().trim()).replace(/\)\s+/g,")|").split("|");if(a&&a.length){const e={};let n;const l=[];let r=0;return a.forEach(((a,o)=>{const i=a.match(REGEXP_TRANSFORM_ITEM);if(i){let a=i[2];const o=i[1],s=t[o];if("function"==typeof s){if("translate"!==o||/[,\s]+/.test(a.trim())||(a+=",0px"),n=s(a),n.value instanceof Array?n.value.forEach((t=>{(0,_utils.isValidValue)(t.v)&&(e[t.n]=t.v)})):(0,_utils.isValidValue)(n.value)&&(e[o]=n.value),n.reason){let e=n.reason(o,a,n.value);const t=e.match(/^([A-Z]+):/);if(t){const a=logTypes.indexOf(t[1]);r<logTypes.indexOf(t[1])&&(r=a),e=e.replace(t[0],"").trim()}l.push(e)}}else l.push("属性 `"+o+"` 不支持")}else r=2,l.push("属性 `"+o+"` 的值格式不正确")})),{value:(0,_utils.isEmptyObject)(e)?null:JSON.stringify(e),reason:l.length>0?function(e,t){return logTypes[r]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+l.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},background:function(e){let t=(e=(e||"").toString().trim()).split();if(e.indexOf("-gradient")>0){const a=/(repeating-linear|linear)[\s\S]*?(?=\s*(repeating|linear)|$)/g;t=e.match(a)}const a={values:[]};if(t&&t.length){const e=[];let n=0;return t.forEach((t=>{let l,r;if(t.indexOf("-gradient")>=0&&(l=t.indexOf("repeating")>=0?"repeatingLinearGradient":"linearGradient",r=backgroundValidatorMap[l]),"function"==typeof r){const o=r(t);if((0,_utils.isValidValue)(o.value)){const e=JSON.parse(o.value);a.values.push(e)}if(o.reason){let a=o.reason(l,t,o.value);const r=a.match(/^([A-Z]+):/);if(r){const e=logTypes.indexOf(r[1]);n<logTypes.indexOf(r[1])&&(n=e),a=a.replace(r[0],"").trim()}e.push(a)}}else n=2,e.push("背景类型 `"+t+"`暂不支持")})),{value:n<2?JSON.stringify(a):null,reason:e.length>0?function(t,a){return logTypes[n]+": 属性`"+(0,_utils.camelCaseToHyphened)(t)+"` 的值 `"+a+"` 存在问题: \n "+e.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},backgroundSize:function(e,t){let a,n;e=(e||"").toString().trim(),t||(t=cssLengthUnits);let l=0;const r=e.split(/\s+/);if(1===r.length){if(["cover","contain","auto"].indexOf(r[0])>-1)return{value:r[0]};if(n=validator.length(r[0],t),n.reason){a=n.reason("0",r[0],n.value);const e=a.match(/^([A-Z]+):/);e&&(l=logTypes.indexOf(e[1]),a=a.replace(e[0],"").trim())}return{value:(0,_utils.isValidValue)(n.value)?n.value:null,reason:a?function(e,t){return logTypes[l]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+a}:null}}if(2===r.length){const e=[],o=[];return r.forEach(((r,i)=>{if("auto"!==r){if(n=validator.length(r,t),(0,_utils.isValidValue)(n.value)&&e.push(n.value),n.reason){a=n.reason(i.toString(),r,n.value);const e=a.match(/^([A-Z]+):/);if(e){const t=logTypes.indexOf(e[1]);l<t&&(l=t),a=a.replace(e[0],"").trim()}o.push(a)}}else e.push(r)})),{value:l<2?e.join(" "):null,reason:o.length>0?function(e,t){return logTypes[l]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+o.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},backgroundPosition:function(e,t){let a,n;e=(e||"").toString().trim(),t||(t=cssLengthUnits);let l=0,r=[];const o=[],i=e.split(/\s+/);if(1===i.length){if(REGEXP_POSITION.test(i[0]))return{value:i[0]};if(n=validator.length(i[0],t),n.reason){a=n.reason("0",i[0],n.value);const e=a.match(/^([A-Z]+):/);e&&(l=logTypes.indexOf(e[1]),a=a.replace(e[0],"").trim())}return{value:(0,_utils.isValidValue)(n.value)?n.value:null,reason:a?function(e,t){return logTypes[l]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+a}:null}}if(2===i.length){const e=i[0],s=i[1];if("center"===e){if(REGEXP_POSITION.test(s))r=i;else if(n=validator.length(s,t),(0,_utils.isValidValue)(n.value)&&(r=i),n.reason){a=n.reason("1",s,n.value);const e=a.match(/^([A-Z]+):/);if(e){const t=logTypes.indexOf(e[1]);l<t&&(l=t),a=a.replace(e[0],"").trim()}o.push(a)}}else if(["top","bottom"].indexOf(e)>-1&&["left","right","center"].indexOf(s)>-1)r=i;else if(n=validator.length(e,t),["left","right"].indexOf(e)>-1||(0,_utils.isValidValue)(n.value))if(["top","bottom","center"].indexOf(s)>-1)r=i;else if(n=validator.length(s,t),(0,_utils.isValidValue)(n.value)&&(r=i),n.reason){a=n.reason("1",s,n.value);const e=a.match(/^([A-Z]+):/);if(e){const t=logTypes.indexOf(e[1]);l<t&&(l=t),a=a.replace(e[0],"").trim()}o.push(a)}return r.length||(l=2,o.length||o.push("属性值格式不正确")),{value:l<2?r.join(" "):null,reason:o.length>0?function(e,t){return logTypes[l]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+o.join("\n ")}:null}}if(3===i.length){const e=i[0],a=i[1],n=i[2];return REGEXP_POSITION.test(e)&&(REGEXP_POSITION.test(a)&&(0,_utils.isValidValue)(validator.length(n,t).value)||REGEXP_POSITION.test(n)&&(0,_utils.isValidValue)(validator.length(a,t).value))&&(r=i),r.length||(l=2,o.length||o.push("属性值格式不正确")),{value:l<2?r.join(" "):null,reason:o.length>0?function(e,t){return logTypes[l]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+o.join("\n ")}:null}}if(4===i.length){const e=i[0],a=i[1],n=i[2],s=i[3];return REGEXP_POSITION.test(e)&&REGEXP_POSITION.test(n)&&(0,_utils.isValidValue)(validator.length(a,t).value)&&(0,_utils.isValidValue)(validator.length(s,t).value)&&(r=i),r.length||(l=2,o.length||o.push("属性值格式不正确")),{value:l<2?r.join(" "):null,reason:o.length>0?function(e,t){return logTypes[l]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+o.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},fontWeight:function(e,t){return e=(e||"").toString().trim(),REGEXP_FONT_WEIGHT.test(e)||REGEXP_INT_ABS.test(e)?{value:e}:{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确,仅支持normal,bold,lighter,bolder或正整数"}}},linearGradient:function(e){e=(e||"").toString().trim();const t={type:"",directions:["to","bottom"],values:[]};let a={},n={};const l=[];let r=0;const o=e.match(/^([0-9a-zA-Z-]+)\(([\s\S]*)\)/);if(o){const i=(0,_utils.hyphenedToCamelCase)(o[1]);t.type=i;const s=o[2].split(/,/);if(REGEXP_GRADIENT_DIRECTION.test(s[0])){let e;if(/(to|bottom|right|left|top)/.test(s[0])?e=backgroundValidatorMap.linearGradientDirection:s[0].match(REGEXP_ANGLE)&&(e=backgroundValidatorMap.linearGradientAngle),"function"==typeof e&&(n=e(s[0]),s.splice(0,1),(0,_utils.isValidValue)(n.value)&&(t.directions=n.value.split(/\s+/)),n.reason)){let e=n.reason(i,s[0],n.value);if(e){const t=e.match(/^([A-Z]+):/);if(t){const a=logTypes.indexOf(t[1]);r<logTypes.indexOf(t[1])&&(r=a),e=e.replace(t[0],"").trim()}l.push(e)}}}if(s.length>0){if(a=(0,backgroundValidatorMap.linearGradientColor)(s),(0,_utils.isValidValue)(a.value)&&(t.values=JSON.parse(a.value)),a.reason){let e=a.reason(i,s,a.value);if(e){const t=e.match(/^([A-Z]+):/);if(t){const a=logTypes.indexOf(t[1]);r<logTypes.indexOf(t[1])&&(r=a),e=e.replace(t[0],"").trim()}l.push(e)}}}else r=2,l.push("参数 `"+e+"`缺少过渡颜色");return{value:r<2?JSON.stringify(t):null,reason:l.length>0?function(e,t){return logTypes[r]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+l.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},time:validateTime,angle:function(e){const t=(e=(e||"").toString().trim()).match(REGEXP_ANGLE);if(t){const a=t[1];if(a){if(cssAngleUnits.indexOf(a.toLowerCase())>=0)return{value:e};{let t=parseFloat(e);return"rad"===a.toLowerCase()?(t=Math.round(180*t/Math.PI),{value:t+cssAngleUnits[0],reason:function(e){return"WARN: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 不支持单位 `"+a+"`, 自动转换为 `"+cssAngleUnits[0]+"`"}}):{value:t+cssAngleUnits[0],reason:function(e){return"ERROR: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 不支持单位 `"+a+"`, 目前仅支持 `"+JSON.stringify(cssAngleUnits)+"`"}}}}return{value:parseFloat(e)+cssAngleUnits[0],reason:function(e){return"WARN: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 没有指定单位,默认为 `"+cssAngleUnits[0]+"`"}}}return{value:null,reason:function(e,t){return"ERROR: 属性 `"+(0,_utils.camelCaseToHyphened)(e)+"` 的值不正确 `"+t+"` (仅支持数值)"}}},enum:function(e,t){const a=e.indexOf(t);return a>0?{value:t}:0===a?{value:t,reason:!1}:{value:null,reason:function(t,a){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(t)+"` 的值 `"+a+"` 无效 ` (有效枚举值为: `"+e.join("`|`")+"`)"}}},animationTimingFunction:validateTimingFunction,gradientdirection:function(e){const t=(e=(e||"").toString().trim()).split(/\s+/);let a=[];const n=[];return t.forEach((e=>{"to"===e?n.push(0):"top"===e|"bottom"===e?n.push(1):"left"===e|"right"===e?n.push(2):a.push(e)})),0===a.length&&n.length>1&&n.length<4&&0===n[0]&&0!==n[1]?n[2]&&n[1]+n[2]!==3&&(a=t):a=t,{value:a.length>0?null:t.join(" "),reason:a.length>0?function(e){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的属性值 `"+a.join(" ")+"` 格式不正确 `)"}:null}},multipleLength:function(e,t){return"auto"===(e=(e||"").toString().trim())?{value:e}:/^[-+]?[0-9]+.*/.test(e)?validator.length(e,t):{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 的值不正确"}}},arraylength:function(e,t,a){const n=(t=(t||"").toString().trim()).split(/[,\s]+/);if(n&&n.length<=e.length){const l=[];let r;const o=[];let i=0;const s=/^margin.*/.test(e[0]);return n.forEach(((e,t)=>{if(r=s?validator.multipleLength(e,a):validator.length(e,a),(0,_utils.isValidValue)(r.value)&&l.push(r.value),r.reason){let a=r.reason(t.toString(),e,r.value);const n=a.match(/^([A-Z]+):/);if(n){const e=logTypes.indexOf(n[1]);i<logTypes.indexOf(n[1])&&(i=e),a=a.replace(n[0],"").trim()}o.push(a)}})),{value:i<2?(0,_utils.splitAttr)(e,l):null,reason:o.length>0?function(e){return logTypes[i]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+o.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},arraycolor:function(e,t){const a=(t=(t||"").toString()).match(REGEXP_ARRAYCOLOR);if(a&&a.length<=4){const t=[];let n;const l=[];let r=0;return a.forEach(((e,a)=>{if(n=validator.color(e),(0,_utils.isValidValue)(n.value)&&t.push(n.value),n.reason){let t=n.reason(a.toString(),e,n.value);const o=t.match(/^([A-Z]+):/);if(o){const e=logTypes.indexOf(o[1]);r<logTypes.indexOf(o[1])&&(r=e),t=t.replace(o[0],"").trim()}l.push(t)}})),{value:r<2?(0,_utils.splitAttr)(e,t):null,reason:l.length>0?function(e,t){return logTypes[r]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+l.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},arraycolorstop:function(e){const t=(e=(e||"").toString().trim()).match(REGEXP_ARRAYCOLORSTOP);if(t&&t.length>1){const a=[],n=[];let l=0;return t.forEach(((t,r)=>{const o=t.match(/[\s]+[-+0-9]+(px|%|dp)?$/),i=[];if(o){const e=validator.length(o[0]),a=t.indexOf(o[0]);if(t=t.substring(0,a),(0,_utils.isValidValue)(e.value)&&i.push(e.value),e.reason){let t=e.reason(r.toString(),o[0],e.value);const a=t.match(/^([A-Z]+):/);if(a){const e=logTypes.indexOf(a[1]);l<logTypes.indexOf(a[1])&&(l=e),t=t.replace(a[0],"").trim()}n.push(t)}}if(t){const e=validator.color(t);if((0,_utils.isValidValue)(e.value)&&i.unshift(e.value),a.push(i.join(" ")),e.reason){let a=e.reason(r.toString(),t,e.value);const o=a.match(/^([A-Z]+):/);if(o){const e=logTypes.indexOf(o[1]);l<logTypes.indexOf(o[1])&&(l=e),a=a.replace(o[0],"").trim()}n.push(a)}}else l=2,n.push("参数 `"+e+"` 格式不正确")})),{value:l<2?JSON.stringify(a):null,reason:n.length>0?function(e,t){return logTypes[l]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+n.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确,至少指定两种颜色"}}},mylocation:function(e,t){const a=(e=(e||"").toString()).split(/\s+/);if(a&&a.length<=3){const e=[];let n;const l=[];let r=0;const o=[];let i=-1;return a.forEach(((a,i)=>{if((0,_utils.isValidValue)(validator.color(a).value)?(o.push(i),0===i?(n=validatorMap.mylocationFillColor(a),e.push({n:"mylocationFillColor",v:n.value})):1===i&&(n=validatorMap.mylocationStrokeColor(a),e.push({n:"mylocationStrokeColor",v:n.value}))):(0,_utils.isValidValue)(validator.url(a,t).value)?(o.push(2),n=validatorMap.mylocationIconPath(a,t),e.push({n:"mylocationIconPath",v:n.value})):(n={},r=2,l.push("属性`"+i+"` 的值 `"+a+"` 存在问题: \n 不满足fillColor、strokeColor和iconPath的检验标准")),n&&n.reason){let e=n.reason(i.toString(),a,n.value);const t=e.match(/^([A-Z]+):/);if(t){const a=logTypes.indexOf(t[1]);r<logTypes.indexOf(t[1])&&(r=a),e=e.replace(t[0],"").trim()}l.push(e)}})),o.forEach((e=>{e>i?i=e:(r=2,l.push("必须按顺序设置属性fillColor、strokeColor和iconPath"))})),{value:r<2?e:null,reason:l.length>0?function(e,t){return logTypes[r]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+l.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},border:function(e,t,a){e=(e=(e||"").toString()).replace(/\s*,\s*/g,","),a=(a||"").toString();const n=e.split(/\s+/);if(n&&n.length<=3){let e,l=[];const r=[];let o=0;const i=[];let s=-1;return n.forEach(((n,s)=>{if((0,_utils.isValidValue)(validator.length(n,t).value)){i.push(0);const t="border"+a+"Width";e=validatorMap[t](n),e.value instanceof Array?l=l.concat(e.value):a&&(0,_utils.isValidValue)(e.value)&&l.push({n:t,v:e.value})}else if((0,_utils.isValidValue)(validatorMap.borderStyle(n).value))i.push(1),e=validatorMap.borderStyle(n),l.push({n:"border"+a+"Style",v:n});else if((0,_utils.isValidValue)(validator.color(n).value)){i.push(2);const t="border"+a+"Color";e=validatorMap[t](n),e.value instanceof Array?l=l.concat(e.value):a&&(0,_utils.isValidValue)(e.value)&&l.push({n:t,v:e.value})}else e={},o=2,r.push("属性`"+s+"` 的值 `"+n+"` 存在问题: \n 不满足width、style和color的检验标准");if(e&&e.reason){let t=e.reason(s.toString(),n,e.value);const a=t.match(/^([A-Z]+):/);if(a){const e=logTypes.indexOf(a[1]);o<logTypes.indexOf(a[1])&&(o=e),t=t.replace(a[0],"").trim()}r.push(t)}})),i.forEach((e=>{e>s?s=e:(o=2,r.push("必须按顺序设置属性width style color"))})),{value:o<2?l:null,reason:r.length>0?function(e,t){return logTypes[o]+": 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 存在问题: \n "+r.join("\n ")}:null}}return{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确"}}},borderLeft:function(e,t){return validator.border(e,t,"Left")},borderRight:function(e,t){return validator.border(e,t,"Right")},borderTop:function(e,t){return validator.border(e,t,"Top")},borderBottom:function(e,t){return validator.border(e,t,"Bottom")},display:function(e){e=(e||"").toString();const t=["flex","none"],a=t.indexOf(e);return a>0?{value:e}:"block"===e?{value:"flex",reason:function(e,a){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+a+"` 需修改为flex ` (有效枚举值为: `"+t.join("`|`")+"`)"}}:0===a?{value:e,reason:!1}:{value:null,reason:function(e,a){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+a+"` 无效 ` (有效枚举值为: `"+t.join("`|`")+"`)"}}},caretColor:function(e,t){return e=(e||"").toString().trim(),REGEXP_CARET.test(e)||(0,_utils.isValidValue)(validator.color(e).value)?{value:e}:{value:null,reason:function(e,t){return"ERROR: 属性`"+(0,_utils.camelCaseToHyphened)(e)+"` 的值 `"+t+"` 格式不正确,仅支持auto,currentColor,transparent或<color>"}}}};function _lengthValidator(e,t,a){return validator.length(a,e,t)}function makeLengthValidator(e,t){return _lengthValidator.bind(null,e,t)}function _multipleAttributesValidator(e,t){return validator.multipleAttributesValidator(t,e)}function makeMultipleAttributesValidator(e){return _multipleAttributesValidator.bind(null,e)}function makeEnumValidator(e){return validator.enum.bind(null,e)}function makeAbbrAttrValidator(e,t){return validator[e].bind(null,t)}const backgroundValidatorMap={linearGradient:validator.linearGradient,repeatingLinearGradient:validator.linearGradient,linearGradientColor:validator.arraycolorstop,linearGradientAngle:validator.angle,linearGradientDirection:validator.gradientdirection},transformValidatorMap={translate:makeAbbrAttrValidator("arraylength",["translateX","translateY"]),translateX:validator.length,translateY:validator.length,scale:makeAbbrAttrValidator("arraynumber",["scaleX","scaleY"]),scaleX:validator.number,scaleY:validator.number,rotate:validator.angle,rotateX:validator.angle,rotateY:validator.angle},filterValidatorMap={blur:makeLengthValidator(["px","dp"],"0px")},validatorMap={transition:validator.transition,transitionProperty:validator.transitionProperty,transitionDelay:validator.transitionDelay,transitionDuration:validator.transitionDuration,transitionTimingFunction:validateTimingFunction,width:validator.length,height:validator.length,minHeight:validator.length,minWidth:validator.length,maxHeight:validator.length,maxWidth:validator.length,padding:makeAbbrAttrValidator("arraylength",["paddingTop","paddingRight","paddingBottom","paddingLeft"]),paddingLeft:validator.length,paddingRight:validator.length,paddingTop:validator.length,paddingBottom:validator.length,margin:makeAbbrAttrValidator("arraylength",["marginTop","marginRight","marginBottom","marginLeft"]),marginLeft:validator.multipleLength,marginRight:validator.multipleLength,marginTop:validator.multipleLength,marginBottom:validator.multipleLength,border:validator.border,borderLeft:validator.borderLeft,borderRight:validator.borderRight,borderTop:validator.borderTop,borderBottom:validator.borderBottom,borderWidth:makeAbbrAttrValidator("arraylength",["borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth"]),borderLeftWidth:validator.length,borderTopWidth:validator.length,borderRightWidth:validator.length,borderBottomWidth:validator.length,borderColor:makeAbbrAttrValidator("arraycolor",["borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),borderLeftColor:validator.color,borderTopColor:validator.color,borderRightColor:validator.color,borderBottomColor:validator.color,borderStyle:makeEnumValidator(["solid","dotted","dashed"]),borderRadius:validator.length,borderBottomLeftRadius:validator.length,borderBottomRightRadius:validator.length,borderTopLeftRadius:validator.length,borderTopRightRadius:validator.length,indicatorSize:validator.length,indicatorTop:validator.length,indicatorRight:validator.length,indicatorBottom:validator.length,indicatorLeft:validator.length,filter:makeMultipleAttributesValidator(filterValidatorMap),overflow:makeEnumValidator(["hidden","visible"]),flex:validator.number,flexGrow:validator.number,flexShrink:validator.number,flexBasis:validator.length,flexDirection:makeEnumValidator(["row","column","row-reverse","column-reverse"]),flexWrap:makeEnumValidator(["nowrap","wrap","wrap-reverse"]),justifyContent:makeEnumValidator(["flex-start","flex-end","center","space-between","space-around"]),alignItems:makeEnumValidator(["stretch","flex-start","flex-end","center"]),alignContent:makeEnumValidator(["stretch","flex-start","flex-end","center","space-between","space-around"]),alignSelf:makeEnumValidator(["auto","flex-start","flex-end","center","baseline","stretch"]),position:makeEnumValidator(["static","fixed","relative","absolute"]),top:validator.length,bottom:validator.length,left:validator.length,right:validator.length,zIndex:validator.integer,opacity:validator.number,background:validator.background,backgroundColor:validator.color,backgroundImage:validator.url,backgroundSize:validator.backgroundSize,backgroundRepeat:makeEnumValidator(["no-repeat","repeat","repeat-x","repeat-y"]),backgroundPosition:validator.backgroundPosition,display:validator.display,visibility:makeEnumValidator(["visible","hidden"]),objectFit:makeEnumValidator(["fill","contain","cover","none","scale-down"]),altObjectFit:makeEnumValidator(["fill","contain","cover","none","scale-down"]),lines:validator.integer,color:validator.color,fontSize:validator.length,fontStyle:makeEnumValidator(["normal","italic"]),fontWeight:validator.fontWeight,textDecoration:makeEnumValidator(["none","underline","line-through"]),textAlign:makeEnumValidator(["left","center","right"]),lineHeight:validator.length,textOverflow:makeEnumValidator(["clip","ellipsis"]),textIndent:makeLengthValidator(["px","dp","cm","%","em"]),transform:makeMultipleAttributesValidator(transformValidatorMap),transformOrigin:validator.position,animationName:validator.name,animationDuration:validator.time,animationTimingFunction:validateTimingFunction,pageAnimationName:validator.name,pageTransformOrigin:validator.position,animationDelay:validator.time,animationIterationCount:validator.iterationcount,animationFillMode:makeEnumValidator(["none","forwards"]),animationDirection:makeEnumValidator(["normal","reverse","alternate","alternate-reverse"]),placeholderColor:validator.color,selectedColor:validator.color,textColor:validator.color,timeColor:validator.color,textHighlightColor:validator.color,strokeWidth:validator.length,progressColor:validator.color,indicatorColor:validator.color,indicatorSelectedColor:validator.color,slideWidth:validator.length,slideMargin:validator.length,resizeMode:makeEnumValidator(["cover","contain","stretch","center"]),columns:validator.number,columnSpan:validator.number,maskColor:validator.color,blockColor:validator.color,mylocation:validator.mylocation,mylocationFillColor:validator.color,mylocationStrokeColor:validator.color,mylocationIconPath:validator.url,caretColor:validator.caretColor,thumbColor:validator.color,trackColor:validator.color,layerColor:validator.color,layoutType:makeEnumValidator(["grid","stagger"]),starBackground:validator.url,starForeground:validator.url,starSecondary:validator.url,fontSrc:validator.fontSrc,fontFamily:validator.fontFamily};function validate(e,t,a){let n,l;const r=validatorMap[e];return"function"==typeof r?(n="function"!=typeof t?mightReferlocalResource(e)?r(t,a):r(t):{value:t},n.reason&&(l={reason:n.reason(e,t,n.value)})):(n={value:t},l={reason:"WARN: 样式名`"+(0,_utils.camelCaseToHyphened)(e)+"`不支持"}),{value:n.value instanceof Array?n.value:[{n:e,v:n.value}],log:l}}function mightReferlocalResource(e){return cssUseLocalResource.indexOf(e)>-1}function validatePseudoClass(e){return e=e.replace(/^(:)/,""),cssPseudoClasses.indexOf(e.toLowerCase())>=0}function validatePseudoElement(e){return e=e.replace(/^(:)/,""),cssPseudoElements.indexOf(e.toLowerCase())>=0}module.exports={colorNames:colorNames,validatorMap:validatorMap,validator:validator,validate:validate,validatePseudoClass:validatePseudoClass,validatePseudoElement:validatePseudoElement,enumValidatorFactory:makeEnumValidator,mightReferlocalResource:mightReferlocalResource};
//# sourceMappingURL=validator.js.map

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _path=_interopRequireDefault(require("path")),_sharedUtils=require("@hap-toolkit/shared-utils"),_exp=_interopRequireDefault(require("./exp")),_style=_interopRequireDefault(require("../style")),_model=_interopRequireDefault(require("./model")),_utils=require("../utils");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const extList=[".mix",".ux",".vue"],richtextType=["mix","ux"],REG_TAG_DATA_ATTR=/^data-\w+/,REG_CLASS_VALUE=/[^{}\s]+((?=\s)|$)|[^{}\s]*\{\{[^]*?\}\}[^\s]*/g,RESERVED_TAGS=Object.keys(_utils.FRAG_TYPE).map((e=>_utils.FRAG_TYPE[e])),RESERVED_DIRECTIVES=/^(model:|dir:)/,tagCommon={events:["click","focus","blur","key","longpress","appear","disappear","swipe","touchstart","touchmove","touchend","touchcancel","resize","animationstart","animationiteration","animationend"],attrs:{id:{},style:{},class:{},disabled:{enum:["false","true"]},if:{def:"true"},elif:{def:"true"},else:{},for:{},tid:{},show:{def:"true"},"aria-label":{},"aria-unfocusable":{enum:["false","true"]},forcedark:{enum:["true","false"]},focusable:{enum:["false","true"]},vtags:{},vindex:{},autofocus:{enum:["false","true"]},descendantfocusability:{enum:["before","after","block"]}},children:["block","slot","component"],parents:["block"]},tagNatives={div:{supportCard:!0,attrs:{enablevideofullscreencontainer:{enum:["false","true"]}}},a:{supportCard:!0,textContent:!0,children:["span"],attrs:{visited:{enum:["false","true"]},href:{}}},text:{supportCard:!0,textContent:!0,children:["a","span"],attrs:{type:{enum:["text","html"]},"letter-spacing":{}}},span:{supportCard:!0,textContent:!0,excludeRoot:!0,children:["span"],parents:["text","a","span"],attrs:{extendCommon:!1,id:{},style:{},class:{},for:{},tid:{},if:{def:"true"},elif:{def:"true"},else:{}}},label:{supportCard:!0,textContent:!0,atomic:!0,attrs:{target:{}}},image:{events:["complete","error"],empty:!0,supportCard:!0,selfClosing:!0,alias:["img"],atomic:!0,attrs:{src:{},alt:{},enablenightmode:{enum:["true","false"]},autoplay:{enum:["true","false"]}}},slider:{selfClosing:!0,atomic:!0,attrs:{enabled:{enum:["true","false"]},min:{def:0},max:{def:100},step:{def:1},value:{def:0}},events:["change"]},web:{atomic:!0,events:["pagestart","pagefinish","titlereceive","error","message","progress"],attrs:{src:{},trustedurl:{},allowthirdpartycookies:{enum:["false","true"]},enablenightmode:{enum:["true","false"]},showloadingdialog:{enum:["false","true"]},supportzoom:{enum:["true","false"]}}},list:{children:["list-item"],attrs:{scrollpage:{enum:["false","true"]},focusbehavior:{enum:["aligned","edged"]}},events:["scroll","scrollbottom","scrolltop","scrollend","scrolltouchup","selected"]},"list-item":{excludeRoot:!0,parents:["list"],attrs:{type:{required:!0},disallowintercept:{}}},block:{excludeRoot:!0,supportCard:!0,attrs:{extendCommon:!1,for:{},tid:{},if:{def:"true"},elif:{def:"true"},else:{}}},component:{excludeRoot:!0,attrs:{extendCommon:!1,is:{required:!0},for:{},tid:{},if:{def:"true"},elif:{def:"true"},else:{}}},slot:{excludeRoot:!0,attrs:{name:{def:"default"},extendCommon:!1,content:{}}},input:{supportCard:!0,selfClosing:!0,atomic:!0,empty:!0,attrs:{type:{enum:["text","button","checkbox","radio","email","date","time","number","password","tel","eventbutton","hidetext","showtext"]},autocomplete:{enum:["on","off"]},enterkeytype:{enum:["default","next","go","done","send","search"]},eventtype:{enum:["shortcut"]},"true-value":{},"false-value":{},maxlength:{},checked:{enum:["false","true"]},name:{},value:{},placeholder:{}},events:["change","enterkeyclick","selectionchange"]},button:{supportCard:!0,textContent:!0,atomic:!0},refresh:{attrs:{offset:{def:"132px"},refreshing:{enum:["false","true"]},type:{enum:["auto","pulldown"]},"enable-refresh":{enum:["true","false"]}},events:["refresh"]},refresh2:{attrs:{pulldownrefreshing:{enum:["false","true"]},pulluprefreshing:{enum:["false","true"]},animationduration:{def:300},enablepulldown:{enum:["true","false"]},enablepullup:{enum:["false","true"]},reboundable:{enum:["false","true"]},gesture:{enum:["true","false"]},offset:{def:"132px"},refreshing:{enum:["false","true"]},type:{enum:["auto","pulldown"]}},events:["pulldownrefresh","pulluprefresh","refresh"],onceChildren:["refresh-header","refresh-footer"]},"refresh-header":{attrs:{dragrate:{def:300},triggerratio:{def:300},tiggersize:{def:300},maxdragratio:{def:300},maxdragsize:{def:300},refreshdisplayratio:{def:300},refreshdisplaysize:{def:300},spinnerstyle:{enum:["translation","front","behind"]},autorefresh:{enum:["false","true"]},translationwithcontent:{enum:["false","true"]}},events:["move"],parents:["refresh2"]},"refresh-footer":{attrs:{dragrate:{def:300},triggerratio:{def:300},tiggersize:{def:300},maxdragratio:{def:300},maxdragdize:{def:300},refreshdisplayratio:{def:300},refreshdisplaysize:{def:300},spinnerstyle:{enum:["translation","front","behind"]},autorefresh:{enum:["false","true"]},translationwithcontent:{enum:["true","false"]}},events:["move"],parents:["refresh2"]},ad:{attrs:{unitid:{def:""},type:{def:"native"},adid:{}},events:["adclick","error"]},"ad-clickable-area":{supportCard:!0,textContent:!0,atomic:!0,attrs:{type:{enum:["click","button","video","video-click"]}}},"ad-custom":{attrs:{adUnitId:{},channel:{},extendCommon:!1},events:["load","error","show","click","close"]},swiper:{attrs:{index:{def:0},autoplay:{enum:["false","true"]},interval:{def:3e3},indicator:{enum:["true","false"]},loop:{enum:["true","false"]},duration:{},vertical:{enum:["false","true"]},previousmargin:{def:"0px"},nextmargin:{def:"0px"},enableswipe:{enum:["true","false"]}},events:["change"]},progress:{supportCard:!0,selfClosing:!0,atomic:!0,attrs:{percent:{def:0},type:{enum:["horizontal","circular"]}}},picker:{supportCard:!0,selfClosing:!0,atomic:!0,attrs:{type:{required:!0,enum:["text","date","time","multi-text"]},start:{def:"1970-1-1"},end:{def:"2100-12-31"},range:{},selected:{},value:{}},events:["change","columnchange","cancel"]},switch:{supportCard:!0,selfClosing:!0,atomic:!0,attrs:{checked:{enum:["false","true"]}},events:["change"]},textarea:{supportCard:!0,atomic:!0,textContent:!0,attrs:{placeholder:{},maxlength:{}},events:["change","selectionchange","linechange"]},video:{empty:!0,attrs:{src:{},muted:{enum:["false","true"]},autoplay:{enum:["false","true"]},controls:{enum:["true","false"]},poster:{},orientation:{enum:["landscape","portrait"]},titlebar:{enum:["true","false"]},title:{},playcount:{},speed:{def:1}},events:["prepared","start","pause","finish","error","seeking","seeked","timeupdate","fullscreenchange"]},camera:{atomic:!0,selfClosing:!0,attrs:{deviceposition:{enum:["back","front"]},flash:{enum:["auto","on","off","torch"]},framesize:{enum:["low","normal","high"]},autoexposurelock:{enum:["false","true"]},autowhitebalancelock:{enum:["false","true"]}},events:["error","camerainitdone","cameraframe"]},map:{children:["custommarker"],attrs:{latitude:{},longitude:{},coordtype:{},scale:{def:0},rotate:{def:0},markers:{},showmylocation:{enum:["true","false"]},polylines:{},polygons:{},circles:{},controls:{},groundoverlays:{},includepoints:{},heatmaplayer:{},showcompass:{enum:["true","false"]},enableoverlooking:{enum:["false","true"]},enablezoom:{enum:["true","false"]},enablescroll:{enum:["true","false"]},enablerotate:{enum:["true","false"]},showscale:{enum:["false","true"]},showzoom:{enum:["false","true"]}},events:["loaded","regionchange","tap","markertap","callouttap","controltap","poitap"]},custommarker:{parents:["map"],attrs:{custommarkerattr:{}}},canvas:{atomic:!0},stack:{supportCard:!0,events:["fullscreenchange"]},richtext:{textContent:!0,atomic:!0,attrs:{type:{required:!0,enum:["html"].concat(richtextType)},scene:{}},events:["start","complete","pagechanged","splitpage"]},tabs:{children:["tab-bar","tab-content"],attrs:{index:{def:0}},events:["change"]},"tab-content":{parents:["tabs"],attrs:{scrollable:{enum:["true","false"]}}},"tab-bar":{parents:["tabs"],attrs:{mode:{enum:["fixed","scrollable"]}}},popup:{supportCard:!0,children:["text"],attrs:{target:{required:!0},placement:{enum:["left","top","right","bottom","topLeft","topRight","bottomLeft","bottomRight"],def:"bottom"}},events:["visibilitychange"]},rating:{supportCard:!0,atomic:!0,attrs:{numstars:{def:"5"},rating:{def:"0"},stepsize:{def:"0.5"},indicator:{enum:["false","true"]}},events:["change"]},select:{supportCard:!0,children:["option"],events:["change"],excludeRoot:!0},option:{supportCard:!0,parents:["select"],atomic:!0,textContent:!0,attrs:{selected:{def:!1},value:{}},excludeRoot:!0},marquee:{supportCard:!0,textContent:!0,atomic:!0,attrs:{scrollamount:{def:6},loop:{def:-1},direction:{enum:["left","right"]},value:{def:"6px"}},events:["bounce","finish","start"]},scrollview:{attrs:{"scroll-direction":{enum:["vertical","horizontal","vertical_horizontal"]},"show-scrollbar":{enum:["true","false"]}},events:["scroll","scrollbegindrag","scrollenddrag","scrollstart","scrollstop"]},drawer:{attrs:{enableswipe:{enum:["true","false"]}},events:["change","scroll"]},lottie:{empty:!0,attrs:{source:{required:!0},progress:{},speed:{},loop:{enum:[!0,!1]},autoplay:{enum:[!1,!0]},rendermode:{enum:["AUTOMATIC","HARDWARE","SOFTWARE"]}},events:["complete","error","change"]},"drawer-navigation":{parents:["drawer"],attrs:{direction:{enum:["start","end"]}}},"slide-view":{attrs:{edge:{enum:["right","left"]},enableslide:{enum:["true","false"]},isopen:{enum:["false","true"]},layer:{enum:["above","same"]},buttons:{}},events:["open","close","slide","buttonclick"]},"section-list":{children:["section-group","section-item"],events:["scroll","scrollend","scrolltouchup","scrolltop","scrollbottom"]},"section-group":{children:["section-group","section-item","section-header"],attrs:{expand:{enum:["false","true"]}},events:["change"]},"section-header":{parents:["section-group"]},"section-item":{},"share-button":{empty:!0,attrs:{value:{},title:{},description:{},icon:{},url:{},path:{},params:{},platforms:{},usepageparams:{enum:["true","false"],def:"false"}},events:["success","fail","cancel"]},"shortcut-button":{empty:!0,attrs:{value:{}}}},tagReserved={};let tagComponents=[];const tagNativeKeys=Object.keys(tagNatives),tagAliasMap={},tagAttrMap={},tagEnumAttrMap={},tagDefaultAttrMap={},tagRequireAttrMap={},tagAtomics={},tagEmpty={},tagTextContent={},tagChildrenMap={},tagOnceChildrenMap={},tagParentsMap={},tagEventsMap={},tagNotRoot=[];function checkTagName(e,t,a={}){const n=t.result,s=t.log,r=_path.default.extname(a.filePath);let l=e.tagName;const o=e.childNodes||[],i=e.__location||{};tagComponents=a.importNames||[];const u=tagComponents.includes(l);!u&&tagAliasMap[l]&&("img"!==l&&s.push({line:i.line||1,column:i.col||1,reason:"NOTE: 组件名 `"+l+"` 自动转换为 `"+tagAliasMap[l]+"`"}),l=tagAliasMap[l]),n.type=l,RESERVED_TAGS.indexOf(l)>=0?s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件名 `"+l+"` 是系统保留的组件名, 请修改"}):hasTagDefined(l)||s.push({line:i.line||1,column:i.col||1,reason:`WARN: 未识别的标签名 '${l}',如果是自定义组件,请确认已经引入`}),a.uxType===_utils.ENTRY_TYPE.CARD&&tagNatives[l]&&!tagNatives[l].supportCard&&s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 卡片不支持组件名 `"+l+"`, 请修改"}),e._isroot&&tagNotRoot.hasOwnProperty(l)&&s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 不能作为根组件"}),n.attr=n.attr||{};const c=e.attrs||[],p=[];if(c.forEach((function(e){p.push(e.name.toLowerCase())})),e._isroot){const e=["for","if","elif","else","show"];p.forEach((t=>{e.indexOf(t)>=0&&s.push({line:i.line||1,column:i.col||1,reason:"WARN: 根节点 `"+l+"` 不能使用属性 `"+t+"`"})}))}if(!u){if(tagEmpty.hasOwnProperty(l)&&o.length>0&&s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 内不能有子节点与文字,请修改"}),tagAtomics.hasOwnProperty(l)&&"ad-clickable-area"!==l&&(tagTextContent.hasOwnProperty(l)?o.length>0&&o.every((e=>"#text"===e.nodeName||(s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 是原子类型,不应该有子节点"}),!1))):(o.length>1||o[0]&&"#text"!==o[0].nodeName)&&s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 只能有一个文字子节点"})),tagDefaultAttrMap[l]&&Object.keys(tagDefaultAttrMap[l]).forEach((t=>{const n=p.indexOf(t);n>=0&&""===c[n].value?(c[n].value=tagDefaultAttrMap[l][t],s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 属性 `"+t+"` 值为空, 默认设置为缺省值 `"+tagDefaultAttrMap[l][t]+"`"})):"slot"===l&&n<0&&(e.attrs.push({name:t,value:tagDefaultAttrMap[l][t]}),_sharedUtils.colorconsole.warn(`标签 ${l} 的属性 \`${t}\` 值为空, 默认设置为缺省值 \`${tagDefaultAttrMap[l][t]}\` ${a.filePath} @${i.line||1},${i.col||1}`))})),tagRequireAttrMap[l]&&tagRequireAttrMap[l].forEach((e=>{p.indexOf(e)<0&&s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 没有定义属性 `"+e+"`"})})),tagEnumAttrMap[l]&&Object.keys(tagEnumAttrMap[l]).forEach((e=>{const t=p.indexOf(e);if(t>=0){const a=c[t].value;if(!_exp.default.isExpr(a)){const n=tagEnumAttrMap[l][e];n.indexOf(a)<0&&(c[t].value=n[0],s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 属性 `"+e+"` 的值 `"+a+"`非法, 默认设置为缺省值 `"+n[0]+"`"}))}}})),tagAttrMap[l]&&"component"!==l&&p.forEach((e=>{if(!e.match(/^(on|@)/)){if(r.indexOf(extList[2])>=-1&&/^(:|v-|key|ref|is|slot|slot-scope)/.test(e))return;if(RESERVED_DIRECTIVES.test(e))return;const t=checkDataAttr(e),a=Object.prototype.hasOwnProperty.call(tagAttrMap[l],e);t||a||s.push({line:i.line||1,column:i.col||1,reason:"WARN: 组件 `"+l+"` 不支持属性 `"+e})}})),tagEventsMap[l]&&"component"!==l){const e=tagEventsMap[l];p.forEach((t=>{if(t.match(/^(on|@)/)){const n=t.replace(/^(on|@)/,""),r=["appear","disappear","swipe"];a.uxType===_utils.ENTRY_TYPE.CARD&&r.indexOf(n.toLowerCase())>-1&&s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 卡片组件 `"+l+"` 不支持事件 `"+n+"`"}),e.indexOf(n.toLowerCase())<0&&s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 不支持事件 `"+n+"`"})}}))}if(o.length>0){const t=new Set,n={};o.forEach(((e,r)=>{if(isReservedTag(l)&&isReservedTag(e.nodeName)){const o=tagParentsMap[e.nodeName],u=tagChildrenMap[l],c=tagOnceChildrenMap[l];if("slot"===e.nodeName){let n=e.parentNode;for(;n;){if("slot"===n.tagName){_sharedUtils.colorconsole.warn(`slot标签内不应该嵌套slot ${a.filePath}@${i.line||1},${i.col||1}`);break}n=n.parentNode}const s={};e.attrs.map((e=>{s[e.name]=e.value})),s.hasOwnProperty("name")?/\{\{\s*[\w$]+\s*\}\}/.test(s.name)&&_sharedUtils.colorconsole.warn(`标签${e.nodeName}的name属性暂时不支持动态绑定 ${a.filePath}@${i.line||1},${i.col||1}`):s.name="default",t.has(s.name)?_sharedUtils.colorconsole.warn(`标签${l}内存在name为 \`${s.name}\` 重复slot ${a.filePath}@${i.line||1},${i.col||1}`):t.add(s.name)}if(o&&o.indexOf(l)<0||u&&u.indexOf(e.nodeName)<0)s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 不支持子组件 `"+e.nodeName+"`"});else if(c&&c.indexOf(e.nodeName)>-1){let t;(n[e.nodeName]||0===n[e.nodeName])&&(t=!0),n[e.nodeName]={index:r,duplicated:t}}}}));const r=Object.keys(n);r.length&&(r.filter((e=>n[e].duplicated)).forEach((e=>{s.push({line:i.line||1,column:i.col||1,reason:`'WARN: 组件 \`${e}\` 只允许在 \`${l}\` 组件中出现一次`})})),e.childNodes=o.filter(((e,t)=>!(n[e.nodeName]&&n[e.nodeName].duplicated&&t!==n[e.nodeName].index))))}isSupportedSelfClosing(l)||!i.startTag||i.endTag||s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 缺少闭合标签,请检查"}),"list-item"===l&&hasIfOrFor(o)&&s.push({line:i.line||1,column:i.col||1,reason:"WARN: `list-item` 内部需谨慎使用指令 if 或 for,相同 type 属性的 list-item, DOM 结构必须完全相同`"})}}function checkId(e,t){e&&(t.result.id=_exp.default.isExpr(e)?(0,_exp.default)(e):e)}function checkDataAttr(e){return REG_TAG_DATA_ATTR.test(e)}function checkBuild(e,t){e&&(t.result.append="tree"===e?"tree":"single")}function checkClass(className,output){let hasBinding,classList=[];if(className=className.trim(),className){let start=0,end=0;const segs=[],matched=className.match(REG_CLASS_VALUE);if(matched){let e;matched.forEach((t=>{end=className.indexOf(t,start),e=className.slice(start,end),e.length&&segs.push(e),segs.push(t),start+=e.length+t.length}))}if(segs.push(className.slice(start)),classList=segs.reduce(((e,t)=>_exp.default.isExpr(t)?(hasBinding=!0,e.push((0,_exp.default)(t,!1)),e):e.concat(t.split(/\s+/g).filter((e=>e)).map((e=>`'${e}'`)))),[]),classList=classList.filter((e=>e.trim())),hasBinding){const code="(function () {return ["+classList.join(", ")+"]})";try{output.result.classList=eval(code)}catch(e){throw e.isExpressionError=!0,e.expression=className,e}}else output.result.classList=classList.map((e=>e.slice(1,-1)))}}function checkStyle(e,t,a,n){let s={};const r=t.log;if(e){if(_exp.default.singleExpr(e)){const n=_exp.default.removeExprffix(e);return _exp.default.isExpr(n)?r.push({line:a.line||1,column:a.col||1,reason:"ERROR: style 属性不能嵌套多层{{}}"}):s=(0,_exp.default)(e),void(t.result.style=s)}if(e.split(";").forEach((function(e){let t,l,o,i=e.trim().split(":");i.length>2&&(i[1]=i.slice(1).join(":"),i=i.slice(0,2)),2===i.length&&(t=i[0].trim(),t=(0,_utils.hyphenedToCamelCase)(t),l=i[1].trim(),l=(0,_exp.default)(l),o=_style.default.validateDelaration(t,l,n),l=o.value,l.forEach((e=>{((0,_utils.isValidValue)(e.v)||"function"==typeof e.v)&&(s[e.n]=e.v)})),o.log&&r.push({line:a.line||1,column:a.col||1,reason:o.log.reason}))})),"object"==typeof s)for(let e in s)_style.default.shouldAddToDependency(e,s[e])&&t.depFiles.push(s[e]);t.result.style=s}}function checkIs(e,t,a){const n=t.log;e?(e=_exp.default.addExprffix(e),t.result.is=(0,_exp.default)(e)):n.push({line:a.line||1,column:a.col||1,reason:"WARN: is 属性为空"})}function checkIf(e,t,a,n,s){const r=t.log;e?(e=_exp.default.addExprffix(e),a?e="{{"+buildConditionExp(s)+"}}":(s.length>0&&(s.length=0),s.push(`${e.substr(2,e.length-4)}`)),t.result.shown=(0,_exp.default)(e)):a||r.push({line:n.line||1,column:n.col||1,reason:"WARN: if 属性为空"})}function checkElse(e,t,a,n){checkIf(e,t,!0,a,n),n.length=0}function checkElif(e,t,a,n,s){const r=a.log;let l=t;return e?(e=_exp.default.addExprffix(e),t=_exp.default.addExprffix(t),l="{{("+e.substr(2,e.length-4)+") && "+buildConditionExp(s)+"}}",a.result.shown=(0,_exp.default)(l),s.push(`${e.substr(2,e.length-4)}`)):r.push({line:n.line||1,column:n.col||1,reason:"WARN: Elif 属性为空"}),l}function checkFor(e,t,a){const n=t.log;if(e){let a,n;const s=(e=_exp.default.removeExprffix(e)).match(/(.*) (?:in) (.*)/);if(s){const t=s[1].match(/\((.*),(.*)\)/);t?(a=t[1].trim(),n=t[2].trim()):n=s[1].trim(),e=s[2]}let r;e="{{"+e+"}}",a||n?(r={exp:(0,_exp.default)(e)},a&&(r.key=a),n&&(r.value=n)):r=(0,_exp.default)(e),t.result.repeat=r}else n.push({line:a.line||1,column:a.col||1,reason:"WARN: for 属性为空"})}function checkEvent(name,value,output){const originValue=value,eventName=name.replace(/^(on|@)/,"");if(eventName&&value){value=_exp.default.removeExprffix(value);const paramsMatch=value.match(/(.*)\((.*)\)/);if(paramsMatch){const funcName=paramsMatch[1];let params=paramsMatch[2];params?(params=params.split(/\s*,\s*/),-1===params.indexOf("evt")&&(params[params.length]="evt")):params=["evt"],value="{{"+funcName+"("+params.join(",")+")}}";try{value=eval("(function (evt) { return "+(0,_exp.default)(value,!1).replace("this.evt","evt")+"})")}catch(e){throw e.isExpressionError=!0,e.expression=originValue,e}}output.result.events=output.result.events||{},output.result.events[eventName]=value}}function checkCustomDirective(e,t,a,n){const s=e.replace(/^dir:/,"");if(!s)return _sharedUtils.colorconsole.warn(`\`${n.tagName}\` 组件自定义指令名称不能为空`),!1;a.result.directives=a.result.directives||[],a.result.directives.push({name:s,value:_exp.default.isExpr(t)?(0,_exp.default)(t):t})}function checkAttr(e,t,a,n,s,r){if(e&&(0,_utils.isValidValue)(t)){if(shouldConvertPath(e,t,n)){(0,_utils.fileExists)(t,r.filePath)||a.log.push({line:s.line,column:s.column,reason:"WARN: "+n+" 属性 "+e+" 的值 "+t+" 下不存在对应的文件资源"}),t=(0,_utils.resolvePath)(t,r.filePath),a.depFiles.push(t)}a.result.attr=a.result.attr||{},a.result.attr[(0,_utils.hyphenedToCamelCase)(e)]=(0,_exp.default)(t),"value"===e&&"text"===n&&a.log.push({line:s.line,column:s.column,reason:"WARN: `value` 应该写在<text>标签中"})}}function shouldConvertPath(e,t,a){return!("alt"===e&&"blank"===t)&&!(!(["src","alt"].includes(e)&&t&&["img","video"].indexOf(a)>-1)||/^(data:|http|{{)/.test(t))}function isReservedTag(e){return tagReserved.hasOwnProperty(e)}function isTextContentAtomic(e){return tagTextContent.hasOwnProperty(e)&&tagAtomics.hasOwnProperty(e)}function isNotTextContentAtomic(e){return!tagTextContent.hasOwnProperty(e)&&!tagAtomics.hasOwnProperty(e)}function isSupportSpan(e){if(e&&"string"==typeof e)return tagChildrenMap[e]&&tagChildrenMap[e].indexOf("span")>-1}function getTagChildren(e){if(e&&"string"==typeof e)return tagChildrenMap[e]||[]}function isSupportedSelfClosing(e){if(e&&"string"==typeof e)return e=tagAliasMap[e]||e,tagNatives[e]&&!!tagNatives[e].selfClosing}function hasTagDefined(e){return tagNativeKeys.indexOf(e)>-1||tagComponents.indexOf(e)>-1}function isEmptyElement(e){return e=tagAliasMap[e]||e,tagNatives[e]&&!0===tagNatives[e].empty}function buildConditionExp(e){return e.map((e=>`!(${e})`)).join(" && ")}function hasIfOrFor(e){let t=!1;return e.find((e=>(e.attrs||[]).findIndex((e=>["for","if"].indexOf(e.name)>-1))>-1?(t=!0,t):Array.isArray(e.childNodes)?(t=hasIfOrFor(e.childNodes),t):void 0)),t}tagNativeKeys.forEach((function(e){tagReserved[e]=!0;const t=tagNatives[e];t.atomic&&(tagAtomics[e]=!0),t.textContent&&(tagTextContent[e]=!0),t.empty&&(tagEmpty[e]=!0),t.alias&&t.alias.length&&t.alias.forEach((function(t){tagAliasMap[t]=e})),!0===t.excludeRoot&&(tagNotRoot[e]=!0);let a=(0,_utils.extend)({},t.attrs);const n={},s={},r=[];t.attrs&&!1===t.attrs.extendCommon||(a=(0,_utils.extend)(a,tagCommon.attrs)),"extendCommon"in a&&delete a.extendCommon,Object.keys(a).forEach((function(e){const t=a[e];t.enum&&t.enum.length>0&&(n[e]=t.enum,s[e]=t.enum[0]),t.def&&(s[e]=t.def),!0===t.required&&r.push(e)})),tagAttrMap[e]=a,tagEnumAttrMap[e]=n,tagDefaultAttrMap[e]=s,tagRequireAttrMap[e]=r,tagChildrenMap[e]=t.children?(0,_utils.merge)([],tagCommon.children,t.children):null,tagOnceChildrenMap[e]=t.onceChildren?(0,_utils.merge)([],t.onceChildren):null,tagParentsMap[e]=t.parents?(0,_utils.merge)([],tagCommon.parents,t.parents):null,tagEventsMap[e]=(0,_utils.merge)([],tagCommon.events,t.events)}));var _default={checkTagName:checkTagName,checkId:checkId,checkClass:checkClass,checkStyle:checkStyle,checkIs:checkIs,checkIf:checkIf,checkElse:checkElse,checkElif:checkElif,checkFor:checkFor,checkEvent:checkEvent,checkCustomDirective:checkCustomDirective,checkAttr:checkAttr,checkBuild:checkBuild,checkModel:_model.default,isReservedTag:isReservedTag,isTextContentAtomic:isTextContentAtomic,isSupportSpan:isSupportSpan,getTagChildren:getTagChildren,isSupportedSelfClosing:isSupportedSelfClosing,isEmptyElement:isEmptyElement,isNotTextContentAtomic:isNotTextContentAtomic};exports.default=_default;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _path=_interopRequireDefault(require("path")),_sharedUtils=require("@hap-toolkit/shared-utils"),_exp=_interopRequireDefault(require("./exp")),_style=_interopRequireDefault(require("../style")),_model=_interopRequireDefault(require("./model")),_utils=require("../utils");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const extList=[".mix",".ux",".vue"],richtextType=["mix","ux"],REG_TAG_DATA_ATTR=/^data-\w+/,REG_CLASS_VALUE=/[^{}\s]+((?=\s)|$)|[^{}\s]*\{\{[^]*?\}\}[^\s]*/g,RESERVED_TAGS=Object.keys(_utils.FRAG_TYPE).map((e=>_utils.FRAG_TYPE[e])),RESERVED_DIRECTIVES=/^(model:|dir:)/,tagCommon={events:["click","focus","blur","key","longpress","appear","disappear","swipe","touchstart","touchmove","touchend","touchcancel","resize","animationstart","animationiteration","animationend"],attrs:{id:{},style:{},class:{},disabled:{enum:["false","true"]},if:{def:"true"},elif:{def:"true"},else:{},for:{},tid:{},show:{def:"true"},"aria-label":{},"aria-unfocusable":{enum:["false","true"]},forcedark:{enum:["true","false"]},focusable:{enum:["false","true"]},vtags:{},vindex:{},autofocus:{enum:["false","true"]},descendantfocusability:{enum:["before","after","block"]}},children:["block","slot","component"],parents:["block"]},tagNatives={div:{supportCard:!0,attrs:{enablevideofullscreencontainer:{enum:["false","true"]}}},a:{supportCard:!0,textContent:!0,children:["span"],attrs:{visited:{enum:["false","true"]},href:{}}},text:{supportCard:!0,textContent:!0,children:["a","span"],attrs:{type:{enum:["text","html"]},"letter-spacing":{}}},span:{supportCard:!0,textContent:!0,excludeRoot:!0,children:["span"],parents:["text","a","span"],attrs:{extendCommon:!1,id:{},style:{},class:{},for:{},tid:{},if:{def:"true"},elif:{def:"true"},else:{}}},label:{supportCard:!0,textContent:!0,atomic:!0,attrs:{target:{}}},image:{events:["complete","error"],empty:!0,supportCard:!0,selfClosing:!0,alias:["img"],atomic:!0,attrs:{src:{},alt:{},enablenightmode:{enum:["true","false"]},autoplay:{enum:["true","false"]}}},slider:{selfClosing:!0,atomic:!0,attrs:{enabled:{enum:["true","false"]},min:{def:0},max:{def:100},step:{def:1},value:{def:0}},events:["change"]},web:{atomic:!0,events:["pagestart","pagefinish","titlereceive","error","message","progress"],attrs:{src:{},trustedurl:{},allowthirdpartycookies:{enum:["false","true"]},enablenightmode:{enum:["true","false"]},showloadingdialog:{enum:["false","true"]},supportzoom:{enum:["true","false"]}}},list:{children:["list-item"],attrs:{scrollpage:{enum:["false","true"]},focusbehavior:{enum:["aligned","edged","reverseedged","leadingedged","trailingedged"]}},events:["scroll","scrollbottom","scrolltop","scrollend","scrolltouchup","selected"]},"list-item":{excludeRoot:!0,parents:["list"],attrs:{type:{required:!0},disallowintercept:{}}},block:{excludeRoot:!0,supportCard:!0,attrs:{extendCommon:!1,for:{},tid:{},if:{def:"true"},elif:{def:"true"},else:{}}},component:{excludeRoot:!0,attrs:{extendCommon:!1,is:{required:!0},for:{},tid:{},if:{def:"true"},elif:{def:"true"},else:{}}},slot:{excludeRoot:!0,attrs:{name:{def:"default"},extendCommon:!1,content:{}}},input:{supportCard:!0,selfClosing:!0,atomic:!0,empty:!0,attrs:{type:{enum:["text","button","checkbox","radio","email","date","time","number","password","tel","eventbutton","hidetext","showtext"]},autocomplete:{enum:["on","off"]},enterkeytype:{enum:["default","next","go","done","send","search"]},eventtype:{enum:["shortcut"]},"true-value":{},"false-value":{},maxlength:{},checked:{enum:["false","true"]},name:{},value:{},placeholder:{}},events:["change","enterkeyclick","selectionchange"]},button:{supportCard:!0,textContent:!0,atomic:!0},refresh:{attrs:{offset:{def:"132px"},refreshing:{enum:["false","true"]},type:{enum:["auto","pulldown"]},"enable-refresh":{enum:["true","false"]}},events:["refresh"]},refresh2:{attrs:{pulldownrefreshing:{enum:["false","true"]},pulluprefreshing:{enum:["false","true"]},animationduration:{def:300},enablepulldown:{enum:["true","false"]},enablepullup:{enum:["false","true"]},reboundable:{enum:["false","true"]},gesture:{enum:["true","false"]},offset:{def:"132px"},refreshing:{enum:["false","true"]},type:{enum:["auto","pulldown"]}},events:["pulldownrefresh","pulluprefresh","refresh"],onceChildren:["refresh-header","refresh-footer"]},"refresh-header":{attrs:{dragrate:{def:300},triggerratio:{def:300},tiggersize:{def:300},maxdragratio:{def:300},maxdragsize:{def:300},refreshdisplayratio:{def:300},refreshdisplaysize:{def:300},spinnerstyle:{enum:["translation","front","behind"]},autorefresh:{enum:["false","true"]},translationwithcontent:{enum:["false","true"]}},events:["move"],parents:["refresh2"]},"refresh-footer":{attrs:{dragrate:{def:300},triggerratio:{def:300},tiggersize:{def:300},maxdragratio:{def:300},maxdragdize:{def:300},refreshdisplayratio:{def:300},refreshdisplaysize:{def:300},spinnerstyle:{enum:["translation","front","behind"]},autorefresh:{enum:["false","true"]},translationwithcontent:{enum:["true","false"]}},events:["move"],parents:["refresh2"]},ad:{attrs:{unitid:{def:""},type:{def:"native"},adid:{}},events:["adclick","error"]},"ad-clickable-area":{supportCard:!0,textContent:!0,atomic:!0,attrs:{type:{}}},"ad-custom":{attrs:{adUnitId:{},channel:{},extendCommon:!1},events:["load","error","show","click","close"]},swiper:{attrs:{index:{def:0},autoplay:{enum:["false","true"]},interval:{def:3e3},indicator:{enum:["true","false"]},loop:{enum:["true","false"]},duration:{},vertical:{enum:["false","true"]},previousmargin:{def:"0px"},nextmargin:{def:"0px"},enableswipe:{enum:["true","false"]}},events:["change"]},progress:{supportCard:!0,selfClosing:!0,atomic:!0,attrs:{percent:{def:0},type:{enum:["horizontal","circular"]}}},picker:{supportCard:!0,selfClosing:!0,atomic:!0,attrs:{type:{required:!0,enum:["text","date","time","multi-text"]},start:{def:"1970-1-1"},end:{def:"2100-12-31"},range:{},selected:{},value:{}},events:["change","columnchange","cancel"]},switch:{supportCard:!0,selfClosing:!0,atomic:!0,attrs:{checked:{enum:["false","true"]}},events:["change"]},textarea:{supportCard:!0,atomic:!0,textContent:!0,attrs:{placeholder:{},maxlength:{}},events:["change","selectionchange","linechange"]},video:{empty:!0,attrs:{src:{},muted:{enum:["false","true"]},autoplay:{enum:["false","true"]},controls:{enum:["true","false"]},poster:{},orientation:{enum:["landscape","portrait"]},titlebar:{enum:["true","false"]},title:{},playcount:{},speed:{def:1}},events:["prepared","start","pause","finish","error","seeking","seeked","timeupdate","fullscreenchange"]},camera:{atomic:!0,selfClosing:!0,attrs:{deviceposition:{enum:["back","front"]},flash:{enum:["auto","on","off","torch"]},framesize:{enum:["low","normal","high"]},autoexposurelock:{enum:["false","true"]},autowhitebalancelock:{enum:["false","true"]}},events:["error","camerainitdone","cameraframe"]},map:{children:["custommarker"],attrs:{latitude:{},longitude:{},coordtype:{},scale:{def:0},rotate:{def:0},markers:{},showmylocation:{enum:["true","false"]},polylines:{},polygons:{},circles:{},controls:{},groundoverlays:{},includepoints:{},heatmaplayer:{},showcompass:{enum:["true","false"]},enableoverlooking:{enum:["false","true"]},enablezoom:{enum:["true","false"]},enablescroll:{enum:["true","false"]},enablerotate:{enum:["true","false"]},showscale:{enum:["false","true"]},showzoom:{enum:["false","true"]}},events:["loaded","regionchange","tap","markertap","callouttap","controltap","poitap"]},custommarker:{parents:["map"],attrs:{custommarkerattr:{}}},canvas:{atomic:!0},stack:{supportCard:!0,events:["fullscreenchange"]},richtext:{textContent:!0,atomic:!0,attrs:{type:{required:!0,enum:["html"].concat(richtextType)},scene:{}},events:["start","complete","pagechanged","splitpage"]},tabs:{children:["tab-bar","tab-content"],attrs:{index:{def:0}},events:["change"]},"tab-content":{parents:["tabs"],attrs:{scrollable:{enum:["true","false"]}}},"tab-bar":{parents:["tabs"],attrs:{mode:{enum:["fixed","scrollable"]}}},popup:{supportCard:!0,children:["text"],attrs:{target:{required:!0},placement:{enum:["left","top","right","bottom","topLeft","topRight","bottomLeft","bottomRight"],def:"bottom"}},events:["visibilitychange"]},rating:{supportCard:!0,atomic:!0,attrs:{numstars:{def:"5"},rating:{def:"0"},stepsize:{def:"0.5"},indicator:{enum:["false","true"]}},events:["change"]},select:{supportCard:!0,children:["option"],events:["change"],excludeRoot:!0},option:{supportCard:!0,parents:["select"],atomic:!0,textContent:!0,attrs:{selected:{def:!1},value:{}},excludeRoot:!0},marquee:{supportCard:!0,textContent:!0,atomic:!0,attrs:{scrollamount:{def:6},loop:{def:-1},direction:{enum:["left","right"]},value:{def:"6px"}},events:["bounce","finish","start"]},scrollview:{attrs:{"scroll-direction":{enum:["vertical","horizontal","vertical_horizontal"]},"show-scrollbar":{enum:["true","false"]}},events:["scroll","scrollbegindrag","scrollenddrag","scrollstart","scrollstop"]},drawer:{attrs:{enableswipe:{enum:["true","false"]}},events:["change","scroll"]},lottie:{empty:!0,attrs:{source:{required:!0},progress:{},speed:{},loop:{enum:[!0,!1]},autoplay:{enum:[!1,!0]},rendermode:{enum:["AUTOMATIC","HARDWARE","SOFTWARE"]}},events:["complete","error","change"]},"drawer-navigation":{parents:["drawer"],attrs:{direction:{enum:["start","end"]}}},"slide-view":{attrs:{edge:{enum:["right","left"]},enableslide:{enum:["true","false"]},isopen:{enum:["false","true"]},layer:{enum:["above","same"]},buttons:{}},events:["open","close","slide","buttonclick"]},"section-list":{children:["section-group","section-item"],events:["scroll","scrollend","scrolltouchup","scrolltop","scrollbottom"]},"section-group":{children:["section-group","section-item","section-header"],attrs:{expand:{enum:["false","true"]}},events:["change"]},"section-header":{parents:["section-group"]},"section-item":{},"share-button":{empty:!0,attrs:{value:{},title:{},description:{},icon:{},url:{},path:{},params:{},platforms:{},usepageparams:{enum:["true","false"],def:"false"}},events:["success","fail","cancel"]},"shortcut-button":{empty:!0,attrs:{value:{}}}},tagReserved={};let tagComponents=[];const tagNativeKeys=Object.keys(tagNatives),tagAliasMap={},tagAttrMap={},tagEnumAttrMap={},tagDefaultAttrMap={},tagRequireAttrMap={},tagAtomics={},tagEmpty={},tagTextContent={},tagChildrenMap={},tagOnceChildrenMap={},tagParentsMap={},tagEventsMap={},tagNotRoot=[];function checkTagName(e,t,a={}){const n=t.result,s=t.log,r=_path.default.extname(a.filePath);let l=e.tagName;const o=e.childNodes||[],i=e.__location||{};tagComponents=a.importNames||[];const u=tagComponents.includes(l);!u&&tagAliasMap[l]&&("img"!==l&&s.push({line:i.line||1,column:i.col||1,reason:"NOTE: 组件名 `"+l+"` 自动转换为 `"+tagAliasMap[l]+"`"}),l=tagAliasMap[l]),n.type=l,RESERVED_TAGS.indexOf(l)>=0?s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件名 `"+l+"` 是系统保留的组件名, 请修改"}):hasTagDefined(l)||s.push({line:i.line||1,column:i.col||1,reason:`WARN: 未识别的标签名 '${l}',如果是自定义组件,请确认已经引入`}),a.uxType===_utils.ENTRY_TYPE.CARD&&tagNatives[l]&&!tagNatives[l].supportCard&&s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 卡片不支持组件名 `"+l+"`, 请修改"}),e._isroot&&tagNotRoot.hasOwnProperty(l)&&s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 不能作为根组件"}),n.attr=n.attr||{};const c=e.attrs||[],p=[];if(c.forEach((function(e){p.push(e.name.toLowerCase())})),e._isroot){const e=["for","if","elif","else","show"];p.forEach((t=>{e.indexOf(t)>=0&&s.push({line:i.line||1,column:i.col||1,reason:"WARN: 根节点 `"+l+"` 不能使用属性 `"+t+"`"})}))}if(!u){if(tagEmpty.hasOwnProperty(l)&&o.length>0&&s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 内不能有子节点与文字,请修改"}),tagAtomics.hasOwnProperty(l)&&"ad-clickable-area"!==l&&(tagTextContent.hasOwnProperty(l)?o.length>0&&o.every((e=>"#text"===e.nodeName||(s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 是原子类型,不应该有子节点"}),!1))):(o.length>1||o[0]&&"#text"!==o[0].nodeName)&&s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 只能有一个文字子节点"})),tagDefaultAttrMap[l]&&Object.keys(tagDefaultAttrMap[l]).forEach((t=>{const n=p.indexOf(t);n>=0&&""===c[n].value?(c[n].value=tagDefaultAttrMap[l][t],s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 属性 `"+t+"` 值为空, 默认设置为缺省值 `"+tagDefaultAttrMap[l][t]+"`"})):"slot"===l&&n<0&&(e.attrs.push({name:t,value:tagDefaultAttrMap[l][t]}),_sharedUtils.colorconsole.warn(`标签 ${l} 的属性 \`${t}\` 值为空, 默认设置为缺省值 \`${tagDefaultAttrMap[l][t]}\` ${a.filePath} @${i.line||1},${i.col||1}`))})),tagRequireAttrMap[l]&&tagRequireAttrMap[l].forEach((e=>{p.indexOf(e)<0&&s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 没有定义属性 `"+e+"`"})})),tagEnumAttrMap[l]&&Object.keys(tagEnumAttrMap[l]).forEach((e=>{const t=p.indexOf(e);if(t>=0){const a=c[t].value;if(!_exp.default.isExpr(a)){const n=tagEnumAttrMap[l][e];n.indexOf(a)<0&&(c[t].value=n[0],s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 属性 `"+e+"` 的值 `"+a+"`非法, 默认设置为缺省值 `"+n[0]+"`"}))}}})),tagAttrMap[l]&&"component"!==l&&p.forEach((e=>{if(!e.match(/^(on|@)/)){if(r.indexOf(extList[2])>=-1&&/^(:|v-|key|ref|is|slot|slot-scope)/.test(e))return;if(RESERVED_DIRECTIVES.test(e))return;const t=checkDataAttr(e),a=Object.prototype.hasOwnProperty.call(tagAttrMap[l],e);t||a||s.push({line:i.line||1,column:i.col||1,reason:"WARN: 组件 `"+l+"` 不支持属性 `"+e})}})),tagEventsMap[l]&&"component"!==l){const e=tagEventsMap[l];p.forEach((t=>{if(t.match(/^(on|@)/)){const n=t.replace(/^(on|@)/,""),r=["appear","disappear","swipe"];a.uxType===_utils.ENTRY_TYPE.CARD&&r.indexOf(n.toLowerCase())>-1&&s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 卡片组件 `"+l+"` 不支持事件 `"+n+"`"}),e.indexOf(n.toLowerCase())<0&&s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 不支持事件 `"+n+"`"})}}))}if(o.length>0){const t=new Set,n={};o.forEach(((e,r)=>{if(isReservedTag(l)&&isReservedTag(e.nodeName)){const o=tagParentsMap[e.nodeName],u=tagChildrenMap[l],c=tagOnceChildrenMap[l];if("slot"===e.nodeName){let n=e.parentNode;for(;n;){if("slot"===n.tagName){_sharedUtils.colorconsole.warn(`slot标签内不应该嵌套slot ${a.filePath}@${i.line||1},${i.col||1}`);break}n=n.parentNode}const s={};e.attrs.map((e=>{s[e.name]=e.value})),s.hasOwnProperty("name")?/\{\{\s*[\w$]+\s*\}\}/.test(s.name)&&_sharedUtils.colorconsole.warn(`标签${e.nodeName}的name属性暂时不支持动态绑定 ${a.filePath}@${i.line||1},${i.col||1}`):s.name="default",t.has(s.name)?_sharedUtils.colorconsole.warn(`标签${l}内存在name为 \`${s.name}\` 重复slot ${a.filePath}@${i.line||1},${i.col||1}`):t.add(s.name)}if(o&&o.indexOf(l)<0||u&&u.indexOf(e.nodeName)<0)s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 不支持子组件 `"+e.nodeName+"`"});else if(c&&c.indexOf(e.nodeName)>-1){let t;(n[e.nodeName]||0===n[e.nodeName])&&(t=!0),n[e.nodeName]={index:r,duplicated:t}}}}));const r=Object.keys(n);r.length&&(r.filter((e=>n[e].duplicated)).forEach((e=>{s.push({line:i.line||1,column:i.col||1,reason:`'WARN: 组件 \`${e}\` 只允许在 \`${l}\` 组件中出现一次`})})),e.childNodes=o.filter(((e,t)=>!(n[e.nodeName]&&n[e.nodeName].duplicated&&t!==n[e.nodeName].index))))}isSupportedSelfClosing(l)||!i.startTag||i.endTag||s.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 缺少闭合标签,请检查"}),"list-item"===l&&hasIfOrFor(o)&&s.push({line:i.line||1,column:i.col||1,reason:"WARN: `list-item` 内部需谨慎使用指令 if 或 for,相同 type 属性的 list-item, DOM 结构必须完全相同`"})}}function checkId(e,t){e&&(t.result.id=_exp.default.isExpr(e)?(0,_exp.default)(e):e)}function checkDataAttr(e){return REG_TAG_DATA_ATTR.test(e)}function checkBuild(e,t){e&&(t.result.append="tree"===e?"tree":"single")}function checkClass(className,output){let hasBinding,classList=[];if(className=className.trim(),className){let start=0,end=0;const segs=[],matched=className.match(REG_CLASS_VALUE);if(matched){let e;matched.forEach((t=>{end=className.indexOf(t,start),e=className.slice(start,end),e.length&&segs.push(e),segs.push(t),start+=e.length+t.length}))}if(segs.push(className.slice(start)),classList=segs.reduce(((e,t)=>_exp.default.isExpr(t)?(hasBinding=!0,e.push((0,_exp.default)(t,!1)),e):e.concat(t.split(/\s+/g).filter((e=>e)).map((e=>`'${e}'`)))),[]),classList=classList.filter((e=>e.trim())),hasBinding){const code="(function () {return ["+classList.join(", ")+"]})";try{output.result.classList=eval(code)}catch(e){throw e.isExpressionError=!0,e.expression=className,e}}else output.result.classList=classList.map((e=>e.slice(1,-1)))}}function checkStyle(e,t,a,n){let s={};const r=t.log;if(e){if(_exp.default.singleExpr(e)){const n=_exp.default.removeExprffix(e);return _exp.default.isExpr(n)?r.push({line:a.line||1,column:a.col||1,reason:"ERROR: style 属性不能嵌套多层{{}}"}):s=(0,_exp.default)(e),void(t.result.style=s)}if(e.split(";").forEach((function(e){let t,l,o,i=e.trim().split(":");i.length>2&&(i[1]=i.slice(1).join(":"),i=i.slice(0,2)),2===i.length&&(t=i[0].trim(),t=(0,_utils.hyphenedToCamelCase)(t),l=i[1].trim(),l=(0,_exp.default)(l),o=_style.default.validateDelaration(t,l,n),l=o.value,l.forEach((e=>{((0,_utils.isValidValue)(e.v)||"function"==typeof e.v)&&(s[e.n]=e.v)})),o.log&&r.push({line:a.line||1,column:a.col||1,reason:o.log.reason}))})),"object"==typeof s)for(let e in s)_style.default.shouldAddToDependency(e,s[e])&&t.depFiles.push(s[e]);t.result.style=s}}function checkIs(e,t,a){const n=t.log;e?(e=_exp.default.addExprffix(e),t.result.is=(0,_exp.default)(e)):n.push({line:a.line||1,column:a.col||1,reason:"WARN: is 属性为空"})}function checkIf(e,t,a,n,s){const r=t.log;e?(e=_exp.default.addExprffix(e),a?e="{{"+buildConditionExp(s)+"}}":(s.length>0&&(s.length=0),s.push(`${e.substr(2,e.length-4)}`)),t.result.shown=(0,_exp.default)(e)):a||r.push({line:n.line||1,column:n.col||1,reason:"WARN: if 属性为空"})}function checkElse(e,t,a,n){checkIf(e,t,!0,a,n),n.length=0}function checkElif(e,t,a,n,s){const r=a.log;let l=t;return e?(e=_exp.default.addExprffix(e),t=_exp.default.addExprffix(t),l="{{("+e.substr(2,e.length-4)+") && "+buildConditionExp(s)+"}}",a.result.shown=(0,_exp.default)(l),s.push(`${e.substr(2,e.length-4)}`)):r.push({line:n.line||1,column:n.col||1,reason:"WARN: Elif 属性为空"}),l}function checkFor(e,t,a){const n=t.log;if(e){let a,n;const s=(e=_exp.default.removeExprffix(e)).match(/(.*) (?:in) (.*)/);if(s){const t=s[1].match(/\((.*),(.*)\)/);t?(a=t[1].trim(),n=t[2].trim()):n=s[1].trim(),e=s[2]}let r;e="{{"+e+"}}",a||n?(r={exp:(0,_exp.default)(e)},a&&(r.key=a),n&&(r.value=n)):r=(0,_exp.default)(e),t.result.repeat=r}else n.push({line:a.line||1,column:a.col||1,reason:"WARN: for 属性为空"})}function checkEvent(name,value,output){const originValue=value,eventName=name.replace(/^(on|@)/,"");if(eventName&&value){value=_exp.default.removeExprffix(value);const paramsMatch=value.match(/(.*)\((.*)\)/);if(paramsMatch){const funcName=paramsMatch[1];let params=paramsMatch[2];params?(params=params.split(/\s*,\s*/),-1===params.indexOf("evt")&&(params[params.length]="evt")):params=["evt"],value="{{"+funcName+"("+params.join(",")+")}}";try{value=eval("(function (evt) { return "+(0,_exp.default)(value,!1).replace("this.evt","evt")+"})")}catch(e){throw e.isExpressionError=!0,e.expression=originValue,e}}output.result.events=output.result.events||{},output.result.events[eventName]=value}}function checkCustomDirective(e,t,a,n){const s=e.replace(/^dir:/,"");if(!s)return _sharedUtils.colorconsole.warn(`\`${n.tagName}\` 组件自定义指令名称不能为空`),!1;a.result.directives=a.result.directives||[],a.result.directives.push({name:s,value:_exp.default.isExpr(t)?(0,_exp.default)(t):t})}function checkAttr(e,t,a,n,s,r){if(e&&(0,_utils.isValidValue)(t)){if(shouldConvertPath(e,t,n)){(0,_utils.fileExists)(t,r.filePath)||a.log.push({line:s.line,column:s.column,reason:"WARN: "+n+" 属性 "+e+" 的值 "+t+" 下不存在对应的文件资源"}),t=(0,_utils.resolvePath)(t,r.filePath),a.depFiles.push(t)}a.result.attr=a.result.attr||{},a.result.attr[(0,_utils.hyphenedToCamelCase)(e)]=(0,_exp.default)(t),"value"===e&&"text"===n&&a.log.push({line:s.line,column:s.column,reason:"WARN: `value` 应该写在<text>标签中"})}}function shouldConvertPath(e,t,a){return!("alt"===e&&"blank"===t)&&!(!(["src","alt"].includes(e)&&t&&["img","video"].indexOf(a)>-1)||/^(data:|http|{{)/.test(t))}function isReservedTag(e){return tagReserved.hasOwnProperty(e)}function isTextContentAtomic(e){return tagTextContent.hasOwnProperty(e)&&tagAtomics.hasOwnProperty(e)}function isNotTextContentAtomic(e){return!tagTextContent.hasOwnProperty(e)&&!tagAtomics.hasOwnProperty(e)}function isSupportSpan(e){if(e&&"string"==typeof e)return tagChildrenMap[e]&&tagChildrenMap[e].indexOf("span")>-1}function getTagChildren(e){if(e&&"string"==typeof e)return tagChildrenMap[e]||[]}function isSupportedSelfClosing(e){if(e&&"string"==typeof e)return e=tagAliasMap[e]||e,tagNatives[e]&&!!tagNatives[e].selfClosing}function hasTagDefined(e){return tagNativeKeys.indexOf(e)>-1||tagComponents.indexOf(e)>-1}function isEmptyElement(e){return e=tagAliasMap[e]||e,tagNatives[e]&&!0===tagNatives[e].empty}function buildConditionExp(e){return e.map((e=>`!(${e})`)).join(" && ")}function hasIfOrFor(e){let t=!1;return e.find((e=>(e.attrs||[]).findIndex((e=>["for","if"].indexOf(e.name)>-1))>-1?(t=!0,t):Array.isArray(e.childNodes)?(t=hasIfOrFor(e.childNodes),t):void 0)),t}tagNativeKeys.forEach((function(e){tagReserved[e]=!0;const t=tagNatives[e];t.atomic&&(tagAtomics[e]=!0),t.textContent&&(tagTextContent[e]=!0),t.empty&&(tagEmpty[e]=!0),t.alias&&t.alias.length&&t.alias.forEach((function(t){tagAliasMap[t]=e})),!0===t.excludeRoot&&(tagNotRoot[e]=!0);let a=(0,_utils.extend)({},t.attrs);const n={},s={},r=[];t.attrs&&!1===t.attrs.extendCommon||(a=(0,_utils.extend)(a,tagCommon.attrs)),"extendCommon"in a&&delete a.extendCommon,Object.keys(a).forEach((function(e){const t=a[e];t.enum&&t.enum.length>0&&(n[e]=t.enum,s[e]=t.enum[0]),t.def&&(s[e]=t.def),!0===t.required&&r.push(e)})),tagAttrMap[e]=a,tagEnumAttrMap[e]=n,tagDefaultAttrMap[e]=s,tagRequireAttrMap[e]=r,tagChildrenMap[e]=t.children?(0,_utils.merge)([],tagCommon.children,t.children):null,tagOnceChildrenMap[e]=t.onceChildren?(0,_utils.merge)([],t.onceChildren):null,tagParentsMap[e]=t.parents?(0,_utils.merge)([],tagCommon.parents,t.parents):null,tagEventsMap[e]=(0,_utils.merge)([],tagCommon.events,t.events)}));var _default={checkTagName:checkTagName,checkId:checkId,checkClass:checkClass,checkStyle:checkStyle,checkIs:checkIs,checkIf:checkIf,checkElse:checkElse,checkElif:checkElif,checkFor:checkFor,checkEvent:checkEvent,checkCustomDirective:checkCustomDirective,checkAttr:checkAttr,checkBuild:checkBuild,checkModel:_model.default,isReservedTag:isReservedTag,isTextContentAtomic:isTextContentAtomic,isSupportSpan:isSupportSpan,getTagChildren:getTagChildren,isSupportedSelfClosing:isSupportedSelfClosing,isEmptyElement:isEmptyElement,isNotTextContentAtomic:isNotTextContentAtomic};exports.default=_default;
//# sourceMappingURL=validator.js.map
{
"name": "@hap-toolkit/compiler",
"version": "1.9.9",
"version": "1.9.10-beta",
"description": "compiler of hap-toolkit",

@@ -21,3 +21,3 @@ "engines": {

"dependencies": {
"@hap-toolkit/shared-utils": "1.9.9",
"@hap-toolkit/shared-utils": "1.9.10-beta",
"css": "^2.2.4",

@@ -27,3 +27,3 @@ "css-what": "^2.1.3",

},
"gitHead": "e0db8383e2b5cb684c0b46b57c7d68070311e31a"
"gitHead": "f74d2f174adfbba983d99816b254b2afe5918c61"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc