@oracle/oraclejet-audit 16.1.4 → 17.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/corePackMigrator/cli.js +1 -1
  2. package/corePackMigrator/corePackMigrator.js +2 -2
  3. package/corePackMigrator/metadata/actionCardMetadata.json +10 -0
  4. package/corePackMigrator/metadata/avatarMetadata.json +11 -1
  5. package/corePackMigrator/metadata/bindIfMetadata.json +4 -0
  6. package/corePackMigrator/metadata/buttonMetadata.json +65 -49
  7. package/corePackMigrator/metadata/chartMetadata.json +53 -0
  8. package/corePackMigrator/metadata/collapsibleMetadata.json +27 -12
  9. package/corePackMigrator/metadata/conveyorBeltMetadata.json +34 -0
  10. package/corePackMigrator/metadata/datePickerMetadata.json +43 -0
  11. package/corePackMigrator/metadata/drawerLayoutMetadata.json +18 -0
  12. package/corePackMigrator/metadata/drawerPopupMetadata.json +27 -14
  13. package/corePackMigrator/metadata/filePickerMetadata.json +20 -7
  14. package/corePackMigrator/metadata/formLayoutMetadata.json +11 -1
  15. package/corePackMigrator/metadata/highlightTextMetadata.json +10 -0
  16. package/corePackMigrator/metadata/inputDateMetadata.json +110 -0
  17. package/corePackMigrator/metadata/inputNumberMetadata.json +107 -75
  18. package/corePackMigrator/metadata/inputPasswordMetadata.json +111 -75
  19. package/corePackMigrator/metadata/inputTextMetadata.json +118 -81
  20. package/corePackMigrator/metadata/labelValueMetadata.json +245 -0
  21. package/corePackMigrator/metadata/legendItemMetadata.json +11 -1
  22. package/corePackMigrator/metadata/legendMetadata.json +59 -49
  23. package/corePackMigrator/metadata/listItemLayoutMetadata.json +11 -1
  24. package/corePackMigrator/metadata/listviewMetadata.json +104 -63
  25. package/corePackMigrator/metadata/messageBannerMetadata.json +10 -0
  26. package/corePackMigrator/metadata/messagesMetadata.json +11 -1
  27. package/corePackMigrator/metadata/progressBarMetadata.json +11 -1
  28. package/corePackMigrator/metadata/progressCircleMetadata.json +10 -0
  29. package/corePackMigrator/metadata/radiosetMetadata.json +11 -1
  30. package/corePackMigrator/metadata/ratingGaugeMetadata.json +113 -87
  31. package/corePackMigrator/metadata/selectManyMetadata.json +72 -42
  32. package/corePackMigrator/metadata/selectSingleMetadata.json +61 -46
  33. package/corePackMigrator/metadata/selectorMetadata.json +1 -1
  34. package/corePackMigrator/metadata/statusMeterGaugeMetadata.json +1 -1
  35. package/corePackMigrator/metadata/tagCloudMetadata.json +10 -0
  36. package/corePackMigrator/metadata/textAreaMetadata.json +88 -46
  37. package/corePackMigrator/resource/astUtils.js +1 -1
  38. package/corePackMigrator/resource/componentMigrator.js +1 -1
  39. package/corePackMigrator/resource/fileScanner.js +1 -1
  40. package/corePackMigrator/resource/htmlUtils.js +1 -1
  41. package/corePackMigrator/resource/manifest.json +137 -36
  42. package/corePackMigrator/resource/testUtils.js +6 -0
  43. package/corePackMigrator/templates/componentMetaData.json +118 -14
  44. package/corePackMigrator/templates/migrationConfig.json +4 -0
  45. package/corePackMigrator/utilities/deltaWebElementAPIs.js +6 -0
  46. package/corePackMigrator/utilities/logging.js +1 -1
  47. package/jaf-amd.js +1 -1
  48. package/lib/AstJson.js +1 -1
  49. package/lib/Components.js +1 -1
  50. package/lib/Config.js +1 -1
  51. package/lib/ConfigEx.js +6 -0
  52. package/lib/ConfigLib.js +1 -1
  53. package/lib/MetaLib.js +1 -1
  54. package/lib/OjCPack.js +1 -1
  55. package/lib/RegTypes.js +1 -1
  56. package/lib/RulePack.js +1 -1
  57. package/lib/RuleSet.js +1 -1
  58. package/lib/Rules.js +1 -1
  59. package/lib/TsxUtils.js +1 -1
  60. package/lib/checkage.js +1 -1
  61. package/lib/defaults.js +1 -1
  62. package/lib/extends.js +1 -1
  63. package/lib/migrator.js +1 -1
  64. package/lib/ns.js +1 -1
  65. package/libext/expparser.js +1 -1
  66. package/meta/16.1.0/jetauditmeta.js +1 -1
  67. package/meta/17.0.0/jetauditmeta.js +9 -0
  68. package/meta/metaverlist.json +1 -1
  69. package/package.json +3 -3
  70. package/profiles/best-practice.json +97 -78
  71. package/profiles/redwood-strict.json +22 -14
  72. package/rulepacks/csp/csp-json-unsafe-expr.js +1 -1
  73. package/rulepacks/jetwc/jetwc-bootstrap.js +1 -1
  74. package/rulepacks/jetwc/jetwc-css-scoping.js +1 -1
  75. package/rulepacks/jetwc/jetwc-displayname.js +1 -1
  76. package/rulepacks/jetwc/jetwc-jet-version.js +1 -1
  77. package/rulepacks/jetwc/jetwc-markdown-link.js +1 -1
  78. package/rulepacks/jetwc/jetwc-namespace.js +1 -1
  79. package/rulepacks/jetwc/jetwc-nls-languages.js +1 -1
  80. package/rulepacks/jetwc/jetwc-property-nesting.js +1 -1
  81. package/rulepacks/jetwc/jetwc-property-translatable.js +1 -1
  82. package/rulepacks/jetwc/jetwc-require-paths.js +1 -1
  83. package/rulepacks/jetwc/jetwc-reserved-property.js +1 -1
  84. package/rulepacks/jetwc/jetwc-schema.js +1 -1
  85. package/rulepacks/jetwc/jetwc-standard-files.js +1 -1
  86. package/rulepacks/jetwc/jetwc-vb-category.js +1 -1
  87. package/rulepacks/jetwc/rules.json +1 -1
  88. package/rulepacks/jetwc-lib/jetwcutils-auditComponentCacheManager.js +1 -1
  89. package/rulepacks/jetwc-lib/jetwcutils-commonListenerImpls.js +1 -1
  90. package/rulepacks/jetwc-lib/jetwcutils-componentAuditUtils.js +1 -1
  91. package/rulepacks/jetwc-lib/jetwcutils-componentFinder.js +1 -1
  92. package/rulepacks/jetwc-lib/jetwcutils-tsxUtils.js +1 -1
  93. package/rulepacks/jetwco/jetwco-bootstrap.js +1 -1
  94. package/rulepacks/jetwco/jetwco-component-api-baseline-changes.js +1 -1
  95. package/rulepacks/jetwco/jetwco-component-api-changes.js +1 -1
  96. package/rulepacks/jetwco/jetwco-component-api-controlled-changes.js +1 -1
  97. package/rulepacks/jetwco/jetwco-license-info.js +1 -1
  98. package/rulepacks/jetwco/jetwco-prerelease-cdn.js +1 -1
  99. package/rulepacks/jetwco/jetwco-validate-applied-audits.js +1 -1
  100. package/rulepacks/jetwco/rules.json +1 -1
  101. package/rules/jet/helpers/cssHelper.js +1 -1
  102. package/rules/jet/helpers/has-attrib-value.js +6 -0
  103. package/rules/jet/helpers/tsx/has-prop-value.js +6 -0
  104. package/rules/jet/msgid.json +1 -1
  105. package/rules/jet/oj-acc-button-label.js +6 -0
  106. package/rules/jet/oj-css-style-bp-display.js +1 -1
  107. package/rules/jet/oj-html-attr-expr-writeback.js +1 -1
  108. package/rules/jet/oj-html-bindif-test.js +1 -1
  109. package/rules/jet/oj-html-binding-as-slot-child.js +1 -1
  110. package/rules/jet/oj-html-bp-button-xs-chroming.js +6 -0
  111. package/rules/jet/oj-html-bp-title-to-tooltip.js +6 -0
  112. package/rules/jet/oj-html-button-size-chroming.js +6 -0
  113. package/rules/jet/oj-html-dlg-title.js +1 -1
  114. package/rules/jet/oj-html-form-bindif.js +1 -1
  115. package/rules/jet/oj-html-ko-comment.js +1 -1
  116. package/rules/jet/oj-html-ko-databind.js +1 -1
  117. package/rules/jet/oj-html-ojattr-value.js +1 -1
  118. package/rules/jet/oj-html-ojtag-ns.js +1 -1
  119. package/rules/jet/oj-html-redwood-clear-icon.js +6 -0
  120. package/rules/jet/oj-html-slot-default.js +1 -1
  121. package/rules/jet/oj-html-slot-pref-content.js +1 -1
  122. package/rules/jet/oj-html-style-abs-units.js +1 -1
  123. package/rules/jet/oj-html-style-bp-color.js +1 -1
  124. package/rules/jet/oj-html-style-bp-display.js +1 -1
  125. package/rules/jet/oj-html-style-bp-font-family.js +1 -1
  126. package/rules/jet/oj-html-style-bp-font.js +1 -1
  127. package/rules/jet/oj-html-style-bp-margin-padding.js +6 -0
  128. package/rules/jet/oj-html-wctag-maintenance.js +1 -1
  129. package/rules/jet/oj-tsx-acc-button-label.js +6 -0
  130. package/rules/jet/oj-tsx-bp-button-xs-chroming.js +6 -0
  131. package/rules/jet/oj-tsx-bp-title-to-tooltip.js +6 -0
  132. package/rules/jet/oj-tsx-button-size-chroming.js +6 -0
  133. package/rules/jet/oj-tsx-dlg-title.js +1 -1
  134. package/rules/jet/oj-tsx-form-bindif.js +1 -1
  135. package/rules/jet/oj-tsx-ojtag-ns.js +1 -1
  136. package/rules/jet/oj-tsx-redwood-clear-icon.js +6 -0
  137. package/rules/jet/oj-tsx-slot-default.js +6 -0
  138. package/rules/jet/oj-tsx-slot-pref-content.js +1 -1
  139. package/rules/jet/oj-tsx-style-abs-units.js +6 -0
  140. package/rules/jet/oj-tsx-style-bp-margin-padding.js +6 -0
  141. package/rules/jet/oj-tsx-wctag-maintenance.js +1 -1
  142. package/rules/jet/rules.json +1 -1
  143. package/schema/component-schema.json +1 -1
  144. package/src/JafCore.js +1 -1
  145. package/types/index.d.ts +3 -0
package/lib/TsxUtils.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const TSX2_UTILS=require("./TsxUtils2");const HTML_UTILS=require("./HtmlUtils");const CB_END="end";const CB_NEXT_COMP="next-comp";const TSX_COMPONENT="TsxComponent";const TSX_PROPERTY="TsxProperty";const TEMPLATE="template";const OJ_DEFER="oj-defer";const OJ_BIND="oj-bind";const BODY="body";var TsxUtils=function(assert){this._fnAssert=assert;this._metaLib=null};TsxUtils.prototype.extractTsxProperties=function(ruleCtx,tsxRC,cb){this._onTsxRC(ruleCtx,tsxRC,cb)};TsxUtils.prototype.getProperty=function(tsxObj,propName){return this._extractProp(tsxObj,propName)};TsxUtils.prototype._extractProp=function(tsxObj,propName){var ret,ot;if(tsxObj&&(ot=tsxObj.type)){if(ot===TSX_PROPERTY){return tsxObj}if(ot===TSX_COMPONENT&&propName){let props,prop,i;if(props=tsxObj.properties){for(i=0;i<props.length;i++){prop=props[i];if(prop.name===propName){ret=prop;break}}}}}return ret};TsxUtils.prototype.getPropertyRawValue=function(tsxComp,name,stripDelims){var prop,ret;if(prop=this.getProperty(tsxComp,name)){ret=prop.valueRaw;if(stripDelims&&ret.charAt(0)==="\""){ret=ret.charAt(1)==="\""?ret="":ret.substring(1,ret.length-1)}}return typeof ret==="string"?ret:null};TsxUtils.prototype.getPropertyValue=function(tsxComp,propName){var tsxProp,ret,obj,i;var a=propName.split(".");var major=a[0];if(tsxProp=this.getProperty(tsxComp,major)){if(a.length===1){return tsxProp.node.value}if(!this.isPropertyPreactExpr(tsxProp)){return undefined}obj=tsxProp.node.value;for(i=1;i<a.length;i++){major=a.shift();if(!_isObject(obj)){break}if((obj=obj[major])&&_isObject(obj)){continue}break}}return ret};TsxUtils.prototype.getPropertyStringValue=function(tsxObj,propName){var tsxProp,value,ret;if(tsxProp=this._extractProp(tsxObj,propName)){value=tsxProp.node.value;if(value!==null){ret=value.type==="Literal"&&typeof value.value==="string"?value.value:null}}else{ret=null}return ret};TsxUtils.prototype.isPropertyPreactExpr=function(tsxObj,propName){var tsxProp,ret=false;if(tsxProp=this._extractProp(tsxObj,propName)){ret=tsxProp.node.value.type==="JSXExpressionContainer"}return ret};TsxUtils.prototype.isPropertyObjectExpr=function(tsxObj,propName){var tsxProp,ret=false;if(tsxProp=this._extractProp(tsxObj,propName)){if(tsxProp.node.value.type==="JSXExpressionContainer"){let expr=tsxProp.node.value.expression;ret=expr&&expr.type==="ObjectExpression"}}return ret};TsxUtils.prototype.isPropertyString=function(tsxObj,propName){var tsxProp,ret=false;if(tsxProp=this._extractProp(tsxObj,propName)){ret=tsxProp.node.value.type==="Literal"&&typeof tsxProp.node.value.value==="string"}return ret};TsxUtils.prototype.getAncestor=function(tsxComp,name){var o,ret;name=name||tsxComp.name;while(o=tsxComp.parent){if(o.name===name){ret=o;break}tsxComp=o}return ret||null};TsxUtils.prototype.getChildren=function(tsxComp){return tsxComp.children};TsxUtils.prototype.getDescendant=function(tsxComp,name){var childs,child,ret,i;while(childs=tsxComp.children){for(i=0;i<childs.length;i++){child=childs[i];if(child.name===name){ret=child;break}if(ret=this.getDescendant(child,name)){break}}break}return ret||null};TsxUtils.prototype.getDirectDescendant=function(tsxComp,name){var childs,child,ret,i;if(childs=tsxComp.children){for(i=0;i<childs.length;i++){child=childs[i];if(child.name===name){ret=child;break}}}return ret||null};TsxUtils.prototype.isExpressionObject=function(tsxObj,propName){var tsxProp,ret;if(tsxProp=this._extractProp(tsxObj,propName)){if(tsxProp.node.value.type==="JSXExpressionContainer"){let expr=tsxProp.node.value.expression;ret=expr.type==="ObjectExpression"}}return!!ret};TsxUtils.prototype.getExpressionObject=function(tsxObj,propName){var tsxProp,obj;if(tsxProp=this._extractProp(tsxObj,propName)){if(!tsxProp.node.value){return null}if(tsxProp.node.value.type!=="JSXExpressionContainer"){return null}let expr=tsxProp.node.value.expression;if(expr.type==="ObjectExpression"){let props,stack;props=expr.properties;obj={};stack=[];props.forEach(prop=>{_doProp(prop,obj,stack,this._fnAssert)})}}return obj||null};TsxUtils.prototype.toCamelCase=function(str){return TSX2_UTILS.toCamelCase(str)};TsxUtils.prototype.toKebabCase=function(str){return TSX2_UTILS.toKebabCase(str)};function _doProp(prop,obj,stack,fnAssert){let key,elems,propx;if(prop.type==="Property"&&(prop.key.type==="Identifier"||prop.key.type==="Literal")){if(prop.key.type==="Identifier"){key=prop.key.name}else{key=prop.key.value}if(prop.value.type==="Literal"){obj[key]=prop.value.value}else if(prop.value.type==="Identifier"){obj[key]=prop.value.name}else if(prop.value.type==="ArrayExpression"){obj[key]=[];elems=prop.value.elements;elems.forEach(elem=>{if(elem.type==="Literal"){obj[key].push(elem.value)}else if(elem.type==="ObjectExpression"){elem.properties.forEach(prop=>{stack.push(obj);obj={};propx=_doProp(prop,obj,stack,fnAssert);obj=stack.pop();obj[key].push(propx)})}})}else if(prop.value.type==="FunctionExpression"){obj[key]=prop.value.body.body}else if(prop.value.type==="ObjectExpression"){let o,p,i,objProps=prop.value.properties;stack.push(obj);obj[key]=o={};obj=o;for(i=0;i<objProps.length;i++){p=objProps[i];if(p.key.type==="Identifier"){if(p.value.type==="Literal"){o[p.key.name]=p.value.value}else if(p.value.type==="ObjectExpression"){_doProp(p,obj,stack,fnAssert);obj=stack.pop()}else if(p.value.type==="Identifier"){o[p.key.name]=p.value.name}else if(p.value.type==="ArrowFunctionExpression"){o[p.key.name]=p.value}else{fnAssert(`TsxUtils._doProp file line=${prop?.loc.start.line} ${p.value.type}`)}}}}else if(prop.value.type==="MemberExpression"){obj[key]=prop.value}else if(prop.value.type==="TemplateLiteral"){obj[key]=null}else if(prop.value.type==="LogicalExpression"){obj[key]=prop.value}else if(prop.value.type==="AssignmentPattern"){fnAssert(`TsxUtils._doProp2 file line=${prop?.loc.start.line} key=${key} prop value type=${prop.value.type}`);obj[key]="?"}else{fnAssert(`TsxUtils._doProp2 file line=${prop?.loc.start.line} key=${key} prop value type=${prop.value.type}`);obj[key]="?"}}return obj};TsxUtils.prototype.setIssuePosition=function(issue,obj){if(obj.type===TSX_COMPONENT||obj.type===TSX_PROPERTY){let loc=obj.loc;issue.setPosition(loc.start.line,loc.start.column,obj.range[0],obj.range[1])}else{issue.setPosition(0,0,0,0)}};TsxUtils.prototype.setIssuePropValuePosition=function(issue,tsxProp){if(tsxProp.type==="TsxProperty"){let loc=tsxProp.node.value.loc;issue.setPosition(loc.start.line,loc.start.column,tsxProp.node.value.range[0],tsxProp.node.value.range[1])}else{issue.setPosition(0,0,0,0)}};TsxUtils.prototype.getRawtext=function(ruleCtx,tsxRC){return ruleCtx&&tsxRC&&tsxRC.range?ruleCtx.data.substring(tsxRC.range[0],tsxRC.range[1]):""};TsxUtils.prototype._onTsxRC=function(ruleCtx,tsxRC,cb){var comps,tsxComp,ret,i;if(!(comps=tsxRC.components)){return}for(i=0;i<comps.length;i++){tsxComp=comps[i];ret=this._checkComp(ruleCtx,tsxComp,cb);if(ret===CB_END){break}};cb(ruleCtx,null)};TsxUtils.prototype._checkComp=function(ruleCtx,tsxComp,cb){var props;if(props=tsxComp.properties){let prop,ret,i;for(i=0;i<props.length;i++){prop=props[i];ret=cb(ruleCtx,prop);if(ret===CB_END||ret===CB_NEXT_COMP){return ret}};}if(tsxComp.children){tsxComp.children.forEach(child=>{this._checkComp(ruleCtx,child,cb)})}};TsxUtils.prototype.getSlotParent=function(ruleCtx,tsxProp,slotName){var parent,isOjDefer=false,ret=null;parent=tsxProp.parent;if(!(parent=parent.parent)){return}isOjDefer=parent.name==="oj-defer";if(parent&&parent.name){if(parent.name!==BODY){if(ruleCtx.utils.metaLib.isTagSlotName(parent.name,slotName)){ret=parent}if(!ret){if(isOjDefer&&parent.name===TEMPLATE||parent.name==="oj-switcher"){ret=parent}else if(parent.name===TEMPLATE||parent.name.startsWith(OJ_BIND)||parent.name===OJ_DEFER){ret=_continueUpwards(ruleCtx,parent,slotName)}}}}return ret};TsxUtils.prototype.isChildOfElem=function(elemName,tsxComp){var ret=null;while(tsxComp.parent){if(tsxComp.parent.name===elemName){ret=tsxComp.parent;break}tsxComp=tsxComp.parent}return ret};function _continueUpwards(ruleCtx,tsxComp,slotName){var ret=null,parent,tagName;while(parent=tsxComp.parent){tagName=parent.name;if(tagName===TEMPLATE||tagName.startsWith(OJ_BIND)||tagName===OJ_DEFER){parent=parent.parent;continue}if(parent.name!==BODY){if(ruleCtx.utils.metaLib.isTagSlotName(tagName,slotName)){ret=parent}}break}return ret};function _isObject(value){return typeof value==="object"&&!Array.isArray(value)};TsxUtils.prototype.setMetaLib=function(metaLib){this._metaLib=metaLib};TsxUtils.prototype.isCommonElem=function(elem){return HTML_UTILS.isCommonElem(elem)};TsxUtils.prototype.isCommonAttr=function(attrName){return TSX2_UTILS.isCommonProp(attrName)||this.isAriaAttr(attrName)};TsxUtils.prototype.isCommonEventAttr=function(attrName){return TSX2_UTILS.isCommonEventProp(attrName)};TsxUtils.prototype.isHtml5ObsoleteElem=function(tag){return HTML_UTILS.isHtml5ObsoleteElem(tag)};TsxUtils.prototype.isAriaAttr=function(attr){return HTML_UTILS.isAriaAttr(attr)};TsxUtils.prototype.isSelfClosingTag=function(tag){return HTML_UTILS.isSelfClosingTag(tag)};TsxUtils.prototype.isSvgElem=function(elem){return HTML_UTILS.isSvgElem(elem)};module.exports=TsxUtils;
6
+ const TSX2_UTILS=require("./TsxUtils2");const HTML_UTILS=require("./HtmlUtils");const CB_END="end";const CB_NEXT_COMP="next-comp";const TSX_COMPONENT="TsxComponent";const TSX_PROPERTY="TsxProperty";const TEMPLATE="template";const OJ_DEFER="oj-defer";const OJ_BIND="oj-bind";const BODY="body";var TsxUtils=function(assert){this._fnAssert=assert;this._metaLib=null};TsxUtils.prototype.extractTsxProperties=function(ruleCtx,tsxRC,cb){this._onTsxRC(ruleCtx,tsxRC,cb)};TsxUtils.prototype.getProperty=function(tsxObj,propName){return this._extractProp(tsxObj,propName)};TsxUtils.prototype._extractProp=function(tsxObj,propName){var ret,ot;if(tsxObj&&(ot=tsxObj.type)){if(ot===TSX_PROPERTY){return tsxObj}if(ot===TSX_COMPONENT&&propName){let props,prop,i;if(props=tsxObj.properties){for(i=0;i<props.length;i++){prop=props[i];if(prop.name===propName){ret=prop;break}}}}}return ret};TsxUtils.prototype.getPropertyRawValue=function(tsxComp,name,stripDelims){var prop,ret;if(prop=this.getProperty(tsxComp,name)){ret=prop.valueRaw;if(stripDelims&&ret.charAt(0)==="\""){ret=ret.charAt(1)==="\""?ret="":ret.substring(1,ret.length-1)}}return typeof ret==="string"?ret:null};TsxUtils.prototype.getPropertyValue=function(tsxComp,propName){var tsxProp,ret,obj,i;var a=propName.split(".");var major=a[0];if(tsxProp=this.getProperty(tsxComp,major)){if(a.length===1){return tsxProp.node.value}if(!this.isPropertyPreactExpr(tsxProp)){return undefined}obj=tsxProp.node.value;for(i=1;i<a.length;i++){major=a.shift();if(!_isObject(obj)){break}if((obj=obj[major])&&_isObject(obj)){continue}break}}return ret};TsxUtils.prototype.getPropertyStringValue=function(tsxObj,propName){var tsxProp,value,ret;if(tsxProp=this._extractProp(tsxObj,propName)){value=tsxProp.node.value;if(value!==null){ret=value.type==="Literal"&&typeof value.value==="string"?value.value:null}}else{ret=null}return ret};TsxUtils.prototype.isPropertyPreactExpr=function(tsxObj,propName){var tsxProp,ret=false;if(tsxProp=this._extractProp(tsxObj,propName)){ret=tsxProp.node.value.type==="JSXExpressionContainer"}return ret};TsxUtils.prototype.isPropertyObjectExpr=function(tsxObj,propName){var tsxProp,ret=false;if(tsxProp=this._extractProp(tsxObj,propName)){if(tsxProp.node.value.type==="JSXExpressionContainer"){let expr=tsxProp.node.value.expression;ret=expr&&expr.type==="ObjectExpression"}}return ret};TsxUtils.prototype.isPropertyString=function(tsxObj,propName){var tsxProp,ret=false;if(tsxProp=this._extractProp(tsxObj,propName)){ret=tsxProp.node.value.type==="Literal"&&typeof tsxProp.node.value.value==="string"}return ret};TsxUtils.prototype.getAncestor=function(tsxComp,name){var o,ret;name=name||tsxComp.name;while(o=tsxComp.parent){if(o.name===name){ret=o;break}tsxComp=o}return ret||null};TsxUtils.prototype.getChildren=function(tsxComp){return tsxComp.children};TsxUtils.prototype.getDescendant=function(tsxComp,name){var childs,child,ret,i;while(childs=tsxComp.children){for(i=0;i<childs.length;i++){child=childs[i];if(child.name===name){ret=child;break}if(ret=this.getDescendant(child,name)){break}}break}return ret||null};TsxUtils.prototype.getDirectDescendant=function(tsxComp,name){var childs,child,ret,i;if(childs=tsxComp.children){for(i=0;i<childs.length;i++){child=childs[i];if(child.name===name){ret=child;break}}}return ret||null};TsxUtils.prototype.isExpressionObject=function(tsxObj,propName){var tsxProp,ret;if(tsxProp=this._extractProp(tsxObj,propName)){if(tsxProp.node.value.type==="JSXExpressionContainer"){let expr=tsxProp.node.value.expression;ret=expr.type==="ObjectExpression"}}return!!ret};TsxUtils.prototype.getExpressionObject=function(tsxObj,propName){var tsxProp,obj;if(tsxProp=this._extractProp(tsxObj,propName)){if(!tsxProp.node.value){return null}if(tsxProp.node.value.type!=="JSXExpressionContainer"){return null}let expr=tsxProp.node.value.expression;if(expr.type==="ObjectExpression"){let props,stack;props=expr.properties;obj={};stack=[];props.forEach(prop=>{_doProp(prop,obj,stack,this._fnAssert)})}}return obj||null};TsxUtils.prototype.toCamelCase=function(str){return TSX2_UTILS.toCamelCase(str)};TsxUtils.prototype.toKebabCase=function(str){return TSX2_UTILS.toKebabCase(str)};function _doProp(prop,obj,stack,fnAssert){let key,elems,propx;if(prop.type==="Property"&&(prop.key.type==="Identifier"||prop.key.type==="Literal")){if(prop.key.type==="Identifier"){key=prop.key.name}else{key=prop.key.value}if(prop.value.type==="Literal"){obj[key]=prop.value.value}else if(prop.value.type==="Identifier"){obj[key]=prop.value.name}else if(prop.value.type==="ArrayExpression"){obj[key]=[];elems=prop.value.elements;elems.forEach(elem=>{if(elem.type==="Literal"){obj[key].push(elem.value)}else if(elem.type==="ObjectExpression"){elem.properties.forEach(prop=>{stack.push(obj);obj={};propx=_doProp(prop,obj,stack,fnAssert);obj=stack.pop();obj[key].push(propx)})}})}else if(prop.value.type==="FunctionExpression"){obj[key]=prop.value.body.body}else if(prop.value.type==="ObjectExpression"){let o,p,i,objProps=prop.value.properties;stack.push(obj);obj[key]=o={};obj=o;for(i=0;i<objProps.length;i++){p=objProps[i];if(p.key.type==="Identifier"){if(p.value.type==="Literal"){o[p.key.name]=p.value.value}else if(p.value.type==="ObjectExpression"){_doProp(p,obj,stack,fnAssert);obj=stack.pop()}else if(p.value.type==="Identifier"){o[p.key.name]=p.value.name}else if(p.value.type==="ArrowFunctionExpression"){o[p.key.name]=p.value}else{fnAssert(`TsxUtils._doProp file line=${prop?.loc.start.line} ${p.value.type}`)}}}}else if(prop.value.type==="MemberExpression"){obj[key]=prop.value}else if(prop.value.type==="TemplateLiteral"){obj[key]=null}else if(prop.value.type==="LogicalExpression"){obj[key]=prop.value}else if(prop.value.type==="AssignmentPattern"){fnAssert(`TsxUtils._doProp2 file line=${prop?.loc.start.line} key=${key} prop value type=${prop.value.type}`);obj[key]="?"}else{fnAssert(`TsxUtils._doProp2 file line=${prop?.loc.start.line} key=${key} prop value type=${prop.value.type}`);obj[key]="?"}}return obj};TsxUtils.prototype.setIssuePosition=function(issue,obj){if(obj.type===TSX_COMPONENT||obj.type===TSX_PROPERTY){let loc=obj.loc;issue.setPosition(loc.start.line,loc.start.column,obj.range[0],obj.range[1])}else{issue.setPosition(0,0,0,0)}};TsxUtils.prototype.setIssuePropValuePosition=function(issue,tsxProp){if(tsxProp.type==="TsxProperty"){let loc=tsxProp.node.value.loc;issue.setPosition(loc.start.line,loc.start.column,tsxProp.node.value.range[0],tsxProp.node.value.range[1])}else{issue.setPosition(0,0,0,0)}};TsxUtils.prototype.getRawtext=function(ruleCtx,tsxRC){return ruleCtx&&tsxRC&&tsxRC.range?ruleCtx.data.substring(tsxRC.range[0],tsxRC.range[1]):""};TsxUtils.prototype._onTsxRC=function(ruleCtx,tsxRC,cb){var comps,tsxComp,ret,i;if(!(comps=tsxRC.components)){return}for(i=0;i<comps.length;i++){tsxComp=comps[i];ret=this._checkComp(ruleCtx,tsxComp,cb);if(ret===CB_END){break}};cb(ruleCtx,null)};TsxUtils.prototype._checkComp=function(ruleCtx,tsxComp,cb){var props;if(props=tsxComp.properties){let prop,ret,i;for(i=0;i<props.length;i++){prop=props[i];ret=cb(ruleCtx,prop);if(ret===CB_END||ret===CB_NEXT_COMP){return ret}};}if(tsxComp.children){tsxComp.children.forEach(child=>{this._checkComp(ruleCtx,child,cb)})}};TsxUtils.prototype.getSlotParent=function(ruleCtx,tsxProp,slotName){var parent,isOjDefer=false,ret=null;parent=tsxProp.parent;if(!(parent=parent.parent)){return}isOjDefer=parent.name==="oj-defer";if(parent&&parent.name){if(parent.name!==BODY){if(ruleCtx.utils.metaLib.isTagSlotName(parent.name,slotName)){ret=parent}if(!ret){if(isOjDefer&&parent.name===TEMPLATE||parent.name==="oj-switcher"){ret=parent}else if(parent.name===TEMPLATE||parent.name.startsWith(OJ_BIND)||parent.name===OJ_DEFER){ret=_continueUpwards(ruleCtx,parent,slotName)}}}}return ret};TsxUtils.prototype.isChildOfElem=function(elemName,tsxComp){var ret=null;while(tsxComp.parent){if(tsxComp.parent.name===elemName){ret=tsxComp.parent;break}tsxComp=tsxComp.parent}return ret};function _continueUpwards(ruleCtx,tsxComp,slotName){var ret=null,parent,tagName;while(parent=tsxComp.parent){tagName=parent.name;if(tagName===TEMPLATE||tagName.startsWith(OJ_BIND)||tagName===OJ_DEFER){tsxComp=parent;continue}if(parent.name!==BODY){if(ruleCtx.utils.metaLib.isTagSlotName(tagName,slotName)){ret=parent}}break}return ret};function _isObject(value){return typeof value==="object"&&!Array.isArray(value)};TsxUtils.prototype.setMetaLib=function(metaLib){this._metaLib=metaLib};TsxUtils.prototype.isCommonElem=function(elem){return HTML_UTILS.isCommonElem(elem)};TsxUtils.prototype.isCommonAttr=function(attrName){return TSX2_UTILS.isCommonProp(attrName)||this.isAriaAttr(attrName)};TsxUtils.prototype.isCommonEventAttr=function(attrName){return TSX2_UTILS.isCommonEventProp(attrName)};TsxUtils.prototype.isHtml5ObsoleteElem=function(tag){return HTML_UTILS.isHtml5ObsoleteElem(tag)};TsxUtils.prototype.isAriaAttr=function(attr){return HTML_UTILS.isAriaAttr(attr)};TsxUtils.prototype.isSelfClosingTag=function(tag){return HTML_UTILS.isSelfClosingTag(tag)};TsxUtils.prototype.isSvgElem=function(elem){return HTML_UTILS.isSvgElem(elem)};module.exports=TsxUtils;
package/lib/checkage.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const BUILT="2024-07-02T05:18:09.969Z";const MAJOR_RELS=2;function CheckAge(burnedInJetVer,msgCtx){this._jetRels=-1;this._msgCtx=msgCtx;this._burnedInMajor=parseInt(burnedInJetVer.split(".")[0])};CheckAge.prototype.checkAge=function(){var curDate;var buildDate;var buildMonth;var monthsToNow;curDate=new Date;buildDate=BUILT==="@BUILT@"?curDate:new Date(BUILT);buildMonth=buildDate.getMonth()+1;monthsToNow=_getElapsedMonths(buildDate,curDate);if(!monthsToNow){this._jetRels=0}else{this._jetRels=_getReleases(buildMonth,monthsToNow);if(this._jetRels>MAJOR_RELS){this._emitMsg(monthsToNow)}}return this._jetRels};CheckAge.prototype.getJafReleaseCount=function(){return this._jetRels};CheckAge.prototype.getMajorReleaseCount=function(major){if(typeof major==="string"){let a=major.split(".");major=parseInt(a[0])}if(isNaN(major)){return this._jetRels}let estimatedMajor=this._burnedInMajor+this._jetRels;return estimatedMajor-major};CheckAge.prototype._emitMsg=function(old){var INDENT=" ".repeat(12);var s,h,p;if(this._jetRels){s=""+this._jetRels;if(this._jetRels===1){h="has";p=""}else{h="have";p="s"}}else{s="at least one";h="has";p=""}var s=`\nThis version of JAF is ${old} month${old===1?"":"s"} old, and there ${h} been ${s} scheduled public\n`+`${INDENT}major JET release${p}, together with JAF updates and fixes. It is strongly\n`+INDENT+"recommended that you install the latest version of JAF. [JAF-9100]\n";this._msgCtx.warn(s,"JAF-9100",true)};function _getElapsedMonths(start,end){return end.getMonth()-start.getMonth()+12*(end.getFullYear()-start.getFullYear())};function _getReleases(buildMonth,months){var toNextRel,releases=0;if(buildMonth===1){toNextRel=0}else if(buildMonth>1&&buildMonth<7){toNextRel=7-buildMonth}else if(buildMonth===7){toNextRel=0}else{toNextRel=13-buildMonth}if((releases=months-toNextRel)>=0){releases=1+Math.floor(releases/6)}else{releases=0}return releases};module.exports=CheckAge;
6
+ const BUILT="2024-08-10T00:33:27.889Z";const MAJOR_RELS=2;function CheckAge(burnedInJetVer,msgCtx){this._jetRels=-1;this._msgCtx=msgCtx;this._burnedInMajor=parseInt(burnedInJetVer.split(".")[0])};CheckAge.prototype.checkAge=function(){var curDate;var buildDate;var buildMonth;var monthsToNow;curDate=new Date;buildDate=BUILT==="@BUILT@"?curDate:new Date(BUILT);buildMonth=buildDate.getMonth()+1;monthsToNow=_getElapsedMonths(buildDate,curDate);if(!monthsToNow){this._jetRels=0}else{this._jetRels=_getReleases(buildMonth,monthsToNow);if(this._jetRels>MAJOR_RELS){this._emitMsg(monthsToNow)}}return this._jetRels};CheckAge.prototype.getJafReleaseCount=function(){return this._jetRels};CheckAge.prototype.getMajorReleaseCount=function(major){if(typeof major==="string"){let a=major.split(".");major=parseInt(a[0])}if(isNaN(major)){return this._jetRels}let estimatedMajor=this._burnedInMajor+this._jetRels;return estimatedMajor-major};CheckAge.prototype._emitMsg=function(old){var INDENT=" ".repeat(12);var s,h,p;if(this._jetRels){s=""+this._jetRels;if(this._jetRels===1){h="has";p=""}else{h="have";p="s"}}else{s="at least one";h="has";p=""}var s=`\nThis version of JAF is ${old} month${old===1?"":"s"} old, and there ${h} been ${s} scheduled public\n`+`${INDENT}major JET release${p}, together with JAF updates and fixes. It is strongly\n`+INDENT+"recommended that you install the latest version of JAF. [JAF-9100]\n";this._msgCtx.warn(s,"JAF-9100",true)};function _getElapsedMonths(start,end){return end.getMonth()-start.getMonth()+12*(end.getFullYear()-start.getFullYear())};function _getReleases(buildMonth,months){var toNextRel,releases=0;if(buildMonth===1){toNextRel=0}else if(buildMonth>1&&buildMonth<7){toNextRel=7-buildMonth}else if(buildMonth===7){toNextRel=0}else{toNextRel=13-buildMonth}if((releases=months-toNextRel)>=0){releases=1+Math.floor(releases/6)}else{releases=0}return releases};module.exports=CheckAge;
package/lib/defaults.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const defaults={JETVER:"16.1.4".replace(/(\d*\.\d*)(\.\d*)+$/g,"$1")+".0",THEME:"Alta",ECMAVER:14};module.exports=defaults;
6
+ const defaults={JETVER:"17.0.0".replace(/(\d*\.\d*)(\.\d*)+$/g,"$1")+".0",THEME:"Alta",ECMAVER:14};module.exports=defaults;
package/lib/extends.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const TSCONFIG="tsconfig.json";const PROFILE_DIR="profiles";const MERGEABLE_BY_DEFAULT={components:true,componentUrls:true,exclude:true,files:true,groups:true,message:true,nameSpaces:true,options:true,ruleMods:true,ruleNames:true,rulePacks:true,sevMap:true,typescript:true};const MERGEABLE_BY_OPTION={};const EXOPT_IGNORE="ignore";const EXOPT_MERGE="merge";const MSG={OBJ:"Config '%s' is not an object - %p",ARRAY:"Config '%s' is not an array - %p",STR:"Config '%s' is not a string - %p",STR_OR_AR_STR:"Config '%s' is not a string or an array of strings - %p",AR_OBJ:"Config '%s' is not an array of objects - %p",AR_STR:"Config '%s' is not an array of strings - %p",AR_STR_OBJ:"Config '%s' is not an array of strings or objects - %p",BOOL:"Config '%s' is not a boolean - %p",EXT_OPT:"Config 'extendOptions.%s' cannot be 'merge' - %p",EXT_OPT_VAL:"Config 'extendOptions.%s' not 'ignore' or 'merge' - %p",UNKNOWN:"Unknown config prop - '%s' - %p"};const REPL_PROP="%s";const REPL_PATH="%p";const DUMMY_FP="$_$";class Extends{constructor(configLib,configInst,cfg,path,nd,msgCtx,utils,fsUtils,isAMD){this._path=path;this._cfg=cfg;this._fp=cfg.base;this._nd=nd;this._msgCtx=msgCtx;this._utils=utils;this._fsUtils=fsUtils;this._cwd=nd.process.cwd();this._cfgLib=configLib;this._cfgInst=configInst;this._isAMD=isAMD;this._stack=[];this._extendOpts=null;this._profResult=null;this._error=msgCtx.error;this._info=msgCtx.info;this._isDebug=msgCtx.isDebug;this._isVerbose=msgCtx.isVerbose;this._mergeHandlers={components:this._mergePropComponents.bind(this),componentUrls:this._mergePropCompUrls.bind(this),exclude:this._mergePropExclude.bind(this),files:this._mergePropFiles.bind(this),groups:this._mergePropGroups.bind(this),messages:this._mergePropMessages,nameSpaces:this._mergePropNameSpaces.bind(this),options:this._mergePropOptions.bind(this),ruleMods:this._mergePropRuleMods.bind(this),ruleNames:this._mergePropRuleNames.bind(this),rulePacks:this._mergePropRulePacks,sevMap:this._mergePropSevMap.bind(this),typescript:this._mergePropTypescript.bind(this)}}extend(){if(!this._isDebug){this._isDebug=this._cfg.options&&this._cfg.options.debug}if(!this._isVerbose){this._isVerbose=this._cfg.options&&this._cfg.options.verbose}if(this._isDebug||this._isVerbose){this._msgCtx.info("[Info]: Merging configurations...","I",true)}if(!this._createStack()){return null}if(this._isDebug){this._dumpStack()}if(!this._isError){this._checkMergePropTypes();if(this._isError){return null}}if(!this._checkStackEnableDisableConflicts()||!this._checkUnsupportedProfileProps()||!this._checkProfileExtend()||!this._checkExtendOptionsProfile()||this._isError){return null}if(!this._stack.length){return this._cfg}return this._mergeStack()}_createStack(fp){var cfg,json,fp,first,stkEntry,profile;if(first=!fp){cfg=this._cfg;fp=this._isAMD?DUMMY_FP:this._path?this._path:this._fp}if(!fp){return true}if(this._utils.isObject(fp)){if(!(fp=this._resolveProfilePath(fp))){return false}if(fp.profile){profile=fp.profile}fp=fp.path}else if(!first&&typeof fp==="string"&&this._isAMD){this._error("Config cannot extend a non-profile config in AMD mode");return false}if(first){json=cfg}else if(this._isAMD){if(profile){if(json=this._nd.AmdProfLoader(profile)){json=this._parseJson(json)}if(!json){return false}}else{this._error("Config extends must contain a 'profile' propery in AMD mode");return false}fp=null}else{fp=this._getAbsolutePath(fp);if(!this._fsUtils.fileExists(fp)){let err=profile?`Configuration profile '${profile}' not found`:`Configuration file not found : ${fp}`;this._error(err);return false}if(this._isCircular(fp)){this._error(`Circular configuration 'extends' detected : ${fp}`);return false}try{if(!(json=this._readParseConfig(fp))){return false}}catch(e){this._error(`Error reading 'extends' config : ${fp}`);return false}}if(fp===DUMMY_FP){fp=null}stkEntry={path:fp,cfg:json};if(profile){stkEntry.profile=profile}this._stack.push(stkEntry);if(profile){if(!this._profResult){this._profResult={profiles:[profile]};if(json.ruleMods){if(json.ruleMods.enable){this._profResult.enable=json.ruleMods.enable}else{this._profResult.enable=[]}if(json.ruleMods.disable){this._profResult.disable=json.ruleMods.disable}else{this._profResult.disable=[]}}}else{this._profResult.profiles.push(profile)}}if(json.extends){if(!this._createStack(json.extends)){return false}}return true}_readParseConfig(fp){var json;json=this._nd.fs.readFileSync(fp,"utf8");json=this._nd.decomment(json);if(!(json=this._preprocessRawJson(json,fp))){return null}return this._parseJson(json,fp)}_parseJson(json,fp){var o;o=this._utils.parseJson(json,false);if(o.msg){let pos=`[${o.line}, ${o.col}]`;fp=fp?" : "+fp:"";this._error(`Config 'extends' error at ${pos} : ${o.msg}${fp}`);return null}return o.obj}_preprocessRawJson(txt,fp){var json=this._cfgInst.processIncludes(txt,fp);if(this._cfgInst.isOk()){json=this._cfgInst.processTokens(json);if(this._cfgInst.isOk()){}}return this._cfgInst.isOk()?json:null}_mergeStack(){if(!this._fixupPaths()){return null}for(let i=this._stack.length-1;i>0;i--){if(!this._mergePair(this._stack[i-1],this._stack[i])){return null}}if(this._isMergeProp("files")){if(this._stack[0].cfg.hasOwnProperty("files")){this._stack[0].cfg.files=_removeDupes(this._stack[0].cfg.files)}}if(this._isMergeProp("exclude")){if(this._stack[0].cfg.hasOwnProperty("exclude")){this._stack[0].cfg.exclude=_removeDupes(this._stack[0].cfg.exclude)}}if(this._stack[0].cfg.extends){delete this._stack[0].cfg.extends}return this._stack[0].cfg}_mergePair(parSE,chSE){var props,parent,child,merger,ret=true;parent=parSE.cfg;child=chSE.cfg;this._extendOpts=parSE.cfg.extendOptions||{};props=Object.keys(child);props.forEach(prop=>{if(prop.startsWith("_")||prop==="base"||prop==="extends"||prop==="tokens"||this._extendOpts[prop]===EXOPT_IGNORE){return}if(prop==="title"&&chSE.profile){return}if(!parent.hasOwnProperty(prop)){parent[prop]=child[prop];return}if(!this._isMergeProp(prop)){return}if(merger=this._mergeHandlers[prop]){if(!merger(parSE,chSE)){ret=false}}});if(!ret){return ret}if(!parSE.profile&&parSE.cfg.ruleNames){if(!this._checkRuleNamesProfileConflicts(parSE)){return false}}let type,what;if(chSE.profile){type="profile";what=chSE.profile}else{type="config";what=chSE.path}this._msgCtx.info(`[Info]: Inheriting ${type} '${what}'`,"I",true);return true}_checkMergePropTypes(){var cfg,se,prop,prop2,val;for(let i=0;i<this._stack.length;i++){se=this._stack[i];cfg=se.cfg;if(!this._cfgLib.checkPropNames(cfg,se.path)){this._isError=true}if(cfg.extendOptions){if(this._utils.isObject(cfg.extendOptions)){this._extendOpts=cfg.extendOptions;for(prop in this._extendOpts){val=this._extendOpts[prop];if(val===EXOPT_MERGE&&!MERGEABLE_BY_OPTION[prop]){this._emitErrorMsg(MSG.EXT_OPT,prop,se.path);return}else if(val!==EXOPT_MERGE&&val!==EXOPT_IGNORE){this._emitErrorMsg(MSG.EXT_OPT_VAL,prop,se.path);return}}}else{this._emitErrorMsg(MSG.OBJ,"extendOptions",se.path);return}}else{this._extendOpts={}}for(prop in cfg){if(!this._isMergeProp(prop)){continue}val=cfg[prop];if(prop==="components"||prop==="componentUrls"){if(typeof val!=="string"&&!Array.isArray(val)||!this._utils.isArrayContentsType(val,"string")){this._emitErrorMsg(MSG.STR_OR_AR_STR,prop,se.path)}}else if(prop==="files"){if(!Array.isArray(val)){this._emitErrorMsg(prop,prop,se.path)}if(!this._utils.isArrayContentsType(val,["string","object"])){this._emitErrorMsg(MSG.AR_STR_OBJ,prop,se.path)}}else if(prop==="exclude"){if(!Array.isArray(val)||!this._utils.isArrayContentsType(val,"string")){this._emitErrorMsg(MSG.STR_OR_AR_STR,prop,se.path)}}else if(prop==="groups"){if(!Array.isArray(val)){this._emitErrorMsg(MSG.STR,prop,se.path)}}else if(prop==="messages"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}if(se.messages.reject){if(!Array.isArray(se.messages.reject)){this._emitErrorMsg(MSG.OBJ,"messages.reject",se.path)}}if(se.messages.accept){if(!Array.isArray(se.messages.accept)){this._emitErrorMsg(MSG.OBJ,"messages.accept",se.path)}}}else if(prop==="nameSpaces"){if(!Array.isArray(val)){this._emitErrorMsg(MSG.AR_STR,prop,se.path)}}else if(prop==="options"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}}else if(prop==="ruleMods"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path);continue}for(prop2 in val){if(prop2==="enable"||prop2==="disable"){if(!Array.isArray(val[prop2])){this._emitErrorMsg(MSG.AR_OBJ,prop2==="enable"?"ruleMods.enable":"ruleMods.disable",se.path)}}else{if(!this._utils.isObject(val[prop2])){this._emitErrorMsg(MSG.AR_OBJ,prop+"."+prop2,se.path)}}}}else if(prop==="ruleNames"){if(!Array.isArray(val)||!this._utils.isArrayContentsType(val,"string")){this._emitErrorMsg(MSG.AR_STR,prop,se.path)}}else if(prop==="rulePacks"){if(!Array.isArray(val)||!this._utils.isArrayContentsType(val,"object")){this._emitErrorMsg(MSG.AR_OBJ,prop,se.path)}}else if(prop==="sevMap"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}if(val.sevMsg&&!this._utils.isObject(val.sevMsg)){this._emitErrorMsg(MSG.OBJ,prop+".sevMsg",se.path)}if(val.sevSet&&!this._utils.isObject(val.sevSet)){this._emitErrorMsg(MSG.OBJ,prop+".sevSet",se.path)}}else if(prop==="tokens"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}}else if(prop==="typescript"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}for(prop2 in val){if(prop2==="tsconfig"&&typeof val[prop2]!=="string"){this._emitErrorMsg(MSG.STR,"typescript.tsconfig",se.path)}if(prop2==="compile"&&typeof val[prop2]!=="boolean"){this._emitErrorMsg(MSG.BOOL,"typescript.compile",se.path)}}}else{this._error(`JAF ERROR: unhandled 'extends' property '${prop}' - ${se.path}`);this._isError=true}}}}_checkStackEnableDisableConflicts(){var config,i,b=true;for(i=this._stack.length-1;i>=0;i--){config=this._stack[i];if(!this._cfgLib.processRuleMods(config.cfg,config.profile?`profile '${config.profile}'`:config.path)){b=false}}if(!b){this._isError=true}return b}_checkRuleNamesProfileConflicts(parSE){var enable,rules,rule,i,profiles,isSet,b=true;if(!(this._profResult&&this._profResult.enable)){return true}rules=parSE.cfg.ruleNames;enable=this._profResult.enable;isSet=this._profResult.profiles.length>1;profiles=(isSet?"set [":"'")+this._profResult.profiles.join(", ")+(isSet?"]":"'");for(i=0;i<enable.length;i++){rule=enable[i];if(!rules.includes(rule)){this._msgCtx.error(`Config 'ruleNames' cannot disable rule '${rule}' enabled in profile ${profiles} - ${parSE.path}`);b=false}}if(!b){this._isError=true}return b}_checkUnsupportedProfileProps(){var se,config,i,b=true;var _self=this;function _emitUnsupProfileError(prof,prop){_self._msgCtx.error(`Property '${prop}' is not supported in profile ('${prof}')`);_self._isError=true;b=false}for(i=this._stack.length-1;i>=0;i--){se=this._stack[i];if(se.profile){config=se.cfg;if(config.ruleNames){_emitUnsupProfileError(se.profile,"ruleNames")}if(config.groups){_emitUnsupProfileError(se.profile,"groups")}}}return b}_checkProfileExtend(){var i;var stk=this._stack;for(i=0;i<stk.length;i++){if(!stk[i].profile){continue}for(i=i+1;i<stk.length;i++){if(!stk[i].profile){this._msgCtx.error(`Profile '${stk[i-1].profile}' cannot extend from a non-profile config - ${stk[i].path}`);return false}}break}return true}_checkExtendOptionsProfile(){if(this._profResult){let stk=this._stack;let opts;for(let i=0;i<stk.length;i++){if(opts=stk[i].cfg.extendOptions){if(opts.ruleMods==="ignore"){let isSet=this._profResult.profiles.length>1;let profiles=(isSet?"set [":"'")+this._profResult.profiles.join(", ")+(isSet?"]":"'");this._msgCtx.error(`Config cannot use 'extendsOptions.ruleMods' to ignore inherited 'ruleMods' from profile ${profiles} - ${stk[i].path}`);return false}}}}return true}_resolveProfilePath(o){var prof,ret;if(!(prof=o.profile)){this._error(`JAF ERROR: 'extends' declared as an object but property 'profile' is missing.`);this._isError=true;return null}ret={profile:o.profile};if(!this._isAMD){ret.path=this._nd.path.join(__dirname,"../"+PROFILE_DIR,prof)+".json"};return ret}_fixupPaths(){var se,ret=true;for(let i=this._stack.length-1;i>=0;i--){se=this._stack[i];if(!(this._cleanBase(se)&&this._fixupConfig(se))){ret=false;break}}return ret}_cleanBase(se){if(this._isAMD){return true}var src,ft;var nd=this._nd;src=se.cfg.base;if(src==="$jafcwd"){src=this._cwd}else{if(!src){src=this._nd.path.dirname(se.path)}src=nd.path.normalize(src);if(!nd.path.isAbsolute(src)){src=nd.path.join(nd.path.dirname(se.path),src)}ft=this._fsUtils.getFileType(src);if(ft!=="d"){this._msgCtx.error(`Config file 'base' is not a directory - '${src}' in ${se.path}`);return false}}se.cfg.base=src;this._info(`[Info]: Using config base '${src}' in ${se.path}`,"I");return true}_fixupConfig(se){var nd,cfg,src,dir,ft,i;nd=this._nd;cfg=se.cfg;if(cfg.files){if(!this._cfgLib.validateFileList(cfg.files)){this._bErrors=true;return}if(src=se.cfg.files){for(i=0;i<src.length;i++){if(!src[i].startsWith("http")){src[i]=nd.path.normalize(src[i]);src[i]=nd.path.resolve(cfg.base,src[i])}}}}if(cfg.exclude){if(!this._cfgLib.validateFileList(cfg.exclude)){this._bErrors=true;return}if(src=cfg.exclude){for(i=0;i<src.length;i++){src[i]=nd.path.normalize(src[i]);src[i]=nd.path.resolve(cfg.base,src[i])}}}src=cfg.components;if(src){for(i=0;i<src.length;i++){dir=nd.path.normalize(src[i]);dir=nd.path.resolve(cfg.base,dir);cfg.components[i]=dir}}src=cfg.outPath;if(src&&src!=="$noout"){src=nd.path.normalize(src);src=nd.path.resolve(cfg.base,src);cfg.outPath=src}src=cfg.rulePacks;if(src){for(i=0;i<src.length;i++){dir=src[i].path;dir=nd.path.normalize(dir);src[i].path=nd.path.resolve(cfg.base,dir);if(src[i].path.endsWith(".zip")){continue}ft=this._fsUtils.getFileType(src[i].path);if(ft!=="d"){this._error("'rulePacks (entry "+(i+1)+"): path' is not a directory - \""+src[i].path+"\"");this._bErrors=true}}}if(cfg.typescript&&cfg.typescript.tsconfig){src=cfg.typescript.tsconfig;if(src&&typeof src==="string"){if(!nd.path.isAbsolute(src)){dir=nd.path.normalize(src);dir=nd.path.resolve(cfg.base,dir)}else{dir=src}if(!dir.endsWith(TSCONFIG)){dir=nd.path.join(dir,TSCONFIG)}cfg.typescript.tsconfig=dir}}if(this._bErrors){this._error(`Errors found in inherited config '${se.path}'`)}return!this._bErrors}_getAbsolutePath(fp){if(this._nd.path.isAbsolute(fp)){return fp}let prevFp,prevBase,p;prevFp=this._stack[this._stack.length-1].path;prevFp=this._nd.path.dirname(prevFp);prevBase=this._stack[this._stack.length-1].cfg.base;if(prevBase){if(!this._nd.path.isAbsolute(prevBase)){p=this._nd.path.join(prevFp,prevBase,fp)}else{p=this._nd.path.join(prevBase,fp)}}else{p=this._nd.path.join(prevFp,fp)}if(!this._nd.path.isAbsolute(p)){p=this._nd.path.join(this._dir,p)}return p}_isCircular(fp){var ret;for(let i=0;i<this._stack.length;i++){if(this._stack[i].path===fp){ret=true;break}}return ret}_isMergeProp(p){return MERGEABLE_BY_DEFAULT[p]||this._extendOpts[p]===EXOPT_MERGE}_mergePropFiles(parSE,chSE){return this._mergePropFilesExclude(parSE,chSE,"files")}_mergePropExclude(parSE,chSE){return this._mergePropFilesExclude(parSE,chSE,"exclude")}_mergePropFilesExclude(parSE,chSE,prop){var parent,child,ch,i;var parent=parSE.cfg[prop];var child=chSE.cfg[prop];for(i=0;i<child.length;i++){ch=child[i];if(!parent.includes(ch)){parent.push(ch)}}return true}_mergePropOptions(parSE,chSE){return this._mergeObjects(parSE,chSE,"options")}_mergePropGroups(parSE,chSE){return this._mergeArrays(parSE,chSE,"groups")}_mergePropTokens(parSE,chSE){return this._mergeObjects(parSE,chSE,"tokens")}_mergePropNameSpaces(parSE,chSE){return this._mergeArrays(parSE,chSE,"nameSpaces")}_mergePropRuleMods(parSE,chSE){var pname,pack,parPack,rule,rval;var parent=parSE.cfg.ruleMods;var child=chSE.cfg.ruleMods;if(!this._mergeRuleModsEnableDisable(parSE,chSE)){return false}for(pname in child){if(pname==="enable"||pname==="disable"){continue}pack=child[pname];if(!parent[pname]){parent[pname]=pack;continue}this._mergeRuleModsPackObjects(parent[pname],pack)}parPack=parent[pname];for(rule in rval){if(!parPack[rule]){parPack[rule]=rval[rule]}}return true}_mergeRuleModsEnableDisable(parSE,chSE){var parent,child,val,x;var parEnable,parDisable,chEnable,chDisable;var parent=parSE.cfg.ruleMods;var child=chSE.cfg.ruleMods;parEnable=parent.enable;parDisable=parent.disable;chEnable=child.enable;chDisable=child.disable;var self=this;function _profVetoEnable(val){var ret=false;if(self._profResult&&self._profResult.disable){ret=self._profResult.disable.includes(val)}return ret}function _profVetoDisable(val){var ret=false;if(self._profResult&&self._profResult.enable){ret=self._profResult.enable.includes(val)}return ret}if(parEnable&&chDisable){for(val of parEnable){if(!(parSE.profile&&chSE.profile)){if(_profVetoEnable(val)){this._emitProfileVetoError(val,parSE.path,false);return false}}if((x=chDisable.indexOf(val))>=0){chDisable.splice(x,1)}}}if(parDisable&&chEnable){for(val of parDisable){if(!(parSE.profile&&chSE.profile)){if(_profVetoDisable(val)){this._emitProfileVetoError(val,parSE.path,true);return false}}if((x=chEnable.indexOf(val))>=0){chEnable.splice(x,1)}}}if(chEnable){if(!parEnable){parent.enable=parEnable=[]}for(val of chEnable){if(!parEnable.includes(val)){parEnable.push(val)}}}if(chDisable){if(!parDisable){parent.disable=parDisable=[]}for(val of chDisable){if(!parDisable.includes(val)){parDisable.push(val)}}}if(parSE.profile&&chSE.profile){if(!this._profResult){this._profResult={}}this._profResult.enable=parEnable;this._profResult.disable=parDisable;if(this._isDebug){console.log(`Profile merge: ${parSE.profile} <- ${chSE.profile}`)}}else{if(this._isDebug){console.log(`Merge: '${parSE.path}' <- '${chSE.profile?chSE.profile:chSE.path}'`)}}if(this._isDebug){console.log(`${parSE.path} <- ${chSE.path}`);console.log(`Enable = ${parEnable.join(",\n ")}`);console.log(`Disable = ${parDisable.join(",\n ")}\n`)}return true}_emitProfileVetoError(rule,cfgPath,disable){var profiles,temp,op1,op2;temp=[...this._profResult.profiles];temp.forEach((rule,i)=>{temp[i]="'"+rule+"'"});temp=temp.join(", ");if(disable){op1="disable";op2="enabled"}else{op1="enable";op2="disabled"}profiles="profile"+`${this._profResult.profiles.length>1?" set [":""} ${temp}${this._profResult.profiles.length>1?"]":""}`;cfgPath=cfgPath?`in ${cfgPath} `:"";this._error(`Config 'ruleMods' conflict: cannot ${op1} rule '${rule}' ${cfgPath}- ${op2} by ${profiles}`)}_mergePropRuleNames(parSE,chSE){return this._mergeArrays(parSE,chSE,"ruleNames")}_mergePropRulePacks(parSE,chSE){var parent=parSE.cfg.rulePacks;var child=chSE.cfg.rulePacks;for(let i=0;i<child.length;i++){let ch=child[i];let b=false;for(let j=0;j<parent.length;j++){let par=parent[j];if(ch.path===par.path){b=true;break}}if(!b){parent.push(ch)}}return true}_mergePropMessages(parSE,chSE){var parent=parSE.cfg.messages;var child=chSE.cfg.messages;var parReject=parent.reject;var chReject=child.reject;if(!parReject&&chReject){parent.reject=chReject}else if(parReject&&chReject){parent.reject=_removeDupes(parReject.concat(chReject))}var parAccept=parent.accept;var chAccept=child.accept;if(!parAccept&&chAccept){parent.accept=chAccept}else if(parAccept&&chAccept){parent.accept=_removeDupes(parAccept.concat(chAccept))}return true}_mergePropComponents(parSE,chSE){return this._mergeArrays(parSE,chSE,"components")}_mergePropCompUrls(parSE,chSE){return this._mergeArrays(parSE,chSE,"componentUrls")}_mergePropTypescript(parSE,chSE){return this._mergeObjects(parSE,chSE,"typescript")}_mergePropSevMap(parSE,chSE){var parent=parSE.cfg.sevMap;var child=chSE.cfg.sevMap;var parSevMsg,chSevMsg;var parSevSet,chSevSet;if(parent){parSevMsg=parent.sevMsg;parSevSet=parent.sevSet}if(child){chSevMsg=child.sevMsg;chSevSet=child.sevSet}if(parSevMsg&&chSevMsg){this._mergeObjects(parSE,chSE,"sevMap")}else if(!parSevMsg&&chSevMsg){parent.sevMsg=chSevMsg}if(parSevSet&&chSevSet){this._mergeObjects(parSE,chSE,"sevSet")}else if(!parSevSet&&chSevSet){parent.sevSet=chSevSet}if(parent.sevSet&&parent.sevMsg){let sev,msg,oldsev,val;for(val in parent.sevSet){sev=parent.sevSet[val];for(msg in parent.sevMsg){oldsev=parent.sevMsg[msg];if(val===oldsev){parent.sevMsg[msg]=sev}}}}return true}_mergeObjects(parSE,chSE,prop){var parent,child;parent=parSE.cfg[prop];child=chSE.cfg[prop];for(let prop in child){if(!parent.hasOwnProperty(prop)){parent[prop]=child[prop]}}return true}_mergeRuleModsPackObjects(to,from){var rule;for(rule in from){if(!to[rule]){to[rule]=from[rule]}}}_mergeArrays(parSE,chSE,prop){var parent,child,isPS,isCS,isPA,isCA,val;parent=parSE.cfg[prop];child=chSE.cfg[prop];isPS=typeof parent==="string";isCS=typeof child==="string";if(isPS&&isCS&&parent===child){return}isPA=Array.isArray(parent);isCA=Array.isArray(child);parent=isPA?parent:[parent];child=isCA?child:[child];for(let i=0;i<child.length;i++){val=child[i];if(!parent.includes(val)){parent.push(val)}}return true}_emitErrorMsg(s,prop,path){var s=s||MSG.UNKNOWN;if(prop){s=s.replace(REPL_PROP,prop)}this._error(s.replace(REPL_PATH,path));this._isError=true}_parseError(msg){this._parseError=msg}_dumpStack(){var type,msg;this._msgCtx.info("[Info]: -- Config 'extends' stack --","I",true);for(let i=0;i<this._stack.length;i++){type=this._stack[i].profile;type=type?type:"config ";msg=!this._isAMD?`${type} ${this._stack[i].path}`:`${type}`;this._msgCtx.info(`[Info]: ${msg}`,"I",true)}}}function _removeDupes(ar){return Array.isArray(ar)?ar.filter((val,x)=>ar.indexOf(val)===x):ar};module.exports=Extends;
6
+ const TSCONFIG="tsconfig.json";const PROFILE_DIR="profiles";const MERGEABLE_BY_DEFAULT={components:true,componentUrls:true,exclude:true,files:true,groups:true,message:true,nameSpaces:true,options:true,ruleMods:true,ruleNames:true,rulePacks:true,sevMap:true,typescript:true};const MERGEABLE_BY_OPTION={};const EXOPT_IGNORE="ignore";const EXOPT_MERGE="merge";const MSG={OBJ:"Config '%s' is not an object - %p",ARRAY:"Config '%s' is not an array - %p",STR:"Config '%s' is not a string - %p",STR_OR_AR_STR:"Config '%s' is not a string or an array of strings - %p",AR_OBJ:"Config '%s' is not an array of objects - %p",AR_STR:"Config '%s' is not an array of strings - %p",AR_STR_OBJ:"Config '%s' is not an array of strings or objects - %p",BOOL:"Config '%s' is not a boolean - %p",EXT_OPT:"Config 'extendOptions.%s' cannot be 'merge' - %p",EXT_OPT_VAL:"Config 'extendOptions.%s' not 'ignore' or 'merge' - %p",UNKNOWN:"Unknown config prop - '%s' - %p"};const REPL_PROP="%s";const REPL_PATH="%p";const DUMMY_FP="$_$";class Extends{constructor(configEx,configInst,cfg,path,nd,msgCtx,utils,fsUtils,isAMD){this._path=path;this._cfg=cfg;this._fp=cfg.base;this._nd=nd;this._msgCtx=msgCtx;this._utils=utils;this._fsUtils=fsUtils;this._cwd=nd.process.cwd();this._cfgEx=configEx;this._cfgInst=configInst;this._isAMD=isAMD;this._stack=[];this._extendOpts=null;this._profResult=null;this._error=msgCtx.error;this._info=msgCtx.info;this._isDebug=msgCtx.isDebug;this._isVerbose=msgCtx.isVerbose;this._mergeHandlers={components:this._mergePropComponents.bind(this),componentUrls:this._mergePropCompUrls.bind(this),exclude:this._mergePropExclude.bind(this),files:this._mergePropFiles.bind(this),groups:this._mergePropGroups.bind(this),messages:this._mergePropMessages,nameSpaces:this._mergePropNameSpaces.bind(this),options:this._mergePropOptions.bind(this),ruleMods:this._mergePropRuleMods.bind(this),ruleNames:this._mergePropRuleNames.bind(this),rulePacks:this._mergePropRulePacks,sevMap:this._mergePropSevMap.bind(this),typescript:this._mergePropTypescript.bind(this)}}extend(){if(!this._isDebug){this._isDebug=this._cfg.options&&this._cfg.options.debug}if(!this._isVerbose){this._isVerbose=this._cfg.options&&this._cfg.options.verbose}if(this._isDebug||this._isVerbose){this._msgCtx.info("[Info]: Merging configurations...","I",true)}if(!this._createStack()){return null}if(this._isDebug){this._dumpStack()}if(!this._isError){this._checkMergePropTypes();if(this._isError){return null}}if(!this._checkStackEnableDisableConflicts()||!this._checkUnsupportedProfileProps()||!this._checkProfileExtend()||!this._checkExtendOptionsProfile()||this._isError){return null}if(!this._stack.length){return this._cfg}return this._mergeStack()}_createStack(fp){var cfg,json,fp,first,stkEntry,profile;if(first=!fp){cfg=this._cfg;fp=this._isAMD?DUMMY_FP:this._path?this._path:this._fp}if(!fp){return true}if(this._utils.isObject(fp)){if(!(fp=this._resolveProfilePath(fp))){return false}if(fp.profile){profile=fp.profile}fp=fp.path}else if(!first&&typeof fp==="string"&&this._isAMD){this._error("Config cannot extend a non-profile config in AMD mode");return false}if(first){json=cfg}else if(this._isAMD){if(profile){if(json=this._nd.AmdProfLoader(profile)){json=this._parseJson(json)}if(!json){return false}}else{this._error("Config extends must contain a 'profile' propery in AMD mode");return false}fp=null}else{fp=this._getAbsolutePath(fp);if(!this._fsUtils.fileExists(fp)){let err=profile?`Configuration profile '${profile}' not found`:`Configuration file not found : ${fp}`;this._error(err);return false}if(this._isCircular(fp)){this._error(`Circular configuration 'extends' detected : ${fp}`);return false}try{if(!(json=this._readParseConfig(fp))){return false}}catch(e){this._error(`Error reading 'extends' config : ${fp}`);return false}}if(fp===DUMMY_FP){fp=null}stkEntry={path:fp,cfg:json};if(profile){stkEntry.profile=profile}this._stack.push(stkEntry);if(profile){if(!this._profResult){this._profResult={profiles:[profile]};if(json.ruleMods){if(json.ruleMods.enable){this._profResult.enable=json.ruleMods.enable}else{this._profResult.enable=[]}if(json.ruleMods.disable){this._profResult.disable=json.ruleMods.disable}else{this._profResult.disable=[]}}}else{this._profResult.profiles.push(profile)}}if(json.extends){if(!this._createStack(json.extends)){return false}}return true}_readParseConfig(fp){var json;json=this._nd.fs.readFileSync(fp,"utf8");json=this._nd.decomment(json);if(!(json=this._preprocessRawJson(json,fp))){return null}return this._parseJson(json,fp)}_parseJson(json,fp){var o;o=this._utils.parseJson(json,false);if(o.msg){let pos=`[${o.line}, ${o.col}]`;fp=fp?" : "+fp:"";this._error(`Config 'extends' error at ${pos} : ${o.msg}${fp}`);return null}return o.obj}_preprocessRawJson(txt,fp){var json=this._cfgInst.processIncludes(txt,fp);if(this._cfgInst.isOk()){json=this._cfgInst.processTokens(json);if(this._cfgInst.isOk()){}}return this._cfgInst.isOk()?json:null}_mergeStack(){if(!this._fixupPaths()){return null}for(let i=this._stack.length-1;i>0;i--){if(!this._mergePair(this._stack[i-1],this._stack[i])){return null}}if(this._isMergeProp("files")){if(this._stack[0].cfg.hasOwnProperty("files")){this._stack[0].cfg.files=_removeDupes(this._stack[0].cfg.files)}}if(this._isMergeProp("exclude")){if(this._stack[0].cfg.hasOwnProperty("exclude")){this._stack[0].cfg.exclude=_removeDupes(this._stack[0].cfg.exclude)}}if(this._stack[0].cfg.extends){delete this._stack[0].cfg.extends}return this._stack[0].cfg}_mergePair(parSE,chSE){var props,parent,child,merger,ret=true;parent=parSE.cfg;child=chSE.cfg;this._extendOpts=parSE.cfg.extendOptions||{};props=Object.keys(child);props.forEach(prop=>{if(prop.startsWith("_")||prop==="base"||prop==="extends"||prop==="tokens"||this._extendOpts[prop]===EXOPT_IGNORE){return}if(prop==="title"&&chSE.profile){return}if(!parent.hasOwnProperty(prop)){parent[prop]=child[prop];return}if(!this._isMergeProp(prop)){return}if(merger=this._mergeHandlers[prop]){if(!merger(parSE,chSE)){ret=false}}});if(!ret){return ret}if(!parSE.profile&&parSE.cfg.ruleNames){if(!this._checkRuleNamesProfileConflicts(parSE)){return false}}let type,what;if(chSE.profile){type="profile";what=chSE.profile}else{type="config";what=chSE.path}this._msgCtx.info(`[Info]: Inheriting ${type} '${what}'`,"I",true);return true}_checkMergePropTypes(){var cfg,se,prop,prop2,val;for(let i=0;i<this._stack.length;i++){se=this._stack[i];cfg=se.cfg;if(!this._cfgEx.checkPropNames(cfg,se.path)){this._isError=true}if(cfg.extendOptions){if(this._utils.isObject(cfg.extendOptions)){this._extendOpts=cfg.extendOptions;for(prop in this._extendOpts){val=this._extendOpts[prop];if(val===EXOPT_MERGE&&!MERGEABLE_BY_OPTION[prop]){this._emitErrorMsg(MSG.EXT_OPT,prop,se.path);return}else if(val!==EXOPT_MERGE&&val!==EXOPT_IGNORE){this._emitErrorMsg(MSG.EXT_OPT_VAL,prop,se.path);return}}}else{this._emitErrorMsg(MSG.OBJ,"extendOptions",se.path);return}}else{this._extendOpts={}}for(prop in cfg){if(!this._isMergeProp(prop)){continue}val=cfg[prop];if(prop==="components"||prop==="componentUrls"){if(typeof val!=="string"&&!Array.isArray(val)||!this._utils.isArrayContentsType(val,"string")){this._emitErrorMsg(MSG.STR_OR_AR_STR,prop,se.path)}}else if(prop==="files"){if(!Array.isArray(val)){this._emitErrorMsg(prop,prop,se.path)}if(!this._utils.isArrayContentsType(val,["string","object"])){this._emitErrorMsg(MSG.AR_STR_OBJ,prop,se.path)}}else if(prop==="exclude"){if(!Array.isArray(val)||!this._utils.isArrayContentsType(val,"string")){this._emitErrorMsg(MSG.STR_OR_AR_STR,prop,se.path)}}else if(prop==="groups"){if(!Array.isArray(val)){this._emitErrorMsg(MSG.STR,prop,se.path)}}else if(prop==="messages"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}if(se.messages.reject){if(!Array.isArray(se.messages.reject)){this._emitErrorMsg(MSG.OBJ,"messages.reject",se.path)}}if(se.messages.accept){if(!Array.isArray(se.messages.accept)){this._emitErrorMsg(MSG.OBJ,"messages.accept",se.path)}}}else if(prop==="nameSpaces"){if(!Array.isArray(val)){this._emitErrorMsg(MSG.AR_STR,prop,se.path)}}else if(prop==="options"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}}else if(prop==="ruleMods"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path);continue}for(prop2 in val){if(prop2==="enable"||prop2==="disable"){if(!Array.isArray(val[prop2])){this._emitErrorMsg(MSG.AR_OBJ,prop2==="enable"?"ruleMods.enable":"ruleMods.disable",se.path)}}else{if(!this._utils.isObject(val[prop2])){this._emitErrorMsg(MSG.AR_OBJ,prop+"."+prop2,se.path)}}}}else if(prop==="ruleNames"){if(!Array.isArray(val)||!this._utils.isArrayContentsType(val,"string")){this._emitErrorMsg(MSG.AR_STR,prop,se.path)}}else if(prop==="rulePacks"){if(!Array.isArray(val)||!this._utils.isArrayContentsType(val,"object")){this._emitErrorMsg(MSG.AR_OBJ,prop,se.path)}}else if(prop==="sevMap"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}if(val.sevMsg&&!this._utils.isObject(val.sevMsg)){this._emitErrorMsg(MSG.OBJ,prop+".sevMsg",se.path)}if(val.sevSet&&!this._utils.isObject(val.sevSet)){this._emitErrorMsg(MSG.OBJ,prop+".sevSet",se.path)}}else if(prop==="tokens"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}}else if(prop==="typescript"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}for(prop2 in val){if(prop2==="tsconfig"&&typeof val[prop2]!=="string"){this._emitErrorMsg(MSG.STR,"typescript.tsconfig",se.path)}if(prop2==="compile"&&typeof val[prop2]!=="boolean"){this._emitErrorMsg(MSG.BOOL,"typescript.compile",se.path)}}}else{this._error(`JAF ERROR: unhandled 'extends' property '${prop}' - ${se.path}`);this._isError=true}}}}_checkStackEnableDisableConflicts(){var config,i,b=true;for(i=this._stack.length-1;i>=0;i--){config=this._stack[i];if(!this._cfgEx.processRuleMods(config.cfg,config.profile?`profile '${config.profile}'`:config.path)){b=false}}if(!b){this._isError=true}return b}_checkRuleNamesProfileConflicts(parSE){var enable,rules,rule,i,profiles,isSet,b=true;if(!(this._profResult&&this._profResult.enable)){return true}rules=parSE.cfg.ruleNames;enable=this._profResult.enable;isSet=this._profResult.profiles.length>1;profiles=(isSet?"set [":"'")+this._profResult.profiles.join(", ")+(isSet?"]":"'");for(i=0;i<enable.length;i++){rule=enable[i];if(!rules.includes(rule)){this._msgCtx.error(`Config 'ruleNames' cannot disable rule '${rule}' enabled in profile ${profiles} - ${parSE.path}`);b=false}}if(!b){this._isError=true}return b}_checkUnsupportedProfileProps(){var se,config,i,b=true;var _self=this;function _emitUnsupProfileError(prof,prop){_self._msgCtx.error(`Property '${prop}' is not supported in profile ('${prof}')`);_self._isError=true;b=false}for(i=this._stack.length-1;i>=0;i--){se=this._stack[i];if(se.profile){config=se.cfg;if(config.ruleNames){_emitUnsupProfileError(se.profile,"ruleNames")}if(config.groups){_emitUnsupProfileError(se.profile,"groups")}}}return b}_checkProfileExtend(){var i;var stk=this._stack;for(i=0;i<stk.length;i++){if(!stk[i].profile){continue}for(i=i+1;i<stk.length;i++){if(!stk[i].profile){this._msgCtx.error(`Profile '${stk[i-1].profile}' cannot extend from a non-profile config - ${stk[i].path}`);return false}}break}return true}_checkExtendOptionsProfile(){if(this._profResult){let stk=this._stack;let opts;for(let i=0;i<stk.length;i++){if(opts=stk[i].cfg.extendOptions){if(opts.ruleMods==="ignore"){let isSet=this._profResult.profiles.length>1;let profiles=(isSet?"set [":"'")+this._profResult.profiles.join(", ")+(isSet?"]":"'");this._msgCtx.error(`Config cannot use 'extendsOptions.ruleMods' to ignore inherited 'ruleMods' from profile ${profiles} - ${stk[i].path}`);return false}}}}return true}_resolveProfilePath(o){var prof,ret;if(!(prof=o.profile)){this._error(`JAF ERROR: 'extends' declared as an object but property 'profile' is missing.`);this._isError=true;return null}ret={profile:o.profile};if(!this._isAMD){ret.path=this._nd.path.join(__dirname,"../"+PROFILE_DIR,prof)+".json"};return ret}_fixupPaths(){var se,ret=true;for(let i=this._stack.length-1;i>=0;i--){se=this._stack[i];if(!(this._cleanBase(se)&&this._fixupConfig(se))){ret=false;break}}return ret}_cleanBase(se){if(this._isAMD){return true}var src,ft;var nd=this._nd;src=se.cfg.base;if(src==="$jafcwd"){src=this._cwd}else{if(!src){src=this._nd.path.dirname(se.path)}src=nd.path.normalize(src);if(!nd.path.isAbsolute(src)){src=nd.path.join(nd.path.dirname(se.path),src)}ft=this._fsUtils.getFileType(src);if(ft!=="d"){this._msgCtx.error(`Config file 'base' is not a directory - '${src}' in ${se.path}`);return false}}se.cfg.base=src;this._info(`[Info]: Using config base '${src}' in ${se.path}`,"I");return true}_fixupConfig(se){var nd,cfg,src,dir,ft,i;nd=this._nd;cfg=se.cfg;if(cfg.files){if(!this._cfgEx.validateFileList(cfg.files)){this._bErrors=true;return}if(src=se.cfg.files){for(i=0;i<src.length;i++){if(!src[i].startsWith("http")){src[i]=nd.path.normalize(src[i]);src[i]=nd.path.resolve(cfg.base,src[i])}}}}if(cfg.exclude){if(!this._cfgEx.validateFileList(cfg.exclude)){this._bErrors=true;return}if(src=cfg.exclude){for(i=0;i<src.length;i++){src[i]=nd.path.normalize(src[i]);src[i]=nd.path.resolve(cfg.base,src[i])}}}src=cfg.components;if(src){for(i=0;i<src.length;i++){dir=nd.path.normalize(src[i]);dir=nd.path.resolve(cfg.base,dir);cfg.components[i]=dir}}src=cfg.outPath;if(src&&src!=="$noout"){src=nd.path.normalize(src);src=nd.path.resolve(cfg.base,src);cfg.outPath=src}src=cfg.rulePacks;if(src){for(i=0;i<src.length;i++){dir=src[i].path;dir=nd.path.normalize(dir);src[i].path=nd.path.resolve(cfg.base,dir);if(src[i].path.endsWith(".zip")){continue}ft=this._fsUtils.getFileType(src[i].path);if(ft!=="d"){this._error("'rulePacks (entry "+(i+1)+"): path' is not a directory - \""+src[i].path+"\"");this._bErrors=true}}}if(cfg.typescript&&cfg.typescript.tsconfig){src=cfg.typescript.tsconfig;if(src&&typeof src==="string"){if(!nd.path.isAbsolute(src)){dir=nd.path.normalize(src);dir=nd.path.resolve(cfg.base,dir)}else{dir=src}if(!dir.endsWith(TSCONFIG)){dir=nd.path.join(dir,TSCONFIG)}cfg.typescript.tsconfig=dir}}if(this._bErrors){this._error(`Errors found in inherited config '${se.path}'`)}return!this._bErrors}_getAbsolutePath(fp){if(this._nd.path.isAbsolute(fp)){return fp}let prevFp,prevBase,p;prevFp=this._stack[this._stack.length-1].path;prevFp=this._nd.path.dirname(prevFp);prevBase=this._stack[this._stack.length-1].cfg.base;if(prevBase){if(!this._nd.path.isAbsolute(prevBase)){p=this._nd.path.join(prevFp,prevBase,fp)}else{p=this._nd.path.join(prevBase,fp)}}else{p=this._nd.path.join(prevFp,fp)}if(!this._nd.path.isAbsolute(p)){p=this._nd.path.join(this._dir,p)}return p}_isCircular(fp){var ret;for(let i=0;i<this._stack.length;i++){if(this._stack[i].path===fp){ret=true;break}}return ret}_isMergeProp(p){return MERGEABLE_BY_DEFAULT[p]||this._extendOpts[p]===EXOPT_MERGE}_mergePropFiles(parSE,chSE){return this._mergePropFilesExclude(parSE,chSE,"files")}_mergePropExclude(parSE,chSE){return this._mergePropFilesExclude(parSE,chSE,"exclude")}_mergePropFilesExclude(parSE,chSE,prop){var parent,child,ch,i;var parent=parSE.cfg[prop];var child=chSE.cfg[prop];for(i=0;i<child.length;i++){ch=child[i];if(!parent.includes(ch)){parent.push(ch)}}return true}_mergePropOptions(parSE,chSE){return this._mergeObjects(parSE,chSE,"options")}_mergePropGroups(parSE,chSE){return this._mergeArrays(parSE,chSE,"groups")}_mergePropTokens(parSE,chSE){return this._mergeObjects(parSE,chSE,"tokens")}_mergePropNameSpaces(parSE,chSE){return this._mergeArrays(parSE,chSE,"nameSpaces")}_mergePropRuleMods(parSE,chSE){var pname,pack,parPack,rule,rval;var parent=parSE.cfg.ruleMods;var child=chSE.cfg.ruleMods;if(!this._mergeRuleModsEnableDisable(parSE,chSE)){return false}for(pname in child){if(pname==="enable"||pname==="disable"){continue}pack=child[pname];if(!parent[pname]){parent[pname]=pack;continue}this._mergeRuleModsPackObjects(parent[pname],pack)}parPack=parent[pname];for(rule in rval){if(!parPack[rule]){parPack[rule]=rval[rule]}}return true}_mergeRuleModsEnableDisable(parSE,chSE){var parent,child,val,x;var parEnable,parDisable,chEnable,chDisable;var parent=parSE.cfg.ruleMods;var child=chSE.cfg.ruleMods;parEnable=parent.enable;parDisable=parent.disable;chEnable=child.enable;chDisable=child.disable;var self=this;function _profVetoEnable(val){var ret=false;if(self._profResult&&self._profResult.disable){ret=self._profResult.disable.includes(val)}return ret}function _profVetoDisable(val){var ret=false;if(self._profResult&&self._profResult.enable){ret=self._profResult.enable.includes(val)}return ret}if(parEnable&&chDisable){for(val of parEnable){if(!(parSE.profile&&chSE.profile)){if(_profVetoEnable(val)){this._emitProfileVetoError(val,parSE.path,false);return false}}if((x=chDisable.indexOf(val))>=0){chDisable.splice(x,1)}}}if(parDisable&&chEnable){for(val of parDisable){if(!(parSE.profile&&chSE.profile)){if(_profVetoDisable(val)){this._emitProfileVetoError(val,parSE.path,true);return false}}if((x=chEnable.indexOf(val))>=0){chEnable.splice(x,1)}}}if(chEnable){if(!parEnable){parent.enable=parEnable=[]}for(val of chEnable){if(!parEnable.includes(val)){parEnable.push(val)}}}if(chDisable){if(!parDisable){parent.disable=parDisable=[]}for(val of chDisable){if(!parDisable.includes(val)){parDisable.push(val)}}}if(parSE.profile&&chSE.profile){if(!this._profResult){this._profResult={}}this._profResult.enable=parEnable;this._profResult.disable=parDisable;if(this._isDebug){console.log(`Profile merge: ${parSE.profile} <- ${chSE.profile}`)}}else{if(this._isDebug){console.log(`Merge: '${parSE.path}' <- '${chSE.profile?chSE.profile:chSE.path}'`)}}if(this._isDebug){console.log(`${parSE.path} <- ${chSE.path}`);console.log(`Enable = ${parEnable.join(",\n ")}`);console.log(`Disable = ${parDisable.join(",\n ")}\n`)}return true}_emitProfileVetoError(rule,cfgPath,disable){var profiles,temp,op1,op2;temp=[...this._profResult.profiles];temp.forEach((rule,i)=>{temp[i]="'"+rule+"'"});temp=temp.join(", ");if(disable){op1="disable";op2="enabled"}else{op1="enable";op2="disabled"}profiles="profile"+`${this._profResult.profiles.length>1?" set [":""} ${temp}${this._profResult.profiles.length>1?"]":""}`;cfgPath=cfgPath?`in ${cfgPath} `:"";this._error(`Config 'ruleMods' conflict: cannot ${op1} rule '${rule}' ${cfgPath}- ${op2} by ${profiles}`)}_mergePropRuleNames(parSE,chSE){return this._mergeArrays(parSE,chSE,"ruleNames")}_mergePropRulePacks(parSE,chSE){var parent=parSE.cfg.rulePacks;var child=chSE.cfg.rulePacks;for(let i=0;i<child.length;i++){let ch=child[i];let b=false;for(let j=0;j<parent.length;j++){let par=parent[j];if(ch.path===par.path){b=true;break}}if(!b){parent.push(ch)}}return true}_mergePropMessages(parSE,chSE){var parent=parSE.cfg.messages;var child=chSE.cfg.messages;var parReject=parent.reject;var chReject=child.reject;if(!parReject&&chReject){parent.reject=chReject}else if(parReject&&chReject){parent.reject=_removeDupes(parReject.concat(chReject))}var parAccept=parent.accept;var chAccept=child.accept;if(!parAccept&&chAccept){parent.accept=chAccept}else if(parAccept&&chAccept){parent.accept=_removeDupes(parAccept.concat(chAccept))}return true}_mergePropComponents(parSE,chSE){return this._mergeArrays(parSE,chSE,"components")}_mergePropCompUrls(parSE,chSE){return this._mergeArrays(parSE,chSE,"componentUrls")}_mergePropTypescript(parSE,chSE){return this._mergeObjects(parSE,chSE,"typescript")}_mergePropSevMap(parSE,chSE){var parent=parSE.cfg.sevMap;var child=chSE.cfg.sevMap;var parSevMsg,chSevMsg;var parSevSet,chSevSet;if(parent){parSevMsg=parent.sevMsg;parSevSet=parent.sevSet}if(child){chSevMsg=child.sevMsg;chSevSet=child.sevSet}if(parSevMsg&&chSevMsg){this._mergeObjects(parSE,chSE,"sevMap")}else if(!parSevMsg&&chSevMsg){parent.sevMsg=chSevMsg}if(parSevSet&&chSevSet){this._mergeObjects(parSE,chSE,"sevSet")}else if(!parSevSet&&chSevSet){parent.sevSet=chSevSet}if(parent.sevSet&&parent.sevMsg){let sev,msg,oldsev,val;for(val in parent.sevSet){sev=parent.sevSet[val];for(msg in parent.sevMsg){oldsev=parent.sevMsg[msg];if(val===oldsev){parent.sevMsg[msg]=sev}}}}return true}_mergeObjects(parSE,chSE,prop){var parent,child;parent=parSE.cfg[prop];child=chSE.cfg[prop];for(let prop in child){if(!parent.hasOwnProperty(prop)){parent[prop]=child[prop]}}return true}_mergeRuleModsPackObjects(to,from){var rule;for(rule in from){if(!to[rule]){to[rule]=from[rule]}}}_mergeArrays(parSE,chSE,prop){var parent,child,isPS,isCS,isPA,isCA,val;parent=parSE.cfg[prop];child=chSE.cfg[prop];isPS=typeof parent==="string";isCS=typeof child==="string";if(isPS&&isCS&&parent===child){return}isPA=Array.isArray(parent);isCA=Array.isArray(child);parent=isPA?parent:[parent];child=isCA?child:[child];for(let i=0;i<child.length;i++){val=child[i];if(!parent.includes(val)){parent.push(val)}}return true}_emitErrorMsg(s,prop,path){var s=s||MSG.UNKNOWN;if(prop){s=s.replace(REPL_PROP,prop)}this._error(s.replace(REPL_PATH,path));this._isError=true}_parseError(msg){this._parseError=msg}_dumpStack(){var type,msg;this._msgCtx.info("[Info]: -- Config 'extends' stack --","I",true);for(let i=0;i<this._stack.length;i++){type=this._stack[i].profile;type=type?type:"config ";msg=!this._isAMD?`${type} ${this._stack[i].path}`:`${type}`;this._msgCtx.info(`[Info]: ${msg}`,"I",true)}}}function _removeDupes(ar){return Array.isArray(ar)?ar.filter((val,x)=>ar.indexOf(val)===x):ar};module.exports=Extends;
package/lib/migrator.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- function run(cwd,rtf,appCtx,fnOpenWriter,JafVersion,fnShowVersion){var mig,isVerboseDebug=rtf.verboseMode||rtf.debugMode;var ctx;fnShowVersion();appCtx.debug("Loading migrator entry-point...");try{if(rtf.outPath){if(!fnOpenWriter(rtf.outPath)){return}}ctx=_makeContext(rtf,appCtx,JafVersion,cwd);mig=new(require("../corePackMigrator/cli"))(ctx)}catch(e){let s="[JAF-9100]: Error loading Migrator support.";if(isVerboseDebug){s+=`\n{e.message}`}appCtx.msg(appCtx.colors.RED(s))}if(!mig){return}appCtx.debug("Checking entry-points...");let isError;if(!mig.run){_missingEntry("run",appCtx);isError=true}if(rtf.unitTest&&!mig.test){_missingEntry("test",appCtx);isError=true}if(isError||rtf.help){return}_displayOptions(ctx,appCtx);appCtx.debug("Invoking migrator...");try{return mig.run()}catch(e){let s,x,i;s=e.stack;if((x=s.indexOf("migrator.js"))>=0){for(i=x;;i--){if(s.charAt(i)==="\n"){s=s.substring(0,i);break}}}appCtx.error(appCtx.colors.RED(`[JAF-9102]: Migrator run failure.\n${s}`))}return 0};function _makeContext(rtf,appCtx,JafVersion,cwd){return{jafVersion:JafVersion,jetVersion:rtf.jetverSet?rtf.jetverSet:appCtx.defaultJetVer,configPath:rtf.configPath||null,cwd:cwd,logPath:rtf.outPath,log:{error:appCtx.error,warn:appCtx.warn,info:appCtx.info,msg:appCtx.msg,console:appCtx.console,debug:appCtx.debug},options:{verboseMode:rtf.verboseMode,debugMode:rtf.debugMode,dryRunMode:rtf.dryRunSet,colorMode:appCtx.colors.isColor(),unitTest:!!rtf.unitTest},runMode:appCtx.runMode,utils:{utils:appCtx.utils,fsUtils:appCtx.fsUtils,color:appCtx.colors}}};function _displayOptions(ctx,appCtx){if(ctx.options.debugMode){appCtx.debug("Migrator options:");appCtx.debug(` jafVersion: ${ctx.jafVersion}`);appCtx.debug(` jetVersion: ${ctx.jetVersion}`);appCtx.debug(` configPath: ${ctx.configPath}`);appCtx.debug(` debugMode: ${ctx.options.debugMode}`);appCtx.debug(` verboseMode: ${ctx.options.verboseMode}`);appCtx.debug(` dryRunMode: ${ctx.options.dryRunMode}`);appCtx.debug(` colorMode: ${ctx.options.colorMode}`);appCtx.debug(` logPath: ${ctx.logPath}`);appCtx.debug(` unitTest: ${ctx.options.unitTest}`)}else{appCtx.info(`Migrator log -> ${ctx.logPath}\n`)}};function _missingEntry(method,appCtx){appCtx.error(appCtx.colors.RED(`[JAF-9101]: Migrator linkage support - no ${method}() method exported.`))};module.exports={run};
6
+ function run(cwd,rtf,appCtx,fnOpenWriter,JafVersion,fnShowVersion){var mig,isVerboseDebug=rtf.verboseMode||rtf.debugMode;var ctx;appCtx.debug("Loading migrator entry-point...");try{if(rtf.outPath){if(!fnOpenWriter(rtf.outPath)){return}}ctx=_makeContext(rtf,appCtx,JafVersion,cwd);mig=new(require("../corePackMigrator/cli"))(ctx)}catch(e){let s="[JAF-9100]: Error loading Migrator support.";if(isVerboseDebug){s+=`\n{e.message}`}appCtx.msg(appCtx.colors.RED(s))}if(!mig){return}appCtx.debug("Checking entry-points...");let isError;if(!mig.run){_missingEntry("run",appCtx);isError=true}if(rtf.unitTest&&!mig.test){_missingEntry("test",appCtx);isError=true}if(!mig.getVersion){}if(isError){return}_displayOptions(ctx,appCtx);if(rtf.help){let migVer;if(mig.getVersion){migVer=mig.getVersion()}migVer?appCtx.console(migVer,"I"):fnShowVersion();return}appCtx.debug("Invoking migrator...");try{return mig.run()}catch(e){let s,x,i;s=e.stack;if((x=s.indexOf("migrator.js"))>=0){for(i=x;;i--){if(s.charAt(i)==="\n"){s=s.substring(0,i);break}}}appCtx.error(appCtx.colors.RED(`[JAF-9102]: Migrator run failure.\n${s}`))}return 0};function _makeContext(rtf,appCtx,JafVersion,cwd){return{jafVersion:JafVersion,jetVersion:rtf.jetverSet?rtf.jetverSet:appCtx.defaultJetVer,configPath:rtf.configPath||null,cwd:cwd,logPath:rtf.outPath,log:{error:appCtx.error,warn:appCtx.warn,info:appCtx.info,msg:appCtx.msg,console:appCtx.console,debug:appCtx.debug},options:{verboseMode:rtf.verboseMode,debugMode:rtf.debugMode,dryRunMode:rtf.dryRunSet,colorMode:appCtx.colors.isColor(),unitTest:!!rtf.unitTest},runMode:appCtx.runMode,platform:appCtx.platform,utils:{utils:appCtx.utils,fsUtils:appCtx.fsUtils,color:appCtx.colors}}};function _displayOptions(ctx,appCtx){if(ctx.options.debugMode){appCtx.debug("Migrator options:");appCtx.debug(` jafVersion: ${ctx.jafVersion}`);appCtx.debug(` jetVersion: ${ctx.jetVersion}`);appCtx.debug(` configPath: ${ctx.configPath}`);appCtx.debug(` runMode: ${ctx.options.runMode}`);appCtx.debug(` debugMode: ${ctx.options.debugMode}`);appCtx.debug(` verboseMode: ${ctx.options.verboseMode}`);appCtx.debug(` dryRunMode: ${ctx.options.dryRunMode}`);appCtx.debug(` colorMode: ${ctx.options.colorMode}`);appCtx.debug(` logPath: ${ctx.logPath}`);appCtx.debug(` unitTest: ${ctx.options.unitTest}`)}else{appCtx.info(`Migrator log -> ${ctx.logPath}\n`)}};function _missingEntry(method,appCtx){appCtx.error(appCtx.colors.RED(`[JAF-9102]: Internal error - Migrator support method ${method}() not exported.`))};module.exports={run};
package/lib/ns.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const _ns=["oj-acx","oj-acx-assets","oj-adp","oj-approvals","oj-av","oj-bi","oj-bi-sac","oj-cagbu","oj-cegbu","oj-cegbu-scp","oj-cgbu","oj-cgm","oj-cic","oj-communities","oj-core","oj-cp","oj-cso","oj-csp","oj-cx","oj-cx-aiapps","oj-cx-ap","oj-cx-cg","oj-cx-dcs","oj-cx-fsvc","oj-cx-hd","oj-cx-interviews","oj-cx-iss","oj-cx-km","oj-cx-km-agent","oj-cx-marketing","oj-cx-ma","oj-cx-mc","oj-cx-ol","oj-cx-saleshub","oj-cx-svc","oj-cxi","oj-cxm","oj-dbt","oj-dcs","oj-doceng","oj-dyn","oj-ee","oj-em","oj-epm","oj-fa","oj-faw","oj-fa-fin","oj-fnd","oj-fom","oj-fsgbu","oj-fsgbu-demo","oj-fwk","oj-gbu","oj-gbu-comp","oj-gcs","oj-hcm","oj-hed","oj-hsgbu","oj-hsp","oj-hsp-common","oj-hsp-cruise","oj-hsp-hdp","oj-hsp-ohip","oj-hsp-opera","oj-ia","oj-i18n","oj-idaas","oj-ips","oj-j4s","oj-jv","oj-lux","oj-lx","oj-mca","oj-mcps","oj-oa","oj-oac","oj-oal","oj-oal-ni","oj-oal-ux","oj-oax","oj-ob","oj-oc","oj-oce","oj-ocm","oj-oda","oj-oda-chat","oj-odcs","oj-odcs-oit","oj-odps","oj-ofsc","oj-ohi","oj-oic","oj-oit","oj-ofs","oj-ol","oj-omc","oj-omnichannel","oj-opa","oj-opaas","oj-opac","oj-pa","oj-psc","oj-prmt","oj-psm","oj-ref","oj-rgbu","oj-rgbu-jraf","oj-rw","oj-scs","oj-sp","oj-spatial","oj-spectra","oj-svc","oj-taui","oj-ugbu","oj-ux","oj-vb","oj-vb-sample","oj-vbdt","oj","oj-c","oj-cc","oj-dynamic","oj-ext","oj-sample","oj-sample-internal","ns","ns-ui","demo","my","app"];const _setNS=new Set(_ns);module.exports={has:function(k){return _setNS.has(k)},getKeys:function(){return[..._setNS]}};
6
+ const _ns=["oj-acx","oj-acx-assets","oj-adp","oj-approvals","oj-av","oj-bangylon","oj-bi","oj-bi-sac","oj-cagbu","oj-cegbu","oj-cegbu-scp","oj-cgbu","oj-cgm","oj-cic","oj-clm","oj-communities","oj-core","oj-cp","oj-cso","oj-csp","oj-cx","oj-cx-aiapps","oj-cx-ap","oj-cx-cg","oj-cx-dcs","oj-cx-fsvc","oj-cx-hd","oj-cx-interviews","oj-cx-iss","oj-cx-km","oj-cx-km-agent","oj-cx-marketing","oj-cx-ma","oj-cx-mc","oj-cx-ol","oj-cx-saleshub","oj-cx-svc","oj-cxi","oj-cxm","oj-dbt","oj-dcs","oj-doceng","oj-dyn","oj-ee","oj-ehrc","oj-em","oj-epm","oj-fa","oj-faw","oj-fa-fin","oj-fnd","oj-fom","oj-fsgbu","oj-fsgbu-demo","oj-fwk","oj-gbu","oj-gbu-comp","oj-gcs","oj-hcm","oj-hed","oj-hsgbu","oj-hsp","oj-hsp-common","oj-hsp-cruise","oj-hsp-hdp","oj-hsp-ohip","oj-hsp-opera","oj-ia","oj-i18n","oj-idaas","oj-ips","oj-j4s","oj-jv","oj-lux","oj-lx","oj-mca","oj-mcps","oj-nav","oj-oa","oj-oac","oj-oal","oj-oal-ni","oj-oal-ux","oj-oax","oj-ob","oj-oc","oj-oce","oj-ocm","oj-oda","oj-oda-chat","oj-odcs","oj-odcs-oit","oj-odps","oj-ofsc","oj-ogg","oj-ohi","oj-oic","oj-oit","oj-ofs","oj-ol","oj-omc","oj-omnichannel","oj-opa","oj-opaas","oj-opac","oj-pa","oj-psc","oj-prmt","oj-psm","oj-ref","oj-rgbu","oj-rgbu-jraf","oj-rw","oj-scs","oj-sp","oj-spatial","oj-spectra","oj-svc","oj-taui","oj-ugbu","oj-uw","oj-ux","oj-vb","oj-vb-sample","oj-vbdt","oj-wcc","oj","oj-c","oj-cc","oj-dynamic","oj-ext","oj-sample","oj-sample-internal","ns","ns-ui","demo","my","app"];const _setNS=new Set(_ns);module.exports={has:function(k){return _setNS.has(k)},getKeys:function(){return[..._setNS]}};
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const ExpParser=function(){this.parse=function(expr){var length=expr.length;var context={index:0,expr:expr};var nodes=[];while(context.index<length){var ch_i=expr.charCodeAt(context.index);if(ch_i===SEMCOL_CODE||ch_i===COMMA_CODE){context.index++}else{var node=_gobbleExpression(context);if(node){nodes.push(node)}else if(context.index<length){_throwError("Unexpected \""+expr.charAt(context.index)+"\"",context.index)}}}if(nodes.length===1){return nodes[0]}return{type:0,body:nodes}};function _gobbleSpaces(context){var expr=context.expr;var ch=expr.charCodeAt(context.index);while(ch===32||ch===9||ch===10||ch===13){ch=expr.charCodeAt(++context.index)}}function _gobbleExpression(context){var expr=context.expr;var test=_gobbleBinaryExpression(context),consequent,alternate;_gobbleSpaces(context);if(expr.charCodeAt(context.index)===QUMARK_CODE){context.index++;consequent=_gobbleExpression(context);if(!consequent){_throwError("Expected expression",context.index)}_gobbleSpaces(context);if(expr.charCodeAt(context.index)===COLON_CODE){context.index++;alternate=_gobbleExpression(context);if(!alternate){_throwError("Expected expression",context.index)}return{type:8,test:test,consequent:consequent,alternate:alternate}}_throwError("Expected :",context.index)}else{return test}}function _gobbleBinaryOp(context){var expr=context.expr;_gobbleSpaces(context);var to_check=expr.substr(context.index,_max_binop_len),tc_len=to_check.length;while(tc_len>0){if(_binary_ops[to_check]&&(!_isIdentifierStart(expr.charCodeAt(context.index))||context.index+to_check.length<expr.length&&!_isIdentifierPart(expr.charCodeAt(context.index+to_check.length)))){context.index+=tc_len;return to_check}to_check=to_check.substr(0,--tc_len)}return false}function _gobbleBinaryExpression(context){var node,biop,prec,stack,biop_info,left,right,i,cur_biop;left=_gobbleToken(context);biop=_gobbleBinaryOp(context);if(!biop){return left}biop_info={value:biop,prec:_binaryPrecedence(biop)};right=_gobbleToken(context);if(!right){_throwError("Expected expression after "+biop,context.index)}stack=[left,biop_info,right];while(biop=_gobbleBinaryOp(context)){prec=_binaryPrecedence(biop);if(prec===0){break}biop_info={value:biop,prec:prec};cur_biop=biop;while(stack.length>2&&prec<=stack[stack.length-2].prec){right=stack.pop();biop=stack.pop().value;left=stack.pop();node=_createBinaryExpression(biop,left,right,context);stack.push(node)}node=_gobbleToken(context);if(!node){_throwError("Expected expression after "+cur_biop,context.index)}stack.push(biop_info,node)}i=stack.length-1;node=stack[i];while(i>1){node=_createBinaryExpression(stack[i-1].value,stack[i-2],node,context);i-=2}return node}function _gobbleToken(context){var expr=context.expr;var ch,to_check,tc_len;_gobbleSpaces(context);ch=expr.charCodeAt(context.index);if(_isDecimalDigit(ch)||ch===PERIOD_CODE){return _gobbleNumericLiteral(context)}else if(ch===SQUOTE_CODE||ch===DQUOTE_CODE||ch===OBRACK_CODE){return _gobbleVariable(context)}else if(ch===OBRACE_CODE){return _gobbleObjectLiteral(context)}to_check=expr.substr(context.index,_max_unop_len);tc_len=to_check.length;while(tc_len>0){if(to_check in _unary_ops&&(!_isIdentifierStart(expr.charCodeAt(context.index))||context.index+to_check.length<expr.length&&!_isIdentifierPart(expr.charCodeAt(context.index+to_check.length)))){context.index+=tc_len;return{type:5,operator:to_check,argument:_gobbleToken(context),prefix:true}}to_check=to_check.substr(0,--tc_len)}var start=context.index;var funcEnd=context.index+8;if(expr.substring(start,funcEnd)==="function"&&!_isIdentifierPart(expr.charCodeAt(funcEnd))){context.index=funcEnd;return _gobbleFunction(context)}if(_isIdentifierStart(ch)||ch===OPAREN_CODE){return _gobbleVariable(context)}return false}function _gobbleNumericLiteral(context){var expr=context.expr;var number="",ch,chCode;while(_isDecimalDigit(expr.charCodeAt(context.index))){number+=expr.charAt(context.index++)}if(expr.charCodeAt(context.index)===PERIOD_CODE){number+=expr.charAt(context.index++);while(_isDecimalDigit(expr.charCodeAt(context.index))){number+=expr.charAt(context.index++)}}ch=expr.charAt(context.index);if(ch==="e"||ch==="E"){number+=expr.charAt(context.index++);ch=expr.charAt(context.index);if(ch==="+"||ch==="-"){number+=expr.charAt(context.index++)}while(_isDecimalDigit(expr.charCodeAt(context.index))){number+=expr.charAt(context.index++)}if(!_isDecimalDigit(expr.charCodeAt(context.index-1))){_throwError("Expected exponent ("+number+expr.charAt(context.index)+")",context.index)}}chCode=expr.charCodeAt(context.index);if(_isIdentifierStart(chCode)){_throwError("Variable names cannot start with a number ("+number+expr.charAt(context.index)+")",context.index)}else if(chCode===PERIOD_CODE){_throwError("Unexpected period",context.index)}return{type:3,value:parseFloat(number),raw:number}}function _gobbleStringLiteral(context){var expr=context.expr;var str="",quote=expr.charAt(context.index++),closed=false,ch;var length=expr.length;while(context.index<length){ch=expr.charAt(context.index++);if(ch===quote){closed=true;break}else if(ch==="\\"){ch=expr.charAt(context.index++);switch(ch){case"n":str+="\n";break;case"r":str+="\r";break;case"t":str+="\t";break;case"b":str+="\b";break;case"f":str+="\f";break;case"v":str+="\x0B";break;default:str+=ch}}else{str+=ch}}if(!closed){_throwError("Unclosed quote after \""+str+"\"",context.index)}return{type:3,value:str,raw:quote+str+quote}}function _gobbleIdentifier(context,bMemberExpr){var expr=context.expr;var ch=expr.charCodeAt(context.index),start=context.index,identifier;if(_isIdentifierStart(ch)){context.index++}else{_throwError("Unexpected "+expr.charAt(context.index),context.index)}var length=expr.length;while(context.index<length){ch=expr.charCodeAt(context.index);if(_isIdentifierPart(ch)){context.index++}else{break}}identifier=expr.slice(start,context.index);if(identifier==="new"&&!bMemberExpr){_gobbleSpaces(context);var constructorNode=_gobbleVariable(context,4);if(constructorNode.type!==4){_throwError("Expression of type: "+constructorNode.type+" not supported for constructor expression")}return{type:12,callee:constructorNode.callee,arguments:constructorNode.arguments}}if(_literals.has(identifier)){return{type:3,value:_literals.get(identifier),raw:identifier}}return{type:1,name:identifier}}function _gobbleArguments(context,termination,identifiersOnly){var expr=context.expr;var length=expr.length;var ch_i,args=[],node,closed=false;var separator_count=0;while(context.index<length){_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(ch_i===termination){closed=true;context.index++;if(termination===CPAREN_CODE&&separator_count&&separator_count>=args.length){_throwError("Unexpected token "+String.fromCharCode(termination),context.index)}break}else if(ch_i===COMMA_CODE){context.index++;separator_count++;if(separator_count!==args.length){if(termination===CPAREN_CODE){_throwError("Unexpected token ,",context.index)}else if(termination===CBRACK_CODE){for(var arg=args.length;arg<separator_count;arg++){args.push(null)}}}}else{if(identifiersOnly){node=_gobbleIdentifier(context)}else{node=_gobbleExpression(context)}if(!node||args.length>separator_count){_throwError("Expected comma",context.index)}args.push(node)}}if(!closed){_throwError("Expected "+String.fromCharCode(termination),context.index)}return args}function _gobbleVariable(context,stopAtType){var expr=context.expr;var ch_i,node;ch_i=expr.charCodeAt(context.index);if(ch_i===OPAREN_CODE){node=_gobbleGroup(context)}else if(ch_i===SQUOTE_CODE||ch_i===DQUOTE_CODE){node=_gobbleStringLiteral(context)}else if(ch_i===OBRACK_CODE){node=_gobbleArray(context)}else{node=_gobbleIdentifier(context)}_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);while(ch_i===PERIOD_CODE||ch_i===OBRACK_CODE||ch_i===OPAREN_CODE||_isOptionalChaining(context)){context.index++;if(ch_i===PERIOD_CODE){_gobbleSpaces(context);node={type:2,computed:false,object:node,property:_gobbleIdentifier(context,true)}}else if(ch_i===QUMARK_CODE){context.index++;_gobbleSpaces(context);node={type:2,computed:false,conditional:true,object:node,property:_gobbleIdentifier(context,true)}}else if(ch_i===OBRACK_CODE){node={type:2,computed:true,object:node,property:_gobbleExpression(context)};_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(ch_i!==CBRACK_CODE){_throwError("Unclosed [",context.index)}context.index++}else if(ch_i===OPAREN_CODE){node={type:4,arguments:_gobbleArguments(context,CPAREN_CODE),callee:node}}if(stopAtType===node.type){return node}_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index)}return node}function _gobbleGroup(context){context.index++;var node=_gobbleExpression(context);_gobbleSpaces(context);if(context.expr.charCodeAt(context.index)===CPAREN_CODE){context.index++;return node}_throwError("Unclosed (",context.index)}function _gobbleArray(context){context.index++;return{type:9,elements:_gobbleArguments(context,CBRACK_CODE)}}function _gobbleFunction(context){var expr=context.expr;_gobbleSpaces(context);var ch_i=expr.charCodeAt(context.index);if(ch_i!==OPAREN_CODE){_throwError("Expected (,",context.index)}context.index++;var args=_gobbleArguments(context,CPAREN_CODE,true);_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(ch_i!==OBRACE_CODE){_throwError("Expected {,",context.index)}context.index++;_gobbleSpaces(context);var startDef=context.index;var hasReturn;var start=context.index;if(expr.substring(start,start+6)==="return"){hasReturn=true;context.index+=6}_gobbleSpaces(context);var body=_gobbleExpression(context);_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(ch_i===SEMCOL_CODE){context.index++;_gobbleSpaces(context)}ch_i=expr.charCodeAt(context.index);if(ch_i!==CBRACE_CODE){_throwError("Expected },",context.index)}context.index++;return{type:11,arguments:args,body:body,expr:expr.substring(startDef,context.index-1),return:hasReturn}}function _gobbleObjectLiteral(context){var expr=context.expr;context.index++;var props=[];var closed;var separator_count=0;var length=expr.length;while(context.index<length&&!closed){_gobbleSpaces(context);var ch_i=expr.charCodeAt(context.index);if(ch_i===CBRACE_CODE){closed=true;context.index++}else if(ch_i===COMMA_CODE){context.index++;separator_count++;if(separator_count!==props.length){_throwError("Unexpected token ,",context.index)}}else{var key;if(ch_i===SQUOTE_CODE||ch_i===DQUOTE_CODE){key=_gobbleStringLiteral(context).value}else{key=_gobbleIdentifier(context).name}_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(ch_i!==COLON_CODE){_throwError("Expected ':'. Found "+String.fromCharCode(ch_i),context.index)}context.index++;var writer=context.writer;if(key==="_ko_property_writers"){context.writer=1}try{props.push({key:key,value:_gobbleExpression(context)})}finally{context.writer=writer}}}if(!closed){_throwError("Expected "+String.fromCharCode(CBRACE_CODE),context.index)}return{type:10,properties:props}}var PERIOD_CODE=46,COMMA_CODE=44,SQUOTE_CODE=39,DQUOTE_CODE=34,OPAREN_CODE=40,CPAREN_CODE=41,OBRACK_CODE=91,CBRACK_CODE=93,QUMARK_CODE=63,SEMCOL_CODE=59,COLON_CODE=58,OBRACE_CODE=123,CBRACE_CODE=125;function _getMaxKeyLen(obj){return Object.keys(obj).reduce(function(curr,key){return Math.max(curr,key.length)},0)}var t=true,_unary_ops={"-":t,"!":t,"~":t,"+":t},_binary_ops={"=":1,"||":2,"&&":3,"|":4,"^":5,"&":6,"==":7,"!=":7,"===":7,"!==":7,"<":8,">":8,"<=":8,">=":8,"<<":9,">>":9,">>>":9,"+":10,"-":10,"*":11,"/":11,"%":11},_max_unop_len=_getMaxKeyLen(_unary_ops),_max_binop_len=_getMaxKeyLen(_binary_ops);var _literals=new Map;_literals.set("true",true);_literals.set("false",false);_literals.set("null",null);_literals.set("undefined",undefined);function _binaryPrecedence(op_val){return _binary_ops[op_val]||0}function _createBinaryExpression(operator,left,right,context){if(operator==="="&&!context.writer){_throwError("Unexpected operator '='",context.index)}var type=operator==="||"||operator==="&&"?7:6;return{type:type,operator:operator,left:left,right:right}}function _isOptionalChaining(context){var expr=context.expr;if(expr.charCodeAt(context.index)===QUMARK_CODE&&expr.charCodeAt(context.index+1)===PERIOD_CODE&&!_isDecimalDigit(expr.charCodeAt(context.index+2))){return true}return false}function _isDecimalDigit(ch){return ch>=48&&ch<=57}function _isIdentifierStart(ch){return ch===36||ch===95||ch>=65&&ch<=90||ch>=97&&ch<=122||ch>=128&&!_binary_ops[String.fromCharCode(ch)]}function _isIdentifierPart(ch){return ch===36||ch===95||ch>=65&&ch<=90||ch>=97&&ch<=122||ch>=48&&ch<=57||ch>=128&&!_binary_ops[String.fromCharCode(ch)]}function _throwError(message,index){var error=new Error(message+" at character "+index);error.index=index;error.description=message;throw error}};module.exports=ExpParser;
6
+ const ExpParser=function(){this.parse=function(expr){var context={index:0,expr:expr};var nodes=_gobbleExpressions(context);if(nodes.length===1){return nodes[0]}return{type:COMPOUND,body:nodes}};function _gobbleExpressions(context,untilICode){const expr=context.expr;const length=expr.length;const nodes=[];while(context.index<length){_gobbleSpaces(context);const ch_i=expr.charCodeAt(context.index);if(ch_i===untilICode){break}else if(ch_i===SEMCOL_CODE||ch_i===COMMA_CODE){context.index++}else{const node=_gobbleExpression(context);if(node){nodes.push(node)}else if(context.index<length){_throwError("Unexpected \""+expr.charAt(context.index)+"\"",context.index)}}}return nodes}function _gobbleSpaces(context){var expr=context.expr;var ch=expr.charCodeAt(context.index);while(ch===32||ch===9||ch===10||ch===13){ch=expr.charCodeAt(++context.index)}}function _gobbleExpression(context){var expr=context.expr;var test=_gobbleBinaryExpression(context),consequent,alternate;_gobbleSpaces(context);if(expr.charCodeAt(context.index)===QUMARK_CODE){context.index++;consequent=_gobbleExpression(context);if(!consequent){_throwError("Expected expression",context.index)}_gobbleSpaces(context);if(expr.charCodeAt(context.index)===COLON_CODE){context.index++;alternate=_gobbleExpression(context);if(!alternate){_throwError("Expected expression",context.index)}return{type:CONDITIONAL_EXP,test:test,consequent:consequent,alternate:alternate}}_throwError("Expected :",context.index)}else{return test}}function _gobbleBinaryOp(context){var expr=context.expr;_gobbleSpaces(context);var to_check=expr.substr(context.index,_max_binop_len),tc_len=to_check.length;while(tc_len>0){if(_binary_ops[to_check]&&(!_isIdentifierStart(expr.charCodeAt(context.index))||context.index+to_check.length<expr.length&&!_isIdentifierPart(expr.charCodeAt(context.index+to_check.length)))){context.index+=tc_len;return to_check}to_check=to_check.substr(0,--tc_len)}return false}function _gobbleBinaryExpression(context){var node,biop,prec,stack,biop_info,left,right,i,cur_biop,cur_prec;left=_gobbleToken(context);biop=_gobbleBinaryOp(context);if(!biop){return left}biop_info={value:biop,prec:_binaryPrecedence(biop)};right=_gobbleToken(context);if(!right){_throwError("Expected expression after "+biop,context.index)}stack=[left,biop_info,right];cur_biop=biop;cur_prec=biop_info.prec;while(biop=_gobbleBinaryOp(context)){prec=_binaryPrecedence(biop,cur_biop,cur_prec);if(prec===0){break}biop_info={value:biop,prec:prec};cur_biop=biop;cur_prec=prec;while(stack.length>2&&prec<=stack[stack.length-2].prec){right=stack.pop();biop=stack.pop().value;left=stack.pop();node=_createBinaryExpression(biop,left,right,context);stack.push(node)}node=_gobbleToken(context);if(!node){_throwError("Expected expression after "+cur_biop,context.index)}stack.push(biop_info,node)}i=stack.length-1;node=stack[i];while(i>1){node=_createBinaryExpression(stack[i-1].value,stack[i-2],node,context);i-=2}return node}function _gobbleToken(context){var expr=context.expr;var ch,to_check,tc_len;_gobbleSpaces(context);ch=expr.charCodeAt(context.index);if(_isDecimalDigit(ch)||ch===PERIOD_CODE){return _gobbleNumericLiteral(context)}else if(ch===SQUOTE_CODE||ch===DQUOTE_CODE||ch===OBRACK_CODE){return _gobbleVariable(context)}else if(ch===OBRACE_CODE){return _gobbleObjectLiteral(context)}else if(ch===BTICK_CODE){return _gobbleTemplateLiteral(context)}to_check=expr.substr(context.index,_max_unop_len);tc_len=to_check.length;while(tc_len>0){if(to_check in _unary_ops&&(!_isIdentifierStart(expr.charCodeAt(context.index))||context.index+to_check.length<expr.length&&!_isIdentifierPart(expr.charCodeAt(context.index+to_check.length)))){context.index+=tc_len;return{type:UNARY_EXP,operator:to_check,argument:_gobbleToken(context),prefix:true}}to_check=to_check.substr(0,--tc_len)}var start=context.index;var funcEnd=context.index+8;if(expr.substring(start,funcEnd)==="function"&&!_isIdentifierPart(expr.charCodeAt(funcEnd))){context.index=funcEnd;return _gobbleFunction(context)}if(_isIdentifierStart(ch)||ch===OPAREN_CODE){return _gobbleVariable(context)}return false}function _gobbleNumericLiteral(context){var expr=context.expr;var number="",ch,chCode;while(_isDecimalDigit(expr.charCodeAt(context.index))){number+=expr.charAt(context.index++)}if(expr.charCodeAt(context.index)===PERIOD_CODE){number+=expr.charAt(context.index++);while(_isDecimalDigit(expr.charCodeAt(context.index))){number+=expr.charAt(context.index++)}}ch=expr.charAt(context.index);if(ch==="e"||ch==="E"){number+=expr.charAt(context.index++);ch=expr.charAt(context.index);if(ch==="+"||ch==="-"){number+=expr.charAt(context.index++)}while(_isDecimalDigit(expr.charCodeAt(context.index))){number+=expr.charAt(context.index++)}if(!_isDecimalDigit(expr.charCodeAt(context.index-1))){_throwError("Expected exponent ("+number+expr.charAt(context.index)+")",context.index)}}chCode=expr.charCodeAt(context.index);if(_isIdentifierStart(chCode)){_throwError("Variable names cannot start with a number ("+number+expr.charAt(context.index)+")",context.index)}else if(chCode===PERIOD_CODE){_throwError("Unexpected period",context.index)}return{type:LITERAL,value:parseFloat(number),raw:number}}function _gobbleStringLiteral(context){var expr=context.expr;var str="",quote=expr.charAt(context.index++),closed=false,ch;var length=expr.length;while(context.index<length){ch=expr.charAt(context.index++);if(ch===quote){closed=true;break}else if(ch==="\\"){ch=expr.charAt(context.index++);switch(ch){case"n":str+="\n";break;case"r":str+="\r";break;case"t":str+="\t";break;case"b":str+="\b";break;case"f":str+="\f";break;case"v":str+="\x0B";break;default:str+=ch}}else{str+=ch}}if(!closed){_throwError("Unclosed quote after \""+str+"\"",context.index)}return{type:LITERAL,value:str,raw:quote+str+quote}}function _gobbleIdentifier(context,bMemberExpr){var expr=context.expr;var ch=expr.charCodeAt(context.index),start=context.index,identifier;if(_isIdentifierStart(ch)){context.index++}else{_throwError("Unexpected "+expr.charAt(context.index),context.index)}var length=expr.length;while(context.index<length){ch=expr.charCodeAt(context.index);if(_isIdentifierPart(ch)){context.index++}else{break}}identifier=expr.slice(start,context.index);if(identifier==="new"&&!bMemberExpr){_gobbleSpaces(context);var constructorNode=_gobbleVariable(context,CALL_EXP);if(constructorNode.type!==CALL_EXP){_throwError("Expression of type: "+constructorNode.type+" not supported for constructor expression")}return{type:NEW_EXP,callee:constructorNode.callee,arguments:constructorNode.arguments}}if(_literals.has(identifier)){return{type:LITERAL,value:_literals.get(identifier),raw:identifier}}return{type:IDENTIFIER,name:identifier}}function _gobbleArguments(context,termination,identifiersOnly){var expr=context.expr;var length=expr.length;var ch_i,args=[],node,closed=false;var separator_count=0;while(context.index<length){_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(ch_i===termination){closed=true;context.index++;if(termination===CPAREN_CODE&&separator_count&&separator_count>=args.length){_throwError("Unexpected token "+String.fromCharCode(termination),context.index)}break}else if(ch_i===COMMA_CODE){context.index++;separator_count++;if(separator_count!==args.length){if(termination===CPAREN_CODE){_throwError("Unexpected token ,",context.index)}else if(termination===CBRACK_CODE){for(var arg=args.length;arg<separator_count;arg++){args.push(null)}}}}else{if(identifiersOnly){node=_gobbleIdentifier(context)}else{node=_gobbleExpression(context)}if(!node||args.length>separator_count){_throwError("Expected comma",context.index)}args.push(node)}}if(!closed){_throwError("Expected "+String.fromCharCode(termination),context.index)}return args}function _gobbleVariable(context,stopAtType){var expr=context.expr;var ch_i,node;ch_i=expr.charCodeAt(context.index);if(ch_i===OPAREN_CODE){node=_gobbleGroup(context)}else if(ch_i===SQUOTE_CODE||ch_i===DQUOTE_CODE){node=_gobbleStringLiteral(context)}else if(ch_i===OBRACK_CODE){node=_gobbleArray(context)}else{node=_gobbleIdentifier(context)}_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);while(ch_i===PERIOD_CODE||ch_i===OBRACK_CODE||ch_i===OPAREN_CODE||_isOptionalChaining(context)){context.index++;if(ch_i===PERIOD_CODE){_gobbleSpaces(context);node={type:MEMBER_EXP,computed:false,object:node,property:_gobbleIdentifier(context,true)}}else if(ch_i===QUMARK_CODE){context.index++;_gobbleSpaces(context);node={type:MEMBER_EXP,computed:false,optional:true,object:node,property:_gobbleIdentifier(context,true)}}else if(ch_i===OBRACK_CODE){node={type:MEMBER_EXP,computed:true,object:node,property:_gobbleExpression(context)};_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(ch_i!==CBRACK_CODE){_throwError("Unclosed [",context.index)}context.index++}else if(ch_i===OPAREN_CODE){node={type:CALL_EXP,arguments:_gobbleArguments(context,CPAREN_CODE),callee:node}}if(stopAtType===node.type){return node}_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index)}return node}function _gobbleGroup(context){context.index++;var node=_gobbleExpression(context);_gobbleSpaces(context);if(context.expr.charCodeAt(context.index)===CPAREN_CODE){context.index++;return node}_throwError("Unclosed (",context.index)}function _gobbleArray(context){context.index++;return{type:ARRAY_EXP,elements:_gobbleArguments(context,CBRACK_CODE)}}function _gobbleFunction(context){var expr=context.expr;_gobbleSpaces(context);var ch_i=expr.charCodeAt(context.index);if(ch_i!==OPAREN_CODE){_throwError("Expected (,",context.index)}context.index++;var args=_gobbleArguments(context,CPAREN_CODE,true);_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(ch_i!==OBRACE_CODE){_throwError("Expected {,",context.index)}context.index++;_gobbleSpaces(context);var startDef=context.index;var hasReturn;var start=context.index;if(expr.substring(start,start+6)==="return"){hasReturn=true;context.index+=6}_gobbleSpaces(context);var body=_gobbleExpression(context);_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(ch_i===SEMCOL_CODE){context.index++;_gobbleSpaces(context)}ch_i=expr.charCodeAt(context.index);if(ch_i!==CBRACE_CODE){_throwError("Expected },",context.index)}context.index++;return{type:FUNCTION_EXP,arguments:args,body:body,expr:expr.substring(startDef,context.index-1),return:hasReturn}}function _gobbleObjectLiteral(context){var expr=context.expr;context.index++;var props=[];var closed;var separator_count=0;var length=expr.length;while(context.index<length&&!closed){_gobbleSpaces(context);var ch_i=expr.charCodeAt(context.index);if(ch_i===CBRACE_CODE){closed=true;context.index++}else if(ch_i===COMMA_CODE){context.index++;separator_count++;if(separator_count!==props.length){_throwError("Unexpected token ,",context.index)}}else{var key=ch_i===SQUOTE_CODE||ch_i===DQUOTE_CODE?_gobbleStringLiteral(context):_gobbleIdentifier(context);_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(key.type===IDENTIFIER&&(ch_i===COMMA_CODE||ch_i===CBRACE_CODE)){props.push({type:PROPERTY,key:key,value:key,shorthand:true})}else if(ch_i===COLON_CODE){context.index++;var writer=context.writer;var keyValue=getKeyValue(key);if(keyValue==="_ko_property_writers"){context.writer=1}try{props.push({type:PROPERTY,key:key,value:_gobbleExpression(context),shorthand:false})}finally{context.writer=writer}}else{_throwError("Expected ':'. Found "+String.fromCharCode(ch_i),context.index)}}}if(!closed){_throwError("Expected "+String.fromCharCode(CBRACE_CODE),context.index)}return{type:OBJECT_EXP,properties:props}}function _gobbleTemplateLiteral(context){const expr=context.expr;let ch_i=expr.charCodeAt(context.index);if(ch_i===BTICK_CODE){const node={type:TEMPLATE_LITERAL,quasis:[],expressions:[]};let cooked="";let raw="";let closed=false;const length=expr.length;const pushQuasi=()=>node.quasis.push({type:TEMPLATE_ELEMENT,value:{raw,cooked},tail:closed});while(context.index<length){let ch=expr.charAt(++context.index);if(ch==="`"){context.index+=1;closed=true;pushQuasi();return node}else if(ch==="$"&&expr.charAt(context.index+1)==="{"){context.index+=2;pushQuasi();raw="";cooked="";try{node.expressions.push(..._gobbleExpressions(context,CBRACE_CODE))}finally{ch_i=expr.charCodeAt(context.index);if(ch_i!==CBRACE_CODE){_throwError("Unclosed ${ in template literal",expr)}}}else if(ch==="\\"){raw+=ch;ch=expr.charAt(++context.index);raw+=ch;switch(ch){case"n":cooked+="\n";break;case"r":cooked+="\r";break;case"t":cooked+="\t";break;case"b":cooked+="\b";break;case"f":cooked+="\f";break;case"v":cooked+="\x0B";break;default:cooked+=ch}}else{cooked+=ch;raw+=ch}}if(context.index===length){_throwError("Unclosed backtick ` in template literal",expr)}}return false}var PERIOD_CODE=46,COMMA_CODE=44,SQUOTE_CODE=39,DQUOTE_CODE=34,OPAREN_CODE=40,CPAREN_CODE=41,OBRACK_CODE=91,CBRACK_CODE=93,QUMARK_CODE=63,SEMCOL_CODE=59,COLON_CODE=58,BTICK_CODE=96,OBRACE_CODE=123,CBRACE_CODE=125;function _getMaxKeyLen(obj){return Object.keys(obj).reduce(function(curr,key){return Math.max(curr,key.length)},0)}var t=true,_unary_ops={"-":t,"!":t,"~":t,"+":t,typeof:t},_binary_ops={"=":1,"||":2,"??":2,"&&":3,"|":4,"^":5,"&":6,"==":7,"!=":7,"===":7,"!==":7,"<":8,">":8,"<=":8,">=":8,instanceof:8,"<<":9,">>":9,">>>":9,"+":10,"-":10,"*":11,"/":11,"%":11,"**":12},_max_unop_len=_getMaxKeyLen(_unary_ops),_max_binop_len=_getMaxKeyLen(_binary_ops);var _literals=new Map;_literals.set("true",true);_literals.set("false",false);_literals.set("null",null);_literals.set("undefined",undefined);function _binaryPrecedence(op_val,prev_op_val,prev_op_prec){const basePrec=_binary_ops[op_val]||0;if(basePrec!==12||prev_op_val===undefined||op_val!==prev_op_val){return basePrec}return(prev_op_prec+13)*0.5}function _createBinaryExpression(operator,left,right,context){if(operator==="="&&!context.writer){_throwError("Unexpected operator '='",context.index)}var type=operator==="||"||operator==="&&"||operator==="??"?LOGICAL_EXP:BINARY_EXP;return{type:type,operator:operator,left:left,right:right}}function _isOptionalChaining(context){var expr=context.expr;if(expr.charCodeAt(context.index)===QUMARK_CODE&&expr.charCodeAt(context.index+1)===PERIOD_CODE&&!_isDecimalDigit(expr.charCodeAt(context.index+2))){return true}return false}function _isDecimalDigit(ch){return ch>=48&&ch<=57}function _isIdentifierStart(ch){return ch===36||ch===95||ch>=65&&ch<=90||ch>=97&&ch<=122||ch>=128&&!_binary_ops[String.fromCharCode(ch)]}function _isIdentifierPart(ch){return ch===36||ch===95||ch>=65&&ch<=90||ch>=97&&ch<=122||ch>=48&&ch<=57||ch>=128&&!_binary_ops[String.fromCharCode(ch)]}function _throwError(message,index){var error=new Error(message+" at character "+index);error.index=index;error.description=message;throw error}};const getKeyValue=function(keyObj){return keyObj.type===IDENTIFIER?keyObj.name:keyObj.value};module.exports=ExpParser;const COMPOUND="Compound";const IDENTIFIER="Identifier";const MEMBER_EXP="MemberExpression";const LITERAL="Literal";const CALL_EXP="CallExpression";const UNARY_EXP="UnaryExpression";const BINARY_EXP="BinaryExpression";const LOGICAL_EXP="LogicalExpression";const CONDITIONAL_EXP="ConditionalExpression";const ARRAY_EXP="ArrayExpression";const OBJECT_EXP="ObjectExpression";const FUNCTION_EXP="FunctionExpression";const NEW_EXP="NewExpression";const PROPERTY="Property";const TEMPLATE_LITERAL="TemplateLiteral";const TEMPLATE_ELEMENT="TemplateElement";