@hap-toolkit/compiler 2.0.8-beta.2 → 2.0.9-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +1 -1
- package/lib/lifecycle/index.js +2 -0
- package/lib/lifecycle/validator.js +2 -0
- package/lib/style/mediaquery.js +1 -1
- package/lib/template/index.js +1 -1
- package/lib/template/validator.js +1 -1
- package/package.json +3 -3
- package/LICENSE +0 -51
package/lib/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _exportNames={parseFragmentsWithCache:!0,parseTemplate:!0,parseStyle:!0,parseScript:!0,parseActions:!0,templater:!0,actioner:!0,styler:!0,scripter:!0,serialize:!0,ENTRY_TYPE:!0,FRAG_TYPE:!0,isEmptyObject:!0};Object.defineProperty(exports,"ENTRY_TYPE",{enumerable:!0,get:function(){return _utils.ENTRY_TYPE}}),Object.defineProperty(exports,"FRAG_TYPE",{enumerable:!0,get:function(){return _utils.FRAG_TYPE}}),Object.defineProperty(exports,"actioner",{enumerable:!0,get:function(){return _actions.default}}),Object.defineProperty(exports,"isEmptyObject",{enumerable:!0,get:function(){return _utils.isEmptyObject}}),exports.parseActions=parseActions,exports.parseFragmentsWithCache=parseFragmentsWithCache,exports.parseScript=parseScript,exports.parseStyle=parseStyle,exports.parseTemplate=parseTemplate,Object.defineProperty(exports,"scripter",{enumerable:!0,get:function(){return _script.default}}),Object.defineProperty(exports,"serialize",{enumerable:!0,get:function(){return _utils.serialize}}),Object.defineProperty(exports,"styler",{enumerable:!0,get:function(){return _style.default}}),Object.defineProperty(exports,"templater",{enumerable:!0,get:function(){return _template.default}});var _parse=_interopRequireDefault(require("parse5")),_template=_interopRequireDefault(require("./template")),_actions=_interopRequireDefault(require("./actions")),_style=_interopRequireWildcard(require("./style"));Object.keys(_style).forEach((function(e){"default"!==e&&"__esModule"!==e&&(Object.prototype.hasOwnProperty.call(_exportNames,e)||e in exports&&exports[e]===_style[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _style[e]}}))}));var _script=_interopRequireDefault(require("./script")),_utils=require("./utils");function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(_getRequireWildcardCache=function(e){return e?r:t})(e)}function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=_getRequireWildcardCache(t);if(r&&r.has(e))return r.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _exportNames={parseFragmentsWithCache:!0,parseTemplate:!0,parseStyle:!0,parseScript:!0,parseActions:!0,parseLifecycle:!0,templater:!0,actioner:!0,lifecycler:!0,styler:!0,scripter:!0,serialize:!0,ENTRY_TYPE:!0,FRAG_TYPE:!0,isEmptyObject:!0};Object.defineProperty(exports,"ENTRY_TYPE",{enumerable:!0,get:function(){return _utils.ENTRY_TYPE}}),Object.defineProperty(exports,"FRAG_TYPE",{enumerable:!0,get:function(){return _utils.FRAG_TYPE}}),Object.defineProperty(exports,"actioner",{enumerable:!0,get:function(){return _actions.default}}),Object.defineProperty(exports,"isEmptyObject",{enumerable:!0,get:function(){return _utils.isEmptyObject}}),Object.defineProperty(exports,"lifecycler",{enumerable:!0,get:function(){return _lifecycle.default}}),exports.parseActions=parseActions,exports.parseFragmentsWithCache=parseFragmentsWithCache,exports.parseLifecycle=parseLifecycle,exports.parseScript=parseScript,exports.parseStyle=parseStyle,exports.parseTemplate=parseTemplate,Object.defineProperty(exports,"scripter",{enumerable:!0,get:function(){return _script.default}}),Object.defineProperty(exports,"serialize",{enumerable:!0,get:function(){return _utils.serialize}}),Object.defineProperty(exports,"styler",{enumerable:!0,get:function(){return _style.default}}),Object.defineProperty(exports,"templater",{enumerable:!0,get:function(){return _template.default}});var _parse=_interopRequireDefault(require("parse5")),_template=_interopRequireDefault(require("./template")),_actions=_interopRequireDefault(require("./actions")),_lifecycle=_interopRequireDefault(require("./lifecycle")),_style=_interopRequireWildcard(require("./style"));Object.keys(_style).forEach((function(e){"default"!==e&&"__esModule"!==e&&(Object.prototype.hasOwnProperty.call(_exportNames,e)||e in exports&&exports[e]===_style[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _style[e]}}))}));var _script=_interopRequireDefault(require("./script")),_utils=require("./utils");function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(_getRequireWildcardCache=function(e){return e?r:t})(e)}function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=_getRequireWildcardCache(t);if(r&&r.has(e))return r.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var i=n?Object.getOwnPropertyDescriptor(e,s):null;i&&(i.get||i.set)?Object.defineProperty(a,s,i):a[s]=e[s]}return a.default=e,r&&r.set(e,a),a}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _formatFragment(e,t){let r,a,n,s;const i={};if(t.__location){const e=t.__location;e.startTag&&e.endTag?(r=e.startTag.endOffset||0,a=e.endTag.startOffset||0):(r=e.startOffset||0,a=e.endOffset||0),n=e.line,s=e.col}else r=a=n=s=0;return t.attrs&&t.attrs.length&&t.attrs.forEach((function(e){i[e.name]=e.value})),{type:t.nodeName,attrs:i,content:e.substring(r,a),location:{start:r,end:a,line:n,column:s}}}function parseFragments(e,t){const r={import:[],template:[],style:[],script:[],data:[]};return _parse.default.parseFragment(e,{treeAdapter:_parse.default.treeAdapters.default,locationInfo:!0}).childNodes.forEach((a=>{const n=_formatFragment(e,a);if(r[a.nodeName]&&r[a.nodeName].push(n),"import"===a.nodeName&&a.__location&&!a.__location.endTag)throw new Error(`${t} : <import> 组件缺少闭合标签,请检查 @${n.location.line} : ${n.location.column}`);if("plaintext"===a.nodeName.toLowerCase())throw new Error(`${t} : 禁止使用plaintext @${n.location.line} : ${n.location.column}`)})),r}const fragsCache=new Map;function parseFragmentsWithCache(e,t){return fragsCache.has(t)&&fragsCache.get(t).source===e||fragsCache.set(t,{source:e,frags:parseFragments(e,t)}),fragsCache.get(t).frags}function parseTemplate(e,t){const r=_template.default.parse(e,t),{jsonTemplate:a,log:n,depFiles:s}=r;return{parsed:(0,_utils.serialize)(a,2),log:n,depFiles:s}}function parseStyle(e){const t=_style.default.parse(e),{jsonStyle:r,depList:a,log:n,depFiles:s}=t;return{parsed:JSON.stringify(r,null,2),depList:a,log:n,depFiles:s,jsonStyle:r}}function parseScript(e){return{parsed:_script.default.parse(e)}}function parseActions(e){const{jsonAction:t}=_actions.default.parse(e);return{parsed:JSON.stringify(t)}}function parseLifecycle(e){const{jsonLifecycle:t}=_lifecycle.default.parse(e);return{parsed:JSON.stringify(t)}}
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _validator=require("./validator");function parse(e){if(e&&"[object Object]"!==Object.prototype.toString.call(e))throw new Error("<data> create/update 必须为 Object 对象");return(0,_validator.checkParams)(e.params,1),{jsonLifecycle:e}}var _default={parse:parse};exports.default=_default;
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkParams=checkParams;var _exp=_interopRequireDefault(require("../template/exp"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function isReserved(e){return 36===(e+"").charCodeAt(0)}function checkParams(e,r){e&&"[object Object]"===Object.prototype.toString.call(e)&&Object.keys(e).forEach((t=>{if(isReserved(t))throw new Error("<data> create/update 中 params 参数名不能以 “$” 开头");if(_exp.default.isExpr(e[t])&&r>1)throw new Error("<data> create/update 中 params 参数值只支持一级结构中绑定变量");checkParams(e[t],r+1)}))}
|
|
2
|
+
//# sourceMappingURL=validator.js.map
|
package/lib/style/mediaquery.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const RE_MEDIA_QUERY=/(?:(only|not)?\s*)?(\s*[^\s()]+)?(?:(?:\s*(and)\s*)?(.+))?/i,RE_MEDIA_FEATURE=/^(\(\s*[^()]+\)\s+[a-zA-Z]+\s+)+\(\s*[^()]+\)\s*$|^\(\s*[^()]+\)$/,RE_MQ_DISCRETE_EXPRESSION=/\(\s*([^\s:)]+)\s*(?::\s*([^\s)]+))?\s*\)/,RE_MQ_RANGE_EXPRESSION=/^\((?:([-+]?\d*\.?(?:\d+[a-zA-Z]*|\d+\s*\/\s*\d+))\s*(<|>|<=|>=)?\s*)?(aspect-ratio|resolution|width|height|device-width|device-height)(?:\s*(<|>|<=|>=)?\s*([-+]?\d*\.?(?:\d+[a-zA-Z]*|\d+\s*\/\s*\d+)))?\)$/,mediaQueryTypes=["screen"],featureValidatorMap={height:"number","min-height":"number","max-height":"number",width:"number","min-width":"number","max-width":"number",resolution:"resolution","min-resolution":"resolution","max-resolution":"resolution",orientation:"orientation","aspect-ratio":"ratio","min-aspect-ratio":"ratio","max-aspect-ratio":"ratio","device-height":"number","min-device-height":"number","max-device-height":"number","device-width":"number","min-device-width":"number","max-device-width":"number","prefers-color-scheme":"preferColorScheme",scene:"scene","widget-size":"widgetSize","device-type":"deviceType",manufacturer:"manufacturer","theme-mode":"themeMode"},featureValidator={number:e=>/^(\d+)(px|dp)?$/.test(e)?{value:e}:{reason:function(t){return"ERROR: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `数值`"}},resolution(e){if(/^\d+(dpi|dppx)$/.test(e))return{value:e};if(/^\d+$/.test(e)){return{value:e+"dpi",reason:function(e){return"WARN: 媒体特征 `"+e+"` 的单位为 `dpi | dppx` 自动补齐为 `dpi`"}}}return{reason:function(t){return"ERROR: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `数值 + dpi | dppx`"}}},orientation:e=>/^(portrait|landscape)$/.test(e)?{value:e}:{reason:function(t){return"WARN: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `portrait | landscape`"}},scene:e=>/^(assistantscreen|launcher|globalsearch|calendar|lockscreen|suggestion|voiceassistant|sms|servicecenter|cardesktop|pictorial)$/.test(e)?{value:e}:{reason:function(t){return"WARN: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `assistantscreen | launcher | globalsearch | calendar | lockscreen | suggestion | voiceassistant | sms | servicecenter | cardesktop | pictorial`"}},widgetSize(e){if(e){let t=e.trim();'"'!==t[0]&&"'"!==t[0]||(t=t.slice(1,t.length-1));if(/^(1|2|4|8|AUTO|FULL)x(1|2|4|8|AUTO|FULL)$/.test(t))return{value:t}}return{reason:function(t){return"WARN: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `1x1 | 1x2 | 2x1 | 2x2 | 4x2 | 4x4 | 4xN`"}}},deviceType:e=>/^(phone|watch|car|tablet|foldable|flip)$/.test(e)?{value:e}:{reason:function(t){return"WARN: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `phone | watch | car`"}},manufacturer:e=>/^(xiaomi|vivo|OPPO|honor)$/.test(e)?{value:e}:{reason:function(t){return"WARN: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `xiaomi | vivo | OPPO| honor`"}},ratio:e=>/^(\d+\s*\/\s*\d+|\d+\.\d+|\d+)$/.test(e)?{value:e}:{reason:function(t){return"WARN: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `数值 | 数值/数值`"}},preferColorScheme:e=>/^(light|dark|no-preference)$/.test(e)?{value:e}:{reason:function(t){return"WARN: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `light | dark | no-preference`"}},themeMode:e=>/^(color|default)$/.test(e)?{value:e}:{reason:function(t){return"WARN: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `color | default`"}}};function parseQuery(e){const t=[];return{result:e.split(",").map((function(e){const r=(e=e.trim()).match(RE_MEDIA_QUERY),n=r[1],
|
|
1
|
+
"use strict";const RE_MEDIA_QUERY=/(?:(only|not)?\s*)?(\s*[^\s()]+)?(?:(?:\s*(and)\s*)?(.+))?/i,RE_MEDIA_FEATURE=/^(\(\s*[^()]+\)\s+[a-zA-Z]+\s+)+\(\s*[^()]+\)\s*$|^\(\s*[^()]+\)$/,RE_MQ_DISCRETE_EXPRESSION=/\(\s*([^\s:)]+)\s*(?::\s*([^\s)]+))?\s*\)/,RE_MQ_RANGE_EXPRESSION=/^\((?:([-+]?\d*\.?(?:\d+[a-zA-Z]*|\d+\s*\/\s*\d+))\s*(<|>|<=|>=)?\s*)?(aspect-ratio|resolution|width|height|device-width|device-height)(?:\s*(<|>|<=|>=)?\s*([-+]?\d*\.?(?:\d+[a-zA-Z]*|\d+\s*\/\s*\d+)))?\)$/,mediaQueryTypes=["screen"],featureValidatorMap={height:"number","min-height":"number","max-height":"number",width:"number","min-width":"number","max-width":"number",resolution:"resolution","min-resolution":"resolution","max-resolution":"resolution",orientation:"orientation","aspect-ratio":"ratio","min-aspect-ratio":"ratio","max-aspect-ratio":"ratio","device-height":"number","min-device-height":"number","max-device-height":"number","device-width":"number","min-device-width":"number","max-device-width":"number","prefers-color-scheme":"preferColorScheme","prefers-material":"preferMaterial",scene:"scene","widget-size":"widgetSize","device-type":"deviceType","fold-state":"foldState",manufacturer:"manufacturer","theme-mode":"themeMode"},featureValidator={number:e=>/^(\d+)(px|dp)?$/.test(e)?{value:e}:{reason:function(t){return"ERROR: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `数值`"}},resolution(e){if(/^\d+(dpi|dppx)$/.test(e))return{value:e};if(/^\d+$/.test(e)){return{value:e+"dpi",reason:function(e){return"WARN: 媒体特征 `"+e+"` 的单位为 `dpi | dppx` 自动补齐为 `dpi`"}}}return{reason:function(t){return"ERROR: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `数值 + dpi | dppx`"}}},orientation:e=>/^(portrait|landscape)$/.test(e)?{value:e}:{reason:function(t){return"WARN: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `portrait | landscape`"}},scene:e=>/^(assistantscreen|launcher|globalsearch|calendar|lockscreen|suggestion|voiceassistant|sms|servicecenter|cardesktop|pictorial|notification|island)$/.test(e)?{value:e}:{reason:function(t){return"WARN: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `assistantscreen | launcher | globalsearch | calendar | lockscreen | suggestion | voiceassistant | sms | servicecenter | cardesktop | pictorial | notification | island`"}},widgetSize(e){if(e){let t=e.trim();'"'!==t[0]&&"'"!==t[0]||(t=t.slice(1,t.length-1));if(/^(1|2|4|8|AUTO|FULL)x(1|2|4|8|AUTO|FULL|N)$/.test(t))return{value:t}}return{reason:function(t){return"WARN: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `1x1 | 1x2 | 2x1 | 2x2 | 4x2 | 4x4 | 4xN`"}}},deviceType:e=>/^(phone|watch|car|tablet|foldable|flip)$/.test(e)?{value:e}:{reason:function(t){return"WARN: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `phone | watch | car`"}},foldState:e=>/^(close|open)$/.test(e)?{value:e}:{reason:function(t){return"WARN: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `close | open`"}},manufacturer:e=>/^(xiaomi|vivo|OPPO|honor)$/.test(e)?{value:e}:{reason:function(t){return"WARN: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `xiaomi | vivo | OPPO| honor`"}},ratio:e=>/^(\d+\s*\/\s*\d+|\d+\.\d+|\d+)$/.test(e)?{value:e}:{reason:function(t){return"WARN: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `数值 | 数值/数值`"}},preferColorScheme:e=>/^(light|dark|no-preference)$/.test(e)?{value:e}:{reason:function(t){return"WARN: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `light | dark | no-preference`"}},preferMaterial:e=>/^(none|frosted|glass)$/.test(e)?{value:e}:{reason:function(t){return"WARN: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `none | frosted | glass`"}},themeMode:e=>/^(color|default)$/.test(e)?{value:e}:{reason:function(t){return"WARN: 媒体特征 `"+t+"` 的值 `"+e+"` 不正确, 必须为 `color | default`"}}};function parseQuery(e){const t=[];return{result:e.split(",").map((function(e){const r=(e=e.trim()).match(RE_MEDIA_QUERY),n=r[1],a=r[2],i=r[3],o=r[4]||"";if(o&&!o.match(RE_MEDIA_FEATURE))return void t.push("WARN: 媒体特征格式错误");const s={};s.modifier=n,s.type=a?a.toLowerCase():"screen";let u=o.match(/\([^)]+\)/g)||[];return s.operator=i,s.expressions=u.map((function(r){const n=new RegExp(`\\)\\s+([a-zA-Z]+)?\\s+${r.replace(/\(/,"\\(").replace(/\)/,"\\)")}`),a=e.match(n);let i="";if(a&&(i=a[1],"and"!==i&&"or"!==i))return void t.push("WARN: 媒体特征连接符必须为 and 或者 or");let o=r.match(RE_MQ_DISCRETE_EXPRESSION);return o?{type:"discrete",combineSymbol:i,feature:o[1],value:o[2]}:(o=r.match(RE_MQ_RANGE_EXPRESSION),o?{type:"range",combineSymbol:i,beforeValue:o[1],beforeSymbol:o[2],feature:o[3],afterSymbol:o[4],afterValue:o[5]}:void t.push('WARN: 无效的媒体特征表达式: "'+r+'"'))})),s})),error:t}}function validateDiscreteValue(e,t,r,n){const a=featureValidator[r](e.value),{value:i,reason:o}=a;let s="";return o&&o&&n.push(o(t)),i&&(s+=`${t}: ${i}`),s}function validateRangeValue(e,t,r,n){function a(e){let a=featureValidator[r](e);const{reason:i,value:o}=a;return i&&n.push(i(t)),o}let{beforeValue:i,beforeSymbol:o,afterSymbol:s,afterValue:u}=e,d=t;if(i){if(i=a(i),!i)return"";d=`${i} ${o} ${d}`}if(u){if(u=a(u),!u)return"";d=`${d} ${s} ${u}`}return d}function validateMediaCondition(e){if(e){const t=[],r=parseQuery(e);if(r.error.length>0)return r.error.forEach((r=>{r+=", 表达式: `"+e+"` 有错误,请检查",t.push(r)})),{reason:t};const n=[];return r.result.forEach((e=>{const{modifier:r,type:a,operator:i,expressions:o}=e;if(-1===mediaQueryTypes.indexOf(a))return void t.push("WARN: 媒体类型 `"+a+"` 不支持");let s=i||"";o.length>0&&!i&&(s="and");let u=r?`${r} ${a} ${s}`:`${a} ${s}`;o.forEach((e=>{const{feature:r,combineSymbol:n,type:a}=e,i=featureValidatorMap[r];if(!i)return u="",void t.push("WARN: 媒体特征 `"+r+"` 不支持");let o="";"discrete"===a?o=validateDiscreteValue(e,r,i,t):"range"===a&&(o=validateRangeValue(e,r,i,t)),o?u+=n?` ${n} (${o})`:` (${o})`:u=""})),n.push(u)})),{value:n.join(" or "),reason:t}}return{value:""}}function findMediaClassByCondition(e,t){if(t){return e.find((e=>e.condition===t))}return null}function wrapMediaCode(e,t){return`@media ${t} {\n${e}\n}`}module.exports={validateMediaCondition:validateMediaCondition,findMediaClassByCondition:findMediaClassByCondition,wrapMediaCode:wrapMediaCode};
|
|
2
2
|
//# sourceMappingURL=mediaquery.js.map
|
package/lib/template/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _parse=_interopRequireDefault(require("parse5")),_parser=_interopRequireDefault(require("parse5/lib/parser")),_tokenizer=_interopRequireDefault(require("parse5/lib/tokenizer")),_sharedUtils=require("@hap-toolkit/shared-utils"),_validator=_interopRequireDefault(require("./validator")),_compress=require("./compress");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function calcSubTextNodesNum(e,t){let a=0;if(_validator.default.isSupportSpan(e)){const l=_validator.default.getTagChildren(e);t.forEach((function(e){("#text"===e.nodeName&&e.value.trim()||l.indexOf(e.nodeName)>-1)&&++a}))}return a}function traverse(e,t,a,l,o){_validator.default.checkTagName(e,t,o);(e.attrs||[]).forEach((function(r){let i=r.name;const n=i.match(/^:+/);n&&(i=i.slice(n.length));const s=r.value;let c={line:1,column:1};switch(e.__location&&(c={line:e.__location.line,column:e.__location.col}),i){case"id":_validator.default.checkId(s,t,o),_validator.default.checkAttr(i,s,t,e.tagName,c,o);break;case"class":_validator.default.checkClass(s,t,o);break;case"style":_validator.default.checkStyle(s,t,c,o);break;case"if":e._isroot||_validator.default.checkIf(s,t,!1,c,l,o);break;case"is":_validator.default.checkIs(s,t,c,o);break;case"else":e._isroot||a&&a.__cond__&&_validator.default.checkElse(a.__cond__,t,c,l,o);break;case"elif":e._isroot||a&&a.__cond__&&(e.__cond__=_validator.default.checkElif(s,a.__cond__,t,c,l,o));break;case"for":e._isroot||_validator.default.checkFor(s,t,c,o);break;case"tree":_validator.default.checkBuild("tree",t);break;default:i.match(/^(on|@)/)?_validator.default.checkEvent(i,s,t,o):i.match(/^model:/)?_validator.default.checkModel(i,s,t,e,c,o):i.match(/^dir:/)?_validator.default.checkCustomDirective(i,s,t,e,o):_validator.default.checkAttr(i,s,t,e.tagName,c,o)}}));const r=t.result,i=e.childNodes;if(i&&i.length){let a,l;const n=[],s=calcSubTextNodesNum(r.type,i);i.forEach((function(c,u){u>0&&(l=i[u-1],l.nodeName.match(/^#/)||(a=l,a.__cond__||a.attrs&&a.attrs.forEach((function(e){"if"!==e.name&&"elif"!==e.name||(a.__cond__=e.value)}))));const d={};if(c.nodeName.match(/^#/)){if("#text"===c.nodeName&&c.value.trim()){l&&_validator.default.isSupportedSelfClosing(l.nodeName)||_validator.default.isNotTextContentAtomic(e.tagName)&&t.log.push({line:e.__location.line,column:e.__location.col,reason:`Warn: 组件 ${e.tagName} 不支持文本内容作为子节点`});const a=_validator.default.isSupportSpan(e.tagName)&&s>=2,i=o.importNames&&o.importNames.indexOf(e.tagName)>-1;if((a||i)&&(d.type="span",t.result=d,r.children=r.children||[],r.children.push(d),t.log.push({line:e.__location.line,column:e.__location.col,reason:`WARN: 文本和span标签并行存在,编译时将文本节点:"${c.value}" 用span包裹(关于span嵌套的使用,请参考官方文档"span嵌套")`}),_validator.default.checkAttr("value",c.value,t,null,null,o)),"option"===e.tagName){const e=t.result;return t.result=r,r.attr.hasOwnProperty("value")||_validator.default.checkAttr("value",c.value,t,null,null,o),_validator.default.checkAttr("content",c.value,t,null,null,o),void(t.result=e)}if(_validator.default.isSupportSpan(e.tagName)&&1===s||_validator.default.isTextContentAtomic(e.tagName)){const e=t.result;t.result=r,_validator.default.checkAttr("value",c.value,t,null,null,o),t.result=e}}}else t.result=d,r.children=r.children||[],r.children.push(d),traverse(c,t,a,n,o)})),r.children&&0===r.children.length&&(r.children=void 0)}t.result=r}function initParser(e,t,a){const l=new _parser.default(t),o=l._appendElement,r=l._insertElement;function i(e){if(!e.tagName)return;const t=e.tagName.toLowerCase(),o=e.selfClosing,r=_validator.default.isSupportedSelfClosing(t),i=_validator.default.isEmptyElement(t);if(l.__m.tagName&&!l.__m.selfClosing&&!i){const t=String(e.location.line)+":"+String(e.location.col);(!r||t!==l.__m.pos&&e.type===_tokenizer.default.START_TAG_TOKEN)&&(_sharedUtils.colorconsole.warn(`${l.__m.tagName}标签要闭合,请遵循XML规范 ${a}@${l.__m.pos}`),l.__m={})}r&&(e.type!==_tokenizer.default.START_TAG_TOKEN||o||(l.__m.tagName=t,l.__m.selfClosing=!1,l.__m.pos=String(e.location.line)+":"+String(e.location.col)),e.type===_tokenizer.default.END_TAG_TOKEN&&t===l.__m.tagName&&(l.__m.selfClosing=!0))}function n(e){e.tagName&&"plaintext"===e.tagName.toLowerCase()&&_sharedUtils.colorconsole.error(`${a} : 禁止使用 plaintext 标签@${e.location.line}:${e.location.col}`)}return l._insertElement=function(e){const t=(e.tagName||"").toLowerCase(),l=e.selfClosing,i=_validator.default.isSupportedSelfClosing(t);l&&!i&&_sharedUtils.colorconsole.error(`${t}标签,禁止使用自闭合 ${a}@${e.location.line}:${e.location.col}`),i||l&&t?o.apply(this,arguments):r.apply(this,arguments)},l.__m={},l._runParsingLoop=function(e){for(;!this.stopped;){this._setupTokenizerCDATAMode();const t=this.tokenizer.getNextToken();if(i(t),n(t),t.type===_tokenizer.default.HIBERNATION_TOKEN)break;if(this.skipNextNewLine&&(this.skipNextNewLine=!1,t.type===_tokenizer.default.WHITESPACE_CHARACTER_TOKEN&&"\n"===t.chars[0])){if(1===t.chars.length)continue;t.chars=t.chars.substr(1)}if(this._processInputToken(t),e&&this.pendingScript)break}},l.parseFragment(e)}function parse(e,t){const a=initParser(e,{treeAdapter:_parse.default.treeAdapters.default,locationInfo:!0},t.filePath),l={result:{},log:[],depFiles:[]};if(!a||!a.childNodes)return l.log.push({reason:"ERROR: <template>解析失败",line:1,column:1}),{jsonTemplate:l.result,log:l.log,depFiles:l.depFiles};const o=a.childNodes.filter((function(e){return"#"!==e.nodeName.charAt(0)}));if(0===o.length)return l.log.push({reason:"ERROR: 没有合法的根节点",line:1,column:1}),{jsonTemplate:l.result,log:l.log,depFiles:l.depFiles};if(o.length>1)return l.log.push({reason:"ERROR: <template>节点里只能有一个根节点",line:1,column:1}),{jsonTemplate:l.result,log:l.log,depFiles:l.depFiles};const r=o[0];r._isroot=!0;try{traverse(r,l,null,null,t)}catch(e){if(!e.isExpressionError)throw e;l.log.push({reason:`ERROR: 表达式解析失败 ${e.message}\n\n> ${e.expression}\n\nat ${t.filePath}`})}return _sharedUtils.compileOptionsObject.optimizeTemplateAttr&&(0,_compress.compressTemplateAttr)(l.result),{jsonTemplate:l.result,log:l.log,depFiles:l.depFiles}}var _default={parse:parse,validator:_validator.default};exports.default=_default;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _parse=_interopRequireDefault(require("parse5")),_parser=_interopRequireDefault(require("parse5/lib/parser")),_tokenizer=_interopRequireDefault(require("parse5/lib/tokenizer")),_sharedUtils=require("@hap-toolkit/shared-utils"),_validator=_interopRequireDefault(require("./validator")),_compress=require("./compress");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function calcSubTextNodesNum(e,t){let a=0;if(_validator.default.isSupportSpan(e)){const l=_validator.default.getTagChildren(e);t.forEach((function(e){("#text"===e.nodeName&&e.value.trim()||l.indexOf(e.nodeName)>-1)&&++a}))}return a}function traverse(e,t,a,l,o){_validator.default.checkTagName(e,t,o);(e.attrs||[]).forEach((function(r){let i=r.name;const n=i.match(/^:+/);n&&(i=i.slice(n.length));const s=r.value;let c={line:1,column:1};switch(e.__location&&(c={line:e.__location.line,column:e.__location.col}),_validator.default.checkForbiddenFeature(s,c,o),i){case"id":_validator.default.checkId(s,t,o),_validator.default.checkAttr(i,s,t,e.tagName,c,o);break;case"class":_validator.default.checkClass(s,t,o);break;case"style":_validator.default.checkStyle(s,t,c,o);break;case"if":e._isroot||_validator.default.checkIf(s,t,!1,c,l,o);break;case"is":_validator.default.checkIs(s,t,c,o);break;case"else":e._isroot||a&&a.__cond__&&_validator.default.checkElse(a.__cond__,t,c,l,o);break;case"elif":e._isroot||a&&a.__cond__&&(e.__cond__=_validator.default.checkElif(s,a.__cond__,t,c,l,o));break;case"for":e._isroot||_validator.default.checkFor(s,t,c,o);break;case"tree":_validator.default.checkBuild("tree",t);break;default:i.match(/^(on|@)/)?_validator.default.checkEvent(i,s,t,o):i.match(/^model:/)?_validator.default.checkModel(i,s,t,e,c,o):i.match(/^dir:/)?_validator.default.checkCustomDirective(i,s,t,e,o):_validator.default.checkAttr(i,s,t,e.tagName,c,o)}}));const r=t.result,i=e.childNodes;if(i&&i.length){let a,l;const n=[],s=calcSubTextNodesNum(r.type,i);i.forEach((function(c,u){u>0&&(l=i[u-1],l.nodeName.match(/^#/)||(a=l,a.__cond__||a.attrs&&a.attrs.forEach((function(e){"if"!==e.name&&"elif"!==e.name||(a.__cond__=e.value)}))));const d={};if(c.nodeName.match(/^#/)){if("#text"===c.nodeName&&c.value.trim()){_validator.default.checkForbiddenFeature(c.value,e.__location?{line:e.__location.line,column:e.__location.col}:null,o),l&&_validator.default.isSupportedSelfClosing(l.nodeName)||_validator.default.isNotTextContentAtomic(e.tagName)&&t.log.push({line:e.__location.line,column:e.__location.col,reason:`Warn: 组件 ${e.tagName} 不支持文本内容作为子节点`});const a=_validator.default.isSupportSpan(e.tagName)&&s>=2,i=o.importNames&&o.importNames.indexOf(e.tagName)>-1;if((a||i)&&(d.type="span",t.result=d,r.children=r.children||[],r.children.push(d),t.log.push({line:e.__location.line,column:e.__location.col,reason:`WARN: 文本和span标签并行存在,编译时将文本节点:"${c.value}" 用span包裹(关于span嵌套的使用,请参考官方文档"span嵌套")`}),_validator.default.checkAttr("value",c.value,t,null,null,o)),"option"===e.tagName){const e=t.result;return t.result=r,r.attr.hasOwnProperty("value")||_validator.default.checkAttr("value",c.value,t,null,null,o),_validator.default.checkAttr("content",c.value,t,null,null,o),void(t.result=e)}if(_validator.default.isSupportSpan(e.tagName)&&1===s||_validator.default.isTextContentAtomic(e.tagName)){const e=t.result;t.result=r,_validator.default.checkAttr("value",c.value,t,null,null,o),t.result=e}}}else t.result=d,r.children=r.children||[],r.children.push(d),traverse(c,t,a,n,o)})),r.children&&0===r.children.length&&(r.children=void 0)}t.result=r}function initParser(e,t,a){const l=new _parser.default(t),o=l._appendElement,r=l._insertElement;function i(e){if(!e.tagName)return;const t=e.tagName.toLowerCase(),o=e.selfClosing,r=_validator.default.isSupportedSelfClosing(t),i=_validator.default.isEmptyElement(t);if(l.__m.tagName&&!l.__m.selfClosing&&!i){const t=String(e.location.line)+":"+String(e.location.col);(!r||t!==l.__m.pos&&e.type===_tokenizer.default.START_TAG_TOKEN)&&(_sharedUtils.colorconsole.warn(`${l.__m.tagName}标签要闭合,请遵循XML规范 ${a} @${l.__m.pos}`),l.__m={})}r&&(e.type!==_tokenizer.default.START_TAG_TOKEN||o||(l.__m.tagName=t,l.__m.selfClosing=!1,l.__m.pos=String(e.location.line)+":"+String(e.location.col)),e.type===_tokenizer.default.END_TAG_TOKEN&&t===l.__m.tagName&&(l.__m.selfClosing=!0))}function n(e){e.tagName&&"plaintext"===e.tagName.toLowerCase()&&_sharedUtils.colorconsole.error(`${a} : 禁止使用 plaintext 标签@${e.location.line}:${e.location.col}`)}return l._insertElement=function(e){const t=(e.tagName||"").toLowerCase(),l=e.selfClosing,i=_validator.default.isSupportedSelfClosing(t);l&&!i&&_sharedUtils.colorconsole.error(`${t}标签,禁止使用自闭合 ${a} @${e.location.line}:${e.location.col}`),i||l&&t?o.apply(this,arguments):r.apply(this,arguments)},l.__m={},l._runParsingLoop=function(e){for(;!this.stopped;){this._setupTokenizerCDATAMode();const t=this.tokenizer.getNextToken();if(i(t),n(t),t.type===_tokenizer.default.HIBERNATION_TOKEN)break;if(this.skipNextNewLine&&(this.skipNextNewLine=!1,t.type===_tokenizer.default.WHITESPACE_CHARACTER_TOKEN&&"\n"===t.chars[0])){if(1===t.chars.length)continue;t.chars=t.chars.substr(1)}if(this._processInputToken(t),e&&this.pendingScript)break}},l.parseFragment(e)}function parse(e,t){const a=initParser(e,{treeAdapter:_parse.default.treeAdapters.default,locationInfo:!0},t.filePath),l={result:{},log:[],depFiles:[]};if(!a||!a.childNodes)return l.log.push({reason:"ERROR: <template>解析失败",line:1,column:1}),{jsonTemplate:l.result,log:l.log,depFiles:l.depFiles};const o=a.childNodes.filter((function(e){return"#"!==e.nodeName.charAt(0)}));if(0===o.length)return l.log.push({reason:"ERROR: 没有合法的根节点",line:1,column:1}),{jsonTemplate:l.result,log:l.log,depFiles:l.depFiles};if(o.length>1)return l.log.push({reason:"ERROR: <template>节点里只能有一个根节点",line:1,column:1}),{jsonTemplate:l.result,log:l.log,depFiles:l.depFiles};const r=o[0];r._isroot=!0;try{traverse(r,l,null,null,t)}catch(e){if(e.isForbiddenFeatureError)l.log.push({line:e.line,column:e.column,fatal:!0,reason:`ERROR: 耗时 Feature "${e.feature}" 不允许在模板表达式中使用。\n 原因:模板表达式在 UI 线程同步执行,耗时调用会阻塞渲染。\n 建议:将该调用移到 create.params 或 action params 中。\n 表达式:${e.expression}\n at ${t.filePath}`});else{if(!e.isExpressionError)throw e;l.log.push({reason:`ERROR: 表达式解析失败 ${e.message}\n\n> ${e.expression}\n\nat ${t.filePath}`})}}return _sharedUtils.compileOptionsObject.optimizeTemplateAttr&&(0,_compress.compressTemplateAttr)(l.result),{jsonTemplate:l.result,log:l.log,depFiles:l.depFiles}}var _default={parse:parse,validator:_validator.default};exports.default=_default;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"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"],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"]},overflow:{enum:["visible","hidden"]}},children:["block","slot","component"],parents:["block"]},tagNatives={div:{supportCard:!0,attrs:{enablevideofullscreencontainer:{enum:["false","true"]},uiversion:{enum:["g2"]}}},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":{},uiversion:{enum:["g2"]}}},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"]},uiversion:{enum:["g2"]}}},slider:{supportCard:!0,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:{supportCard:!0,children:["list-item"],attrs:{scrollpage:{enum:["false","true"]},focusbehavior:{enum:["aligned","edged"]}},events:["scroll","scrollbottom","scrolltop","scrollend","scrolltouchup","selected"]},"list-item":{supportCard:!0,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:{supportCard:!0,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:{supportCard:!0,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","round","segmented"]}}},picker:{minRequiredRuntimeVersion:1201,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:{supportCard:!0,minRequiredRuntimeVersion:1201,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:{minRequiredRuntimeVersion:1201,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:{supportCard:!0,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 s=t.result,n=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);if(!u&&tagAliasMap[l]&&("img"!==l&&n.push({line:i.line||1,column:i.col||1,reason:"NOTE: 组件名 `"+l+"` 自动转换为 `"+tagAliasMap[l]+"`"}),l=tagAliasMap[l]),s.type=l,RESERVED_TAGS.indexOf(l)>=0?n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件名 `"+l+"` 是系统保留的组件名, 请修改"}):hasTagDefined(l)||n.push({line:i.line||1,column:i.col||1,reason:`WARN: 未识别的标签名 '${l}',如果是自定义组件,请确认已经引入`}),a.uxType===_utils.ENTRY_TYPE.CARD&&tagNatives[l]&&!tagNatives[l].supportCard&&n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 卡片不支持组件名 `"+l+"`, 请修改"}),(a.uxType===_utils.ENTRY_TYPE.CARD||a.uxType===_utils.ENTRY_TYPE.COMP)&&tagNatives[l]&&a.minCardRuntimeVersion&&a.minCardRuntimeVersion<tagNatives[l].minRequiredRuntimeVersion){const e=i.line&&i.column?"@"+i.line+":"+i.column:"";a.isTargetVivo?_sharedUtils.colorconsole.throw("ERROR: "+e+" 使用 `"+l+"` 组件,要求卡片配置 minCardPlatformVersion 或 minPlatformVersion 不低于 "+tagNatives[l].minRequiredRuntimeVersion+", 请修改"):_sharedUtils.colorconsole.warn("ERROR: "+e+" 使用 `"+l+"` 组件,要求卡片配置 minCardPlatformVersion 或 minPlatformVersion 不低于 "+tagNatives[l].minRequiredRuntimeVersion+", 请修改")}e._isroot&&tagNotRoot.hasOwnProperty(l)&&n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 不能作为根组件"}),s.attr=s.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&&n.push({line:i.line||1,column:i.col||1,reason:"WARN: 根节点 `"+l+"` 不能使用属性 `"+t+"`"})}))}if(!u){if(tagEmpty.hasOwnProperty(l)&&o.length>0&&n.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||(n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 是原子类型,不应该有子节点"}),!1))):(o.length>1||o[0]&&"#text"!==o[0].nodeName)&&n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 只能有一个文字子节点"})),tagDefaultAttrMap[l]&&Object.keys(tagDefaultAttrMap[l]).forEach((t=>{const s=p.indexOf(t);s>=0&&""===c[s].value?(c[s].value=tagDefaultAttrMap[l][t],n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 属性 `"+t+"` 值为空, 默认设置为缺省值 `"+tagDefaultAttrMap[l][t]+"`"})):"slot"===l&&s<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&&n.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 s=tagEnumAttrMap[l][e];s.indexOf(a)<0&&(c[t].value=s[0],n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 属性 `"+e+"` 的值 `"+a+"`非法, 默认设置为缺省值 `"+s[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||n.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 s=t.replace(/^(on|@)/,""),r=["appear","disappear","swipe"];a.uxType===_utils.ENTRY_TYPE.CARD&&r.indexOf(s.toLowerCase())>-1&&n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 卡片组件 `"+l+"` 不支持事件 `"+s+"`"}),e.indexOf(s.toLowerCase())<0&&n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 不支持事件 `"+s+"`"})}}))}if(o.length>0){const t=new Set,s={};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 s=e.parentNode;for(;s;){if("slot"===s.tagName){_sharedUtils.colorconsole.warn(`slot标签内不应该嵌套slot ${a.filePath}@${i.line||1},${i.col||1}`);break}s=s.parentNode}const n={};e.attrs.map((e=>{n[e.name]=e.value})),n.hasOwnProperty("name")?/\{\{\s*[\w$]+\s*\}\}/.test(n.name)&&_sharedUtils.colorconsole.warn(`标签${e.nodeName}的name属性暂时不支持动态绑定 ${a.filePath}@${i.line||1},${i.col||1}`):n.name="default",t.has(n.name)?_sharedUtils.colorconsole.warn(`标签${l}内存在name为 \`${n.name}\` 重复slot ${a.filePath}@${i.line||1},${i.col||1}`):t.add(n.name)}if(o&&o.indexOf(l)<0||u&&u.indexOf(e.nodeName)<0)n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 不支持子组件 `"+e.nodeName+"`"});else if(c&&c.indexOf(e.nodeName)>-1){let t;(s[e.nodeName]||0===s[e.nodeName])&&(t=!0),s[e.nodeName]={index:r,duplicated:t}}}}));const r=Object.keys(s);r.length&&(r.filter((e=>s[e].duplicated)).forEach((e=>{n.push({line:i.line||1,column:i.col||1,reason:`'WARN: 组件 \`${e}\` 只允许在 \`${l}\` 组件中出现一次`})})),e.childNodes=o.filter(((e,t)=>!(s[e.nodeName]&&s[e.nodeName].duplicated&&t!==s[e.nodeName].index))))}isSupportedSelfClosing(l)||!i.startTag||i.endTag||n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+l+"` 缺少闭合标签,请检查"}),"list-item"===l&&hasIfOrFor(o)&&n.push({line:i.line||1,column:i.col||1,reason:"WARN: `list-item` 内部需谨慎使用指令 if 或 for,相同 type 属性的 list-item, DOM 结构必须完全相同`"})}}function checkId(e,t,a){if(e){const s=a.lite,n=a.newJSCard;t.result.id=_exp.default.isExpr(e)?(0,_exp.default)(e,!0,s,n):e,n&&(t.result.idRaw=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,options){let hasBinding,classList=[];className=className.trim();const isLite=options.lite,isNewJSCard=options.newJSCard;if(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,isLite)),e):e.concat(t.split(/\s+/g).filter((e=>e)).map((e=>isLite?e:`'${e}'`)))),[]),classList=classList.filter((e=>e.trim())),isLite){if(!isValidClassArray(segs)){const e=new Error("轻卡 class 样式不支持动态数据绑定 {{}} 和静态样式混用");throw e.isExpressionError=!0,e.expression=className,e}output.result.classList=classList}else if(hasBinding)try{let code="";isNewJSCard?(code="function () {return ["+classList.join(", ")+"]}",output.result.classList=code):(code="(function () {return ["+classList.join(", ")+"]})",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)))}isNewJSCard&&(output.result.class=className,output.result.classListRaw=className)}function checkStyle(e,t,a,s){let n={},r={};const l=t.log;if(e){const o=s.lite,i=s.newJSCard;if(_exp.default.singleExpr(e)){const s=_exp.default.removeExprffix(e);return _exp.default.isExpr(s)?l.push({line:a.line||1,column:a.col||1,reason:"ERROR: style 属性不能嵌套多层{{}}"}):n=(0,_exp.default)(e,!0,o,i),t.result.style=n,void(i&&(t.result.styleRaw=e))}if(e.split(";").forEach((function(e){let t,u,c,p=e.trim().split(":");if(p.length>2&&(p[1]=p.slice(1).join(":"),p=p.slice(0,2)),2===p.length){t=p[0].trim(),t=(0,_utils.hyphenedToCamelCase)(t),u=p[1].trim();const e=u;u=(0,_exp.default)(u,!0,o,i),c=_style.default.validateDelaration(t,u,s),u=c.value,u.forEach((t=>{((0,_utils.isValidValue)(t.v)||"function"==typeof t.v)&&(n[t.n]=t.v,i&&(r[t.n]=e))})),c.log&&l.push({line:a.line||1,column:a.col||1,reason:c.log.reason})}})),"object"==typeof n)for(let e in n)_style.default.shouldAddToDependency(e,n[e])&&t.depFiles.push(n[e]);t.result.style=n,i&&(t.result.styleRaw=r)}}function checkIs(e,t,a,s){const n=t.log;if(e){e=_exp.default.addExprffix(e);const a=s.lite,n=s.newJSCard;t.result.is=(0,_exp.default)(e,!0,a,n),n&&(t.result.isRaw=e)}else n.push({line:a.line||1,column:a.col||1,reason:"WARN: is 属性为空"})}function checkIf(e,t,a,s,n,r){const l=t.log;if(e){e=_exp.default.addExprffix(e);const s=r.lite,l=r.newJSCard;a?e="{{"+buildConditionExp(n)+"}}":(n.length>0&&(n.length=0),n.push(`${e.substr(2,e.length-4)}`)),t.result.shown=s?e:(0,_exp.default)(e,!0,s,l),l&&(t.result.shownRaw=e)}else a||l.push({line:s.line||1,column:s.col||1,reason:"WARN: if 属性为空"})}function checkElse(e,t,a,s,n){checkIf(e,t,!0,a,s,n),s.length=0}function checkElif(e,t,a,s,n,r){const l=a.log;let o=t;if(e){e=_exp.default.addExprffix(e),t=_exp.default.addExprffix(t);const s=r.lite,l=r.newJSCard;o="{{("+e.substr(2,e.length-4)+") && "+buildConditionExp(n)+"}}",a.result.shown=s?o:(0,_exp.default)(o,!0,s,l),l&&(a.result.shownRaw=o),n.push(`${e.substr(2,e.length-4)}`)}else l.push({line:s.line||1,column:s.col||1,reason:"WARN: Elif 属性为空"});return o}function checkFor(e,t,a,s){const n=t.log;if(e){let a,n;const r=(e=_exp.default.removeExprffix(e)).match(/(.*) (?:in) (.*)/);if(r){const t=r[1].match(/\((.*),(.*)\)/);t?(a=t[1].trim(),n=t[2].trim()):n=r[1].trim(),e=r[2]}e="{{"+e+"}}";const l=s.lite,o=s.newJSCard;let i,u;a||n?(i={exp:(0,_exp.default)(e,!0,l,o)},u={expRaw:e},a&&(i.key=a),n&&(i.value=n)):(i=(0,_exp.default)(e,!0,l,o),u=e),t.result.repeat=i,o&&(t.result.repeatRaw=u)}else n.push({line:a.line||1,column:a.col||1,reason:"WARN: for 属性为空"})}function checkEvent(name,value,output,options){const originValue=value,eventName=name.replace(/^(on|@)/,"");if(eventName&&value){value=_exp.default.removeExprffix(value);const paramsMatch=value.match(/(.*)\((.*)\)/);if(paramsMatch){if(options.lite){const e=new Error("轻卡不支持带参数的事件");throw e.isExpressionError=!0,e.expression=value,e}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=options.newJSCard?"function (evt) { return "+(0,_exp.default)(value,!1).replace("this.evt","evt")+"}":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,s,n){const r=e.replace(/^dir:/,"");if(!r)return _sharedUtils.colorconsole.warn(`\`${s.tagName}\` 组件自定义指令名称不能为空`),!1;const l=n.newJSCard;a.result.directives=a.result.directives||[],l?(t=_exp.default.addExprffix(t),a.result.directives.push({name:r,value:_exp.default.isExpr(t)?(0,_exp.default)(t,!0,n.lite,n.newJSCard):t,valueRaw:t})):a.result.directives.push({name:r,value:_exp.default.isExpr(t)?(0,_exp.default)(t,!0,n.lite,n.newJSCard):t})}function checkAttr(e,t,a,s,n,r){if(e&&(0,_utils.isValidValue)(t)){const l=r.cardEntry;if(shouldConvertPath(e,t,s)){if(!_exp.default.isExpr(t)){(0,_utils.fileExists)(t,r.filePath)||a.log.push({line:n.line,column:n.column,reason:"WARN: "+s+" 属性 "+e+" 的值 "+t+" 下不存在对应的文件资源"})}t=(0,_utils.resolvePath)(t,r.filePath,l),a.depFiles.push(t)}const o=r.lite,i=r.newJSCard;a.result.attr=a.result.attr||{},a.result.attr[(0,_utils.hyphenedToCamelCase)(e)]=(0,_exp.default)(t,!0,o,i),i&&(a.result.attr[(0,_utils.hyphenedToCamelCase)(e)+"Raw"]=t),"value"===e&&"text"===s&&a.log.push({line:n.line,column:n.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}function isValidClassArray(e){const t=e.filter((e=>e.length>0));let a=!1;for(let e=0;e<t.length;e++)if(_exp.default.isExpr(t[e])){a=!0;break}return!a||1===t.length}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,_sharedUtils.extend)({},t.attrs);const s={},n={},r=[];t.attrs&&!1===t.attrs.extendCommon||(a=(0,_sharedUtils.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&&(s[e]=t.enum,n[e]=t.enum[0]),t.def&&(n[e]=t.def),!0===t.required&&r.push(e)})),tagAttrMap[e]=a,tagEnumAttrMap[e]=s,tagDefaultAttrMap[e]=n,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,isExpr:_exp.default.isExpr,parseText:_exp.default.parseText};exports.default=_default;
|
|
1
|
+
"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"],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"]},overflow:{enum:["visible","hidden"]}},children:["block","slot","component"],parents:["block"]},tagNatives={div:{supportCard:!0,attrs:{enablevideofullscreencontainer:{enum:["false","true"]},uiversion:{enum:["g2"]}}},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":{},uiversion:{enum:["g2"]}}},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"]},uiversion:{enum:["g2"]}}},slider:{supportCard:!0,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","intercepturl"],attrs:{src:{},trustedurl:{},allowthirdpartycookies:{enum:["false","true"]},enablenightmode:{enum:["true","false"]},showloadingdialog:{enum:["false","true"]},supportzoom:{enum:["true","false"]},intercepturl:{}}},list:{supportCard:!0,children:["list-item"],attrs:{scrollpage:{enum:["false","true"]},focusbehavior:{enum:["aligned","edged"]}},events:["scroll","scrollbottom","scrolltop","scrollend","scrolltouchup","selected"]},"list-item":{supportCard:!0,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:{supportCard:!0,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:{supportCard:!0,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","round","segmented","arc"]}}},picker:{minRequiredRuntimeVersion:1201,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:{supportCard:!0,minRequiredRuntimeVersion:1201,empty:!0,attrs:{src:{},loop:{enum:["true","false"]},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},"object-fit":{enum:["contain","cover","fill","none","scale-down"]}},events:["prepared","start","pause","finish","error","seeking","seeked","timeupdate","fullscreenchange","firstframe","buffering","error"]},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:{minRequiredRuntimeVersion:1201,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:{supportCard:!0,empty:!0,attrs:{source:{required:!0},progress:{},speed:{},"start-frame":{},"end-frame":{},loop:{enum:[!0,!1]},autoplay:{enum:[!1,!0]},rendermode:{enum:["AUTOMATIC","HARDWARE","SOFTWARE"]}},events:["complete","error","change","loaded"]},"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 s=t.result,n=t.log,r=_path.default.extname(a.filePath);let o=e.tagName;const l=e.childNodes||[],i=e.__location||{};tagComponents=a.importNames||[];const u=tagComponents.includes(o);if(!u&&tagAliasMap[o]&&("img"!==o&&n.push({line:i.line||1,column:i.col||1,reason:"NOTE: 组件名 `"+o+"` 自动转换为 `"+tagAliasMap[o]+"`"}),o=tagAliasMap[o]),s.type=o,RESERVED_TAGS.indexOf(o)>=0?n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件名 `"+o+"` 是系统保留的组件名, 请修改"}):hasTagDefined(o)||n.push({line:i.line||1,column:i.col||1,reason:`WARN: 未识别的标签名 '${o}',如果是自定义组件,请确认已经引入`}),a.uxType===_utils.ENTRY_TYPE.CARD&&tagNatives[o]&&!tagNatives[o].supportCard&&n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 卡片不支持组件名 `"+o+"`, 请修改"}),(a.uxType===_utils.ENTRY_TYPE.CARD||a.uxType===_utils.ENTRY_TYPE.COMP)&&tagNatives[o]&&a.minCardRuntimeVersion&&a.minCardRuntimeVersion<tagNatives[o].minRequiredRuntimeVersion){const e=i.line&&i.column?"@"+i.line+":"+i.column:"";a.isTargetVivo?_sharedUtils.colorconsole.throw("ERROR: "+e+" 使用 `"+o+"` 组件,要求卡片配置 minCardPlatformVersion 或 minPlatformVersion 不低于 "+tagNatives[o].minRequiredRuntimeVersion+", 请修改"):_sharedUtils.colorconsole.warn("ERROR: "+e+" 使用 `"+o+"` 组件,要求卡片配置 minCardPlatformVersion 或 minPlatformVersion 不低于 "+tagNatives[o].minRequiredRuntimeVersion+", 请修改")}e._isroot&&tagNotRoot.hasOwnProperty(o)&&n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+o+"` 不能作为根组件"}),s.attr=s.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&&n.push({line:i.line||1,column:i.col||1,reason:"WARN: 根节点 `"+o+"` 不能使用属性 `"+t+"`"})}))}if(!u){if(tagEmpty.hasOwnProperty(o)&&l.length>0&&n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+o+"` 内不能有子节点与文字,请修改"}),tagAtomics.hasOwnProperty(o)&&"ad-clickable-area"!==o&&(tagTextContent.hasOwnProperty(o)?l.length>0&&l.every((e=>"#text"===e.nodeName||(n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+o+"` 是原子类型,不应该有子节点"}),!1))):(l.length>1||l[0]&&"#text"!==l[0].nodeName)&&n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+o+"` 只能有一个文字子节点"})),tagDefaultAttrMap[o]&&Object.keys(tagDefaultAttrMap[o]).forEach((t=>{const s=p.indexOf(t);s>=0&&""===c[s].value?(c[s].value=tagDefaultAttrMap[o][t],n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+o+"` 属性 `"+t+"` 值为空, 默认设置为缺省值 `"+tagDefaultAttrMap[o][t]+"`"})):"slot"===o&&s<0&&(e.attrs.push({name:t,value:tagDefaultAttrMap[o][t]}),_sharedUtils.colorconsole.warn(`标签 ${o} 的属性 \`${t}\` 值为空, 默认设置为缺省值 \`${tagDefaultAttrMap[o][t]}\` ${a.filePath} @${i.line||1},${i.col||1}`))})),tagRequireAttrMap[o]&&tagRequireAttrMap[o].forEach((e=>{p.indexOf(e)<0&&n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+o+"` 没有定义属性 `"+e+"`"})})),tagEnumAttrMap[o]&&Object.keys(tagEnumAttrMap[o]).forEach((e=>{const t=p.indexOf(e);if(t>=0){const a=c[t].value;if(!_exp.default.isExpr(a)){const s=tagEnumAttrMap[o][e];s.indexOf(a)<0&&(c[t].value=s[0],n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+o+"` 属性 `"+e+"` 的值 `"+a+"`非法, 默认设置为缺省值 `"+s[0]+"`"}))}}})),tagAttrMap[o]&&"component"!==o&&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[o],e);t||a||n.push({line:i.line||1,column:i.col||1,reason:"WARN: 组件 `"+o+"` 不支持属性 `"+e})}})),tagEventsMap[o]&&"component"!==o){const e=tagEventsMap[o];p.forEach((t=>{if(t.match(/^(on|@)/)){const s=t.replace(/^(on|@)/,""),r=["appear","disappear","swipe"];a.uxType===_utils.ENTRY_TYPE.CARD&&r.indexOf(s.toLowerCase())>-1&&n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 卡片组件 `"+o+"` 不支持事件 `"+s+"`"}),e.indexOf(s.toLowerCase())<0&&n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+o+"` 不支持事件 `"+s+"`"})}}))}if(l.length>0){const t=new Set,s={};l.forEach(((e,r)=>{if(isReservedTag(o)&&isReservedTag(e.nodeName)){const l=tagParentsMap[e.nodeName],u=tagChildrenMap[o],c=tagOnceChildrenMap[o];if("slot"===e.nodeName){let s=e.parentNode;for(;s;){if("slot"===s.tagName){_sharedUtils.colorconsole.warn(`slot标签内不应该嵌套slot ${a.filePath}@${i.line||1},${i.col||1}`);break}s=s.parentNode}const n={};e.attrs.map((e=>{n[e.name]=e.value})),n.hasOwnProperty("name")?/\{\{\s*[\w$]+\s*\}\}/.test(n.name)&&_sharedUtils.colorconsole.warn(`标签${e.nodeName}的name属性暂时不支持动态绑定 ${a.filePath}@${i.line||1},${i.col||1}`):n.name="default",t.has(n.name)?_sharedUtils.colorconsole.warn(`标签${o}内存在name为 \`${n.name}\` 重复slot ${a.filePath}@${i.line||1},${i.col||1}`):t.add(n.name)}if(l&&l.indexOf(o)<0||u&&u.indexOf(e.nodeName)<0)n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+o+"` 不支持子组件 `"+e.nodeName+"`"});else if(c&&c.indexOf(e.nodeName)>-1){let t;(s[e.nodeName]||0===s[e.nodeName])&&(t=!0),s[e.nodeName]={index:r,duplicated:t}}}}));const r=Object.keys(s);r.length&&(r.filter((e=>s[e].duplicated)).forEach((e=>{n.push({line:i.line||1,column:i.col||1,reason:`'WARN: 组件 \`${e}\` 只允许在 \`${o}\` 组件中出现一次`})})),e.childNodes=l.filter(((e,t)=>!(s[e.nodeName]&&s[e.nodeName].duplicated&&t!==s[e.nodeName].index))))}isSupportedSelfClosing(o)||!i.startTag||i.endTag||n.push({line:i.line||1,column:i.col||1,reason:"ERROR: 组件 `"+o+"` 缺少闭合标签,请检查"}),"list-item"===o&&hasIfOrFor(l)&&n.push({line:i.line||1,column:i.col||1,reason:"WARN: `list-item` 内部需谨慎使用指令 if 或 for,相同 type 属性的 list-item, DOM 结构必须完全相同`"})}}function checkId(e,t,a){if(e){const s=a.lite,n=a.newJSCard;t.result.id=_exp.default.isExpr(e)?(0,_exp.default)(e,!0,s,n):e,n&&(t.result.idRaw=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,options){let hasBinding,classList=[];className=className.trim();const isLite=options.lite,isNewJSCard=options.newJSCard;if(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,isLite)),e):e.concat(t.split(/\s+/g).filter((e=>e)).map((e=>isLite?e:`'${e}'`)))),[]),classList=classList.filter((e=>e.trim())),isLite){if(!isValidClassArray(segs)){const e=new Error("轻卡 class 样式不支持动态数据绑定 {{}} 和静态样式混用");throw e.isExpressionError=!0,e.expression=className,e}output.result.classList=classList}else if(hasBinding)try{let code="";isNewJSCard?(code="function () {return ["+classList.join(", ")+"]}",output.result.classList=code):(code="(function () {return ["+classList.join(", ")+"]})",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)))}isNewJSCard&&(output.result.class=className,output.result.classListRaw=className)}function checkStyle(e,t,a,s){let n={},r={};const o=t.log;if(e){const l=s.lite,i=s.newJSCard;if(_exp.default.singleExpr(e)){const s=_exp.default.removeExprffix(e);return _exp.default.isExpr(s)?o.push({line:a.line||1,column:a.col||1,reason:"ERROR: style 属性不能嵌套多层{{}}"}):n=(0,_exp.default)(e,!0,l,i),t.result.style=n,void(i&&(t.result.styleRaw=e))}if(e.split(";").forEach((function(e){let t,u,c,p=e.trim().split(":");if(p.length>2&&(p[1]=p.slice(1).join(":"),p=p.slice(0,2)),2===p.length){t=p[0].trim(),t=(0,_utils.hyphenedToCamelCase)(t),u=p[1].trim();const e=u;u=(0,_exp.default)(u,!0,l,i),c=_style.default.validateDelaration(t,u,s),u=c.value,u.forEach((t=>{((0,_utils.isValidValue)(t.v)||"function"==typeof t.v)&&(n[t.n]=t.v,i&&(r[t.n]=e))})),c.log&&o.push({line:a.line||1,column:a.col||1,reason:c.log.reason})}})),"object"==typeof n)for(let e in n)_style.default.shouldAddToDependency(e,n[e])&&t.depFiles.push(n[e]);t.result.style=n,i&&(t.result.styleRaw=r)}}function checkIs(e,t,a,s){const n=t.log;if(e){e=_exp.default.addExprffix(e);const a=s.lite,n=s.newJSCard;t.result.is=(0,_exp.default)(e,!0,a,n),n&&(t.result.isRaw=e)}else n.push({line:a.line||1,column:a.col||1,reason:"WARN: is 属性为空"})}function checkIf(e,t,a,s,n,r){const o=t.log;if(e){e=_exp.default.addExprffix(e);const s=r.lite,o=r.newJSCard;a?e="{{"+buildConditionExp(n)+"}}":(n.length>0&&(n.length=0),n.push(`${e.substr(2,e.length-4)}`)),t.result.shown=s?e:(0,_exp.default)(e,!0,s,o),o&&(t.result.shownRaw=e)}else a||o.push({line:s.line||1,column:s.col||1,reason:"WARN: if 属性为空"})}function checkElse(e,t,a,s,n){checkIf(e,t,!0,a,s,n),s.length=0}function checkElif(e,t,a,s,n,r){const o=a.log;let l=t;if(e){e=_exp.default.addExprffix(e),t=_exp.default.addExprffix(t);const s=r.lite,o=r.newJSCard;l="{{("+e.substr(2,e.length-4)+") && "+buildConditionExp(n)+"}}",a.result.shown=s?l:(0,_exp.default)(l,!0,s,o),o&&(a.result.shownRaw=l),n.push(`${e.substr(2,e.length-4)}`)}else o.push({line:s.line||1,column:s.col||1,reason:"WARN: Elif 属性为空"});return l}function checkFor(e,t,a,s){const n=t.log;if(e){let a,n;const r=(e=_exp.default.removeExprffix(e)).match(/(.*) (?:in) (.*)/);if(r){const t=r[1].match(/\((.*),(.*)\)/);t?(a=t[1].trim(),n=t[2].trim()):n=r[1].trim(),e=r[2]}e="{{"+e+"}}";const o=s.lite,l=s.newJSCard;let i,u;a||n?(i={exp:(0,_exp.default)(e,!0,o,l)},u={expRaw:e},a&&(i.key=a),n&&(i.value=n)):(i=(0,_exp.default)(e,!0,o,l),u=e),t.result.repeat=i,l&&(t.result.repeatRaw=u)}else n.push({line:a.line||1,column:a.col||1,reason:"WARN: for 属性为空"})}function checkEvent(name,value,output,options){const originValue=value,eventName=name.replace(/^(on|@)/,"");if(eventName&&value){value=_exp.default.removeExprffix(value);const paramsMatch=value.match(/(.*)\((.*)\)/);if(paramsMatch){if(options.lite){const e=new Error("轻卡不支持带参数的事件");throw e.isExpressionError=!0,e.expression=value,e}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=options.newJSCard?"function (evt) { return "+(0,_exp.default)(value,!1).replace("this.evt","evt")+"}":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,s,n){const r=e.replace(/^dir:/,"");if(!r)return _sharedUtils.colorconsole.warn(`\`${s.tagName}\` 组件自定义指令名称不能为空`),!1;const o=n.newJSCard;a.result.directives=a.result.directives||[],o?(t=_exp.default.addExprffix(t),a.result.directives.push({name:r,value:_exp.default.isExpr(t)?(0,_exp.default)(t,!0,n.lite,n.newJSCard):t,valueRaw:t})):a.result.directives.push({name:r,value:_exp.default.isExpr(t)?(0,_exp.default)(t,!0,n.lite,n.newJSCard):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,_sharedUtils.extend)({},t.attrs);const s={},n={},r=[];t.attrs&&!1===t.attrs.extendCommon||(a=(0,_sharedUtils.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&&(s[e]=t.enum,n[e]=t.enum[0]),t.def&&(n[e]=t.def),!0===t.required&&r.push(e)})),tagAttrMap[e]=a,tagEnumAttrMap[e]=s,tagDefaultAttrMap[e]=n,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)}));const FORBIDDEN_TEMPLATE_FEATURES=["system.geolocation.getLocation","service.push.subscribe"],FORBIDDEN_FEATURE_MATCHERS=FORBIDDEN_TEMPLATE_FEATURES.map((e=>{const t=e.split(".").map((e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))).join("\\s*\\.\\s*");return{feature:e,re:new RegExp("(?:^|[^\\w$.])"+t+"\\s*\\(")}}));function checkForbiddenFeature(e,t,a){if(a&&a.lite&&e&&"string"==typeof e&&_exp.default.isExpr(e))for(let a=0;a<FORBIDDEN_FEATURE_MATCHERS.length;a++){const{feature:s,re:n}=FORBIDDEN_FEATURE_MATCHERS[a];if(n.test(e)){const a=new Error(`耗时 Feature "${s}" 不允许在模板表达式中使用`);throw a.isForbiddenFeatureError=!0,a.feature=s,a.expression=e.trim(),t&&(a.line=t.line,a.column=t.column),a}}}function checkAttr(e,t,a,s,n,r){if(e&&(0,_utils.isValidValue)(t)){const o=r.cardEntry;if(shouldConvertPath(e,t,s)){if(!_exp.default.isExpr(t)){(0,_utils.fileExists)(t,r.filePath)||a.log.push({line:n.line,column:n.column,reason:"WARN: "+s+" 属性 "+e+" 的值 "+t+" 下不存在对应的文件资源"})}t=(0,_utils.resolvePath)(t,r.filePath,o),a.depFiles.push(t)}const l=r.lite,i=r.newJSCard;a.result.attr=a.result.attr||{},a.result.attr[(0,_utils.hyphenedToCamelCase)(e)]=(0,_exp.default)(t,!0,l,i),i&&(a.result.attr[(0,_utils.hyphenedToCamelCase)(e)+"Raw"]=t),"value"===e&&"text"===s&&a.log.push({line:n.line,column:n.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}function isValidClassArray(e){const t=e.filter((e=>e.length>0));let a=!1;for(let e=0;e<t.length;e++)if(_exp.default.isExpr(t[e])){a=!0;break}return!a||1===t.length}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,checkForbiddenFeature:checkForbiddenFeature,checkBuild:checkBuild,checkModel:_model.default,isReservedTag:isReservedTag,isTextContentAtomic:isTextContentAtomic,isSupportSpan:isSupportSpan,getTagChildren:getTagChildren,isSupportedSelfClosing:isSupportedSelfClosing,isEmptyElement:isEmptyElement,isNotTextContentAtomic:isNotTextContentAtomic,isExpr:_exp.default.isExpr,parseText:_exp.default.parseText};exports.default=_default;
|
|
2
2
|
//# sourceMappingURL=validator.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hap-toolkit/compiler",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9-alpha.1",
|
|
4
4
|
"description": "compiler of hap-toolkit",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=14.0.0"
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"lib/**/*.js"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@hap-toolkit/shared-utils": "2.0.
|
|
25
|
+
"@hap-toolkit/shared-utils": "2.0.9-alpha.1",
|
|
26
26
|
"@jayfate/path": "^0.0.13",
|
|
27
27
|
"css": "^2.2.4",
|
|
28
28
|
"css-what": "^2.1.3",
|
|
29
29
|
"parse5": "^3.0.3"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "9fbf8ec01cc7fbd44a4908ecdc407a5022e89e7e"
|
|
32
32
|
}
|
package/LICENSE
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
-
|
|
11
|
-
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
-
|
|
13
|
-
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
|
-
|
|
15
|
-
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
-
|
|
17
|
-
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
-
|
|
19
|
-
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
-
|
|
21
|
-
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
22
|
-
|
|
23
|
-
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
24
|
-
|
|
25
|
-
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
26
|
-
|
|
27
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
-
|
|
29
|
-
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
30
|
-
|
|
31
|
-
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
32
|
-
|
|
33
|
-
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
34
|
-
|
|
35
|
-
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
36
|
-
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
37
|
-
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
38
|
-
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
39
|
-
|
|
40
|
-
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
41
|
-
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
42
|
-
|
|
43
|
-
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
44
|
-
|
|
45
|
-
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
46
|
-
|
|
47
|
-
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
48
|
-
|
|
49
|
-
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
50
|
-
|
|
51
|
-
END OF TERMS AND CONDITIONS
|