@oracle/oraclejet-audit 12.1.0 → 13.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.
- package/jaf-amd.js +2 -20
- package/jaf.js +1 -1
- package/jafapi.js +1 -1
- package/lib/AstJson.js +1 -1
- package/lib/AstMd.js +1 -1
- package/lib/Cli.js +6 -0
- package/lib/Color.js +6 -0
- package/lib/Comments.js +1 -1
- package/lib/ComponentSvcs.js +1 -1
- package/lib/Components.js +1 -1
- package/lib/Config.js +1 -1
- package/lib/ConfigLib.js +1 -1
- package/lib/CssUtils.js +1 -1
- package/lib/FileSet.js +1 -1
- package/lib/FsUtils.js +1 -1
- package/lib/Issue.js +1 -1
- package/lib/JafEvents.js +1 -1
- package/lib/JafLib.js +1 -1
- package/lib/Json.js +1 -1
- package/lib/JsonLoader.js +1 -1
- package/lib/Md.js +1 -1
- package/lib/MetaLib.js +1 -1
- package/lib/OjCPack.js +6 -0
- package/lib/OjetLib.js +6 -0
- package/lib/Registry.js +1 -1
- package/lib/RuleSet.js +1 -1
- package/lib/Rules.js +1 -1
- package/lib/Scope.js +1 -1
- package/lib/Utils.js +1 -1
- package/lib/ZipUtils.js +1 -1
- package/lib/amdlist.js +6 -0
- package/lib/api.js +1 -1
- package/lib/betalist.js +6 -0
- package/lib/builtinpacks.js +1 -1
- package/lib/checkage.js +6 -0
- package/lib/cliStats.js +1 -1
- package/lib/cmdline.js +1 -1
- package/lib/defaults.js +1 -1
- package/lib/deflist.js +1 -1
- package/lib/dislist.js +1 -1
- package/lib/exportRules.js +1 -1
- package/lib/extends.js +1 -1
- package/lib/grouplist.js +1 -1
- package/lib/groups.js +1 -1
- package/lib/help.js +1 -1
- package/lib/jetver.js +1 -1
- package/lib/manpage.js +6 -0
- package/lib/manual.js +1 -1
- package/lib/metaLoader.js +1 -1
- package/lib/metahist.js +1 -1
- package/lib/msgidLoader.js +1 -1
- package/lib/ns.js +1 -1
- package/lib/outfile.js +1 -1
- package/lib/proflist.js +6 -0
- package/lib/rlolist.js +6 -0
- package/lib/scaffold.js +1 -1
- package/lib/scaffoldRule.js +1 -1
- package/lib/schema.js +1 -1
- package/meta/13.0.0/jetauditmeta.js +9 -0
- package/meta/metaverlist.json +1 -1
- package/package.json +6 -4
- package/profiles/best-practice.json +146 -0
- package/profiles/redwood-strict.json +31 -0
- package/rulepacks/jetwc/jetwc-bootstrap.js +1 -1
- package/rulepacks/jetwc/jetwc-css-oj-complete.js +1 -1
- package/rulepacks/jetwc/jetwc-pack-children.js +1 -1
- package/rulepacks/jetwc/jetwc-schema.js +1 -1
- package/rulepacks/jetwc/jetwc-supproperty-propagation.js +6 -0
- package/rulepacks/jetwc/msgid.json +1 -1
- package/rulepacks/jetwc/rules.json +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-componentFinder.js +1 -1
- package/rulepacks/jetwco/jetwco-bootstrap.js +1 -1
- package/rulepacks/jetwco/jetwco-component-api-controlled-changes.js +1 -1
- package/rulepacks/jetwco/rules.json +1 -1
- package/rules/jaf/jaf-sys-age.js +6 -0
- package/rules/jaf/msgid.json +1 -1
- package/rules/jaf/rules.json +1 -1
- package/rules/jet/helpers/extractStylesFromClass.js +1 -1
- package/rules/jet/msgid.json +1 -1
- package/rules/jet/oj-acc-aria-ojselector-labelledby.js +6 -0
- package/rules/jet/oj-acc-aria-prop.js +1 -1
- package/rules/jet/oj-c-acc-avatar-aria-role.js +6 -0
- package/rules/jet/oj-cca-compjson-bp-jetver.js +1 -1
- package/rules/jet/oj-css-var-override.js +1 -1
- package/rules/jet/oj-html-alta-deprecated.js +1 -1
- package/rules/jet/oj-html-attr-2def.js +1 -1
- package/rules/jet/oj-html-attr-req.js +1 -1
- package/rules/jet/oj-html-cca-tagname.js +1 -1
- package/rules/jet/oj-html-cdn.js +1 -1
- package/rules/jet/oj-html-combo-converter.js +1 -1
- package/rules/jet/oj-html-file-pick-accept.js +1 -1
- package/rules/jet/oj-html-notag-style.js +1 -1
- package/rules/jet/oj-html-ojattr-deprecated.js +1 -1
- package/rules/jet/oj-html-ojattr-enum-deprecated.js +1 -1
- package/rules/jet/oj-html-ojattr-evt-syntax.js +1 -1
- package/rules/jet/oj-html-ojattr-value.js +1 -1
- package/rules/jet/oj-html-ojattr.js +1 -1
- package/rules/jet/oj-html-ojtag-deprecated.js +1 -1
- package/rules/jet/oj-html-pageopts-type.js +6 -0
- package/rules/jet/oj-html-rating-gauge-size.js +6 -0
- package/rules/jet/oj-html-redwood-bp-endslot.js +6 -0
- package/rules/jet/oj-html-slot-deprecated.js +6 -0
- package/rules/jet/oj-html-slot-pref-content.js +1 -1
- package/rules/jet/oj-html-wctag-maintenance.js +6 -0
- package/rules/jet/rules.json +1 -1
- package/schema/component-schema.json +1 -1482
- package/src/JafCore.js +1 -1
- package/types/index.d.ts +26 -8
- package/lib/colors.js +0 -6
package/lib/CssUtils.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 NAMED_COLORS={"transparent":true,"black":true,"silver":true,"gray":true,"white":true,"maroon":true,"red":true,"purple":true,"fuchsia":true,"green":true,"lime":true,"olive":true,"yellow":true,"navy":true,"blue":true,"teal":true,"aqua":true,"orange":true,"aliceblue":true,"antiquewhite":true,"aquamarine":true,"azure":true,"beige":true,"bisque":true,"blanchedalmond":true,"blueviolet":true,"brown":true,"burlywood":true,"cadetblue":true,"chartreuse":true,"chocolate":true,"coral":true,"cornflowerblue":true,"cornsilk":true,"crimson":true,"cyan":true,"darkblue":true,"darkcyan":true,"darkgoldenrod":true,"darkgray":true,"darkgreen":true,"darkgrey":true,"darkkhaki":true,"darkmagenta":true,"darkolivegreen":true,"darkorange":true,"darkorchid":true,"darkred":true,"darksalmon":true,"darkseagreen":true,"darkslateblue":true,"darkslategray":true,"darkslategrey":true,"darkturquoise":true,"darkviolet":true,"deeppink":true,"deepskyblue":true,"dimgray":true,"dimgrey":true,"dodgerblue":true,"firebrick":true,"floralwhite":true,"forestgreen":true,"gainsboro":true,"ghostwhite":true,"gold":true,"goldenrod":true,"greenyellow":true,"grey":true,"honeydew":true,"hotpink":true,"indianred":true,"indigo":true,"ivory":true,"khaki":true,"lavender":true,"lavenderblush":true,"lawngreen":true,"lemonchiffon":true,"lightblue":true,"lightcoral":true,"lightcyan":true,"lightgoldenrodyellow":true,"lightgray":true,"lightgreen":true,"lightgrey":true,"lightpink":true,"lightsalmon":true,"lightseagreen":true,"lightskyblue":true,"lightslategray":true,"lightslategrey":true,"lightsteelblue":true,"lightyellow":true,"limegreen":true,"linen":true,"magenta":true,"mediumaquamarine":true,"mediumblue":true,"mediumorchid":true,"mediumpurple":true,"mediumseagreen":true,"mediumslateblue":true,"mediumspringgreen":true,"mediumturquoise":true,"mediumvioletred":true,"midnightblue":true,"mintcream":true,"mistyrose":true,"moccasin":true,"navajowhite":true,"oldlace":true,"olivedrab":true,"orangered":true,"orchid":true,"palegoldenrod":true,"palegreen":true,"paleturquoise":true,"palevioletred":true,"papayawhip":true,"peachpuff":true,"peru":true,"pink":true,"plum":true,"powderblue":true,"rosybrown":true,"royalblue":true,"saddlebrown":true,"salmon":true,"sandybrown":true,"seagreen":true,"seashell":true,"sienna":true,"skyblue":true,"slateblue":true,"slategray":true,"slategrey":true,"snow":true,"springgreen":true,"steelblue":true,"tan":true,"thistle":true,"tomato":true,"turquoise":true,"violet":true,"wheat":true,"whitesmoke":true,"yellowgreen":true,"rebeccapurple":true};const MARKER_STYLES={"oj-visited":true,"oj-disabled":true,"oj-enabled":true,"oj-read-only":true,"oj-invalid":true,"oj-warning":true,"oj-info":true,"oj-confirmation":true,"oj-required":true,"oj-indeterminate":true,"oj-active":true,"oj-selected":true,"oj-hover":true,"oj-focus":true,"oj-focus-only":true,"oj-focus-highlight":true,"oj-default":true,"oj-draggable":true,"oj-drag":true,"oj-drop":true,"oj-active-drop":true,"oj-valid-drop":true,"oj-invalid-drop":true,"oj-expanded":true,"oj-collapsed":true,"oj-right":true,"oj-center":true,"oj-left":true,"oj-start":true,"oj-end":true,"oj-top":true,"oj-middle":true,"oj-bottom":true,"oj-full-width":true,"oj-hicontrast":true,"oj-component":true,"oj-component-initnode":true,"oj-complete":true,"oj-animate-open":true,"oj-animate-open-active":true,"oj-animate-close":true,"oj-animate-close-active":true,"oj-animate-add":true,"oj-animate-add-active":true,"oj-animate-remove":true,"oj-animate-remove-active":true,"oj-animate-update":true,"oj-animate-update-active":true};function isColorName(s){return!!NAMED_COLORS[s.toLowerCase()]};function isMarkerStyle(style){return!!MARKER_STYLES[style]};function getPosition(ruleCtx,loc){var pos={};var start=loc.start;pos.line=start.line;pos.col=start.column;pos.startIndex=start.offset;pos.endIndex=loc.end.offset;pos.line+=ruleCtx.offset.row-1;pos.startIndex+=ruleCtx.offset.index;pos.endIndex+=ruleCtx.offset.index;return pos};module.exports={isColorName,isMarkerStyle,getPosition};
|
|
6
|
+
var HtmlUtils=require("./HtmlUtils");const NAMED_COLORS={"transparent":true,"black":true,"silver":true,"gray":true,"white":true,"maroon":true,"red":true,"purple":true,"fuchsia":true,"green":true,"lime":true,"olive":true,"yellow":true,"navy":true,"blue":true,"teal":true,"aqua":true,"orange":true,"aliceblue":true,"antiquewhite":true,"aquamarine":true,"azure":true,"beige":true,"bisque":true,"blanchedalmond":true,"blueviolet":true,"brown":true,"burlywood":true,"cadetblue":true,"chartreuse":true,"chocolate":true,"coral":true,"cornflowerblue":true,"cornsilk":true,"crimson":true,"cyan":true,"darkblue":true,"darkcyan":true,"darkgoldenrod":true,"darkgray":true,"darkgreen":true,"darkgrey":true,"darkkhaki":true,"darkmagenta":true,"darkolivegreen":true,"darkorange":true,"darkorchid":true,"darkred":true,"darksalmon":true,"darkseagreen":true,"darkslateblue":true,"darkslategray":true,"darkslategrey":true,"darkturquoise":true,"darkviolet":true,"deeppink":true,"deepskyblue":true,"dimgray":true,"dimgrey":true,"dodgerblue":true,"firebrick":true,"floralwhite":true,"forestgreen":true,"gainsboro":true,"ghostwhite":true,"gold":true,"goldenrod":true,"greenyellow":true,"grey":true,"honeydew":true,"hotpink":true,"indianred":true,"indigo":true,"ivory":true,"khaki":true,"lavender":true,"lavenderblush":true,"lawngreen":true,"lemonchiffon":true,"lightblue":true,"lightcoral":true,"lightcyan":true,"lightgoldenrodyellow":true,"lightgray":true,"lightgreen":true,"lightgrey":true,"lightpink":true,"lightsalmon":true,"lightseagreen":true,"lightskyblue":true,"lightslategray":true,"lightslategrey":true,"lightsteelblue":true,"lightyellow":true,"limegreen":true,"linen":true,"magenta":true,"mediumaquamarine":true,"mediumblue":true,"mediumorchid":true,"mediumpurple":true,"mediumseagreen":true,"mediumslateblue":true,"mediumspringgreen":true,"mediumturquoise":true,"mediumvioletred":true,"midnightblue":true,"mintcream":true,"mistyrose":true,"moccasin":true,"navajowhite":true,"oldlace":true,"olivedrab":true,"orangered":true,"orchid":true,"palegoldenrod":true,"palegreen":true,"paleturquoise":true,"palevioletred":true,"papayawhip":true,"peachpuff":true,"peru":true,"pink":true,"plum":true,"powderblue":true,"rosybrown":true,"royalblue":true,"saddlebrown":true,"salmon":true,"sandybrown":true,"seagreen":true,"seashell":true,"sienna":true,"skyblue":true,"slateblue":true,"slategray":true,"slategrey":true,"snow":true,"springgreen":true,"steelblue":true,"tan":true,"thistle":true,"tomato":true,"turquoise":true,"violet":true,"wheat":true,"whitesmoke":true,"yellowgreen":true,"rebeccapurple":true};const MARKER_STYLES={"oj-visited":true,"oj-disabled":true,"oj-enabled":true,"oj-read-only":true,"oj-invalid":true,"oj-warning":true,"oj-info":true,"oj-confirmation":true,"oj-required":true,"oj-indeterminate":true,"oj-active":true,"oj-selected":true,"oj-hover":true,"oj-focus":true,"oj-focus-only":true,"oj-focus-highlight":true,"oj-default":true,"oj-draggable":true,"oj-drag":true,"oj-drop":true,"oj-active-drop":true,"oj-valid-drop":true,"oj-invalid-drop":true,"oj-expanded":true,"oj-collapsed":true,"oj-right":true,"oj-center":true,"oj-left":true,"oj-start":true,"oj-end":true,"oj-top":true,"oj-middle":true,"oj-bottom":true,"oj-full-width":true,"oj-hicontrast":true,"oj-component":true,"oj-component-initnode":true,"oj-complete":true,"oj-animate-open":true,"oj-animate-open-active":true,"oj-animate-close":true,"oj-animate-close-active":true,"oj-animate-add":true,"oj-animate-add-active":true,"oj-animate-remove":true,"oj-animate-remove-active":true,"oj-animate-update":true,"oj-animate-update-active":true};function isColorName(s){return!!NAMED_COLORS[s.toLowerCase()]};function isMarkerStyle(style){return!!MARKER_STYLES[style]};function getPosition(ruleCtx,loc){var pos={};var start=loc.start;pos.line=start.line;pos.col=start.column;pos.startIndex=start.offset;pos.endIndex=loc.end.offset;pos.line+=ruleCtx.offset.row-1;pos.startIndex+=ruleCtx.offset.index;pos.endIndex+=ruleCtx.offset.index;return pos};function isCommonElem(tag){return HtmlUtils.isCommonElem(tag)}module.exports={isColorName,isMarkerStyle,getPosition,isCommonElem};
|
package/lib/FileSet.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 FileSet(nd){this._contentStack=null;this._contentStackIndex=-1;this._srcStack=null;this._srcStackIndex=-1;this._globOpts=null;this._fileErrorCount=0;this._info=null;this._nd=nd};FileSet.prototype.setFiles=function(files,excludes,msgCtx){this._srcStack=files;this._globOpts=addGlobIgnoreOpts(this._globOpts,excludes);this._contentStack=null;this._contentStackIndex=-1;this._srcStackIndex=-1;this._fileErrorCount=0;if(msgCtx){this._info=msgCtx.info}};FileSet.prototype.getFiles=function(){if(this._srcStack){return{files:this._srcStack,exclude:this._globOpts.ignore}}};FileSet.prototype.getFileErrorCount=function(){return this._fileErrorCount};FileSet.prototype.getNextFile=function(){var path,ft,files,i;if(this._contentStack){for(i=this._contentStackIndex+1;i<this._contentStack.length;i++){path=this._contentStack[i];if(!path){continue}this._contentStackIndex=i;ft=this.
|
|
6
|
+
function FileSet(nd,fsUtils){this._contentStack=null;this._contentStackIndex=-1;this._srcStack=null;this._srcStackIndex=-1;this._globOpts=null;this._fileErrorCount=0;this._info=null;this._nd=nd;this._fsUtils=fsUtils};FileSet.prototype.setFiles=function(files,excludes,msgCtx){this._srcStack=files;this._globOpts=addGlobIgnoreOpts(this._globOpts,excludes);this._contentStack=null;this._contentStackIndex=-1;this._srcStackIndex=-1;this._fileErrorCount=0;if(msgCtx){this._info=msgCtx.info}};FileSet.prototype.getFiles=function(){if(this._srcStack){return{files:this._srcStack,exclude:this._globOpts.ignore}}};FileSet.prototype.getFileErrorCount=function(){return this._fileErrorCount};FileSet.prototype.getNextFile=function(){var path,ft,files,i;if(this._contentStack){for(i=this._contentStackIndex+1;i<this._contentStack.length;i++){path=this._contentStack[i];if(!path){continue}this._contentStackIndex=i;ft=this._fsUtils.getFileType(path);if(ft==='f'){if(i+1>=this._contentStack.length){this._contentStack=null;this._contentStackIndex=-1}return path}else if(ft==='?'){this._info('** File \''+path+'\' : ignored');this._fileErrorCount++}}}for(i=this._srcStackIndex+1;i<this._srcStack.length;i++){path=this._srcStack[i];this._srcStackIndex++;if(typeof path==='object'){return path}if(!path.startsWith('http')){if(this._globOpts){files=this._nd.glob.sync(path,this._globOpts)}else{files=this._nd.glob.sync(path)}if(this._removeDirs(files)){this._contentStack=files;this._contentStackIndex=-1;return this.getNextFile()}}else{return path}}return null};function addGlobIgnoreOpts(opts,excludes){if(!excludes||excludes.length===0){return opts}if(!opts){opts={}}opts.ignore=excludes;return opts};FileSet.prototype._removeDirs=function(ar){var i,ft,count=0;for(i=0;i<ar.length;i++){ft=this._fsUtils.getFileTypeWithMsg(ar[i]);if(ft==='d'){ar[i]=null;continue}count++}return count};module.exports=FileSet;
|
package/lib/FsUtils.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
|
-
|
|
6
|
+
const tmpFile=require('tmp');function FSU(nd,utils){this._nd=nd;this._utils=utils};FSU.prototype.getFileType=function(path){var stats,ret;try{stats=this._nd.fs.statSync(path);if(stats.isFile()){ret='f'}else if(stats.isDirectory()){ret='d'}}catch(e){ret=e}return ret};FSU.prototype.getFileTypeSync=function(path){return this.getFileType(path)};FSU.prototype.getFileTypeWithMsg=function(path){var ret;ret=this.getFileType(path);if(ret!=='f'&&ret!=='d'){if(ret.message.startsWith('ENOENT:')){console.log('\n** File "'+path+'" not found')}else{console('\n** File "'+path+'" error.\n'+' '+ret.message+'.\n')}ret='?'}return ret};FSU.prototype.getFileTypeWithMsgSync=function(path){return this.getFileTypeWithMsg(path)};FSU.prototype.getFileExt=function(path){var s;try{if(!this.isSymLink(path)){s=this._nd.path.extname(path)}else{let p=this._nd.fs.readlinkSync(path);if(p){s=this._nd.path.extname(p)}}if(s&&s.charAt(0)==='.'){s=s.substring(1)}return s}catch(e){}return''};FSU.prototype.getFileExtSync=function(path){return this.getFileExt(path)};FSU.prototype.isSymLink=function(path){var stats;try{stats=this._nd.fs.lstatSync(path);return stats.isSymbolicLink()}catch(e){}return false};FSU.prototype.fileExists=function(filepath,dir){var stats,ret=false;try{stats=this._nd.fs.lstatSync(filepath);ret=dir?stats.isDirectory():stats.isFile()}catch(e){}return ret};FSU.prototype.fileExistsSync=function(filepath,dir){return this.fileExists(filepath,dir)};FSU.prototype.pathExistsSync=function(filepath){try{return this._nd.fs.existsSync(filepath)}catch(e){}return false};FSU.prototype.readDir=function(path){var ret=[];try{this._readDir(path,ret)}catch(e){ret=null}return ret};FSU.prototype.readDirSync=function(path){return this.readDir(path)};FSU.prototype._readDir=function(dir,ar){var files,file,filePath,stat,arDir,i;files=this._nd.fs.readdirSync(dir);for(i=0;i<files.length;i++){file=files[i];if(file[0]==='.'){continue}filePath=this._nd.path.join(dir,file);stat=this._nd.fs.statSync(filePath);if(stat.isFile()){ar.push({name:file,isFile:true})}else if(stat.isDirectory()){arDir=[];ar.push({name:file,isFile:false,files:arDir});this._readDir(filePath,arDir)}}};FSU.prototype.createFolder=function(dirPath,orig){var rc;dirPath=this._nd.path.resolve(dirPath);if(!orig){orig=dirPath}try{if(!this._nd.fs.statSync(dirPath).isDirectory()){return new Error(dirPath+' exists but is not a directory')}}catch(err){if(err.code==='ENOENT'){var np=this._nd.path.dirname(dirPath);if(np===dirPath){return new Error(orig+' cannot be created')}rc=this.createFolder(np,orig);if(typeof rc!=='boolean'){return rc}this._nd.fs.mkdirSync(dirPath);if(dirPath===orig){return true}}else{return err}}return true};FSU.prototype.createFolderSync=function(dirPath){return this.createFolder(dirPath)};FSU.prototype.deleteFolder=function(filepath,deleteTarget){if(this._nd.fs.existsSync(filepath)){this._nd.fs.readdirSync(filepath).forEach(function(file){var curPath=this._nd.path.join(filepath,file);if(this._nd.fs.lstatSync(curPath).isDirectory()){this.deleteFolder(curPath,true)}else{this._nd.fs.unlinkSync(curPath)}},this);if(deleteTarget){this._nd.fs.rmdirSync(filepath)}}};FSU.prototype.deleteFolderSync=function(filepath,deleteTarget){return this.deleteFolder(filepath,deleteTarget)};FSU.prototype.getUniqueFileNameSync=function(template,targetFolder){const opts={template:template};if(targetFolder){opts.dir=targetFolder}return tmpFile.tmpNameSync(opts)};FSU.prototype.getUniqueFileName=function(template,targetFolder){return this.getUniqueFileNameSync(template,targetFolder)};FSU.prototype.findFile=function(dir,name,fncb){var ret;try{ret=this._findFile(dir,name,fncb)}catch(e){}return ret};FSU.prototype._findFile=function(dir,name,fncb){var files,file,filePath,stat,ret,i;files=this._nd.fs.readdirSync(dir);for(i=0;i<files.length;i++){file=files[i];if(!fncb||fncb(dir,file)){if(file===name){return dir}}if(file[0]==='.'){continue}filePath=this._nd.path.join(dir,file);stat=this._nd.fs.statSync(filePath);if(stat.isDirectory()){ret=this._findFile(filePath,name,fncb);if(ret){return ret}}}return null};FSU.prototype.findFileSync=function(dir,name,fncb){return this.findFile(dir,name,fncb)};FSU.prototype.readFileSync=function(filePath,error){return this._readFileSync(filePath,false,error)};FSU.prototype.readFileBufSync=function(filePath,error){return this._readFileSync(filePath,true,error)};FSU.prototype._readFileSync=function(filePath,wantBuffer,error){var haveFn,doThrow,noThrow,t;t=typeof error;doThrow=t==='boolean'&&error;noThrow=t==='boolean'&&!error;haveFn=t==='function';try{return wantBuffer?this._nd.fs.readFileSync(filePath):this._nd.fs.readFileSync(filePath,'utf8')}catch(e){function _prepErr(){var s=e.message;if(s.startsWith('ENOENT')){s=`ENOENT: file not found - '${filePath}'`}return s}if(haveFn){error(_prepErr())}else if(doThrow){throw new Error(e)}else if(noThrow){return _prepErr()}}return null};FSU.prototype.readJsonSync=function(filepath,comments,error){var e,haveFn,doThrow,noThrow,t;t=typeof error;doThrow=t==='boolean'&&error;noThrow=t==='boolean'&&!error;haveFn=t==='function';var _fn=function(err){err='SYNTAX: '+err;e=err;if(haveFn){error(err)}};filepath=this.makeAbsolutePath(filepath);var o=this._nd.jsonLoader.load(filepath,this._nd,_fn,comments,this._utils);if(e){if(doThrow){throw new Error(e)}else if(noThrow){return e}return null}if(o){return o}let msg='NOFILE: '+filepath;if(doThrow){throw new Error(msg)}if(noThrow){return msg}if(haveFn){error(msg)}return null};FSU.prototype.writeJsonSync=function(obj,filepath,opts,error){var repl,ind,err;var doThrow,noThrow,haveFn,t;t=typeof error;doThrow=t==='boolean'&&error;noThrow=t==='boolean'&&!error;haveFn=t==='function';if(opts){repl=opts.replacer?opts.replacer:null;ind=opts.spaces}filepath=this.makeAbsolutePath(filepath);try{let s=JSON.stringify(obj,repl,ind);this._nd.fs.writeFileSync(filepath,s);return true}catch(e){if(doThrow){throw e}err=e}if(err){if(haveFn){error(err.message);return false}if(noThrow){return err.message}}return false};FSU.prototype.makeAbsolutePath=function(filepath){if(!this._nd.path.isAbsolute(filepath)){filepath=this._nd.path.resolve(process.cwd(),filepath)}return filepath};module.exports=FSU;
|
package/lib/Issue.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
|
-
var Issue=function(msg,id){this.msg=msg;if(id){this.setId(id)}};Issue.prototype.setMsg=function(msg){this.msg=msg;return this};Issue.prototype.setId=function(id){this.msgId=id||"0000";return this};Issue.prototype.setMsgKey=function(key){this.msgKey=key;return this};Issue.prototype.setPosition=function(arg,col,startIndex,endIndex){var line;if(arg&&typeof arg==="object"){if(arg.hasOwnProperty("startIndex")){startIndex=arg.startIndex}else if(arg.hasOwnProperty("start")){startIndex=arg.start}if(arg.hasOwnProperty("endIndex")){endIndex=arg.endIndex}else if(arg.hasOwnProperty("end")){endIndex=arg.end}if(arg.hasOwnProperty("line")){line=arg.line}else if(arg.hasOwnProperty("row")){line=arg.row}col=arg.col}else{line=arg}if(line!==null&&col!==null){this.index={line:line,col:col}}if(startIndex!==undefined){if(!this.index){this.index={}}this.index.start=startIndex;this.index.end=endIndex}return this};Issue.prototype.setSeverity=function(severity){if(severity){this.severity=severity}return this};Issue.prototype.setReportedFilePath=function(fp){this.filepath=fp};module.exports=Issue;
|
|
6
|
+
const EMPTY="";var Issue=function(msg,id){this.msg=msg!==undefined?msg:EMPTY;if(id){this.setId(id)}};Issue.prototype.setMsg=function(msg){this.msg=typeof msg==="string"?msg:EMPTY;return this};Issue.prototype.setId=function(id){this.msgId=id||"0000";return this};Issue.prototype.setMsgKey=function(key){this.msgKey=key;return this};Issue.prototype.setPosition=function(arg,col,startIndex,endIndex){var line;if(arg&&typeof arg==="object"){if(arg.hasOwnProperty("startIndex")){startIndex=arg.startIndex}else if(arg.hasOwnProperty("start")){startIndex=arg.start}if(arg.hasOwnProperty("endIndex")){endIndex=arg.endIndex}else if(arg.hasOwnProperty("end")){endIndex=arg.end}if(arg.hasOwnProperty("line")){line=arg.line}else if(arg.hasOwnProperty("row")){line=arg.row}col=arg.col}else{line=arg}if(line!==null&&col!==null){this.index={line:line,col:col}}if(startIndex!==undefined){if(!this.index){this.index={}}this.index.start=startIndex;this.index.end=endIndex}return this};Issue.prototype.setSeverity=function(severity){if(severity){this.severity=severity}return this};Issue.prototype.setReportedFilePath=function(fp){this.filepath=fp};module.exports=Issue;
|
package/lib/JafEvents.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 EVENT_ISSUE="on-jaf-issue";const EVENT_MESSAGE="on-jaf-message";const EVENT_SUMMARY="on-jaf-summary";const EVENTS=[EVENT_ISSUE,EVENT_MESSAGE,EVENT_SUMMARY];function JafEvents(){this._emitter=null;this._listeners=[];this.JAF_EVENT_ISSUE=EVENT_ISSUE;this.JAF_EVENT_MESSAGE=EVENT_MESSAGE;this.JAF_EVENT_SUMMARY=EVENT_SUMMARY};JafEvents.prototype.setListener=function(evName,fn,obj){if(EVENTS.includes(evName)){if(!this._emitter){var EventEmitter=require("events").EventEmitter;this._emitter=new EventEmitter}this._listeners.push({event:evName,fn:fn,obj:obj});this._emitter.on(evName,fn)}};JafEvents.prototype.emit=function(evName,obj){if(this._emitter)this._emitter.emit(evName,obj,this._getEventExtra(evName))};JafEvents.prototype.removeAllListeners=function(evName){if(this._emitter){if(evName){this._emitter.removeAllListeners(evName)
|
|
6
|
+
const EVENT_ISSUE="on-jaf-issue";const EVENT_MESSAGE="on-jaf-message";const EVENT_SUMMARY="on-jaf-summary";const EVENTS=[EVENT_ISSUE,EVENT_MESSAGE,EVENT_SUMMARY];function JafEvents(){this._emitter=null;this._listeners=[];this.JAF_EVENT_ISSUE=EVENT_ISSUE;this.JAF_EVENT_MESSAGE=EVENT_MESSAGE;this.JAF_EVENT_SUMMARY=EVENT_SUMMARY};JafEvents.prototype.setListener=function(evName,fn,obj){if(EVENTS.includes(evName)){if(!this._emitter){var EventEmitter=require("events").EventEmitter;this._emitter=new EventEmitter}this._listeners.push({event:evName,fn:fn,obj:obj});this._emitter.on(evName,fn)}};JafEvents.prototype.emit=function(evName,obj){if(this._emitter)this._emitter.emit(evName,obj,this._getEventExtra(evName))};JafEvents.prototype.removeAllListeners=function(evName){if(this._emitter){if(evName){this._emitter.removeAllListeners(evName);this._removeFromInternalList(evName)}else{this._emitter.removeAllListeners();this._listeners.length=0}}};JafEvents.prototype.removeListener=function(evName,fn){var a,i;if(!this._emitter){return}a=this._emitter.listeners(evName);for(i=0;i<a.length;i++){if(a[i]===fn){this._emitter.removeListener(evName,fn)}}this._removeFromInternalList(evName,fn)};JafEvents.prototype._removeFromInternalList=function(evName,fn){if(this._listeners){let listener,i;for(i=0;i<this._listeners.length;i++){listener=this._listeners[i];if(evName===listener.event){if(fn&&fn!==listener.fn){continue}this._listeners.splice(i,1);i--}}}};JafEvents.prototype._getEventExtra=function(evName){var listener,i,ret;for(i=0;i<this._listeners.length;i++){listener=this._listeners[i];if(evName===listener.event){ret=listener.obj;break}}return ret};module.exports=JafEvents;
|
package/lib/JafLib.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 CLI_MODE="cli";const API_MODE="api";const AMD_MODE="amd";function JafLib(nd,jfs,mctx,runMode,jafver,jv,cfg){this._rdy=-1;this.setup(nd,jfs,mctx,runMode,jafver,jv,cfg)};JafLib.prototype.getFileset=function(ruleCtx){if(this._nd&&ruleCtx.phase&&ruleCtx.phase==="startaudit"){return this._jfs.getFiles()}};JafLib.prototype.setFileset=function(ruleCtx,files,exclude){var rc=false;if(this._nd&&ruleCtx.phase&&ruleCtx.phase==="startaudit"){if(files&&!Array.isArray(files)||exclude&&!Array.isArray(exclude)){this._mCtx.error("Rule '"+ruleCtx.ruleName+"' attempt to call JafLib.setfiles() with non-array");this._jfs.setFiles(null,null);return false}this._jfs.setFiles(files,exclude);rc=true}return rc};JafLib.prototype.getRunMode=function(){return this._runMode};JafLib.prototype.getConfig=function(){return this._cfg};JafLib.prototype.getTsConfigObj=function(){return this._cfg.getTsConfigObj()};JafLib.prototype.isCLI=function(){return this._runMode===CLI_MODE};JafLib.prototype.isAPI=function(){return this._runMode===API_MODE};JafLib.prototype.isAMD=function(){return this._runMode===AMD_MODE};JafLib.prototype.getJetVer=function(){return this._jetver};JafLib.prototype.getJafVer=function(){return this._jafver};JafLib.prototype.setup=function(nd,jfs,mctx,runMode,jafver,jv,cfg){if(this._rdy===-1){this._nd=nd;this._jfs=jfs;this._mCtx=mctx;this._runMode=runMode;this._jafver=jafver;this._jetver=jv;this._cfg=cfg}};JafLib.prototype.disable=function(){this._rdy=-2};JafLib.prototype.getJafLib=function(){return{getConfig:this.getConfig.bind(this),getTsConfigObj:this.getTsConfigObj.bind(this),getRunMode:this.getRunMode.bind(this),isCLI:this.isCLI.bind(this),isAPI:this.isAPI.bind(this),isAMD:this.isAMD.bind(this),getJetVer:this.getJetVer.bind(this),getJafVer:this.getJafVer.bind(this)}};JafLib.prototype.getPublic=function(){return{setFileset:this.setFileset.bind(this),getFileset:this.getFileset.bind(this)}};module.exports=JafLib;
|
|
6
|
+
const CLI_MODE="cli";const API_MODE="api";const AMD_MODE="amd";function JafLib(nd,jfs,mctx,runMode,jafver,jv,cfg,ageLib){this._rdy=-1;this.setup(nd,jfs,mctx,runMode,jafver,jv,cfg,ageLib)};JafLib.prototype.getFileset=function(ruleCtx){if(this._nd&&ruleCtx.phase&&ruleCtx.phase==="startaudit"){return this._jfs.getFiles()}};JafLib.prototype.setFileset=function(ruleCtx,files,exclude){var rc=false;if(this._nd&&ruleCtx.phase&&ruleCtx.phase==="startaudit"){if(files&&!Array.isArray(files)||exclude&&!Array.isArray(exclude)){this._mCtx.error("Rule '"+ruleCtx.ruleName+"' attempt to call JafLib.setfiles() with non-array");this._jfs.setFiles(null,null);return false}this._jfs.setFiles(files,exclude);rc=true}return rc};JafLib.prototype.getRunMode=function(){return this._runMode};JafLib.prototype.getConfig=function(){return this._cfg};JafLib.prototype.getTsConfigObj=function(){return this._cfg.getTsConfigObj()};JafLib.prototype.isCLI=function(){return this._runMode===CLI_MODE};JafLib.prototype.isAPI=function(){return this._runMode===API_MODE};JafLib.prototype.isAMD=function(){return this._runMode===AMD_MODE};JafLib.prototype.getJetVer=function(){return this._jetver};JafLib.prototype.getJafVer=function(){return this._jafver};JafLib.prototype.getJetReleaseCount=function(){return this._ageLib.getJetReleaseCount()};JafLib.prototype.setup=function(nd,jfs,mctx,runMode,jafver,jv,cfg,ageLib){if(this._rdy===-1){this._nd=nd;this._jfs=jfs;this._mCtx=mctx;this._runMode=runMode;this._jafver=jafver;this._jetver=jv;this._cfg=cfg;this._ageLib=ageLib}};JafLib.prototype.disable=function(){this._rdy=-2};JafLib.prototype.getJafLib=function(){return{getConfig:this.getConfig.bind(this),getTsConfigObj:this.getTsConfigObj.bind(this),getRunMode:this.getRunMode.bind(this),isCLI:this.isCLI.bind(this),isAPI:this.isAPI.bind(this),isAMD:this.isAMD.bind(this),getJetVer:this.getJetVer.bind(this),getJafVer:this.getJafVer.bind(this),getJetReleaseCount:this.getJetReleaseCount.bind(this)}};JafLib.prototype.getPublic=function(){return{setFileset:this.setFileset.bind(this),getFileset:this.getFileset.bind(this)}};module.exports=JafLib;
|
package/lib/Json.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 AstJson=require("../lib/AstJson");const FILETYPE=require("./filetypes");class Json{constructor(parser,nd,rules,fileIndex,appCtx,msgCtx){this._parser=parser;this._rules=rules;this._Issue=appCtx.Issue;this._reporter=appCtx.reporter;this._fileIndex=fileIndex;this._utils=appCtx.utils;this._msgCtx=msgCtx;this._nd=nd;this._Ast=null;this._AstJson=new AstJson(msgCtx)}parse(data,file){var suppData,rc;suppData=this._checkSyntax(data,false);rc=this._parser.fireHookFileRules(suppData.ast,suppData,false);if(typeof rc==="undefined"||typeof rc==="boolean"&&rc){this._rules.fireRules({type:FILETYPE.JSON,obj:suppData,tagNode:null,rawData:this._rawData,data:
|
|
6
|
+
const AstJson=require("../lib/AstJson");const FILETYPE=require("./filetypes");class Json{constructor(parser,nd,rules,fileIndex,appCtx,msgCtx){this._parser=parser;this._rules=rules;this._Issue=appCtx.Issue;this._reporter=appCtx.reporter;this._fileIndex=fileIndex;this._utils=appCtx.utils;this._msgCtx=msgCtx;this._nd=nd;this._Ast=null;this._AstJson=new AstJson(msgCtx)}parse(data,file){var suppData,rc;suppData=this._checkSyntax(data,false);rc=this._parser.fireHookFileRules(suppData.ast,suppData,false);if(typeof rc==="undefined"||typeof rc==="boolean"&&rc){this._rules.fireRules({type:FILETYPE.JSON,obj:suppData,tagNode:null,node:suppData.ast,rawData:this._rawData,data:data,suppData:suppData},null,file,FILETYPE.JSON,suppData,false)}this._parser.fireHookFileRules(null,null)}parseOnly(data){return this._checkSyntax(data,false)}getAst(){return this._Ast}clear(){}_checkSyntax(data,hasComments){var suppData=this._isValidJson(data,hasComments);if(typeof suppData.msg==="string"){suppData.ast=null;this._parser.startIndex=this._parser.endIndex=suppData.position}else{suppData.ast=this._AstJson.parse(data);this._startIndex=this._endIndex=0}return suppData}_isValidJson(data,isComments){var obj=this._utils.parseJson(data,isComments);if(obj.msg){obj.msg=obj.msg+` at line ${obj.line}, col ${obj.col} (position ${obj.startIndex})`;obj.position=obj.startIndex}return obj}}module.exports=Json;
|
package/lib/JsonLoader.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 load(inFile,nd,fnError,allowComments,utils){var obj=null,json;try{if(nd.fs.existsSync(inFile)){json=nd.fs.readFileSync(inFile,'utf8');if(allowComments){json=nd.decomment(json)}obj=JSON.parse(nd.decomment(json))}else{if(fnError){fnError(`file not found "${inFile}"`)}}}catch(e){if(fnError){let msg=_convertJsonPosToRowCol(e.message,nd.fs.readFileSync(inFile,'utf8'),utils);fnError(msg
|
|
6
|
+
function load(inFile,nd,fnError,allowComments,utils){var obj=null,json;try{if(nd.fs.existsSync(inFile)){json=nd.fs.readFileSync(inFile,'utf8');if(allowComments){json=nd.decomment(json)}obj=JSON.parse(nd.decomment(json))}else{if(fnError){fnError(`file not found "${inFile}"`)}}}catch(e){if(fnError){let msg=_convertJsonPosToRowCol(e.message,nd.fs.readFileSync(inFile,'utf8'),utils);fnError(msg?`${msg} : ${inFile}`:`${e.message}`)}}return obj};function _convertJsonPosToRowCol(msg,data,utils){var x,y,n,rc;x=msg.indexOf('position');if(x<0){return null}y=msg.indexOf('token');if(y>=0){y+=6;msg=msg.substring(0,y)+'\''+msg.substring(y,y+1)+'\''+msg.substring(y+1)}x=msg.indexOf('position');n=parseInt(msg.substr(x+8).trim());rc=utils.getRowColFromIndex(data,n);return msg.substring(0,x)+'line '+rc.row+', col '+rc.col};module.exports.load=load;
|
package/lib/Md.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 AstMd=require("../lib/AstMd");const FILETYPE=require("./filetypes");class Md{constructor(parser,nd,rules,fileIndex,appCtx,msgCtx){this._parser=parser;this._rules=rules;this._Issue=appCtx.Issue;this._reporter=appCtx.reporter;this._utils=appCtx.utils;this._msgCtx=msgCtx;this._nd=nd;this._Ast=null;this._AstMd=new AstMd(appCtx)}parse(data,file){var suppData,rc;this._Ast=this._AstMd.parse(data,{});suppData={ast:this._Ast,utils:this._AstMd.createHandler()};rc=this._parser.fireHookFileRules(suppData.ast,suppData,false);if(typeof rc==="undefined"||typeof rc==="boolean"&&rc){this._fireMdEvents(suppData,file)}this._parser.fireHookFileRules(null,null)}getAst(){return this._Ast}clear(){this._Ast=null}_fireMdEvents(suppData,file){var data,prop,obj,val,utils=suppData.utils;data=utils.getLinks();data.forEach(link=>{this._fireEvent("md-link",link,suppData,file)});data=utils.getRefLinks();obj={};for(prop in data){val=data[prop];obj.refKey=prop;obj.link=val.link;obj.pos=val.pos;this._fireEvent("md-ref",obj,suppData,file)}data=utils.getParas();data.forEach(para=>{this._fireEvent("md-para",para,suppData,file)});data=utils.getImages();data.forEach(img=>{this._fireEvent("md-image",img,suppData,file)});data=utils.getLists();data.forEach(list=>{this._fireEvent("md-list",list,suppData,file)});data=utils.getCode();data.forEach(code=>{this._fireEvent("md-code",code,suppData,file)})}_fireEvent(type,arg1,suppData,file){this._rules.fireRules({type:type,obj:suppData,tagNode:null,rawData:this._rawData,data:this._data,suppData:suppData},arg1,file,FILETYPE.MD,suppData,false)}}module.exports=Md;
|
|
6
|
+
const AstMd=require("../lib/AstMd");const FILETYPE=require("./filetypes");class Md{constructor(parser,nd,rules,fileIndex,appCtx,msgCtx){this._parser=parser;this._rules=rules;this._Issue=appCtx.Issue;this._reporter=appCtx.reporter;this._utils=appCtx.utils;this._msgCtx=msgCtx;this._nd=nd;this._Ast=null;this._data=null;this._AstMd=new AstMd(appCtx)}parse(data,file){var suppData,rc;this._data=data;this._Ast=this._AstMd.parse(data,{});suppData={ast:this._Ast,utils:this._AstMd.createHandler()};rc=this._parser.fireHookFileRules(suppData.ast,suppData,false);if(typeof rc==="undefined"||typeof rc==="boolean"&&rc){this._fireMdEvents(suppData,file)}this._parser.fireHookFileRules(null,null)}getAst(){return this._Ast}clear(){this._Ast=null}_fireMdEvents(suppData,file){var data,prop,obj,val,utils=suppData.utils;data=utils.getLinks();data.forEach(link=>{this._fireEvent("md-link",link,suppData,file)});data=utils.getRefLinks();obj={};for(prop in data){val=data[prop];obj.refKey=prop;obj.link=val.link;obj.pos=val.pos;this._fireEvent("md-ref",obj,suppData,file)}data=utils.getParas();data.forEach(para=>{this._fireEvent("md-para",para,suppData,file)});data=utils.getImages();data.forEach(img=>{this._fireEvent("md-image",img,suppData,file)});data=utils.getLists();data.forEach(list=>{this._fireEvent("md-list",list,suppData,file)});data=utils.getCode();data.forEach(code=>{this._fireEvent("md-code",code,suppData,file)})}_fireEvent(type,arg1,suppData,file){this._rules.fireRules({type:type,obj:suppData,tagNode:null,rawData:this._rawData,data:this._data,suppData:suppData},arg1,file,FILETYPE.MD,suppData,false)}}module.exports=Md;
|
package/lib/MetaLib.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
|
-
"use strict";const Namespaces=require("./ns");const HtmlUtils=require("./HtmlUtils");const SemVer=require("semver");var nodeDeps;const NO_SUGGESTION_AVAIL="No suggestion available.";const OJPREFIX="oj-";const OJEVENTPREFIX="on-oj-";const OJS="ojs/oj";const EVENT_PREFIX="on-";const DOT=".";const DATA_OJ_CMD="data-oj-command";const PROP_SLOTS="slots";const PROP_PROPS="props";const PROP_EVENTS="events";const PROP_IMPLEMENTS="implements";const PROP_FOLDER="folder";const PROP_VERSION="version";const PROP_UNSUP_THEME="unsupTheme";const PROP_SUBCOMPONENT_TYPE="subcomponentType";const PACK_PRIVATE="packPrivate";const DEPRECATED="deprecated";function MetaLib(nd,runMode,msgCtx,utils){this._json=null;this._delHist=null;this._renHist=null;this._reqAttrs=null;this._nonClasses=null;this._implements=null;this._hasJetWCIFCs=false;this._components=null;this._compSvcs=null;this._stylesets=null;this._runMode=runMode;this._utils=utils;this._domUtils=null;if(nd.jetver){this._jetVersions=nd.jetver.getVersions()}this._jetVer=null;this._theme=null;this._deprecatedMethods=null;this._deprecatedMembers=null;this._deletedMethods=null;this._deletedMembers=null;this._error=msgCtx.error;this._debug=msgCtx.debug;this._info=msgCtx.info;this._msg=msgCtx.msg;this._console=msgCtx.console;this._isDebug=msgCtx.isdebug;this._isVerbose=msgCtx.isVerbose;nodeDeps=nd};MetaLib.prototype.isNSRegistered=function(prefix){return Namespaces.has(prefix)};MetaLib.prototype.isNamespacePrefix=function(tagName){return HtmlUtils.isNamespaceTag(tagName)};MetaLib.prototype.isJetTag=function(tagName){return!!this._getComponentNameFromTag(_removeChevrons(tagName))};MetaLib.prototype.isComponentTag=function(tagName){return this._components&&this._components.isTag(_removeChevrons(tagName))};MetaLib.prototype.isWCTag=function(tagName){return this.isJetTag(tagName)||this.isComponentTag(tagName)};MetaLib.prototype.isCCATag=function(tagName){return this.isWCTag(tagName)};MetaLib.prototype.isTagDeprecated=function(tagName){var clazz,ret;if(clazz=this._getComponentNameFromTag(_removeChevrons(tagName))){ret=this.isClassDeprecated(clazz)}else{ret=this._components.isTagDeprecated(tagName)}return ret};MetaLib.prototype.isTagAttrDeprecated=function(tagName,attrName){var member,ret=null;member=this._getTagAttrMemberObj(tagName,attrName);ret=member?this._isSubStateDeprecated(member,true):this._components.isTagAttrDeprecated(tagName,attrName);if(ret){ret.forEach(status=>{if(status.description){status.description=HtmlUtils.replaceEntities(status.description)}})}return ret};MetaLib.prototype.isTagEventDeprecated=function(tag,attr){var x1,x2;if((x1=attr.indexOf("-"))<0){return false}attr=attr.substring(x1+1);if((x2=attr.lastIndexOf("-"))>=0){attr=attr.substring(0,x2)}return this.isTagAttrDeprecated(tag,attr)};MetaLib.prototype.isTagAttr=function(tagName,attrName){var o,ret=false;attrName=attrName.charAt(0)===":"?attrName.substr(1):attrName;if(this.isCCATag(tagName)){o=this._getComponentFromTag(tagName);if(o){ret=this.isJetTagAttr(o,attrName)}else{ret=this._components&&this._components.isTagAttr(tagName,attrName)}}return ret};MetaLib.prototype.isJetTagAttr=function(tagObj,attrName){attrName=attrName.charAt(0)===":"?attrName.substr(1):attrName;var ret=!!(tagObj.htmlattributes&&tagObj.htmlattributes[attrName]);if(!ret&&attrName===DATA_OJ_CMD&&tagObj.member){ret=!!tagObj.member[DATA_OJ_CMD]}return ret};MetaLib.prototype._getTagAttrMemberObj=function(tagName,attrName){var obj,attrib,member,x;obj=this._getComponentFromTag(_removeChevrons(tagName));attrName=attrName.charAt(0)===":"?attrName.substring(1):attrName;if(!obj||!obj.htmlattributes||!obj.htmlattributes[attrName]){return null}member=null;attrib=obj.htmlattributes[attrName];if(attrib){x=attrib.indexOf(DOT);if(x>=0){if(obj.member){member=this._findSubMember(obj,obj.member,attrib,attrib)}}else{member=obj.member[attrib];if(member){return member}}}return member};MetaLib.prototype._findSubMember=function(obj,mem,attrName,subMemberPart){var member,ts,sm,rest,x,ret=null;x=subMemberPart.indexOf(DOT);if(x>=0){sm=subMemberPart.substring(0,x);rest=subMemberPart.substring(x+1)}else{sm=subMemberPart;rest=null}for(member in mem){member=mem[member];if(member.name===attrName&&!rest){ret=member;break}if(member.name!==sm){continue}if(!rest){ret=member;break}if(member.submember){ret=this._findSubMember(obj,member.submember,attrName,rest);if(ret){break}}else if(member.tstype){ts=this._getTsTypeObject(member);if(ts){ret=this._findSubMember(obj,ts.member,attrName,rest);if(ret){break}}}if(ret){break}}return ret};MetaLib.prototype._getTsTypeObject=function(mem){var ts,o,s,x;ts=mem.tstype;if(ts&&ts.target==="Type"&&typeof ts.value==="string"){s=ts.value;s=s.replace("=","");x=s.indexOf("|");if(x>=0){s=s.substring(0,x).trimRight()}if(s.charAt(s.length-1)===">"){x=s.lastIndexOf("<");if(s>=0){s=s.substring(0,x)}}o=this._json[s];if(!o){o=this._json[mem.memberof];if(o.typedef){s=ts.value;x=s.lastIndexOf(DOT);if(x>=0){s=s.substring(x+1);o=o.typedef[s]}}}}return o?o:null};MetaLib.prototype._getSubMemberPart=function(fullAttr,soFar){var s,x;s=fullAttr.replace(soFar,"");if(s.length){if(s.charAt(0)==="."){x=s.indexOf(DOT,1);if(x>=0){s=soFar+s.substring(0,x)}else{s=soFar+s}}}else{s=soFar}return s};MetaLib.prototype._handleAttrObject=function(member){var link,types,i,x;types=member.tstype;if(types){for(i=0;i<types.length;i++){if(types[i].target==="Type"){link=types[i].value;link=link.replace("=","");x=link.indexOf("<K");if(x>=0){link=link.substring(0,x)}break}}}return link};MetaLib.prototype.hasTagAttrValues=function(tagName,attrName){var member,ojv,ret=false;member=this._getTagAttrMemberObj(tagName,attrName);if(member){ojv=this._getOjValues(member);return!!ojv}else if(this._components.isTag(tagName)){ret=this._components.hasTagAttrValues(tagName,attrName)}return ret};MetaLib.prototype.isTagAttrValue=function(tagName,attrName,attrValue){var member,ojv,values,curValue,valType,i,ret=false;member=this._getTagAttrMemberObj(tagName,attrName);if(member){ojv=this._getOjValues(member);if(ojv){values=ojv.name;for(i=0;i<values.length;i++){if(ojv.type){valType=ojv.type[i];curValue=_convertValue(valType,attrValue);ret=curValue===values[i]}else{ret=attrValue===values[i]}if(ret){break}}}else{ret=true}}else{if(this._components.isTag(tagName)){ret=this._components.isTagAttrValue(tagName,attrName,attrValue)}}return ret};MetaLib.prototype.isTagAttrEnumValueDeprecated=function(tagName,attrName,enumValue){var member,ojv,values,deps,dep,i,j,ret=null;member=this._getTagAttrMemberObj(tagName,attrName);if(!member){return this._isCompTagAttrEnumDepr(tagName,attrName,enumValue)}if(!member.ojdeprecated){return null}if(ojv=this._getOjValues(member)){values=ojv.name;for(i=0;i<values.length;i++){if(values[i]===enumValue){deps=member.ojdeprecated;for(j=0;j<deps.length;j++){dep=deps[j];if(dep.target==="propertyValue"&&dep.for===enumValue){ret={type:DEPRECATED,since:dep.since,description:dep.description};break}}}if(ret){break}}}return ret};MetaLib.prototype._isCompTagAttrEnumDepr=function(tagName,attrName,enumValue){return this._components?this._components.isTagAttrEnumDeprecated(tagName,attrName,enumValue):null};MetaLib.prototype.hasTagSlot=function(tagName){return this._getSlots(tagName)?true:false};MetaLib.prototype.hasDynamicTagSlot=function(tagName){};MetaLib.prototype.isTagSlotName=function(tagName,slotName){var tag,slot;tag=_removeChevrons(tagName);if(this.isJetTag(tagName)){slot=this._getSlotByName(this._getComponentFromTag(tag),slotName)}else if(this._components){if(!HtmlUtils.isCommonElem(tag)){slot=this._components.hasTagSlotName(tag,slotName)}}return!!slot};MetaLib.prototype.isTagSlotValue=function(tagName,slotName){return this.isTagSlotName(tagName,slotName)};MetaLib.prototype.isTagDynamicSlotValue=function(tagName,slotName){};MetaLib.prototype.getPreferredSlotContent=function(tag,slot){var ret;tag=_removeChevrons(tag);if(this.isJetTag(tag)){ret=this.getJetPreferredSlotContent(tag,slot)}else if(this._components&&this._implements){ret=this._components.getPreferredSlotContent(tag,slot,this._implements)}return ret};MetaLib.prototype.getJetPreferredSlotContent=function(tag,slot){var clazz,slot,prefContent,content,comps;if(!this._implements){return null}if(clazz=this._getComponentFromTag(tag)){if(clazz.slot){if(slot=clazz.slot[slot]){if(prefContent=slot.ojpreferredcontent){prefContent.forEach(impl=>{if(content=this._implements[impl]){if(!comps){comps=[]}comps.push(...content)}})}}}else{{let defMem;if(clazz.member&&(defMem=clazz.member["Default"])&&defMem.ojchild){if(prefContent=defMem.ojpreferredcontent){prefContent.forEach(impl=>{if(content=this._implements[impl]){if(!comps){comps=[]}comps.push(...content)}})}}}}}return prefContent||comps?{interfaces:prefContent,components:comps}:null};MetaLib.prototype.getTagSlotMetadata=function(tag,slot){var ret;tag=_removeChevrons(tag);if(this.isJetTag(tag)){ret=this._getJetTagSlotMetadata(tag,slot)}else if(this._components){ret=this._components.getTagSlotMetadata(tag,slot)}return ret};MetaLib.prototype._getJetTagSlotMetadata=function(tag,slot){};MetaLib.prototype.isTagSupportedInTheme=function(tag){var o,a,ret=true;o=this._getComponentFromTag(tag);if(o){if(o.header){a=o.header.ojunsupportedthemes;ret=!(a&&a.includes(this._theme))}}else{ret=this._components&&this._components.isTagSupportedInTheme(tag,this._theme)}return ret};MetaLib.prototype.isAttrSupportedInTheme=function(tag,attr){var o,a,ret=true;o=this._getTagAttrMemberObj(tag,attr);if(o){a=o.ojunsupportedthemes;ret=!(a&&a.includes(this._theme))}else{ret=this._components.isAttrSupportedInTheme(tag,attr,this._theme)}return ret};MetaLib.prototype.hasTagCompPropSubprop=function(tagName,propName){var obj,ret=false;if(this.isCCATag(tagName)){obj=this._getComponentFromTag(tagName);if(obj&&obj.member){ret=obj.member[propName];ret=ret&&ret.submember}else if(this._components){ret=this._components.getTagProp(tagName,propName);ret=ret&&ret.properties}}return ret};MetaLib.prototype.isTagCompProp=function(tagName,propName){var obj,ret=false;if(this.isCCATag(tagName)){obj=this._getComponentFromTag(tagName);if(obj&&obj.member){ret=obj.member[propName]}else if(this._components){ret=this._components.isTagProp(tagName,propName)}}return ret};MetaLib.prototype.getTagAttrType=function(tag,attr){var member=this._getTagAttrMemberObj(tag,attr);return member?member.type:this._components.getTagPropType(tag,attr)};MetaLib.prototype.getTagPropType=function(tagName,propName){var ret;if(this._components){ret=this._components.getTagPropType(tagName,propName)}return ret};MetaLib.prototype.getTagAttrMetadata=function(tag,attr){var obj,member,req;var member=this._getTagAttrMemberObj(tag,attr);if(!member){if(this._components){obj=this._components.getTagProp(tag,attr)}}else{obj={type:member.type};if(member.deprecated||member.ojdeprecated){obj.deprecated=true}if(member.ojtranslatable){obj.translatable=true}if(req=this.getRequiredAttrs(tag)){for(let i=0;i<req.length;i++){if(req[i]===attr){obj.required=true;break}}}obj.type=member.type}return obj};MetaLib.prototype.getTagMetadata=function(tag){var obj,comp,hdr,events,props,event,ret;obj=this._getComponentFromTag(_removeChevrons(tag));if(obj){if(hdr=obj.hdr){comp={};comp.name=hdr.customelement;if(hdr.slot){comp[PROP_SLOTS]=obj.slots}}if(obj.properties){comp[PROP_PROPS]=props={};this._extractProps(props,null,obj.properties,obj.name)}if(obj.events){comp[PROP_EVENTS]=events={};for(event in obj.events){}}if(obj.implements){comp[PROP_IMPLEMENTS]=obj.implements}if(obj.extension&&obj.extension.theme&&obj.extension.theme.unsupportedThemes){comp[PROP_UNSUP_THEME]=obj.extension.theme.unsupportedThemes}if(hdr&&hdr.ojsubcomponenttype){comp[PROP_SUBCOMPONENT_TYPE]=hdr.subcomponenttype}}else if(this._components){ret=this._components.getTagMetadata(tag)}return ret};MetaLib.prototype.isTagStyleDeprecated=function(tagName,styleName){var o,ret;o=this.isWCStyleDeprecated(styleName);if(o){tagName=_removeChevrons(tagName);if(this._json.ojStyles.containers[o.index]===tagName){ret=o.dep.description}}return ret};MetaLib.prototype.isTagStyle=function(tagName,styleName){var obj,ret=false,compName,containers,indices,index,i;tagName=_removeChevrons(tagName);obj=this._getComponentFromTag(tagName);if(obj){compName=this._getComponentNameFromTag(tagName);containers=this._json.ojStyles.containers;indices=_getStyleIndices(this._json.ojStyles,styleName);if(indices){for(i=0;i<indices.length;i++){index=indices[i];if(index>=0){if(containers[index]===compName){ret=true;break}}}}}return!!ret};MetaLib.prototype.isStyle=function(style){return this.isGenStyle(style)||this.isClassStyle(style)||this.isStylesetStyle(style)};MetaLib.prototype.isGenStyle=function(style){var x=this._json.genericStyles[style];return x||x===0?true:false};MetaLib.prototype.isJetStyle=function(style){return this._json.genericStyles[style]?"g":this._json.ojStyles[style]?"j":undefined};MetaLib.prototype.isCustomStyle=function(style){return this._components&&this._components.isStyle(style)};MetaLib.prototype.getStyleOrigin=function(style){var ret;if(this._json.genericStyles[style]){ret="g"}if(this._json.ojStyles[style]){ret=ret?"b":"j"}if(!ret&&this._components){if(this._components.isStyle(style)){ret="c"}}return ret};MetaLib.prototype.isClassStyle=function(style){var x=this._json.ojStyles[style];return x||x===0?true:false};MetaLib.prototype.isStylesetStyle=function(style){return this._stylesets?!!this._stylesets[style]:false};MetaLib.prototype.getStyleSelector=function(style,jet){var o,i,ret;if(typeof jet==="boolean"){o=jet?this._json.ojStyles[style]:this._json.genericStyles[style]}else{o=this._json.ojStyles[style];if(!o&&o!==0){o=this._json.genericStyles[style]}if(!o&&this._components){o=this._components.getStyleMetadata(style)}}if(this._utils.isObject(o)){if(o.styleselector){ret=o.styleselector}else if(o.meta){ret=o.meta.styleSelector}}else if(Array.isArray(o)){for(i=0;i<o.length;i++){if(this._utils.isObject(o[i])&&o[i].styleselector){if(!ret){ret=[]}ret.push(o[i].styleselector)}}if(ret&&ret.length===1){ret=ret[0]}}return ret?ret:null};MetaLib.prototype.isJetStylePrefix=function(s){var x;if(!s.startsWith(OJPREFIX)||!this._json.jetCssPrefixes.classes){return false}x=s.indexOf("-",3);if(x>=0){s=s.substring(0,x)}return this._json.jetCssPrefixes.classes.includes(s)};MetaLib.prototype.hasJetStylePrefixes=function(){return this._json.jetCssPrefixes&&this._json.jetCssPrefixes.classes};MetaLib.prototype.getClassesFromStyle=function(styleName,scope){var indices,oStyles,ret;scope=scope||"oj";if(scope==="oj"||scope==="both"){oStyles=this._json.ojStyles;if(oStyles){indices=_getStyleIndices(oStyles,styleName);if(indices){return _toContainers(oStyles,indices)}}}if(scope==="gen"||scope==="both"){oStyles=this._json.genericStyles;if(oStyles){indices=_getStyleIndices(oStyles,styleName);if(indices){ret=_toContainers(oStyles,indices)}}}return ret?ret:null};MetaLib.prototype.getJetTagFromStyle=function(styleName){var indices,oStyles,clazz;oStyles=this._json.ojStyles;if(oStyles){indices=_getStyleIndices(oStyles,styleName)}if(indices){if(indices.length>1||indices.length===0){clazz=null}else{clazz=this.isGenStyle(styleName)?null:_toContainers(oStyles,indices)}}return clazz?this.getTagFromClass(clazz):null};MetaLib.prototype.getJetTagsFromStyle=function(styleName){var indices,oStyles;oStyles=this._json.ojStyles;if(oStyles){indices=_getStyleIndices(oStyles,styleName);if(indices){return _toContainers(oStyles,indices,this._json)}}return null};MetaLib.prototype.getClassFromTag=function(tagName){return this._getComponentNameFromTag(_removeChevrons(tagName))};MetaLib.prototype.getClassFromModule=function(module){var clazz=this._json.moduleLookup[module];return clazz?clazz:null};MetaLib.prototype.getTagFromClass=function(className){if(className==="oj.ojTree"){return"oj-tree"}let ret=this._json[className];return ret&&ret.header?ret.header.customelement:null};MetaLib.prototype.isClass=function(className){var b=this._json[className];if(!b){if(className=this._classChange[className]){b=this._json[className]}}return!!b};MetaLib.prototype.isClassFinal=function(className){var clazz=this._json[className];if(!clazz){if(className=this._classChange[className]){clazz=this._json[className]}}return clazz&&clazz.header&&clazz.header.readonly};MetaLib.prototype.isClassMethod=function(className,methName){var clazz=this._json[className];return!!(clazz&&clazz.function&&clazz.function[methName])};MetaLib.prototype.isClassMethodStatic=function(className,methName){var meth,ret=null;var clazz=this._json[className];if(clazz&&clazz.function){meth=clazz.function[methName];ret=meth&&meth.scope&&meth.scope=="static"}return ret};MetaLib.prototype.getClassMethodScope=function(className,methName){var meth,ret=null;var clazz=this._json[className];if(clazz&&clazz.function){meth=clazz.function[methName];ret=meth.scope}return ret};MetaLib.prototype.isClassMember=function(className,memName){var clazz=this._json[className];return!!(clazz&&clazz.member&&clazz.member[memName])};MetaLib.prototype.isClassMemberStatic=function(className,memName){var mem,ret=null;var clazz=this._json[className];if(clazz&&clazz.member){mem=clazz.member[memName];ret=mem&&mem.scope&&mem.scope=="static"}return ret};MetaLib.prototype.getRequiredAttrs=function(tagName){let obj,clazz,i,ret=null;tagName=_removeChevrons(tagName);obj=this._getComponentFromTag(tagName);if(obj){clazz=this._getComponentNameFromTag(tagName)}ret=obj?this._reqAttrs[clazz]:this._components.getRequiredAttrs(tagName);if(obj&&ret&&ret.length){for(i=0;i<ret.length;i++){ret[i]=this._domUtils.kebabCase(ret[i])}}return ret};MetaLib.prototype.getTagsFromStyle=function(styleName){var classNames,tag,i,ret;ret=null;classNames=this.getClassesFromStyle(styleName);if(classNames){for(i=0;i<classNames.length;i++){tag=this.getTagFromClass(classNames[i]);if(tag){if(!ret){ret=[]}ret.push(tag)}}}return ret?ret:null};MetaLib.prototype.isStyleDeprecated=function(name){var s,o,t,i;s=this._json.genericStyles[name];if(!s&&s!==0&&this._json.ojStyles){s=this._json.ojStyles[name];if(!s&&s!==0&&this._stylesets){s=this._stylesets[name];return this._utils.isObject(s)?s:null}}if(s){t=typeof s;if(Array.isArray(s)){for(i=0;i<s.length;i++){o=s[0];if(typeof o==="object"){break}}}else if(t==="object"){o=s}else{o=null}}return o?o.dep:null};MetaLib.prototype.isStyleDeprecatedEx=function(style){var a=null,ss,t,i;function _pushSS(o){if(o.dep){if(!a){a=[]}a.push(o)}};function _stashSS(s){t=typeof s;if(Array.isArray(s)){for(i=0;i<s.length;i++){_pushSS(s[i])}}else if(t==="object"){_pushSS(s)}};if(ss=this._json.genericStyles[style]){_stashSS(ss)}if(ss=this._json.ojStyles[style]){_stashSS(ss)}else if(ss!==0&&this._stylesets){ss=this._stylesets[style];return this._utils.isObject(ss)?ss:null}return a};MetaLib.prototype.isWCStyleDeprecated=function(name){var s,o,t,i;s=this._json.ojStyles[name];if(s){t=typeof s;if(Array.isArray(s)){for(i=0;i<s.length;i++){o=s[i];if(typeof o==="object"){break}o=null}}else if(t==="object"){o=s}}return o?o:null};MetaLib.prototype.isBindingTag=function(tagName){var obj=this._getComponentFromTag(_removeChevrons(tagName));return obj&&obj.header?!!obj.header.ojbindingelement:false};MetaLib.prototype.isComponent=function(className){var obj=this._json[className];if(!obj){if(!className.startsWith("oj.")){obj=this._json["oj."+className]}}return!!obj};MetaLib.prototype.isClass=function(className){return!!this._json[className]};MetaLib.prototype.isJetComponentClass=function(className){return this.isClass(className)};MetaLib.prototype.isComponentDeprecated=function(className){return this.isClassDeprecated(className)};MetaLib.prototype.isClassDeleted=function(className){var classes,cn,version=null;if(this._delHist){if(classes=this._delHist.classes){cn=this._classChange[className];if(cn){className=cn}version=classes[className]}}return version};MetaLib.prototype.isClassRenamed=function(className){return this._renHist?this._renHist[className]:null};MetaLib.prototype.isClassDeprecated=function(className){var obj,ret=null;if(className==="oj.ojTree"){if(SemVer.gte(this._jetVer,"5.2.0")){return null}else{return{type:DEPRECATED,description:"Use ojTreeView instead"}}}if(!(obj=this._json[className])){className=this._classChange[className];obj=className?this._json[className]:undefined}if(!obj){return false}if(obj.header){ret=this._isClassDeprecated(obj.header)}if(!ret){ret=this._isClassDeprecated(obj)}return ret};MetaLib.prototype._isClassDeprecated=function(obj){var depr,status,ret=null;if(obj){if(obj.ojdeprecated&&obj.ojdeprecated.length){depr=obj.ojdeprecated;for(status of depr){ret=status;break}}else if(depr=obj.deprecated){ret={type:DEPRECATED,description:typeof depr==="boolean"?NO_SUGGESTION_AVAIL:depr}}}return ret};MetaLib.prototype.isClassMethodDeleted=function(className,methodName){var a,cn,i,ret=null;a=this._deletedMethods[methodName];if(a){cn=this._classChange[className];if(cn){className=cn}for(i=0;i<a.length;i++){if(a[i]===className){ret=a[i+1];break}i++}}return ret};MetaLib.prototype.isClassMethodDeprecated=function(className,methodName){var obj,method,ret=null;obj=this._json[className];if(!obj){className=this._classChange[className];obj=className?this._json[className]:undefined}if(obj&&obj.function){for(method in obj.function){if(method===methodName){method=obj.function[method];ret=this._isSubStateDeprecated(method);break}}}return ret};MetaLib.prototype.isClassMemberDeleted=function(className,memberName){var a,i,cname,ret=null;a=this._deletedMembers[memberName];if(a){cname=this._classChange[className];for(i=0;i<a.length;i++){if(a[i]===className||a[i]===cname){ret=a[i+1];break}i++}}return ret};MetaLib.prototype.isClassMemberDeprecated=function(className,memName){var obj,member,obj,ret=null;obj=this._json[className];if(!obj){className=this._classChange[className];obj=className?this._json[className]:undefined}if(obj&&obj.member){memName=memName.charAt(0)===":"?memName.substr(1):memName;for(member in obj.member){if(member===memName){member=obj.member[memName];ret=this._isSubStateDeprecated(member,true);break}}}return ret};MetaLib.prototype.isClassAttrDeprecated=function(className,attrName){var obj,member,ret=null;obj=this._json[className];attrName=attrName.charAt(0)===":"?attrName.substr(1):attrName;if(obj&&obj.member){for(member in obj.member){member=obj.member[member];if(attrName===member.name){ret=this._isSubStateDeprecated(member,true);break}}}return ret};MetaLib.prototype.isComponentDeleted=function(className){return this.isClassDeleted(className)};MetaLib.prototype.isComponentAttrDeprecated=function(className,attrName){return this.isClassAttrDeprecated(className,attrName)};MetaLib.prototype.isComponentMethodDeprecated=function(className,methodName){return this.isClassMethodDeprecated(className,methodName)};MetaLib.prototype.isComponentMemberDeprecated=function(className,memberName){return this.isClassMemberDeprecated(className,memberName)};MetaLib.prototype.isComponentMethodDeleted=function(className,methodName){return this.isClassMethodDeleted(className,methodName)};MetaLib.prototype.isComponentMemberDeleted=function(className,memberName){return this.isClassMemberDeleted(className,memberName)};MetaLib.prototype.isTagPackPrivate=function(tag){var o,ret;tag=_removeChevrons(tag);if(this.isJetTag(tag)){if(o=this._getComponentFromTag(tag)){ret=o.header&&o.header.ojsubcomponenttype===PACK_PRIVATE}}else if(this._components){ret=this._components.isTagPackPrivate(tag)}return ret};MetaLib.prototype.isTagAttrTranslatable=function(tag,attr){var member=this._getTagAttrMemberObj(tag,attr);return member?this._isSubStateTranslatable(member):this._components.isTagAttrTranslatable(tag,attr)};MetaLib.prototype.isTagAttrReadOnly=function(tag,attr){var o,ret=false;tag=_removeChevrons(tag);if(o=this._getTagAttrMemberObj(tag,attr)){ret=o&&o.readonly}else if(this._components){ret=this._components.isTagAttrReadOnly(tag,attr)}return ret};MetaLib.prototype.hasTagDataOjCommand=function(tagName){var obj,ret=false,compName,containers,indexes,i;tagName=_removeChevrons(tagName);obj=this._getComponentFromTag(tagName);if(obj){compName=this._getComponentNameFromTag(tagName);indexes=this._json.dataOjCommand;if(indexes){containers=this._json.ojStyles.containers;for(i=0;i<indexes.length;i++){if(containers[indexes[i]]===compName){ret=true;break}}}}return ret};MetaLib.prototype.isTagEvent=function(tagName,eventName){var obj,attr,x,ret=false;eventName=eventName.charAt(0)===":"?eventName.substr(1):eventName;if(!eventName.startsWith(EVENT_PREFIX)){return ret}if(this.isWCTag(tagName)){if(this._getComponentNameFromTag(tagName)){obj=this._getComponentFromTag(_removeChevrons(tagName));if(obj&&obj.htmlevents){ret=!!obj.htmlevents[eventName]}if(!ret){if((x=eventName.lastIndexOf("-changed"))>=0){attr=eventName.substring(3,x);attr=this._domUtils.camelCase(attr);ret=!!obj.member[attr]}}}else{ret=this._components&&this._components.isTagEvent(tagName,eventName)}if(!ret){ret=HtmlUtils.isCommonEventAttr(eventName)}}return ret};MetaLib.prototype.applySchema=function(obj){return this._compSvcs.validateComponentJsonWithSchema(obj)};MetaLib.prototype.walkElemStackForOJTag=function(ctx,excludeBindIf){var i,name,ret=null;var stack=ctx.elemStack;if(stack&&stack.length){for(i=stack.length-1;i>=0;i--){name=stack[i].name;if(name.toLowerCase().startsWith(OJPREFIX)){if(!name.startsWith("oj-bind-")||!excludeBindIf){ret=name;break}}}}return ret};MetaLib.prototype.walkDomStackForOJTag=function(ctx,excludeBindIf){return this.walkElemStackForOJTag(ctx,excludeBindIf)};MetaLib.prototype.getPublicInterface=function(){return{isJetTag:this.isJetTag.bind(this),isWCTag:this.isWCTag.bind(this),isComponentTag:this.isComponentTag.bind(this),isTagDeprecated:this.isTagDeprecated.bind(this),isTagSupportedInTheme:this.isTagSupportedInTheme.bind(this),isAttrSupportedInTheme:this.isAttrSupportedInTheme.bind(this),isTagAttrDeprecated:this.isTagAttrDeprecated.bind(this),isTagAttrTranslatable:this.isTagAttrTranslatable.bind(this),isTagAttrReadOnly:this.isTagAttrReadOnly.bind(this),isTagEventDeprecated:this.isTagEventDeprecated.bind(this),isTagAttrEnumValueDeprecated:this.isTagAttrEnumValueDeprecated.bind(this),isTagAttr:this.isTagAttr.bind(this),isJetTagAttr:this.isJetTagAttr.bind(this),hasTagAttrValues:this.hasTagAttrValues.bind(this),isTagAttrValue:this.isTagAttrValue.bind(this),getTagAttrType:this.getTagAttrType.bind(this),getTagAttrMetadata:this.getTagAttrMetadata.bind(this),getTagMetadata:this.getTagMetadata.bind(this),isTagCompProp:this.isTagCompProp.bind(this),hasTagCompPropSubprop:this.hasTagCompPropSubprop.bind(this),getTagPropType:this.getTagPropType.bind(this),hasTagSlot:this.hasTagSlot.bind(this),isTagSlotName:this.isTagSlotName.bind(this),isTagSlotValue:this.isTagSlotValue.bind(this),getPreferredSlotContent:this.getPreferredSlotContent.bind(this),getTagSlotMetadata:this.getTagSlotMetadata.bind(this),hasTagDataOjCommand:this.hasTagDataOjCommand.bind(this),isBindingTag:this.isBindingTag.bind(this),isTagPackPrivate:this.isTagPackPrivate.bind(this),isClass:this.isClass.bind(this),isClassRenamed:this.isClassRenamed.bind(this),isClassDeleted:this.isClassDeleted.bind(this),isClassDeprecated:this.isClassDeprecated.bind(this),isClassMethodDeleted:this.isClassMethodDeleted.bind(this),isClassMemberDeleted:this.isClassMemberDeleted.bind(this),isClassMethodDeprecated:this.isClassMethodDeprecated.bind(this),isClassMemberDeprecated:this.isClassMemberDeprecated.bind(this),isClassAttrDeprecated:this.isClassAttrDeprecated.bind(this),isClassFinal:this.isClassFinal.bind(this),isClassMethod:this.isClassMethod.bind(this),isClassMethodStatic:this.isClassMethodStatic.bind(this),isClassMember:this.isClassMember.bind(this),isClassMemberStatic:this.isClassMemberStatic.bind(this),getClassMethodScope:this.getClassMethodScope.bind(this),getStyleOrigin:this.getStyleOrigin.bind(this),isJetStyle:this.isJetStyle.bind(this),isCustomStyle:this.isCustomStyle.bind(this),isTagStyle:this.isTagStyle.bind(this),isStyle:this.isStyle.bind(this),isGenStyle:this.isGenStyle.bind(this),isClassStyle:this.isClassStyle.bind(this),isStylesetStyle:this.isStylesetStyle.bind(this),isStyleDeprecated:this.isStyleDeprecated.bind(this),isStyleDeprecatedEx:this.isStyleDeprecatedEx.bind(this),getStyleSelector:this.getStyleSelector.bind(this),getNonSSStyleElems:this.getNonSSStyleElems.bind(this),isJetStylePrefix:this.isJetStylePrefix.bind(this),hasJetStylePrefixes:this.hasJetStylePrefixes.bind(this),isTagEvent:this.isTagEvent.bind(this),getTagsFromStyle:this.getTagsFromStyle.bind(this),getJetTagFromStyle:this.getJetTagFromStyle.bind(this),getJetTagsFromStyle:this.getJetTagsFromStyle.bind(this),getClassesFromStyle:this.getClassesFromStyle.bind(this),getClassFromTag:this.getClassFromTag.bind(this),getClassFromModule:this.getClassFromModule.bind(this),getTagFromClass:this.getTagFromClass.bind(this),getDeprecatedMethodList:this.getDeprecatedMethodList.bind(this),getDeprecatedMemberList:this.getDeprecatedMemberList.bind(this),getDeletedMethodList:this.getDeletedMethodList.bind(this),getDeletedMemberList:this.getDeletedMemberList.bind(this),getRequiredAttrs:this.getRequiredAttrs.bind(this),isComponent:this.isComponent.bind(this),isNSRegistered:this.isNSRegistered.bind(this),isNamespacePrefix:this.isNamespacePrefix.bind(this),getRenamedClassList:this.getRenamedClassList.bind(this),getDeletedClassList:this.getDeletedClassList.bind(this),processImplements:this.processImplements.bind(this),getWCInterfaces:this.getWCInterfaces.bind(this),hasWCInterfaces:this.hasWCInterfaces.bind(this),hasJetWCInterfaces:this.hasJetWCInterfaces.bind(this),getMetaVers:this.getMetaVers.bind(this),walkElemStackForOJTag:this.walkelemStackForOJTag,walkDomStackForOJTag:this.walkDomStackForOJTag,isIgnoreAttr:this.isIgnoreAttr.bind(this),applySchema:this.applySchema.bind(this),getRevisionInfo:this.getRevisionInfo.bind(this)}};MetaLib.prototype.loadMeta=function(metaFile){var metaObj,ret=false;if(!this._json){try{if(metaObj=nodeDeps.metaLoader.loadMeta(metaFile,nodeDeps)){this._json=metaObj.meta;this._delHist=metaObj.delMeta;this._renHist=metaObj.renMeta;this._reqAttrs=metaObj.reqattr;this._jetVer=this._json.meta.jetversion;this._createNonClassList(this._json.meta);this._createModuleLookup();this._createClassNameChanges();this._fixup_jet_42315();this._createImplements();ret=true}else{this._error(`Metadata '${metaFile}' not found!`)}}catch(e){this._error(`[${e.name}]: Metadata load (${metaFile}) - ${e.message}`)}}return ret};MetaLib.prototype.getRenamedClassList=function(){return this._renHist};MetaLib.prototype.getDeletedClassList=function(){return this._delHist};MetaLib.prototype.processImplements=function(tag,impls){if(Array.isArray(impls)&&this._implements){impls.forEach(impl=>{if(this._implements[impl]){this._implements[impl].push(tag)}else{this._implements[impl]=[tag]}})}};const OJV_CHARS=/[<>]/;MetaLib.prototype._getOjValues=function(mem){var ts,ret;if(!mem){return false}if(mem.ojvalues){if(mem.ojvalues.name&&Array.isArray(mem.ojvalues.name)&&mem.ojvalues.name.length){return mem.ojvalues}return}if(mem.tstype&&mem.tstype.m_ojvalues){return mem.tstype.m_ojvalues}ts=this._getTsTypeObject(mem);if(ts&&ts.ojvalues&&ts.ojvalues.name){if(Array.isArray(ts.ojvalues.name)&&ts.ojvalues.name.length){ret=ts.ojvalues}}return ret};MetaLib.prototype.getWCInterfaces=function(){return this._implements};MetaLib.prototype.hasJetWCInterfaces=function(){return this._hasJetWCIFCs};MetaLib.prototype.hasWCInterfaces=function(){return!!this._implements};MetaLib.prototype._createNonClassList=function(mp){this._nonClasses=mp.nonClasses?mp.nonClasses:["genericStyles","ojStyles"];this._nonClasses.push("moduleLookup");this._nonClasses.push("newGenericStyles");this._nonClasses.push("newOjStyles");if(!this._nonClasses.includes("custElementClassLookup"))this._nonClasses.push("custElementClassLookup");if(!this._nonClasses.includes("meta"))this._nonClasses.push("meta");if(!this._nonClasses.includes("ResponsivePrefixes"))this._nonClasses.push("ResponsivePrefixes")};MetaLib.prototype.setAmdMeta=function(obj){this._json=obj.jetMeta.meta;this._delHist=obj.jetMeta.delMeta;this._reqAttrs=obj.jetMeta.reqattr;this._jetVer=this._json.meta.jetversion;this._createNonClassList(this._json.meta);this._createModuleLookup();return true};MetaLib.prototype.setTheme=function(theme){this._theme=theme};MetaLib.prototype._createModuleLookup=function(){var comps,compName,lookup,hdr;if(this._json.moduleLookup){return}this._json.moduleLookup=lookup={};comps=this._json;for(compName in comps){if(!this._nonClasses.includes(compName)&&!compName.startsWith("oj.__")){hdr=comps[compName].header;if(hdr){lookup[OJS+hdr.name.toLowerCase()]=compName}}}};MetaLib.prototype._createClassNameChanges=function(){var comps,compName,o,hdr;if(this._classChange=this._json.meta.isClassNameChanges){return}this._classChange=o={};comps=this._json;for(compName in comps){if(!this._nonClasses.includes(compName)){hdr=comps[compName].header;if(hdr&&compName!==hdr.name){o[hdr.name]=compName}}}this._json.meta.isClassNameChanges=true};MetaLib.prototype._fixup_jet_42315=function(){var o;if(SemVer.gte(this._jetVer,"8.0.0")){if(o=this._json.Color||this._json["oj.Color"]||this._json["oj.ojColor"]){if(!o.header){o.header={}}o.header.readonly=true}}};MetaLib.prototype._createImplements=function(){var clazzes,clazz,tag,impls,impl,o={},a,hdr;if(this._implements=this._json.meta.interfaces){return}clazzes=this._json;for(clazz in clazzes){if(this._nonClasses.includes(clazz)){continue}if(hdr=clazzes[clazz].header){if(hdr.domInterface&&hdr.customelement){impls=hdr.domInterface;impls=Array.isArray(impls)?impls:[impls];for(impl of impls){if(o[impl]){a=o[impl]}else{o[impl]=a=[]}this._hasJetWCIFCs=true;tag=this.getTagFromClass(clazz);if(tag&&!a.includes(tag)){a.push(tag)}}}}}this._implements=this._hasJetWCIFCs?o:null};MetaLib.prototype.getMetaVers=function(){return{versions:this._jetVersions,runver:this._jetVer}};MetaLib.prototype.setComponentsLib=function(compSvcs,comps){if(compSvcs){this._compSvcs=compSvcs}if(comps){this._components=comps}};MetaLib.prototype.setStylesets=function(ss){if(!ss){return}var o,obj,e,i;if(!this._stylesets){this._stylesets=obj={}}else{obj=this._stylesheets}for(i=0;i<ss.length;i++){o=ss[i];if(typeof o==="string"){obj[o]=true}else if(o.deprecated){obj[o.deprecated]=e={};if(o.since){e.since=o.since}if(o.note){e.description=o.note}else if(o.description){e.description=o.description}}}};MetaLib.prototype.setDomUtils=function(du){this._domUtils=du};MetaLib.prototype.getRevisionInfo=function(){var metaSect=this._json.meta;var revision="";return{revision:revision,tag:metaSect.jetrevision,jetVersion:metaSect.jetversion,date:metaSect.date,time:metaSect.time}};MetaLib.prototype._isSubStateDeprecated=function(obj,isMember){var depr,retStatus=null,o;if(!obj){return false}if(obj.ojdeprecated&&obj.ojdeprecated.length){retStatus=[];depr=obj.ojdeprecated;depr.forEach(status=>{o={type:DEPRECATED};if(status.hasOwnProperty("target")){o.target=status.target;if(isMember&&status.target==="memberType"){o.target="propertyType"}}if(status.hasOwnProperty("description")){o.description=status.description}if(status.hasOwnProperty("since")){o.since=status.since}if(status.hasOwnProperty("for")){o.value=[status.for]}else if(status.hasOwnProperty("value")){o.value=status.value}retStatus.push(o)});retStatus=retStatus.length?retStatus:null}else if(depr=obj.deprecated){retStatus=typeof depr==="boolean"?NO_SUGGESTION_AVAIL:depr;retStatus=[{type:DEPRECATED,description:retStatus}]}return retStatus};MetaLib.prototype._isSubStateTranslatable=function(obj){return obj&&obj.ojtranslatable};MetaLib.prototype._getComponentNameFromTag=function(tagName){tagName=tagName.toLowerCase();return this._json.custElementClassLookup[tagName]?this._json.custElementClassLookup[tagName]:null};MetaLib.prototype.isIgnoreAttr=function(tagName,attrName){var ret=false;attrName=attrName.toLowerCase();attrName=attrName.charAt(0)===":"?attrName.substr(1):attrName;if(HtmlUtils.isCommonElem(attrName)||attrName.startsWith("aria-")){return true}if(tagName==="oj-avatar"){if(attrName==="src"||attrName==="initials")ret=true}else if(tagName==="oj-option"){if(attrName==="value")ret=true}return ret};MetaLib.prototype.getDeprecatedMethodList=function(){if(this._deprecatedMethods){return this._deprecatedMethods}var json=this._json;var name,methName,methObj,o,a;var ret={};for(name in json){o=json[name];if(o&&o.function){for(methName in o.function){methObj=o.function[methName];if(methObj.ojdeprecated){if(ret[methName]){a=ret[methName]}else{ret[methName]=a=[]}a.push(name)}}}}return this._deprecatedMethods=ret};MetaLib.prototype.getDeprecatedMemberList=function(){if(this._deprecatedMembers){return this._deprecatedMembers}var json=this._json;var name,memName,memObj,o,a;var ret={};for(name in json){o=json[name];if(o&&o.member){for(memName in o.member){memObj=o.member[memName];if(memObj.ojdeprecated){if(ret[memName]){a=ret[memName]}else{ret[memName]=a=[]}a.push(name)}}}}return this._deprecatedMembers=ret};MetaLib.prototype.getDeletedMethodList=function(){if(this._deletedMethods){return this._deletedMethods}var json=this._delHist;var name,methName,ver,o,a;var ret={};if(json){for(name in json){o=json[name];if(o&&o.methods){for(methName in o.methods){ver=o.methods[methName];if(ret[methName]){a=ret[methName]}else{ret[methName]=a=[]}a.push(name);a.push(ver)}}}}return this._deletedMethods=ret};MetaLib.prototype.getDeletedMemberList=function(){if(this._deletedMembers){return this._deletedMembers}var json=this._delHist;var name,memName,ver,o,a;var ret={};if(json){for(name in json){o=json[name];if(o&&o.members){for(memName in o.members){ver=o.members[memName];if(ret[memName]){a=ret[memName]}else{ret[memName]=a=[]}a.push(name);a.push(ver)}}}}return this._deletedMembers=ret};MetaLib.prototype._getSlots=function(tagName){var obj=this._getComponentFromTag(_removeChevrons(tagName));return this._getSlots2(obj)};MetaLib.prototype._getSlots2=function(base){var bases,base,i,ret=null;while(base){ret=base&&base.slot?base.slot:null;if(ret){break}bases=base.header&&base.header.augments?base.header.augments:null;if(!bases){break}for(i=0;i<bases.length;i++){base=this._json[bases[i]];ret=this._getSlots2(base);if(ret){base=null;break}}}return ret?ret:null};MetaLib.prototype._getSlotByName=function(base,slotName){var ret=null;while(base){ret=base&&base.slot?base.slot:null;if(ret){ret=base.slot[slotName];if(ret){break}}break}return ret?ret:null};MetaLib.prototype._getComponentFromTag=function(tagName){var o=this._getComponentNameFromTag(tagName);if(o){o=this._json[o]}return o?o:null};function _getStyleIndices(scope,styleName){var a,n,ret,i;a=scope[styleName];if(a||a===0){if(!ret){ret=[]}if(Array.isArray(a)){for(i=0;i<a.length;i++){n=a[i];if(typeof n==="object"){n=a[i].index}ret.push(n)}}else{if(typeof a==="object"){n=a.index}else{n=a}ret.push(n)}}return ret&&ret.length?ret:null};MetaLib.prototype.getNonSSStyleElems=function(styleName,scope){var a,n,ret,i;scope=scope?this._json.ojStyles:this._json.genericStyles;a=scope[styleName];if(a||a===0){if(!ret){ret=[]}if(Array.isArray(a)){for(i=0;i<a.length;i++){n=a[i];if(typeof n==="object"&&!n.styleselector){n=a[i].index}ret.push(n)}}else{if(typeof a==="object"&&!a.styleselector){n=a.index}else{n=a}ret.push(n)}}return ret&&ret.length?_toContainers(scope,ret,this._json):null};MetaLib.prototype.displayImpls=function(){var impls,impl;this._console("[info] :--------- JET Interfaces Implemented ---------","I");if(!(impls=this._implements)){this._console(" None!","I")}else{for(impl in impls){this._console(`${impl} : <- <${impls[impl].join(",")}>`,"I")}}this._console("[info]: -------- End Declared Web Components ---------\n","I")};function _toContainers(scope,indices,json){var cont,ret,clazz,elem,n,i;cont=scope.containers;for(i=0;i<indices.length;i++){n=indices[i];if(n>=0){if(!ret){ret=[]}if(!json){ret[i]=cont[n]}else{clazz=cont[n];elem=json[clazz];if(elem&&elem.header){elem=elem.header.customelement;if(elem){ret[i]=elem}}}}}return ret&&ret.length?ret:null};function _convertValue(valType,value){var retValue=value;if(valType==="string"){retValue=value}else if(valType==="number"){retValue=Number(value)}else if(valType==="boolean"){retValue=value.toLowerCase()==="true"}return retValue};function _removeChevrons(tagName){if(tagName){let len=tagName.length-1;let start=tagName.charAt(0)==="<"?1:0;let end=tagName.charAt(len)===">"?len:++len;tagName=tagName.substring(start,end)}return tagName};module.exports=MetaLib;
|
|
6
|
+
"use strict";const Namespaces=require("./ns");const HtmlUtils=require("./HtmlUtils");const SemVer=require("semver");const NO_SUGGESTION_AVAIL="No suggestion available.";const OJPREFIX="oj-";const OJEVENTPREFIX="on-oj-";const OJS="ojs/oj";const EVENT_PREFIX="on-";const DOT=".";const DATA_OJ_CMD="data-oj-command";const PROP_SLOTS="slots";const PROP_PROPS="props";const PROP_EVENTS="events";const PROP_IMPLEMENTS="implements";const PROP_FOLDER="folder";const PROP_VERSION="version";const PROP_UNSUP_THEME="unsupTheme";const PROP_SUBCOMPONENT_TYPE="subcomponentType";const PACK_PRIVATE="packPrivate";const DEPRECATED="deprecated";const MAINTENANCE="maintenance";const SUPERSEDES="supersedes";const STRING="string";const BOOLEAN="boolean";const OBJECT="object";function MetaLib(nd,runMode,msgCtx,utils,fsUtils){this._json=null;this._delHist=null;this._renHist=null;this._reqAttrs=null;this._nonClasses=null;this._implements=null;this._hasJetWCIFCs=false;this._ignoreRules=null;this._components=null;this._compSvcs=null;this._stylesets=null;this._runMode=runMode;this._utils=utils;this._fsUtils=fsUtils;this._domUtils=null;if(nd.jetver){this._jetVersions=nd.jetver.getVersions()}this._jetVer=null;this._theme=null;this._deprecatedMethods=null;this._deprecatedMembers=null;this._deletedMethods=null;this._deletedMembers=null;this._error=msgCtx.error;this._debug=msgCtx.debug;this._info=msgCtx.info;this._msg=msgCtx.msg;this._console=msgCtx.console;this._isDebug=msgCtx.isdebug;this._isVerbose=msgCtx.isVerbose;this._nd=nd};MetaLib.prototype.isNSRegistered=function(prefix){return Namespaces.has(prefix)};MetaLib.prototype.isNamespacePrefix=function(tagName){return HtmlUtils.isNamespaceTag(tagName)};MetaLib.prototype.isRuleIgnored=function(tagName,ruleName,reqType,reqVal){var obj,rules,ret=false;if(this._ignoreRules){if(obj=this._ignoreRules[tagName]){if(obj.name===reqVal){rules=obj[reqType];ret=rules.includes(ruleName)}}}return ret};MetaLib.prototype.isCoreTag=function(tag){return this._components.isJetTag(tag)};MetaLib.prototype.isJetLegacyTag=function(tag){return this._getComponentNameFromTag(_removeChevrons(tag))};MetaLib.prototype.isJetTag=function(tagName){return this._components.isJetTag(tagName)||this._getComponentNameFromTag(_removeChevrons(tagName))};MetaLib.prototype.isComponentTag=function(tagName){return this._components&&this._components.isTag(_removeChevrons(tagName))};MetaLib.prototype.isWCTag=function(tagName){return this.isJetTag(tagName)||this.isComponentTag(tagName)};MetaLib.prototype.isCCATag=function(tagName){return this.isWCTag(tagName)};MetaLib.prototype.isTagDeprecated=function(tagName){var clazz,ret;if(clazz=this._getComponentNameFromTag(_removeChevrons(tagName))){ret=this.isClassDeprecated(clazz)}else{ret=this._components.isTagDeprecated(tagName)}return ret};MetaLib.prototype.isTagAttrDeprecated=function(tagName,attrName){var member,ret=null;member=this._getTagAttrMemberObj(tagName,attrName);ret=member?this._isSubStateDeprecated(member,true):this._components.isTagAttrDeprecated(tagName,attrName);if(ret){ret.forEach(status=>{if(status.description){status.description=HtmlUtils.replaceEntities(status.description)}})}return ret};MetaLib.prototype.isTagEventDeprecated=function(tag,attr){var x1,x2;if((x1=attr.indexOf("-"))<0){return false}attr=attr.substring(x1+1);if((x2=attr.lastIndexOf("-"))>=0){attr=attr.substring(0,x2)}return this.isTagAttrDeprecated(tag,attr)};MetaLib.prototype.isTagAttr=function(tagName,attrName){var o,ret=false;attrName=attrName.charAt(0)===":"?attrName.substring(1):attrName;if(o=this._getComponentFromTag(tagName)){ret=this.isJetTagAttr(o,attrName)}else{ret=this._components&&this._components.isTagAttr(tagName,attrName)}return ret};MetaLib.prototype.isJetTagAttr=function(tagObj,attrName){attrName=attrName.charAt(0)===":"?attrName.substr(1):attrName;var ret=!!(tagObj.htmlattributes&&tagObj.htmlattributes[attrName]);if(!ret&&attrName===DATA_OJ_CMD&&tagObj.member){ret=!!tagObj.member[DATA_OJ_CMD]}return ret};MetaLib.prototype._getTagAttrMemberObj=function(tagName,attrName){var obj,attrib,member,x;obj=this._getComponentFromTag(_removeChevrons(tagName));attrName=attrName.charAt(0)===":"?attrName.substring(1):attrName;if(!obj||!obj.htmlattributes||!obj.htmlattributes[attrName]){return null}member=null;attrib=obj.htmlattributes[attrName];if(attrib){x=attrib.indexOf(DOT);if(x>=0){if(obj.member){member=this._findSubMember(obj,obj.member,attrib,attrib)}}else{member=obj.member[attrib];if(member){return member}}}return member};MetaLib.prototype._findSubMember=function(obj,mem,attrName,subMemberPart){var member,ts,sm,rest,x,ret=null;x=subMemberPart.indexOf(DOT);if(x>=0){sm=subMemberPart.substring(0,x);rest=subMemberPart.substring(x+1)}else{sm=subMemberPart;rest=null}for(member in mem){member=mem[member];if(member.name===attrName&&!rest){ret=member;break}if(member.name!==sm){continue}if(!rest){ret=member;break}if(member.submember){ret=this._findSubMember(obj,member.submember,attrName,rest);if(ret){break}}else if(member.tstype){ts=this._getTsTypeObject(member);if(ts){ret=this._findSubMember(obj,ts.member,attrName,rest);if(ret){break}}}if(ret){break}}return ret};MetaLib.prototype._getTsTypeObject=function(mem){var ts,o,s,x;ts=mem.tstype;if(ts&&ts.target==="Type"&&typeof ts.value===STRING){s=ts.value;s=s.replace("=","");x=s.indexOf("|");if(x>=0){s=s.substring(0,x).trimRight()}if(s.charAt(s.length-1)===">"){x=s.lastIndexOf("<");if(s>=0){s=s.substring(0,x)}}o=this._json[s];if(!o){o=this._json[mem.memberof];if(o.typedef){s=ts.value;x=s.lastIndexOf(DOT);if(x>=0){s=s.substring(x+1);o=o.typedef[s]}}}}return o?o:null};MetaLib.prototype._getSubMemberPart=function(fullAttr,soFar){var s,x;s=fullAttr.replace(soFar,"");if(s.length){if(s.charAt(0)==="."){x=s.indexOf(DOT,1);if(x>=0){s=soFar+s.substring(0,x)}else{s=soFar+s}}}else{s=soFar}return s};MetaLib.prototype._handleAttrObject=function(member){var link,types,i,x;types=member.tstype;if(types){for(i=0;i<types.length;i++){if(types[i].target==="Type"){link=types[i].value;link=link.replace("=","");x=link.indexOf("<K");if(x>=0){link=link.substring(0,x)}break}}}return link};MetaLib.prototype.hasTagAttrValues=function(tagName,attrName){var member,ojv,ret=false;if(member=this._getTagAttrMemberObj(tagName,attrName)){ojv=this._getOjValues(member);ret=!!ojv}else if(this._components.isKnownTag(tagName)){ret=this._components.hasTagAttrValues(tagName,attrName)}return ret};MetaLib.prototype.isTagAttrValue=function(tagName,attrName,attrValue){var member,ojv,values,curValue,valType,i,ret=false;member=this._getTagAttrMemberObj(tagName,attrName);if(member){ojv=this._getOjValues(member);if(ojv){values=ojv.name;for(i=0;i<values.length;i++){if(ojv.type){valType=ojv.type[i];curValue=_convertValue(valType,attrValue);ret=curValue===values[i]}else{ret=attrValue===values[i]}if(ret){break}}}else{ret=true}}else{if(this._components.isKnownTag(tagName)){ret=this._components.isTagAttrValue(tagName,attrName,attrValue)}}return ret};MetaLib.prototype.isTagAttrEnumValueDeprecated=function(tagName,attrName,enumValue){var member,ojv,values,deps,dep,i,j,ret=null;member=this._getTagAttrMemberObj(tagName,attrName);if(!member){return this._isCompTagAttrEnumDepr(tagName,attrName,enumValue)}if(!member.ojdeprecated){return null}if(ojv=this._getOjValues(member)){values=ojv.name;for(i=0;i<values.length;i++){if(values[i]===enumValue){deps=member.ojdeprecated;for(j=0;j<deps.length;j++){dep=deps[j];if(dep.target==="propertyValue"&&dep.for===enumValue){ret={type:DEPRECATED,since:dep.since,description:dep.description};break}}}if(ret){break}}}return ret};MetaLib.prototype._isCompTagAttrEnumDepr=function(tagName,attrName,enumValue){return this._components?this._components.isTagAttrEnumDeprecated(tagName,attrName,enumValue):null};MetaLib.prototype.hasTagSlot=function(tagName){return this._getSlots(tagName)?true:false};MetaLib.prototype.hasTagDynamicSlot=function(tagName){var tag,b=false;tag=_removeChevrons(tagName);if(this.isJetLegacyTag(tag)){}else if(this._components){b=this._components.hasTagDynamicSlot(tag)}return b};MetaLib.prototype.isTagSlotName=function(tagName,slotName){var tag,slot;tag=_removeChevrons(tagName);if(this.isJetLegacyTag(tag)){slot=this._getSlotByName(this._getComponentFromTag(tag),slotName)}else if(this._components){if(!HtmlUtils.isCommonElem(tag)){slot=this._components.hasTagSlotName(tag,slotName)}}return!!slot};MetaLib.prototype.isTagSlotValue=function(tagName,slotName){return this.isTagSlotName(tagName,slotName)};MetaLib.prototype.isTagDynamicSlotValue=function(tagName,slotName){};MetaLib.prototype.getPreferredSlotContent=function(tag,slot){var obj,ret=null;if(obj=this.getPreferredSlotContentEx(tag,slot)){ret=obj.interfaces}return ret};MetaLib.prototype.getPreferredSlotContentEx=function(tag,slot){var ret;tag=_removeChevrons(tag);if(this.isJetTag(tag)){ret=this.getJetPreferredSlotContent(tag,slot)}else if(this._components&&this._implements){ret=this._components.getPreferredSlotContent(tag,slot,this._implements)}return ret};MetaLib.prototype.getJetPreferredSlotContent=function(tag,slot){var clazz,slot,prefContent,content,comps;if(!this._implements){return null}if(clazz=this._getComponentFromTag(tag)){if(clazz.slot){if(slot=clazz.slot[slot]){if(prefContent=slot.ojpreferredcontent){prefContent.forEach(impl=>{if(content=this._implements[impl]){if(!comps){comps=[]}comps.push(...content)}})}}}else{{let defMem;if(clazz.member&&(defMem=clazz.member["Default"])&&defMem.ojchild){if(prefContent=defMem.ojpreferredcontent){prefContent.forEach(impl=>{if(content=this._implements[impl]){if(!comps){comps=[]}comps.push(...content)}})}}}}}return prefContent||comps?{interfaces:prefContent,components:comps}:null};MetaLib.prototype.getTagSlotMetadata=function(tag,slot){var ret;tag=_removeChevrons(tag);if(this.isJetTag(tag)){ret=this._getJetTagSlotMetadata(tag,slot)}else if(this._components){ret=this._components.getTagSlotMetadata(tag,slot)}return ret};MetaLib.prototype._getJetTagSlotMetadata=function(tag,slot){var o,slots,slot,ret=null;if(o=this._getComponentFromTag(tag)){if(o.slot&&(slots=o.slot[slot])){if(slots=slots.ojdeprecated){let i;for(i=0;i<slots.length;i++){slot=slots[i];if(!slot.type||slot.type===DEPRECATED){ret={type:DEPRECATED};if(slot.hasOwnProperty("since")){ret.since=slot.since}if(slot.hasOwnProperty("description")){ret.description=slot.description}break}}}}}return ret};MetaLib.prototype.isTagSupportedInTheme=function(tag){var o,a,ret=true;o=this._getComponentFromTag(tag);if(o){if(o.header){a=o.header.ojunsupportedthemes;ret=!(a&&a.includes(this._theme))}}else{ret=this._components&&this._components.isTagSupportedInTheme(tag,this._theme)}return ret};MetaLib.prototype.isAttrSupportedInTheme=function(tag,attr){var o,a,ret=true;o=this._getTagAttrMemberObj(tag,attr);if(o){a=o.ojunsupportedthemes;ret=!(a&&a.includes(this._theme))}else{ret=this._components.isAttrSupportedInTheme(tag,attr,this._theme)}return ret};MetaLib.prototype.hasTagCompPropSubprop=function(tagName,propName){var obj,ret=false;if(this.isCCATag(tagName)){obj=this._getComponentFromTag(tagName);if(obj&&obj.member){ret=obj.member[propName];ret=ret&&ret.submember}else if(this._components){ret=this._components.getTagProp(tagName,propName);ret=ret&&ret.properties}}return ret};MetaLib.prototype.isTagCompProp=function(tagName,propName){var obj,ret=false;if(this.isCCATag(tagName)){obj=this._getComponentFromTag(tagName);if(obj&&obj.member){ret=obj.member[propName]}else if(this._components){ret=this._components.isTagProp(tagName,propName)}}return ret};MetaLib.prototype.getTagAttrType=function(tag,attr){var member=this._getTagAttrMemberObj(tag,attr);return member?member.type:this._components.getTagPropType(tag,attr)};MetaLib.prototype.getTagPropType=function(tagName,propName){var ret;if(this._components){ret=this._components.getTagPropType(tagName,propName)}return ret};MetaLib.prototype.getTagAttrMetadata=function(tag,attr){var obj,member,req;var member=this._getTagAttrMemberObj(tag,attr);if(!member){if(this._components){obj=this._components.getTagProp(tag,attr)}}else{obj={type:member.type};if(member.deprecated||member.ojdeprecated){obj.deprecated=true}if(member.ojtranslatable){obj.translatable=true}if(req=this.getRequiredAttrs(tag)){for(let i=0;i<req.length;i++){if(req[i]===attr){obj.required=true;break}}}obj.type=member.type}return obj};MetaLib.prototype.getTagMetadata=function(tag){var obj,comp,hdr,events,props,event,ret;obj=this._getComponentFromTag(_removeChevrons(tag));if(obj){if(hdr=obj.hdr){comp={};comp.name=hdr.customelement;if(hdr.slot){comp[PROP_SLOTS]=obj.slots}}if(obj.properties){comp[PROP_PROPS]=props={};this._extractProps(props,null,obj.properties,obj.name)}if(obj.events){comp[PROP_EVENTS]=events={};for(event in obj.events){}}if(obj.implements){comp[PROP_IMPLEMENTS]=obj.implements}if(obj.extension&&obj.extension.theme&&obj.extension.theme.unsupportedThemes){comp[PROP_UNSUP_THEME]=obj.extension.theme.unsupportedThemes}if(hdr&&hdr.ojsubcomponenttype){comp[PROP_SUBCOMPONENT_TYPE]=hdr.subcomponenttype}}else if(this._components){ret=this._components.getTagMetadata(tag)}return ret};MetaLib.prototype.isTagStyleDeprecated=function(tagName,styleName){var o,ret;o=this.isWCStyleDeprecated(styleName);if(o){tagName=_removeChevrons(tagName);if(this._json.ojStyles.containers[o.index]===tagName){ret=o.dep.description}}return ret};MetaLib.prototype.isTagStyle=function(tagName,styleName){var obj,ret=false,compName,containers,indices,index,i;tagName=_removeChevrons(tagName);if(obj=this._getComponentFromTag(tagName)){compName=this._getComponentNameFromTag(tagName);containers=this._json.ojStyles.containers;indices=_getStyleIndices(this._json.ojStyles,styleName);if(indices){for(i=0;i<indices.length;i++){index=indices[i];if(index>=0){if(containers[index]===compName){ret=true;break}}}}}else{ret=this._components.isTagStyle(tagName)}return ret};MetaLib.prototype.isStyle=function(style){return this.isGenStyle(style)||this.isClassStyle(style)||this.isStylesetStyle(style)};MetaLib.prototype.isGenStyle=function(style){var x=this._json.genericStyles[style];return x||x===0?true:false};MetaLib.prototype.isJetStyle=function(style){return this._json.genericStyles[style]?"g":this._json.ojStyles[style]?"j":undefined};MetaLib.prototype.isCustomStyle=function(style){return this._components&&this._components.isStyle(style)};MetaLib.prototype.getStyleOrigin=function(style){var ret;if(this._json.genericStyles[style]){ret="g"}if(this._json.ojStyles[style]){ret=ret?"b":"j"}if(!ret&&this._components){if(this._components.isStyle(style)){ret="c"}}return ret};MetaLib.prototype.isClassStyle=function(style){var x=this._json.ojStyles[style];return x||x===0?true:false};MetaLib.prototype.isStylesetStyle=function(style){return this._stylesets?!!this._stylesets[style]:false};MetaLib.prototype.getStyleSelector=function(style,jet){var o,i,ret;if(typeof jet===BOOLEAN){o=jet?this._json.ojStyles[style]:this._json.genericStyles[style]}else{o=this._json.ojStyles[style];if(!o&&o!==0){o=this._json.genericStyles[style]}if(!o&&this._components){o=this._components.getStyleMetadata(style)}}if(this._utils.isObject(o)){if(o.styleselector){ret=o.styleselector}else if(o.meta){ret=o.meta.styleSelector}}else if(Array.isArray(o)){for(i=0;i<o.length;i++){if(this._utils.isObject(o[i])&&o[i].styleselector){if(!ret){ret=[]}ret.push(o[i].styleselector)}}if(ret&&ret.length===1){ret=ret[0]}}return ret?ret:null};MetaLib.prototype.isJetStylePrefix=function(s){var x;if(!s.startsWith(OJPREFIX)||!this._json.jetCssPrefixes.classes){return false}x=s.indexOf("-",3);if(x>=0){s=s.substring(0,x)}return this._json.jetCssPrefixes.classes.includes(s)};MetaLib.prototype.hasJetStylePrefixes=function(){return this._json.jetCssPrefixes&&this._json.jetCssPrefixes.classes};MetaLib.prototype.getClassesFromStyle=function(styleName,scope){var indices,oStyles,ret;scope=scope||"oj";if(scope==="oj"||scope==="both"){oStyles=this._json.ojStyles;if(oStyles){indices=_getStyleIndices(oStyles,styleName);if(indices){return _toContainers(oStyles,indices)}}}if(scope==="gen"||scope==="both"){oStyles=this._json.genericStyles;if(oStyles){indices=_getStyleIndices(oStyles,styleName);if(indices){ret=_toContainers(oStyles,indices)}}}return ret?ret:null};MetaLib.prototype.getJetTagFromStyle=function(styleName){var indices,oStyles,clazz;oStyles=this._json.ojStyles;if(oStyles){indices=_getStyleIndices(oStyles,styleName)}if(indices){if(indices.length>1||indices.length===0){clazz=null}else{clazz=this.isGenStyle(styleName)?null:_toContainers(oStyles,indices)}}return clazz?this.getTagFromClass(clazz):null};MetaLib.prototype.getJetTagsFromStyle=function(styleName){var indices,oStyles;oStyles=this._json.ojStyles;if(oStyles){indices=_getStyleIndices(oStyles,styleName);if(indices){return _toContainers(oStyles,indices,this._json)}}return null};MetaLib.prototype.getClassFromTag=function(tagName){return this._getComponentNameFromTag(_removeChevrons(tagName))};MetaLib.prototype.getClassFromModule=function(module){var clazz=this._json.moduleLookup[module];return clazz?clazz:null};MetaLib.prototype.getTagFromClass=function(className){if(className==="oj.ojTree"){return"oj-tree"}let ret=this._json[className];return ret&&ret.header?ret.header.customelement:null};MetaLib.prototype.isClass=function(className){var b=this._json[className];if(!b){if(className=this._classChange[className]){b=this._json[className]}}return!!b};MetaLib.prototype.isClassFinal=function(className){var clazz=this._json[className];if(!clazz){if(className=this._classChange[className]){clazz=this._json[className]}}return clazz&&clazz.header&&clazz.header.readonly};MetaLib.prototype.isClassMethod=function(className,methName){var clazz=this._json[className];return!!(clazz&&clazz.function&&clazz.function[methName])};MetaLib.prototype.isClassMethodStatic=function(className,methName){var meth,ret=null;var clazz=this._json[className];if(clazz&&clazz.function){meth=clazz.function[methName];ret=meth&&meth.scope&&meth.scope=="static"}return ret};MetaLib.prototype.getClassMethodScope=function(className,methName){var meth,ret=null;var clazz=this._json[className];if(clazz&&clazz.function){meth=clazz.function[methName];ret=meth.scope}return ret};MetaLib.prototype.isClassMember=function(className,memName){var clazz=this._json[className];return!!(clazz&&clazz.member&&clazz.member[memName])};MetaLib.prototype.isClassMemberStatic=function(className,memName){var mem,ret=null;var clazz=this._json[className];if(clazz&&clazz.member){mem=clazz.member[memName];ret=mem&&mem.scope&&mem.scope=="static"}return ret};MetaLib.prototype.getRequiredAttrs=function(tagName){let obj,clazz,i,ret=null;tagName=_removeChevrons(tagName);obj=this._getComponentFromTag(tagName);if(obj){clazz=this._getComponentNameFromTag(tagName)}ret=obj?this._reqAttrs[clazz]:this._components.getRequiredAttrs(tagName);if(obj&&ret&&ret.length){for(i=0;i<ret.length;i++){ret[i]=this._domUtils.kebabCase(ret[i])}}return ret};MetaLib.prototype.getTagsFromStyle=function(styleName){var classNames,tag,i,ret;ret=null;classNames=this.getClassesFromStyle(styleName);if(classNames){for(i=0;i<classNames.length;i++){tag=this.getTagFromClass(classNames[i]);if(tag){if(!ret){ret=[]}ret.push(tag)}}}return ret?ret:null};MetaLib.prototype.isStyleDeprecated=function(name){var s,o,t,i;s=this._json.genericStyles[name];if(!s&&s!==0&&this._json.ojStyles){s=this._json.ojStyles[name];if(!s&&s!==0&&this._stylesets){s=this._stylesets[name];return this._utils.isObject(s)?s:null}}if(s){t=typeof s;if(Array.isArray(s)){for(i=0;i<s.length;i++){o=s[0];if(typeof o===OBJECT){break}}}else if(t==="object"){o=s}else{o=null}}return o?o.dep:null};MetaLib.prototype.isStyleDeprecatedEx=function(style){var a=null,ss,t,i;function _pushSS(o){if(o.dep){if(!a){a=[]}a.push(o)}};function _stashSS(s){t=typeof s;if(Array.isArray(s)){for(i=0;i<s.length;i++){_pushSS(s[i])}}else if(t==="object"){_pushSS(s)}};if(ss=this._json.genericStyles[style]){_stashSS(ss)}if(ss=this._json.ojStyles[style]){_stashSS(ss)}else if(ss!==0&&this._stylesets){ss=this._stylesets[style];return this._utils.isObject(ss)?ss:null}return a};MetaLib.prototype.isWCStyleDeprecated=function(name){var s,o,t,i;s=this._json.ojStyles[name];if(s){t=typeof s;if(Array.isArray(s)){for(i=0;i<s.length;i++){o=s[i];if(typeof o===OBJECT){break}o=null}}else if(t==="object"){o=s}}return o?o:null};MetaLib.prototype.isBindingTag=function(tagName){var obj=this._getComponentFromTag(_removeChevrons(tagName));return obj&&obj.header?!!obj.header.ojbindingelement:false};MetaLib.prototype.isComponent=function(className){var obj=this._json[className];if(!obj){if(!className.startsWith("oj.")){obj=this._json["oj."+className]}}return!!obj};MetaLib.prototype.isClass=function(className){return!!this._json[className]};MetaLib.prototype.isJetComponentClass=function(className){return this.isClass(className)};MetaLib.prototype.isComponentDeprecated=function(className){return this.isClassDeprecated(className)};MetaLib.prototype.isClassDeleted=function(className){var classes,cn,version=null;if(this._delHist){if(classes=this._delHist.classes){cn=this._classChange[className];if(cn){className=cn}version=classes[className]}}return version};MetaLib.prototype.isClassRenamed=function(className){return this._renHist?this._renHist[className]:null};MetaLib.prototype.isClassDeprecated=function(className){var obj,ret=null;if(className==="oj.ojTree"){if(SemVer.gte(this._jetVer,"5.2.0")){return null}else{return{type:DEPRECATED,description:"Use ojTreeView instead"}}}if(!(obj=this._json[className])){className=this._classChange[className];obj=className?this._json[className]:undefined}if(obj){if(obj.header){ret=this._isClassDeprecated(obj.header)}if(!ret){ret=this._isClassDeprecated(obj)}}return ret};MetaLib.prototype._isClassDeprecated=function(obj){var depr,status,ret=null;if(obj){if(obj.ojdeprecated&&obj.ojdeprecated.length){depr=obj.ojdeprecated;for(status of depr){ret=status;break}}else if(depr=obj.deprecated){ret={type:DEPRECATED,description:typeof depr===BOOLEAN?NO_SUGGESTION_AVAIL:depr}}}return ret};MetaLib.prototype.isClassMethodDeleted=function(className,methodName){var a,cn,i,ret=null;a=this._deletedMethods[methodName];if(a){cn=this._classChange[className];if(cn){className=cn}for(i=0;i<a.length;i++){if(a[i]===className){ret=a[i+1];break}i++}}return ret};MetaLib.prototype.isClassMethodDeprecated=function(className,methodName){var obj,method,ret=null;obj=this._json[className];if(!obj){className=this._classChange[className];obj=className?this._json[className]:undefined}if(obj&&obj.function){for(method in obj.function){if(method===methodName){method=obj.function[method];ret=this._isSubStateDeprecated(method);break}}}return ret};MetaLib.prototype.isClassMemberDeleted=function(className,memberName){var a,i,cname,ret=null;a=this._deletedMembers[memberName];if(a){cname=this._classChange[className];for(i=0;i<a.length;i++){if(a[i]===className||a[i]===cname){ret=a[i+1];break}i++}}return ret};MetaLib.prototype.isClassMemberDeprecated=function(className,memName){var obj,member,obj,ret=null;obj=this._json[className];if(!obj){className=this._classChange[className];obj=className?this._json[className]:undefined}if(obj&&obj.member){memName=memName.charAt(0)===":"?memName.substr(1):memName;for(member in obj.member){if(member===memName){member=obj.member[memName];ret=this._isSubStateDeprecated(member,true);break}}}return ret};MetaLib.prototype.isClassAttrDeprecated=function(className,attrName){var obj,member,ret=null;obj=this._json[className];attrName=attrName.charAt(0)===":"?attrName.substr(1):attrName;if(obj&&obj.member){for(member in obj.member){member=obj.member[member];if(attrName===member.name){ret=this._isSubStateDeprecated(member,true);break}}}return ret};MetaLib.prototype.isComponentDeleted=function(className){return this.isClassDeleted(className)};MetaLib.prototype.isComponentAttrDeprecated=function(className,attrName){return this.isClassAttrDeprecated(className,attrName)};MetaLib.prototype.isComponentMethodDeprecated=function(className,methodName){return this.isClassMethodDeprecated(className,methodName)};MetaLib.prototype.isComponentMemberDeprecated=function(className,memberName){return this.isClassMemberDeprecated(className,memberName)};MetaLib.prototype.isComponentMethodDeleted=function(className,methodName){return this.isClassMethodDeleted(className,methodName)};MetaLib.prototype.isComponentMemberDeleted=function(className,memberName){return this.isClassMemberDeleted(className,memberName)};MetaLib.prototype.isTagPackPrivate=function(tag){var o,ret;tag=_removeChevrons(tag);if(this.isJetTag(tag)){if(o=this._getComponentFromTag(tag)){ret=o.header&&o.header.ojsubcomponenttype===PACK_PRIVATE}}else if(this._components){ret=this._components.isTagPackPrivate(tag)}return ret};MetaLib.prototype.isTagAttrTranslatable=function(tag,attr){var member=this._getTagAttrMemberObj(tag,attr);return member?this._isSubStateTranslatable(member):this._components.isTagAttrTranslatable(tag,attr)};MetaLib.prototype.isTagAttrReadOnly=function(tag,attr){var o,ret=false;tag=_removeChevrons(tag);if(o=this._getTagAttrMemberObj(tag,attr)){ret=o&&o.readonly}else if(this._components){ret=this._components.isTagAttrReadOnly(tag,attr)}return ret};MetaLib.prototype.hasTagDataOjCommand=function(tagName){var obj,ret=false,compName,containers,indexes,i;tagName=_removeChevrons(tagName);obj=this._getComponentFromTag(tagName);if(obj){compName=this._getComponentNameFromTag(tagName);indexes=this._json.dataOjCommand;if(indexes){containers=this._json.ojStyles.containers;for(i=0;i<indexes.length;i++){if(containers[indexes[i]]===compName){ret=true;break}}}}return ret};MetaLib.prototype.isTagEvent=function(tagName,eventName){var obj,attr,x,ret=false;eventName=eventName.charAt(0)===":"?eventName.substring(1):eventName;if(!eventName.startsWith(EVENT_PREFIX)){return ret}if(this.isWCTag(tagName)){if(this._getComponentNameFromTag(tagName)){obj=this._getComponentFromTag(_removeChevrons(tagName));if(obj&&obj.htmlevents){ret=!!obj.htmlevents[eventName]}if(!ret){if((x=eventName.lastIndexOf("-changed"))>=0){attr=eventName.substring(3,x);attr=this._domUtils.camelCase(attr);ret=!!obj.member[attr]}}}else{ret=this._components&&this._components.isTagEvent(tagName,eventName)}if(!ret){ret=HtmlUtils.isCommonEventAttr(eventName)}}return ret};MetaLib.prototype.isTagMaintenance=function(tag){var clazz,ret;if(clazz=this._getComponentNameFromTag(_removeChevrons(tag))){}else{ret=this._components.isTagMaintenance(tag)}return ret};MetaLib.prototype.isTagSupersedes=function(tag){var clazz,ret;if(clazz=this._getComponentNameFromTag(_removeChevrons(tag))){}else{ret=this._components.isTagSupersedes(tag)}return ret};MetaLib.prototype.getTagMaintenanceStatus=function(tag){return this._getTagStatus(tag,MAINTENANCE)};MetaLib.prototype.getTagSupersedesStatus=function(tag){return this._getTagStatus(tag,SUPERSEDES)};MetaLib.prototype.getTagStatus=function(tag,type){var clazz,ret=null;if(type!==DEPRECATED&&type!==MAINTENANCE&&type!==SUPERSEDES){return null}if(clazz=this._getComponentNameFromTag(_removeChevrons(tag))){if(clazz==="oj.ojTree"){if(SemVer.gte(this._jetVer,"5.2.0")){return null}else{return{type:DEPRECATED,description:"Use ojTreeView instead"}}}let obj=this._json[clazz];if(obj&&obj.header){let arStat;if(Array.isArray(arStat=obj.header.ojdeprecated)){let stat,i,found;for(i=0;i<arStat.length;i++){stat=arStat[i];if(!stat.type){found=DEPRECATED}else if(stat.type===type){found=type}if(found===type){ret={type:found};if(stat.hasOwnProperty("since")){ret.since=stat.since}if(stat.hasOwnProperty("description")){ret.description=stat.description}break}}}else if(typeof arStat===STRING){ret={description:arStat}}}}else{ret=this._components.getTagStatus(tag,type)}return ret};MetaLib.prototype.applySchema=function(obj){return this._compSvcs.validateComponentJsonWithSchema(obj)};MetaLib.prototype.walkElemStackForOJTag=function(ctx,excludeBindIf){var i,name,ret=null;var stack=ctx.elemStack;if(stack&&stack.length){for(i=stack.length-1;i>=0;i--){name=stack[i].name;if(name.toLowerCase().startsWith(OJPREFIX)){if(!name.startsWith("oj-bind-")||!excludeBindIf){ret=name;break}}}}return ret};MetaLib.prototype.walkDomStackForOJTag=function(ctx,excludeBindIf){return this.walkElemStackForOJTag(ctx,excludeBindIf)};MetaLib.prototype.getPublicInterface=function(){return{isJetTag:this.isJetTag.bind(this),isWCTag:this.isWCTag.bind(this),isComponentTag:this.isComponentTag.bind(this),isTagDeprecated:this.isTagDeprecated.bind(this),isTagSupportedInTheme:this.isTagSupportedInTheme.bind(this),isAttrSupportedInTheme:this.isAttrSupportedInTheme.bind(this),isTagAttrDeprecated:this.isTagAttrDeprecated.bind(this),isTagAttrTranslatable:this.isTagAttrTranslatable.bind(this),isTagAttrReadOnly:this.isTagAttrReadOnly.bind(this),isTagEventDeprecated:this.isTagEventDeprecated.bind(this),isTagAttrEnumValueDeprecated:this.isTagAttrEnumValueDeprecated.bind(this),isTagAttr:this.isTagAttr.bind(this),isJetTagAttr:this.isJetTagAttr.bind(this),hasTagAttrValues:this.hasTagAttrValues.bind(this),isTagAttrValue:this.isTagAttrValue.bind(this),getTagAttrType:this.getTagAttrType.bind(this),getTagAttrMetadata:this.getTagAttrMetadata.bind(this),getTagMetadata:this.getTagMetadata.bind(this),isTagCompProp:this.isTagCompProp.bind(this),hasTagCompPropSubprop:this.hasTagCompPropSubprop.bind(this),getTagPropType:this.getTagPropType.bind(this),hasTagSlot:this.hasTagSlot.bind(this),isTagSlotName:this.isTagSlotName.bind(this),isTagSlotValue:this.isTagSlotValue.bind(this),getPreferredSlotContent:this.getPreferredSlotContent.bind(this),getPreferredSlotContentEx:this.getPreferredSlotContentEx.bind(this),getTagSlotMetadata:this.getTagSlotMetadata.bind(this),hasTagDataOjCommand:this.hasTagDataOjCommand.bind(this),isBindingTag:this.isBindingTag.bind(this),isTagPackPrivate:this.isTagPackPrivate.bind(this),isTagMaintenance:this.isTagMaintenance.bind(this),isTagSupersedes:this.isTagSupersedes.bind(this),getTagMaintenanceStatus:this.getTagMaintenanceStatus.bind(this),getTagSupersedesStatus:this.getTagSupersedesStatus.bind(this),getTagStatus:this.getTagStatus.bind(this),isClass:this.isClass.bind(this),isClassRenamed:this.isClassRenamed.bind(this),isClassDeleted:this.isClassDeleted.bind(this),isClassDeprecated:this.isClassDeprecated.bind(this),isClassMethodDeleted:this.isClassMethodDeleted.bind(this),isClassMemberDeleted:this.isClassMemberDeleted.bind(this),isClassMethodDeprecated:this.isClassMethodDeprecated.bind(this),isClassMemberDeprecated:this.isClassMemberDeprecated.bind(this),isClassAttrDeprecated:this.isClassAttrDeprecated.bind(this),isClassFinal:this.isClassFinal.bind(this),isClassMethod:this.isClassMethod.bind(this),isClassMethodStatic:this.isClassMethodStatic.bind(this),isClassMember:this.isClassMember.bind(this),isClassMemberStatic:this.isClassMemberStatic.bind(this),getClassMethodScope:this.getClassMethodScope.bind(this),getStyleOrigin:this.getStyleOrigin.bind(this),isJetStyle:this.isJetStyle.bind(this),isCustomStyle:this.isCustomStyle.bind(this),isTagStyle:this.isTagStyle.bind(this),isStyle:this.isStyle.bind(this),isGenStyle:this.isGenStyle.bind(this),isClassStyle:this.isClassStyle.bind(this),isStylesetStyle:this.isStylesetStyle.bind(this),isStyleDeprecated:this.isStyleDeprecated.bind(this),isStyleDeprecatedEx:this.isStyleDeprecatedEx.bind(this),getStyleSelector:this.getStyleSelector.bind(this),getNonSSStyleElems:this.getNonSSStyleElems.bind(this),isJetStylePrefix:this.isJetStylePrefix.bind(this),hasJetStylePrefixes:this.hasJetStylePrefixes.bind(this),isTagEvent:this.isTagEvent.bind(this),getTagsFromStyle:this.getTagsFromStyle.bind(this),getJetTagFromStyle:this.getJetTagFromStyle.bind(this),getJetTagsFromStyle:this.getJetTagsFromStyle.bind(this),getClassesFromStyle:this.getClassesFromStyle.bind(this),getClassFromTag:this.getClassFromTag.bind(this),getClassFromModule:this.getClassFromModule.bind(this),getTagFromClass:this.getTagFromClass.bind(this),getDeprecatedMethodList:this.getDeprecatedMethodList.bind(this),getDeprecatedMemberList:this.getDeprecatedMemberList.bind(this),getDeletedMethodList:this.getDeletedMethodList.bind(this),getDeletedMemberList:this.getDeletedMemberList.bind(this),getRequiredAttrs:this.getRequiredAttrs.bind(this),isComponent:this.isComponent.bind(this),isNSRegistered:this.isNSRegistered.bind(this),isNamespacePrefix:this.isNamespacePrefix.bind(this),isRuleIgnored:this.isRuleIgnored.bind(this),getRenamedClassList:this.getRenamedClassList.bind(this),getDeletedClassList:this.getDeletedClassList.bind(this),processImplements:this.processImplements.bind(this),getInterfaces:this.getInterfaces.bind(this),getImplementers:this.getImplementers.bind(this),getSubcomponentType:this.getSubcomponentType.bind(this),getWCInterfaces:this.getWCInterfaces.bind(this),hasWCInterfaces:this.hasWCInterfaces.bind(this),hasJetWCInterfaces:this.hasJetWCInterfaces.bind(this),getMetaVers:this.getMetaVers.bind(this),walkElemStackForOJTag:this.walkelemStackForOJTag,walkDomStackForOJTag:this.walkDomStackForOJTag,isIgnoreAttr:this.isIgnoreAttr.bind(this),applySchema:this.applySchema.bind(this),getRevisionInfo:this.getRevisionInfo.bind(this)}};MetaLib.prototype.loadMeta=function(metaFile){var metaObj,ret=false;if(!this._json){try{if(metaObj=this._nd.metaLoader.loadMeta(metaFile,this._nd,this._fsUtils)){this._json=metaObj.meta;this._delHist=metaObj.delMeta;this._renHist=metaObj.renMeta;this._reqAttrs=metaObj.reqattr;this._jetVer=this._json.meta.jetversion;this._ignoreRules=metaObj.ignoreRules;this._createNonClassList(this._json.meta);this._createModuleLookup();this._createClassNameChanges();this._fixup_jet_42315();this._createImplements();ret=true}else{this._error(`Metadata '${metaFile}' not found!`)}}catch(e){this._error(`[${e.name}]: Metadata load (${metaFile}) - ${e.message}`)}}return ret};MetaLib.prototype.getRenamedClassList=function(){return this._renHist};MetaLib.prototype.getDeletedClassList=function(){return this._delHist};MetaLib.prototype.processImplements=function(tag,impls){if(Array.isArray(impls)&&this._implements){impls.forEach(impl=>{if(this._implements[impl]){this._implements[impl].push(tag)}else{this._implements[impl]=[tag]}})}};const OJV_CHARS=/[<>]/;MetaLib.prototype._getOjValues=function(mem){var ts,ret;if(!mem){return false}if(mem.ojvalues){if(mem.ojvalues.name&&Array.isArray(mem.ojvalues.name)&&mem.ojvalues.name.length){return mem.ojvalues}return}if(mem.tstype&&mem.tstype.m_ojvalues){return mem.tstype.m_ojvalues}ts=this._getTsTypeObject(mem);if(ts&&ts.ojvalues&&ts.ojvalues.name){if(Array.isArray(ts.ojvalues.name)&&ts.ojvalues.name.length){ret=ts.ojvalues}}return ret};MetaLib.prototype.getImplementers=function(ifc){var ret;if(this._implements&&ifc){ret=this._implements[ifc]}return ret||null};MetaLib.prototype.getInterfaces=function(tag){var obj,hdr,impls,ret;if(!tag){return null}tag=_removeChevrons(tag);if(this.isJetTag(tag)){if(obj=this._getComponentFromTag(tag)){if(hdr=obj.header){if(hdr.domInterface&&hdr.customelement){impls=hdr.domInterface;ret=Array.isArray(impls)?impls:[impls]}}}}else if(this.isComponentTag(tag)){ret=this._components.getInterfaces(tag)}return ret||null};MetaLib.prototype.getWCInterfaces=function(){return this._implements};MetaLib.prototype.hasJetWCInterfaces=function(){return this._hasJetWCIFCs};MetaLib.prototype.hasWCInterfaces=function(){return!!this._implements};MetaLib.prototype.getSubcomponentType=function(tag){var obj,hdr,ret;if(tag=_removeChevrons(tag)){if(this.isJetTag(tag)){if(obj=this._getComponentFromTag(tag)){if(hdr=obj.header){ret=hdr.ojsubcomponenttype}}}else if(this.isComponentTag(tag)){ret=this._components.getSubcomponentType(tag)}}return ret||null};MetaLib.prototype._createNonClassList=function(mp){this._nonClasses=mp.nonClasses?mp.nonClasses:["genericStyles","ojStyles"];this._nonClasses.push("moduleLookup");this._nonClasses.push("newGenericStyles");this._nonClasses.push("newOjStyles");if(!this._nonClasses.includes("custElementClassLookup"))this._nonClasses.push("custElementClassLookup");if(!this._nonClasses.includes("meta"))this._nonClasses.push("meta");if(!this._nonClasses.includes("ResponsivePrefixes"))this._nonClasses.push("ResponsivePrefixes")};MetaLib.prototype.setAmdMeta=function(obj){this._json=obj.jetMeta.meta;this._delHist=obj.jetMeta.delMeta;this._reqAttrs=obj.jetMeta.reqattr;this._jetVer=this._json.meta.jetversion;this._createNonClassList(this._json.meta);this._createModuleLookup();return true};MetaLib.prototype.setTheme=function(theme){this._theme=theme};MetaLib.prototype._createModuleLookup=function(){var comps,compName,lookup,hdr;if(this._json.moduleLookup){return}this._json.moduleLookup=lookup={};comps=this._json;for(compName in comps){if(!this._nonClasses.includes(compName)&&!compName.startsWith("oj.__")){hdr=comps[compName].header;if(hdr){lookup[OJS+hdr.name.toLowerCase()]=compName}}}};MetaLib.prototype._createClassNameChanges=function(){var comps,compName,o,hdr;if(this._classChange=this._json.meta.isClassNameChanges){return}this._classChange=o={};comps=this._json;for(compName in comps){if(!this._nonClasses.includes(compName)){hdr=comps[compName].header;if(hdr&&compName!==hdr.name){o[hdr.name]=compName}}}this._json.meta.isClassNameChanges=true};MetaLib.prototype._fixup_jet_42315=function(){var o;if(SemVer.gte(this._jetVer,"8.0.0")){if(o=this._json.Color||this._json["oj.Color"]||this._json["oj.ojColor"]){if(!o.header){o.header={}}o.header.readonly=true}}};MetaLib.prototype._createImplements=function(){var clazzes,clazz,tag,impls,impl,o={},a,hdr;if(this._implements=this._json.meta.interfaces){return}clazzes=this._json;for(clazz in clazzes){if(this._nonClasses.includes(clazz)){continue}if(hdr=clazzes[clazz].header){if(hdr.domInterface&&hdr.customelement){impls=hdr.domInterface;impls=Array.isArray(impls)?impls:[impls];for(impl of impls){if(o[impl]){a=o[impl]}else{o[impl]=a=[]}this._hasJetWCIFCs=true;tag=this.getTagFromClass(clazz);if(tag&&!a.includes(tag)){a.push(tag)}}}}}this._implements=this._hasJetWCIFCs?o:null};MetaLib.prototype.getMetaVers=function(){return{versions:this._jetVersions,runver:this._jetVer}};MetaLib.prototype.setComponentsLib=function(compSvcs,comps){if(compSvcs){this._compSvcs=compSvcs}if(comps){this._components=comps}};MetaLib.prototype.addIgnoredRules=function(component,reqType,reqVal,rules){var obj;if(!this._ignoreRules){this._ignoreRules=[]}if(!(obj=this._ignoreRules[component])){this._ignoreRules[component]=obj={}}obj[reqType]={name:reqVal,rules:rules}};MetaLib.prototype.setStylesets=function(ss){if(!ss){return}var o,obj,e,i;if(!this._stylesets){this._stylesets=obj={}}else{obj=this._stylesheets}for(i=0;i<ss.length;i++){o=ss[i];if(typeof o===STRING){obj[o]=true}else if(o.deprecated){obj[o.deprecated]=e={};if(o.since){e.since=o.since}if(o.note){e.description=o.note}else if(o.description){e.description=o.description}}}};MetaLib.prototype.setDomUtils=function(du){this._domUtils=du};MetaLib.prototype.getRevisionInfo=function(){var metaSect=this._json.meta;var revision="";return{revision:revision,tag:metaSect.jetrevision,jetVersion:metaSect.jetversion,date:metaSect.date,time:metaSect.time}};MetaLib.prototype._isSubStateDeprecated=function(obj,isMember){var depr,retStatus=null,o;if(!obj){return false}if(obj.ojdeprecated&&obj.ojdeprecated.length){retStatus=[];depr=obj.ojdeprecated;depr.forEach(status=>{o={type:DEPRECATED};if(status.hasOwnProperty("target")){o.target=status.target;if(isMember&&status.target==="memberType"){o.target="propertyType"}}if(status.hasOwnProperty("description")){o.description=status.description}if(status.hasOwnProperty("since")){o.since=status.since}if(status.hasOwnProperty("for")){o.value=[status.for]}else if(status.hasOwnProperty("value")){o.value=status.value}retStatus.push(o)});retStatus=retStatus.length?retStatus:null}else if(depr=obj.deprecated){retStatus=typeof depr===BOOLEAN?NO_SUGGESTION_AVAIL:depr;retStatus=[{type:DEPRECATED,description:retStatus}]}return retStatus};MetaLib.prototype._isSubStateTranslatable=function(obj){return obj&&obj.ojtranslatable};MetaLib.prototype._getComponentNameFromTag=function(tagName){tagName=tagName.toLowerCase();return this._json.custElementClassLookup[tagName]?this._json.custElementClassLookup[tagName]:null};MetaLib.prototype.isIgnoreAttr=function(tagName,attrName){var ret=false;attrName=attrName.toLowerCase();attrName=attrName.charAt(0)===":"?attrName.substr(1):attrName;if(HtmlUtils.isCommonElem(attrName)||attrName.startsWith("aria-")){return true}if(tagName==="oj-avatar"){if(attrName==="src"||attrName==="initials")ret=true}else if(tagName==="oj-option"){if(attrName==="value")ret=true}return ret};MetaLib.prototype.getDeprecatedMethodList=function(){if(this._deprecatedMethods){return this._deprecatedMethods}var json=this._json;var name,methName,methObj,o,a;var ret={};for(name in json){o=json[name];if(o&&o.function){for(methName in o.function){methObj=o.function[methName];if(methObj.ojdeprecated){if(ret[methName]){a=ret[methName]}else{ret[methName]=a=[]}a.push(name)}}}}return this._deprecatedMethods=ret};MetaLib.prototype.getDeprecatedMemberList=function(){if(this._deprecatedMembers){return this._deprecatedMembers}var json=this._json;var name,memName,memObj,o,a;var ret={};for(name in json){o=json[name];if(o&&o.member){for(memName in o.member){memObj=o.member[memName];if(memObj.ojdeprecated){if(ret[memName]){a=ret[memName]}else{ret[memName]=a=[]}a.push(name)}}}}return this._deprecatedMembers=ret};MetaLib.prototype.getDeletedMethodList=function(){if(this._deletedMethods){return this._deletedMethods}var json=this._delHist;var name,methName,ver,o,a;var ret={};if(json){for(name in json){o=json[name];if(o&&o.methods){for(methName in o.methods){ver=o.methods[methName];if(ret[methName]){a=ret[methName]}else{ret[methName]=a=[]}a.push(name);a.push(ver)}}}}return this._deletedMethods=ret};MetaLib.prototype.getDeletedMemberList=function(){if(this._deletedMembers){return this._deletedMembers}var json=this._delHist;var name,memName,ver,o,a;var ret={};if(json){for(name in json){o=json[name];if(o&&o.members){for(memName in o.members){ver=o.members[memName];if(ret[memName]){a=ret[memName]}else{ret[memName]=a=[]}a.push(name);a.push(ver)}}}}return this._deletedMembers=ret};MetaLib.prototype._getSlots=function(tagName){var obj=this._getComponentFromTag(_removeChevrons(tagName));return this._getSlots2(obj)};MetaLib.prototype._getSlots2=function(base){var bases,base,i,ret=null;while(base){ret=base&&base.slot?base.slot:null;if(ret){break}bases=base.header&&base.header.augments?base.header.augments:null;if(!bases){break}for(i=0;i<bases.length;i++){base=this._json[bases[i]];ret=this._getSlots2(base);if(ret){base=null;break}}}return ret?ret:null};MetaLib.prototype._getSlotByName=function(base,slotName){var ret=null;while(base){ret=base&&base.slot?base.slot:null;if(ret){ret=base.slot[slotName];if(ret){break}}break}return ret?ret:null};MetaLib.prototype._getComponentFromTag=function(tagName){var o=this._getComponentNameFromTag(tagName);if(o){o=this._json[o]}return o?o:null};function _getStyleIndices(scope,styleName){var a,n,ret,i;a=scope[styleName];if(a||a===0){if(!ret){ret=[]}if(Array.isArray(a)){for(i=0;i<a.length;i++){n=a[i];if(typeof n===OBJECT){n=a[i].index}ret.push(n)}}else{if(typeof a===OBJECT){n=a.index}else{n=a}ret.push(n)}}return ret&&ret.length?ret:null};MetaLib.prototype.getNonSSStyleElems=function(styleName,scope){var a,n,ret,i;scope=scope?this._json.ojStyles:this._json.genericStyles;a=scope[styleName];if(a||a===0){if(!ret){ret=[]}if(Array.isArray(a)){for(i=0;i<a.length;i++){n=a[i];if(typeof n===OBJECT&&!n.styleselector){n=a[i].index}ret.push(n)}}else{if(typeof a===OBJECT&&!a.styleselector){n=a.index}else{n=a}ret.push(n)}}return ret&&ret.length?_toContainers(scope,ret,this._json):null};MetaLib.prototype.displayImpls=function(){var impls,impl;this._console("[info] :--------- JET Interfaces Implemented ---------","I");if(!(impls=this._implements)){this._console(" None!","I")}else{for(impl in impls){this._console(`${impl} : <- <${impls[impl].join(",")}>`,"I")}}this._console("[info]: -------- End Declared Web Components ---------\n","I")};function _toContainers(scope,indices,json){var cont,ret,clazz,elem,n,i;cont=scope.containers;for(i=0;i<indices.length;i++){n=indices[i];if(n>=0){if(!ret){ret=[]}if(!json){ret[i]=cont[n]}else{clazz=cont[n];elem=json[clazz];if(elem&&elem.header){elem=elem.header.customelement;if(elem){ret[i]=elem}}}}}return ret&&ret.length?ret:null};function _convertValue(valType,value){var retValue=value;if(valType===STRING){retValue=value}else if(valType==="number"){retValue=Number(value)}else if(valType==="boolean"){retValue=value.toLowerCase()==="true"}return retValue};function _removeChevrons(tagName){if(tagName){let len=tagName.length-1;let start=tagName.charAt(0)==="<"?1:0;let end=tagName.charAt(len)===">"?len:++len;tagName=tagName.substring(start,end)}return tagName};module.exports=MetaLib;
|
package/lib/OjCPack.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
const PACK_PATH="node_modules/@oracle/oracle-jet-core-pack/oj-c/metadata";const ALLCOMP_JSON="allComponents.json";const LOAD_MSG="Loading Jet Core Pack (oj-c)...";const BOOLEAN="boolean";function Ojc(isOJet,isAMD,cwd,msgCtx,nd,fsUtils){this._isOJet=!!isOJet;this._isAMD=isAMD;this._nd=nd;this._cwd=cwd.replace(/\\/g,"/");this._fsUtils=fsUtils;this._msgCtx=msgCtx;this._fp=undefined;this._components=null}Ojc.prototype.getComponents=function(){return this._components};Ojc.prototype.setPath=function(fp){if(!this._isAMD){if(fp&&this._fsUtils.getFileType(fp)==="d"){fp=this._nd.path.join(fp,ALLCOMP_JSON)}else if(typeof fp===BOOLEAN){fp=null}}this._fp=fp};Ojc.prototype.load=function(){var o,comps,comp,isPath,info=this._msgCtx.info;if(!this._isAMD){if(this._fp===null){return this._components};if(this._fp===undefined){this._fp=this._nd.path.join(this._cwd,PACK_PATH,ALLCOMP_JSON)}else{isPath=true}if(!this._fsUtils.fileExists(this._fp)){let m=`Jet Core Pack metadata not found at '${this._fp}' [JAF-9015]\n`;let fn=isPath?this._msgCtx.error:this._msgCtx.warn;fn(m);return}info(LOAD_MSG);if(!(o=this._fsUtils.readJsonSync(this._fp,false,false))){this.msgCtx.error("Failed to read oj-c- pack allComponents.json");return false}else if(typeof o==="string"){this.msgCtx.error(o);return}comps=o.components}else{comps=this._fp;info(LOAD_MSG)}if(comps){let n=0;for(comp in comps){n++;if(!this._components){this._components={}}this._components[comp]=comps[comp]}info(` ... ${n} components loaded`)}return this._components};module.exports=Ojc;
|
package/lib/OjetLib.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
function OJetLib(ojetConfig,tsConfig,appPath){this._ojetConfig=ojetConfig;this._tsConfig=tsConfig;this._appPath=appPath;this._isVDom=false;let arch;if(arch=this.getConfigProperty("architecture")){this._isVDom=arch==="vdom"}};OJetLib.prototype.getConfig=function(){return this._ojetConfig};OJetLib.prototype.getTsConfig=function(){return this._tsConfig};OJetLib.prototype.getConfigProperty=function(prop){return _getProp(this._ojetConfig,prop)};OJetLib.prototype.getTsConfigProperty=function(prop){return _getProp(this._tsConfig,prop)};OJetLib.prototype.getAppPath=function(){return this._appPath};OJetLib.prototype.isVDom=function(){return this._isVDom};function _getProp(obj,prop){var ret;if(obj){let props=prop.split(".");let p;for(let i=0;i<props.length;i++){p=props[i];if(obj.hasOwnProperty(p)){ret=obj[p];if(i+1<props.length){if(Array.isArray(ret)||typeof ret!=="object"){ret=null;break}obj=ret}continue}ret=null;break}}return ret};module.exports=OJetLib;
|
package/lib/Registry.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 RULE_RE=new RegExp(/[~`!#$%\^&*+\[\]\\';,/{}|\\"\?]/);var Registry=function(appCtx){this._registry={};this._regexps={};this._reObjs={};this._appCtx=appCtx;this._info=appCtx.info;this._assert=appCtx.assert};Registry.prototype.getRegisteredCallbacks=function(type){var reo,ret;ret=this._registry[type];if(!type.startsWith("css-")&&type.indexOf("-")>0&&type.indexOf("|")<0){ret={...ret};type=type.substring(1,type.length-1).trim();for(re in this._regexps){reo=this._reObjs[re];if(reo&&reo.test(type)){if(!ret){ret={}}for(x in this._regexps[re]){ret[x]=this._regexps[re][x]}}};}return ret};Registry.prototype.isRegisteredCallback=function(type){return!!this._registry[type]};Registry.prototype.isRegisteredCallbackRE=function(elem){var ret,i;if(ret=this.isRegisteredCallback(elem)){return ret}elem=elem.startsWith("<")?elem.substring(1,elem.length-1):elem;for(re in this._regexps){if(this._reObjs[re].test(elem)){return true}}return false};Registry.prototype.setRuleCallback=function(ruleName,ruleRegs,rsi){var typeObj,regType,rt,callbacks,func,args,elem;for(regType in ruleRegs){func=ruleRegs[regType];if(typeof func!=="function"){this._info(`Rule ${ruleName} : registered '${regType}' is not a function`);continue}rt=elem=regType;if(regType.charAt(0)==="<"){rt=regType.substring(1,regType.length-1).trim();args=rt.split(" ");if(args.length>1){attrib=args[args.length-1];if(attrib.endsWith("=")){rt=args[0]+"|"+attrib.substring(0,attrib.length-1)}elem=args[0]}else{elem=rt.endsWith("=")?null:rt}regType=`<${rt}>`}if(!elem||!_isRE(elem)){if(!(typeObj=this._registry[regType])){this._registry[regType]=typeObj={}}}else{if(!(typeObj=this._regexps[rt])){this._regexps[rt]=typeObj={}}if(!this._reObjs[rt]){this._reObjs[rt]=new RegExp(rt)}}if(!(callbacks=typeObj[ruleName])){typeObj[ruleName]=callbacks=[]}callbacks.push({cb:func,rsi:rsi})}};Registry.prototype.XXsetRuleCallback=function(ruleName,ruleRegs,rsi){var typeObj,callbackType,ruleCallbacks,func;if(Array.isArray(ruleRegs)){var jj=this._setRuleCallback2(ruleName,ruleRegs)}else if(typeof ruleRegs!=="object"){return}else if(ruleRegs.cb){let regs=this._setExtended(ruleName,ruleRegs,rsi);if(regs){ruleRegs=regs}}for(callbackType in ruleRegs){func=ruleRegs[callbackType];if(typeof func!=="function"){this._info("Rule "+ruleName+" : registered '"+callbackType+"' is not a function");continue}typeObj=this._registry[callbackType];if(!typeObj){this._registry[callbackType]=typeObj={}}ruleCallbacks=typeObj[ruleName];if(!ruleCallbacks){typeObj[ruleName]=ruleCallbacks=[]}ruleCallbacks.push({cb:func,rsi:rsi})}};Registry.prototype.XXsetRuleCallback2=function(ruleName,regs,rsi){var a,i,j,props,prop,reg,val;for(i=0;i<regs.length;i++){reg=regs[i];if(!reg.cb){if(!a){a=[]}a.push(reg);continue}props=Object.keys(reg);if(props.length===2){for(j=0;j<props.length;j++){prop=props[j];if(prop!=="cb"){val=reg[prop];if(typeof val==="boolean"&&val){a.push({prop:val});break}}}continue}}};Registry.prototype.dump=function(){var type,rule,vals,tagWidth,tagLen=0,indent,isFirst,s="";var list2={},ruleWidth,ruleLen=0,source,i;for(type in this._registry){if(type.length>tagLen){tagLen=type.length}}for(type in this._regexps){if(type.length>tagLen){tagLen=type.length}}tagWidth=tagLen+3;indent=" ".repeat(tagWidth);s="\n"+ljustify("--- Tags ---",indent.length,indent)+"----- rules -----";source=this._registry;for(i=0;i<2;i++){for(type in source){s+="\n"+ljustify(type,tagWidth,indent);vals=source[type];isFirst=true;for(rule in vals){s+=(isFirst?"":indent)+rule+"\n";isFirst=false;if(!list2[rule]){list2[rule]=[]}list2[rule].push(type);if(rule.length>ruleLen){ruleLen=rule.length}}}source=this._regexps}ruleWidth=ruleLen+2;indent=" ".repeat(ruleWidth);s+="\n"+ljustify("----- Rules -----",indent.length,indent)+"--- Tags ---";for(rule in list2){vals=list2[rule];s+="\n"+ljustify(rule,ruleWidth,indent);isFirst=true;for(i=0;i<vals.length;i++){s+=(isFirst?"":indent)+vals[i]+"\n";isFirst=false}}return s+"\n"};function ljustify(n,w,blanks){var s=n.toString();var l=s.length;return s+blanks.substr(0,w-l)};function _isRE(s){return RULE_RE.test(s)};module.exports=Registry;
|
|
6
|
+
const RULE_RE=new RegExp(/[~`!#$%\^&*+\[\]\\';,/{}|\\"\?]/);var Registry=function(appCtx){this._registry={};this._regexps={};this._reObjs={};this._appCtx=appCtx;this._info=appCtx.info;this._assert=appCtx.assert};Registry.prototype.getRegisteredCallbacks=function(type){var reo,ret;ret=this._registry[type];if(!type.startsWith("css-")&&type.indexOf("-")>0&&type.indexOf("|")<0){ret={...ret};type=type.substring(1,type.length-1).trim();for(re in this._regexps){reo=this._reObjs[re];if(reo&&reo.test(type)){if(!ret){ret={}}for(x in this._regexps[re]){ret[x]=this._regexps[re][x]}}};}return ret};Registry.prototype.isRegisteredCallback=function(type){return!!this._registry[type]};Registry.prototype.isRegisteredCallbackRE=function(elem){var ret,i;if(ret=this.isRegisteredCallback(elem)){return ret}elem=elem.startsWith("<")?elem.substring(1,elem.length-1):elem;for(re in this._regexps){if(this._reObjs[re].test(elem)){return true}}return false};Registry.prototype.setRuleCallback=function(ruleName,ruleRegs,rsi){var typeObj,regType,rt,callbacks,func,args,elem;for(regType in ruleRegs){func=ruleRegs[regType];if(typeof func!=="function"){this._info(`Rule ${ruleName} : registered '${regType}' is not a function`);continue}rt=elem=regType;if(regType.charAt(0)==="<"){rt=regType.substring(1,regType.length-1).trim();args=rt.split(" ");if(args.length>1){attrib=args[args.length-1];if(attrib.endsWith("=")){rt=args[0]+"|"+attrib.substring(0,attrib.length-1)}elem=args[0]}else{elem=rt.endsWith("=")?null:rt}regType=`<${rt}>`}if(!elem||!_isRE(elem)){if(!(typeObj=this._registry[regType])){this._registry[regType]=typeObj={}}}else{if(!(typeObj=this._regexps[rt])){this._regexps[rt]=typeObj={}}if(!this._reObjs[rt]){this._reObjs[rt]=new RegExp(rt)}}if(!(callbacks=typeObj[ruleName])){typeObj[ruleName]=callbacks=[]}callbacks.push({cb:func,rsi:rsi})}};Registry.prototype.XXsetRuleCallback=function(ruleName,ruleRegs,rsi){var typeObj,callbackType,ruleCallbacks,func;if(Array.isArray(ruleRegs)){var jj=this._setRuleCallback2(ruleName,ruleRegs)}else if(typeof ruleRegs!=="object"){return}else if(ruleRegs.cb){let regs=this._setExtended(ruleName,ruleRegs,rsi);if(regs){ruleRegs=regs}}for(callbackType in ruleRegs){func=ruleRegs[callbackType];if(typeof func!=="function"){this._info("Rule "+ruleName+" : registered '"+callbackType+"' is not a function");continue}typeObj=this._registry[callbackType];if(!typeObj){this._registry[callbackType]=typeObj={}}ruleCallbacks=typeObj[ruleName];if(!ruleCallbacks){typeObj[ruleName]=ruleCallbacks=[]}ruleCallbacks.push({cb:func,rsi:rsi})}};Registry.prototype.XXsetRuleCallback2=function(ruleName,regs,rsi){var a,i,j,props,prop,reg,val;for(i=0;i<regs.length;i++){reg=regs[i];if(!reg.cb){if(!a){a=[]}a.push(reg);continue}props=Object.keys(reg);if(props.length===2){for(j=0;j<props.length;j++){prop=props[j];if(prop!=="cb"){val=reg[prop];if(typeof val==="boolean"&&val){a.push({prop:val});break}}}continue}}};Registry.prototype.isEmpty=function(){return!this._appCtx.utils.hasAnyProps(this._registry)};Registry.prototype.dump=function(){var type,rule,vals,tagWidth,tagLen=0,indent,isFirst,s="";var list2={},ruleWidth,ruleLen=0,source,i;for(type in this._registry){if(type.length>tagLen){tagLen=type.length}}for(type in this._regexps){if(type.length>tagLen){tagLen=type.length}}if(!tagLen){return"\n-- No rules enabled - nothing to report --\n"}tagWidth=tagLen+3;indent=" ".repeat(tagWidth);s="\n"+ljustify("--- Tags ---",indent.length,indent)+"----- rules -----";source=this._registry;for(i=0;i<2;i++){for(type in source){s+="\n"+ljustify(type,tagWidth,indent);vals=source[type];isFirst=true;for(rule in vals){s+=(isFirst?"":indent)+rule+"\n";isFirst=false;if(!list2[rule]){list2[rule]=[]}list2[rule].push(type);if(rule.length>ruleLen){ruleLen=rule.length}}}source=this._regexps}ruleWidth=ruleLen+2;indent=" ".repeat(ruleWidth);s+="\n"+ljustify("----- Rules -----",indent.length,indent)+"--- Tags ---";for(rule in list2){vals=list2[rule];s+="\n"+ljustify(rule,ruleWidth,indent);isFirst=true;for(i=0;i<vals.length;i++){s+=(isFirst?"":indent)+vals[i]+"\n";isFirst=false}}return s+"\n"};function ljustify(n,w,blanks){var s=n.toString();var l=s.length;return s+blanks.substr(0,w-l)};function _isRE(s){return RULE_RE.test(s)};module.exports=Registry;
|
package/lib/RuleSet.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 REG=require("./RegTypes");const FILETYPE=require("./filetypes");const RULE_FILE="rules.json";const BUILTIN_RULES_PATH="../rules/";const BUILTIN_RULEPACK_PATH="../rulepacks/";const JAF_BUILTIN_RULES_PATH=BUILTIN_RULES_PATH+"jaf";const JET_BUILTIN_RULES_PATH=BUILTIN_RULES_PATH+"jet";const SPOC_BUILTIN_RULES_PATH=BUILTIN_RULEPACK_PATH+"spoc";const CSP_BUILTIN_RULES_PATH=BUILTIN_RULEPACK_PATH+"csp";const JETWC_BUILTIN_RULES_PATH=BUILTIN_RULEPACK_PATH+"jetwc";const JETWCO_BUILTIN_RULES_PATH=BUILTIN_RULEPACK_PATH+"jetwco";const VCOMPMIG_BUILTIN_RULES_PATH=BUILTIN_RULEPACK_PATH+"ojcmig";const WEBDRIVER_TEST_BUILTIN_RULES_PATH=BUILTIN_RULEPACK_PATH+"wdt";const JET_MIN_VERSION="5.2.0";const TEMP_FILE_TEMPLATE="@@rpziptmp-XXXXXX";const PROP_$BUILTIN="$builtin";const PROP_$REQUIRED="$required";const RESERVED_RULE_PREFIX=["oj-","jaf-","csp-","spoc-","jetwc-","jetwco-","exch-","demo-"];const RESERVED_PACK_PREFIX=["JAF","JET","SPOC","CSP","JETWC","JETWCO","DEMO"];const NO_MSGID_PACKS=[];const RULE_STATUS=["prod","production","ready","beta","alpha","deprecated"];const FUNCTION="function";const COLON=":";const RULE_RE=new RegExp(/[~`!#$%\^&*+\[\]\\';,/{}|\\"\?]/,"g");const RulePack=require("./RulePack");const Registry=require("./Registry");const SemVer=require("./SemVer");const CssUtils=require("./CssUtils");const AstNodeTypes=require("./AstNodeTypes");const clone=require("./clone");var RuleSet=function(config,nodeDeps,appCtx,AMDRulePacks){this._config=config;this._ruleSets=config.getRulePacks();this._ruleMods=config.getRuleMods();this._ruleCount=0;this._AmdPacks=AMDRulePacks;this._appCtx=appCtx;this._nodeDeps=nodeDeps;this._isAMD=!!nodeDeps.AmdRulePackLoader;this._isCLI=appCtx.runMode==="cli";this._isCliOrApi=!this._isAMD;this._metaLib=appCtx.metaLib;this._utils=appCtx.utils;this._severity=appCtx.severity;this._tmpDir=appCtx.tmpDir;this._semVer=new SemVer;this._targFiletypes=[];this._useBuiltinRules=config._config.builtinJetRules;this._rulePacks=null;this._shadowRulePacks=null;this._rulesetSummary=[];this._registerCtx={sysOpts:{verboseMode:this._appCtx.verboseMode,debugMode:this._appCtx.debugMode}};this._registerCtx.utils={};this._registerCtx.utils.metaLib=this._metaLib;this._registerCtx.runMode=appCtx.runMode;this._registerCtx.VsCodeExtHint=appCtx.VsCodeExtHint;this._registerCtx.utils.semVerUtils=this._semVer;this._registerCtx.utils.utils=this._utils;this._registerCtx.utils.CssUtils=CssUtils;this._registerCtx.config=JSON.parse(JSON.stringify(this._config._config));this._registerCtx.error=appCtx.error;this._registerCtx.info=appCtx.info;this._registerCtx.msg=appCtx.msg;this._registerCtx.utils.msgLib={msg:appCtx.msg,error:appCtx.error,info:appCtx.info,debug:appCtx.debug,assert:appCtx.assert};this._registerCtx.utils.sevLib=this._severity.getSevLib();this._msg=appCtx.msg;this._info=appCtx.info;this._debug=appCtx.debug;this._error=appCtx.error;this._assert=appCtx.assert;this._debugMode=appCtx.debugMode;this._verboseMode=appCtx.verboseMode;if(!this._ruleSets){this._ruleSets=[]}let rsi=0;this._ruleSets.splice(rsi++,0,{"enabled":true,"path":this._isCliOrApi?nodeDeps.path.join(__dirname,JAF_BUILTIN_RULES_PATH):null,"builtin":true});if(config._config.builtinJetRules){this._ruleSets.splice(rsi++,0,{"enabled":true,"path":this._isCliOrApi?nodeDeps.path.join(__dirname,JET_BUILTIN_RULES_PATH):null,"builtin":true})}if(config._config.builtinCspRules){this._ruleSets.splice(rsi++,0,{"enabled":true,"path":nodeDeps.path.join(__dirname,CSP_BUILTIN_RULES_PATH),"builtin":true})}if(!this._isAMD&&config._config.builtinJetWcRules){this._ruleSets.splice(rsi++,0,{"enabled":true,"path":nodeDeps.path.join(__dirname,JETWC_BUILTIN_RULES_PATH),"builtin":true})}if(!this._isAMD&&config._config.builtinJetWcOracleRules){this._ruleSets.splice(rsi++,0,{"enabled":true,"path":nodeDeps.path.join(__dirname,JETWCO_BUILTIN_RULES_PATH),"builtin":true})}if(!this._isAMD&&config._config.builtinSpocRules){this._ruleSets.splice(rsi++,0,{"enabled":true,"path":nodeDeps.path.join(__dirname,SPOC_BUILTIN_RULES_PATH),"builtin":true})}if(!this._isAMD&&config._config.builtinOjcMigrationRules){this._ruleSets.splice(rsi++,0,{"enabled":true,"path":nodeDeps.path.join(__dirname,VCOMPMIG_BUILTIN_RULES_PATH),"builtin":true})}if(!this._isAMD&&config._config.builtinWebDriverTestRules){this._ruleSets.splice(rsi++,0,{"enabled":true,"path":nodeDeps.path.join(__dirname,WEBDRIVER_TEST_BUILTIN_RULES_PATH),"builtin":true})}if(this._isAMD&&this._AmdPacks){let i,apack;for(i=0;i<this._AmdPacks.length;i++){apack=this._AmdPacks[i];this._ruleSets.splice(rsi++,0,{enabled:true,path:null,builtin:false,amdpack:apack})}}};RuleSet.prototype.loadRulePacks=function(config,isDryRun,isRuleDump){var ruleSet,rulePath,rulesJson,rulePack,rsi,rule,prefix,groups,gname,arules,j,k,s="",rulesetSummaryIndex=-1,spocFound,demoFound,errors=false,rc,ruleName,jetVersion;this._config=config;this._confSeverity=config._sev;this._confNamedRules=config.ruleNames;jetVersion=this._metaLib.getRevisionInfo().jetVersion;if(!this._semVer.setReference(jetVersion,JET_MIN_VERSION)){this._error(`JET metadata version ${jetVersion} not supported (less than ${JET_MIN_VERSION})`);return false}if(this._debugMode){this._debug(this._ruleSets?"Processing "+this._ruleSets.length+" Rule Sets":"No Rule Sets defined")}if(!this._ruleSets){return false}this._rulePacks=[];this._shadowRulePacks=[];for(rsi=0;rsi<this._ruleSets.length;rsi++){ruleSet=this._ruleSets[rsi];groups=null;try{if(typeof ruleSet.enabled==="boolean"&&!ruleSet.enabled){s+=(rsi?"\n":"")+" "+(rsi+1)+") "+"Disabled ruleSet at '"+ruleSet.path;continue}if(!ruleSet.status){ruleSet.status=["all"]}if(!this._isAMD){if(this._debugMode){let rname=ruleSet.path.endsWith("jaf")?"JAF":ruleSet.path.endsWith("jet")?"JET":ruleSet.name;this._debug("Ruleset '"+rname+"' path->'"+ruleSet.path+"'")}if(ruleSet.path.endsWith(".zip")){ruleSet.container=ruleSet.path;let tmpFile=this._nodeDeps.fsUtils.getUniqueFileName(TEMP_FILE_TEMPLATE);let tmpDir=this._nodeDeps.path.join(this._tmpDir,tmpFile);rc=this._nodeDeps.fsUtils.createFolder(tmpDir);if(typeof rc!=="boolean"){this._error(`Unable to create folder ${rc.message}`);break}var zipUtils=new this._nodeDeps.zipUtils;;rc=zipUtils.extractAll(tmpDir,ruleSet.container,true);if(typeof rc!=="boolean"){this._error(`Unable to extract from zip ('${rc.message}') : "${ruleSet.container}"`);break}ruleSet.path=tmpDir}rulePath=this._nodeDeps.path.join(ruleSet.path,RULE_FILE);rulesJson=this._loadJson(rulePath)}else{if(ruleSet.builtin){rulesJson=this._nodeDeps.AmdRulePackLoader(this._nodeDeps,rsi,ruleSet,this._error)}else if(ruleSet.amdpack){rulesJson=ruleSet.amdpack.rulesJson}}if(!rulesJson){continue}if(!rulesJson.title){rulesJson.title="unknown"}if(!rulesJson.version){rulesJson.version="0.0.0"}prefix=rulesJson.prefix;ruleSet.prefix=prefix;s+=(rsi?"\n":"")+" "+(rsi+1)+") "+rulesJson.title+"\n "+rulesJson.version+" : "+prefix+(ruleSet.builtin||ruleSet.amdpack?"":" -> "+(ruleSet.container?ruleSet.container:ruleSet.path));if(this._appCtx.isUnitTest&&!spocFound&&prefix==="SPOC"){ruleSet.builtin=true;if(prefix==="SPOC"){spocFound=true}if(prefix==="DEMO"){demoFound=true}}if(!demoFound&&prefix==="DEMO"){ruleSet.builtin=true;if(prefix==="DEMO"){demoFound=true}}if(!ruleSet.builtin){if(RESERVED_PACK_PREFIX.includes(prefix)){this._error("Rule pack at '"+rulePath+"' cannot use use reserved prefix '"+prefix+"'!");break}}for(j=0;j<this._rulesetSummary.length;j++){if(this._rulesetSummary[j].prefix===prefix){this._error("Rule pack prefix '"+prefix+"' at '"+rulePath+"' ignored - previously defined at '"+rulePack.path+"'");break}}if(j<this._rulesetSummary.length){continue}this._rulesetSummary.push({title:rulesJson.title,path:ruleSet.path,version:rulesJson.version,prefix:rulesJson.prefix,status:ruleSet.status,packData:ruleSet.packData});++rulesetSummaryIndex;var reorder,nonReq,reqList=[];reorder=nonReq=false;reqList.length=0;for(ruleName in rulesJson.rules){rule=rulesJson.rules[ruleName];rule._rsi=rulesetSummaryIndex;if(this._ruleSets[rulesetSummaryIndex].builtin){rule[PROP_$BUILTIN]=true}if(rule[PROP_$REQUIRED]){if(!reorder){reorder=nonReq}reqList.push(ruleName)}else{nonReq=true}if(rule.group){groups=groups||{};let rg=rule.group;if(typeof rg==="string"){arules=groups[rg];if(!arules){groups[rg]=arules=[]}arules.push(ruleName)}else if(Array.isArray(rg)){for(k=0;k<rg.length;k++){gname=rg[k];arules=groups[gname];if(!arules){groups[gname]=arules=[]}arules.push(ruleName)}}}}if(reorder){rulesJson.rules=this._promoteRequired(rulesJson.rules,rulesJson.prefix,reqList)}this._rulePacks.push({path:ruleSet.path,rulesJson:rulesJson});ruleSet.groupMap=groups;this._mergeRuleOptions(rulesJson,ruleSet.builtin)}catch(e){this._error(`Failure processing ruleset at '${rulePath}' (${e.message})`);errors=true}}if(s.length){this._info("[info]: ------ Rulepacks found: --------");this._info(s)}if(this._debugMode){this._debug("------ group mappings : --------");let self=this;this._ruleSets.forEach(s=>{self._debug(s.prefix+": "+(s.groupMap?JSON.stringify(s.groupMap,null,3):"none"))})}if(errors){return false}this._registry=new Registry(this._appCtx);this._postProcess_RuleMods();this._postProcess_RuleNames();if(!this._processRuleSets()){return false}if(config.options.debug&&!isRuleDump||config.options.verbose&&!isRuleDump||isDryRun){var f=isDryRun||config.options.verbose?this._info:this._debug;var rules,opts;if(this._ruleCount){f("\n-------- Active Rule Summmary --------");for(rsi=0;rsi<this._rulePacks.length;rsi++){rulePack=this._rulePacks[rsi];f("\n ["+(rsi+1)+"] Rule Set '"+rulePack.rulesJson.title+"'");rules=rulePack.rulesJson.rules;let n=0;for(ruleName in rules){opts=rules[ruleName];if(opts.enabled){f("\n "+ruleName+" : "+JSON.stringify(this._utils.extend(opts)));n++}}if(!n){f("\n "+"No rules enabled in pack.")}}}}return!errors};RuleSet.prototype._postProcess_RuleMods=function(){var rs,rm,are,ard,count=0,n;rm=this._config.ruleMods;if(rm&&(rm.enable||rm.disable)){rs=this._ruleSets;are=rm.enable;if(are){n=_replaceGroups(are,rs);if(n){are=_removeDups(are);count+=n}}ard=rm.disable;if(ard){n=_replaceGroups(ard,rs);if(n){ard=_removeDups(ard);count+=n}}this._enableDisableGroupRules(are,ard)}return count};RuleSet.prototype._enableDisableGroupRules=function(are,ard){var ar,rname,packs,rules,rule,enable,m1,i,j,k;if(this._verboseMode||this._debugMode){this._info("\n[Info]: --- Enabling rules found in ruleMods.enable ---");if(!are){this._info("* None found")}}packs=this._rulePacks;i=2;ar=are;enable=true;m1="enabled";while(i){if(ar){for(j=0;j<ar.length;j++){rname=ar[j];for(k=0;k<packs.length;k++){rules=packs[k];if(rules){rules=rules.rulesJson;if(rules){rule=rules.rules[rname];if(rule){if(!enable&&rule.$required){this._error(`rule '${rname}' is mandatory and cannot be disabled using config 'ruleMods.disable' property.`);continue}rule.enabled=enable;if(this._verboseMode||this._debugMode){this._info(` Rule ${rname} ${m1}`)}break}}}}}}if(enable){ar=ard;if(this._verboseMode||this._debugMode){this._info("\n[Info]: --- Disabling rules found in ruleMods.disable ---");m1="disabled";if(!ard){this._info("* None found")}}if(!ard){return}}enable=false;i--}};RuleSet.prototype._postProcess_RuleNames=function(){var ret=0;if(this._verboseMode||this._debugMode){this._info("\n[Info]: --- Processing config ruleNames entries ---")}if(this._config.ruleNames){ret=_replaceGroups(this._config.ruleNames,this._ruleSets);this._config.ruleNames=_removeDups(this._config.ruleNames)}if(this._verboseMode||this._debugMode){this._info(`\n[Info]: ${ret} ruleNames group entr${ret===1?"y":"ies"} replaced ---`)}return ret};function _replaceGroups(ar,rs){var val,o,group,grules,rc=0,rsi,i;var replaced=[];for(i=0;i<ar.length;i++){val=ar[i];replaced.length=0;for(rsi=0;rsi<rs.length;rsi++){o=rs[rsi];if(o.groupMap){for(group in o.groupMap){if(group===val){grules=o.groupMap[group];replaced.push(...grules);break}}}}if(replaced.length){ar.splice(i,1,...replaced);i+=replaced.length-1;rc++}}return rc};RuleSet.prototype._promoteRequired=function(rules,prefix,reqList){var ret={},keys,rule,n;for(rule of reqList){ret[rule]=rules[rule]}keys=Object.keys(rules);for(rule of keys){if(!rules[rule][PROP_$REQUIRED]){ret[rule]=rules[rule]}}if(this._debugMode||this._verboseMode){this._info(`\n[Info]: Rulepack '${prefix}' - ${reqList.length} rule${reqList.length===1?"":"s"} promoted to top for early $required loading`);let s="";for(n=0;n<reqList.length;n++){s+=" "+(n+1)+"] "+reqList[n]+"\n"}this._info(s+"\n");if(this._debugMode){this._info(`\n[Info]: Rulepack '${prefix}' - Loading Order`);n=0;s="";for(rule in ret){s+=" "+(n+1)+"] "+rule+"\n";n++}this._info(s+"\n")}}return ret?ret:rules};function _removeDups(ar){return[...new Set(ar)]};RuleSet.prototype.dumpRegistry=function(){console.log("\n-------- Active Rule Type Listener Types --------");console.log(this._registry.dump())};RuleSet.prototype.getRulePacks=function(){return this._rulePacks};RuleSet.prototype.getRuleSets=function(){return this._ruleSets};RuleSet.prototype.getRulePacksSummary=function(){return this._rulesetSummary};RuleSet.prototype.getShadowRulePacks=function(){return this._shadowRulePacks};RuleSet.prototype.getActiveRuleCount=function(){return this._ruleCount};RuleSet.prototype.getActiveFiletypes=function(){return this._targFiletypes?this._targFiletypes:[]};RuleSet.prototype.getRegistry=function(){return this._registry};RuleSet.prototype.getRulesetSummary=function(){return this._rulesetSummary};RuleSet.prototype.getRsiFromMsgId=function(msgId){var i,prefix,ret=-1;i=msgId.indexOf("-");prefix=i>=0?msgId.substring(0,i):msgId;if(this._rulesetSummary){for(i=0;i<this._rulesetSummary.length;i++){if(this._rulesetSummary[i].prefix===prefix){ret=i;break}}}return ret};RuleSet.prototype.loadMsgIds=function(){var msgObj,rp,rs,o,rsi,fpath,err;if(this._rulePacks&&this._rulePacks.length){for(rsi=0;rsi<this._rulePacks.length;rsi++){rp=this._rulePacks[rsi];rs=this._ruleSets[rsi];if(rs.builtin&&NO_MSGID_PACKS.includes(rs.prefix)){continue}if(rs.enabled){if(!msgObj){msgObj={}}o=null;try{if(this._isCliOrApi){fpath=this._nodeDeps.path.join(rp.path,"msgid.json");if(rs.builtin||this._nodeDeps.fsUtils.fileExists(fpath)){o=this._nodeDeps.msgidLoader(fpath,this._nodeDeps,this._appCtx)}}else{if(rs.builtin){o=this._nodeDeps.msgidLoader(this._nodeDeps,rsi,this._ruleSets[rsi],this._error)}else if(rs.amdpack&&rs.amdpack.msgid){o=rs.amdpack.msgid}}}catch(e){this._error(`'Failed to load ${rs.builtin?"built-in":"external"} rulepack msgid file : ${e.message}`);err=true;o=null}msgObj[rp.rulesJson.prefix]=o}}}return err?-1:msgObj};RuleSet.prototype.getLoadedRule=function(rsi,ruleName){return this._shadowRulePacks[rsi][ruleName]};RuleSet.prototype.getSemVer=function(){return this._semVer};RuleSet.prototype._processRuleSets=function(){var ruleName,ruleNamesWild,rulePack,rules,opts,ruleJS,rule,rulePath,packStat,rset,callbacks,callback,atLine,rn,rsi,temp,s,i,j;for(rsi=0;rsi<this._rulePacks.length;rsi++){rulePack=this._rulePacks[rsi];rules=rulePack.rulesJson.rules;rulePack.rulePack=new RulePack(this._rulesetSummary,this._rulePacks,this._shadowRulePacks,rsi,this._appCtx);this._registerCtx.rulePack=rulePack.rulePack;packStat=this._rulesetSummary[rsi].status;for(ruleName in rules){opts=rules[ruleName];if(this._debugMode){this._debug(`Loading rule '${ruleName}'`)}if(opts.hasOwnProperty("inservice")){if(!opts.inservice){this._showIgnoredRule(`rule '${ruleName}' is not in service - ignored`);opts.enabled=false;continue}}try{if(this._isAMD){if(!_isAMDRule(opts)){this._showIgnoredRule(`rule '${ruleName}' is not supported in AMD mode - ignored`);opts.enabled=false;continue}}opts.enabled=typeof opts.enabled==="boolean"?opts.enabled:true;if(!opts.enabled){this._showIgnoredRule(`rule '${ruleName}' is disabled - ignored`);continue}if(opts._rsi===undefined){this._showIgnoredRule(`rule '${ruleName}' does not belong to an active ruleset - ignored`);opts.enabled=false;continue}if(opts.severity){if(typeof opts.severity!=="string"||!this._severity.isValidRuleSeverity(opts.severity)){this._showIgnoredRule(`rule '${ruleName}' has invalid 'severity' of ${opts.severity} - assuming default of '${this._severity.DEFAULT}'`,true);opts.severity=this._severity.DEFAULT;opts.enabled=false}}else{opts.severity=this._severity.DEFAULT}if(opts.group){if(rsi&&!this._isGroupActive(opts.group)){this._showIgnoredRule(`rule '${ruleName}' ignored by group`);opts.enabled=false;continue}}if(!opts.status){opts.status="production"}if(!RULE_STATUS.includes(opts.status)){this._showIgnoredRule(`rule '${ruleName}' invalid 'status' (i.e. not 'production', 'prod', 'ready', 'deprecated', 'beta', 'alpha'`,true);opts.enabled=false;continue}if(!_isStatEnabledByPack(packStat,opts.status)){this._showIgnoredRule(`rule '${ruleName}' status does not match rulepack status - ignored`);opts.enabled=false;continue}if(opts.filetype){if(Array.isArray(opts.filetype)){for(j=0;j<opts.filetype.length;j++){opts.filetype[j]=opts.filetype[j].toLowerCase();if(!FILETYPE.isFileTypeSupported(opts.filetype[j])){this._showIgnoredRule(`rule '${ruleName}' ignored by 'filetype' value '${opts.filetype[j]}'`);opts.enabled=false;continue}}}else{if(!FILETYPE.isFileTypeSupported(opts.filetype)){this._showIgnoredRule(`rule '${ruleName}' ignored by 'filetype' value '${opts.filetype}'`);opts.enabled=false;continue}}}if(!ruleName.startsWith("jaf-")&&this._confNamedRules&&this._confNamedRules.length){if(!ruleNamesWild){ruleNamesWild=[];for(j=0;j<this._confNamedRules.length;j++){rn=this._confNamedRules[j];ruleNamesWild.push(_isRE(rn)?new RegExp(rn):null)}}for(j=0;j<this._confNamedRules.length;j++){if(this._confNamedRules.includes(ruleName)){break}rn=ruleNamesWild[j];if(rn){if(rn.test(ruleName)){break}}}if(j>=this._confNamedRules.length){if(opts.$required){this._showIgnoredRule(`rule '${ruleName}' not excluded by config 'ruleNames'- rule is mandatory`)}else{this._showIgnoredRule(`rule '${ruleName}' ignored - excluded by config 'ruleNames'`);opts.enabled=false}continue}}if(opts.jetver){if(!this._semVer.match(opts.jetver)){this._showIgnoredRule(`rule '${ruleName}' ignored : 'jetVer' option is '${opts.jetver}' but metadata is '${this._semVer.getReference()}'`);opts.enabled=false;continue}}if(opts.theme){temp=opts.theme;if(typeof temp==="string"){temp=opts.theme.toLowerCase();if(temp==="redwood"||temp==="alta"){opts.theme=temp.charAt(0).toUpperCase()+temp.substring(1);if(this._config.theme!==opts.theme){this._showIgnoredRule(`rule '${ruleName}' ignored : 'theme' option '${opts.theme}' excluded by config '${this._config.theme}'`);opts.enabled=false;continue}}else{this._showIgnoredRule(`rule '${ruleName}' theme option '${opts.theme}' - must be 'Redwood' or 'Alta'`,true);opts.enabled=false}}else{if(!Array.isArray(temp)){this._showIgnoredRule(`rule '${ruleName}' theme option - must be a string or a string array`,true);opts.enabled=false;continue}temp.forEach((theme,idx)=>{theme=theme.toLowerCase();if(theme==="redwood"||theme==="alta"){theme=theme.charAt(0).toUpperCase()+theme.substring(1);temp[idx]=theme}else{this._showIgnoredRule(`rule '${ruleName}' theme option '${theme}' - must be 'Redwood' or 'Alta'`,true);opts.enabled=false}});if(opts.enabled&&!opts.theme.includes(this._config.theme)){this._showIgnoredRule(`rule '${ruleName}' ignored : 'theme' option '${opts.theme}' excluded by config '${this._config.theme}'`);opts.enabled=false}}}if(this._isCliOrApi){rulePath=this._rulesetSummary[opts._rsi].path;rulePath=this._nodeDeps.path.join(rulePath,ruleName+".js");ruleJS=this._nodeDeps.ruleLoader(rulePath)}else{rset=this._ruleSets[opts._rsi];if(rset.builtin){ruleJS=this._nodeDeps.ruleLoader(ruleName,opts._rsi,this._error)}else if(rset.amdpack){ruleJS=rset.amdpack.rules[ruleName]}}if(!ruleJS){continue}rule=ruleJS;if(rset&&rset.amdpack){try{rule=new ruleJS.default}catch(e){this._showIgnoredRule(`AMD rule '${ruleName}' ${e.message}`,true);rule=null;continue}}else{if(ruleJS.prototype||!ruleJS.getName){try{rule=new ruleJS}catch(e){this._showIgnoredRule(`rule '${ruleName}' ${e.message}`,true);rule=null;continue}}}if(!opts.$internal){if(typeof rule.register!==FUNCTION){this._showIgnoredRule(`rule '${ruleName}' ignored - has no register() method`,true);opts.enabled=false;continue}}if(typeof rule.getName!==FUNCTION){this._showIgnoredRule(`rule '${ruleName}' ignored - has no getName() method`,true);opts.enabled=false;continue}if(typeof rule.getDescription!==FUNCTION){this._showIgnoredRule(`rule '${ruleName}' ignored - has no getDescription() method`,true);opts.enabled=false;continue}if(typeof rule.getShortDescription!==FUNCTION){this._showIgnoredRule(`rule '${ruleName}' ignored - has no getShortDescription() method`,true);opts.enabled=false;continue}if(ruleName!==rule.getName()){this._showIgnoredRule(`rule '${ruleName}' ignored - name '${rule.getName()}' does not match external name '${ruleName}`,true);opts.enabled=false;continue}if(!opts.$internal){this._registerCtx.ruleOpts=clone.cloneOptions(opts);if(opts.filetype){if(typeof opts.filetype==="string"&&opts.filetype==="js"||opts.filetype.includes("js")){this._registerCtx.jsNodeTypes=AstNodeTypes}else if(typeof opts.filetype==="string"&&opts.filetype==="ts"||opts.filetype.includes("ts")){this._registerCtx.tsNodeTypes=AstNodeTypes}}if(this._isCliOrApi){this._registerCtx.utils.fsUtils=this._nodeDeps.fsUtils;if(ruleName==="oj-html-cspexpr"){this._registerCtx.decache=this._nodeDeps.decache}}this._registerCtx.ruleName=ruleName;this._registerCtx.rulePack._setCBCtx(this._registerCtx);callbacks=rule.register(this._registerCtx);if(!callbacks){this._showIgnoredRule(`rule '${ruleName}' has disabled itself during registration`);opts.enabled=false;continue}for(callback in callbacks){if(callbacks[callback]){callbacks[callback]=callbacks[callback].bind(rule)}else{s=`rule '${ruleName}': listener for '${callback}' in register() is not defined - rule is disabled`;this._error(s);this._showIgnoredRule(s);opts.enabled=false;continue}}if(_isHookRule(callbacks)){opts.$hook=true}else{if(!this._checkRuleSeverity(opts)){this._showIgnoredRule(`rule '${ruleName}' ignored by severity`);opts.enabled=false;continue}}}this._addToShadowRulePacks(ruleName,rule,opts);if(!opts.$internal){this._registry.setRuleCallback(ruleName,callbacks,opts._rsi)}this._ruleCount++;this._updateTargetFiletypes(opts)}catch(e){atLine=e.stack.replace(rulePath,"").trim();i=NaN;if(atLine.startsWith(COLON)){i=parseInt(atLine.substr(1))}if(!isNaN(i)){atLine=" line "+i+": "}else{i=atLine.indexOf(COLON);if(i<0){atLine=""}else{atLine=this._utils.eatLine(atLine,i);i=atLine.indexOf(COLON);if(i>=0){atLine=atLine.substring(i+1);i=atLine.indexOf(")");if(i>=0){atLine="("+atLine.substring(0,i).replace(COLON,",")+") - "}}else{atLine=""}};}this._showIgnoredRule(`Cannot load rule ${ruleName} [${atLine} '${e.message}']`,true)}}}this._showIgnoredRule(null);return true};RuleSet.prototype._showIgnoredRule=function(msg,isError){if(msg){if(!this._ignoredRulesShown){this._info("\n--------- Start-up Rule analysis ---------");this._ignoredRulesShown=true}isError?this._error(msg):this._info(msg)}else if(this._ignoredRulesShown){this._info("------------ End Rule analysis -------------")}};RuleSet.prototype._mergeRuleOptions=function(rulesJson,isBuiltinRules){var prefix,rules,overrides,ruleName,opts,error,x;this._debug("Augmenting config defined rules in rulePack from ruleMods...");prefix=rulesJson.prefix;rules=rulesJson.rules;overrides=this._getRuleModsByPrefix(prefix);for(ruleName in rules){error=false;if(!isBuiltinRules){x=RESERVED_RULE_PREFIX.indexOf(ruleName.toLowerCase());if(x>=0){this._showIgnoredRule(`rule '${ruleName}' in rulepack (prefix: '${prefix}') must not use JET reserved prefix '${RESERVED_RULE_PREFIX[x]}'`,true);error=true}}if(overrides){if(error){continue}if(overrides.hasOwnProperty(ruleName)&&rules[ruleName]){if(this._isAMD){opts=rules[ruleName];if(!_isAMDRule(opts)){if(this._debugMode){this._debug(`Rule options override ignored for non-AMD ${ruleName} in AMD mode`)}continue}if(!this._nodeDeps.ruleLoader(ruleName,opts._rsi,this._error)){continue}}if(this._debugMode){this._debug(`Merging rule props of ${ruleName}`)}this._mergeOverrideProps(ruleName,overrides[ruleName],rules[ruleName],isBuiltinRules)}}}};RuleSet.prototype._mergeOverrideProps=function(ruleName,configOpts,ruleOpts){var prop;for(prop in configOpts){if(prop.charAt(0)==="$"){delete configOpts[prop];this._showIgnoredRule(`rule '${ruleName}' : '${prop}' in config 'rulesMod' cannot use reserved '$' prefix`,true);continue}if(prop==="enabled"&&!configOpts[prop]&&ruleOpts["$required"]){this._showIgnoredRule(`rule '${ruleName}' is mandatory and cannot be disabled using config 'ruleMods' property.`,true);continue}ruleOpts[prop]=configOpts[prop]}};RuleSet.prototype._addToShadowRulePacks=function(ruleName,loadedRule,ruleOpts){var rsi=ruleOpts._rsi;var srp=this._shadowRulePacks;while(rsi>=srp.length){srp.push({})}srp[rsi][ruleName]=loadedRule};RuleSet.prototype._updateTargetFiletypes=function(opts){var ft=opts.filetype;if(ft){if(typeof ft==="string"){ft=[ft]}ft.forEach(t=>{if(!opts.$internal){if(!this._targFiletypes.includes(t)){this._targFiletypes.push(t)}}},this)}};RuleSet.prototype._getRuleModsByPrefix=function(prefix){var modPrefix,ret;if(this._ruleMods){prefix=prefix.toLowerCase();for(modPrefix in this._ruleMods){if(prefix===modPrefix.toLowerCase()){ret=this._ruleMods[modPrefix];break}}}return ret};RuleSet.prototype._isGroupActive=function(group){var groups,defs,def,i;groups=this._config.groups;defs=this._config.defGroups;if(this._checkGroups(groups,group)){return true}if(!defs){return false}for(i=0;i<groups.length;i++){def=groups[i];if(this._checkDefGroup(defs,def,group)){return true}}return false};RuleSet.prototype._checkGroups=function(cfgGroups,ruleGroup){var theGroup,i;if(Array.isArray(ruleGroup)){for(i=0;i<ruleGroup.length;i++){theGroup=ruleGroup[i];if(this._checkGroup(cfgGroups,theGroup)){return true}}}else if(this._checkGroup(cfgGroups,ruleGroup)){return true}return false};RuleSet.prototype._checkGroup=function(cfgGroups,group){return!cfgGroups||cfgGroups.includes(group)||cfgGroups.includes(this._severity.ALL)};RuleSet.prototype._isJetInRuleSet=function(jetPrefix){var i,ret=false;if(this._ruleSets&&this._ruleSets.length){for(i=0;i<this._ruleSets.length;i++){if(this._ruleSets[i].prefix===jetPrefix){ret=true;break}}}return ret};RuleSet.prototype._checkRuleSeverity=function(opts){var severities,severity,_sev,i,ret=false;severities=this._config.severity;severity=opts.severity;if(typeof severities==="string"){_sev=this._severity.getConfigSevExpr();if(_sev){ret=true}else{ret=severity===severities||severities===this._severity.ALL}}else{for(var i=0;i<severities.length;i++){if(severity===severities[i]||severities[i]===this._severity.ALL){ret=true;break}}}return ret};RuleSet.prototype._loadJson=function(filepath){var data,stats,msg;try{stats=this._nodeDeps.fs.lstatSync(filepath);if(!stats.isFile()){this._error(`RuleSet '${filepath}' not found!`);return null}else{data=this._nodeDeps.fs.readFileSync(filepath,"utf8");data=JSON.parse(this._nodeDeps.decomment(data))}}catch(e){if(e.code){if(e.message.startsWith("ENOENT:")){this._error(`RuleSet error - '${filepath}' not found!`)}}else if(e.toString().startsWith("SyntaxError")){msg=_convertMsgToRowCol(e.message,data,this._utils)}else{msg=e.message}if(msg){this._error(`JSON load error '${filepath}' - ${msg}`)}data=null}return data};function _isStatEnabledByPack(pstat,rstat){var ret=false;if(pstat.includes("all")||pstat.includes(rstat)){ret=true}else{if(rstat==="ready"||rstat.startsWith("prod")){ret=pstat.includes("ready")||pstat.includes("production")||pstat.includes("prod")}}return ret};function _isHookRule(callbacks){return callbacks[REG.PHASE_STARTUP]||callbacks[REG.PHASE_CLOSEDOWN]||callbacks[REG.PHASE_FILE]?true:false};function _isAMDRule(opts){return opts.hasOwnProperty("amd")?!!opts.amd:true};function _convertMsgToRowCol(msg,data,utils){var x,n,rc;x=msg.indexOf("position");if(x<0){return msg}n=parseInt(msg.substr(x+8).trim());rc=utils.getRowColFromIndex(data,n);return msg.substr(0,x)+"line "+rc.row+", col "+rc.col};function _isRE(s){return RULE_RE.test(s)};module.exports=RuleSet;
|
|
6
|
+
const REG=require("./RegTypes");const FILETYPE=require("./filetypes");const RULE_FILE="rules.json";const BUILTIN_RULES_PATH="../rules/";const BUILTIN_RULEPACK_PATH="../rulepacks/";const JAF_BUILTIN_RULES_PATH=BUILTIN_RULES_PATH+"jaf";const JET_BUILTIN_RULES_PATH=BUILTIN_RULES_PATH+"jet";const SPOC_BUILTIN_RULES_PATH=BUILTIN_RULEPACK_PATH+"spoc";const CSP_BUILTIN_RULES_PATH=BUILTIN_RULEPACK_PATH+"csp";const JETWC_BUILTIN_RULES_PATH=BUILTIN_RULEPACK_PATH+"jetwc";const JETWCO_BUILTIN_RULES_PATH=BUILTIN_RULEPACK_PATH+"jetwco";const VCOMPMIG_BUILTIN_RULES_PATH=BUILTIN_RULEPACK_PATH+"ojcmig";const WEBDRIVER_TEST_BUILTIN_RULES_PATH=BUILTIN_RULEPACK_PATH+"wdt";const JET_MIN_VERSION="5.2.0";const TEMP_FILE_TEMPLATE="@@rpziptmp-XXXXXX";const PROP_$BUILTIN="$builtin";const PROP_$REQUIRED="$required";const RESERVED_RULE_PREFIX=["oj-","jaf-","csp-","spoc-","jetwc-","jetwco-","exch-","demo-"];const RESERVED_PACK_PREFIX=["JAF","JET","SPOC","CSP","JETWC","JETWCO","DEMO"];const NO_MSGID_PACKS=[];const RULE_STATUS=["prod","production","ready","beta","alpha","deprecated"];const FUNCTION="function";const COLON=":";const RULE_RE=new RegExp(/[~`!#$%\^&*+\[\]\\';,/{}|\\"\?]/,"g");const RulePack=require("./RulePack");const Registry=require("./Registry");const SemVer=require("./SemVer");const CssUtils=require("./CssUtils");const AstNodeTypes=require("./AstNodeTypes");const clone=require("./clone");var RuleSet=function(config,nodeDeps,appCtx,AMDRulePacks){this._config=config;this._ruleSets=config.getRulePacks();this._ruleMods=config.getRuleMods();this._ruleCount=0;this._AmdPacks=AMDRulePacks;this._appCtx=appCtx;this._nd=nodeDeps;this._isAMD=!!nodeDeps.AmdRulePackLoader;this._isCLI=appCtx.runMode==="cli";this._isCliOrApi=!this._isAMD;this._metaLib=appCtx.metaLib;this._utils=appCtx.utils;this._fsUtils=appCtx.fsUtils;this._severity=appCtx.severity;this._tmpDir=appCtx.tmpDir;this._semVer=new SemVer;this._targFiletypes=[];this._msgIds=null;this._useBuiltinRules=config._config.builtinJetRules;this._rulePacks=null;this._shadowRulePacks=null;this._rulesetSummary=[];this._registerCtx={sysOpts:{verboseMode:this._appCtx.verboseMode,debugMode:this._appCtx.debugMode}};this._registerCtx.utils={};this._registerCtx.utils.metaLib=this._metaLib.getPublicInterface();this._registerCtx.runMode=appCtx.runMode;this._registerCtx.VsCodeExtHint=appCtx.VsCodeExtHint;this._registerCtx.utils.semVerUtils=this._semVer;this._registerCtx.utils.utils=this._utils;this._registerCtx.utils.CssUtils=CssUtils;this._registerCtx.config=JSON.parse(JSON.stringify(this._config._config));this._registerCtx.error=appCtx.error;this._registerCtx.info=appCtx.info;this._registerCtx.msg=appCtx.msg;this._registerCtx.utils.msgLib={msg:appCtx.msg,error:appCtx.error,info:appCtx.info,debug:appCtx.debug,assert:appCtx.assert};this._registerCtx.utils.sevLib=this._severity.getSevLib();this._registerCtx.utils.OjetLib=appCtx.ojetLib;this._msg=appCtx.msg;this._info=appCtx.info;this._debug=appCtx.debug;this._error=appCtx.error;this._assert=appCtx.assert;this._debugMode=appCtx.debugMode;this._verboseMode=appCtx.verboseMode;if(!this._ruleSets){this._ruleSets=[]}let rsi=0;this._ruleSets.splice(rsi++,0,{"enabled":true,"path":this._isCliOrApi?nodeDeps.path.join(__dirname,JAF_BUILTIN_RULES_PATH):null,"builtin":true});if(config._config.builtinJetRules){this._ruleSets.splice(rsi++,0,{"enabled":true,"path":this._isCliOrApi?nodeDeps.path.join(__dirname,JET_BUILTIN_RULES_PATH):null,"builtin":true})}if(config._config.builtinCspRules){this._ruleSets.splice(rsi++,0,{"enabled":true,"path":nodeDeps.path.join(__dirname,CSP_BUILTIN_RULES_PATH),"builtin":true})}if(!this._isAMD&&config._config.builtinJetWcRules){this._ruleSets.splice(rsi++,0,{"enabled":true,"path":nodeDeps.path.join(__dirname,JETWC_BUILTIN_RULES_PATH),"builtin":true})}if(!this._isAMD&&config._config.builtinJetWcOracleRules){this._ruleSets.splice(rsi++,0,{"enabled":true,"path":nodeDeps.path.join(__dirname,JETWCO_BUILTIN_RULES_PATH),"builtin":true})}if(!this._isAMD&&config._config.builtinSpocRules){this._ruleSets.splice(rsi++,0,{"enabled":true,"path":nodeDeps.path.join(__dirname,SPOC_BUILTIN_RULES_PATH),"builtin":true})}if(!this._isAMD&&config._config.builtinOjcMigrationRules){this._ruleSets.splice(rsi++,0,{"enabled":true,"path":nodeDeps.path.join(__dirname,VCOMPMIG_BUILTIN_RULES_PATH),"builtin":true})}if(!this._isAMD&&config._config.builtinWebDriverTestRules){this._ruleSets.splice(rsi++,0,{"enabled":true,"path":nodeDeps.path.join(__dirname,WEBDRIVER_TEST_BUILTIN_RULES_PATH),"builtin":true})}if(this._isAMD&&this._AmdPacks){let i,apack;for(i=0;i<this._AmdPacks.length;i++){if(apack=this._AmdPacks[i]){this._ruleSets.splice(rsi++,0,{enabled:true,path:null,builtin:false,amdpack:apack})}}}};RuleSet.prototype.loadRulePacks=function(config,isDryRun,isRuleDump){var ruleSet,rulePath,rulesJson,rulePack,rsi,rule,prefix,groups,gname,arules,j,k,s="",rulesetSummaryIndex=-1,spocFound,demoFound,errors=false,rc,ruleName,jetVersion;this._config=config;this._confSeverity=config._sev;this._confNamedRules=config.ruleNames;jetVersion=this._metaLib.getRevisionInfo().jetVersion;if(!this._semVer.setReference(jetVersion,JET_MIN_VERSION)){this._error(`JET metadata version ${jetVersion} not supported (less than ${JET_MIN_VERSION})`);return false}if(this._debugMode){this._debug(this._ruleSets?"Processing "+this._ruleSets.length+" Rule Sets":"No Rule Sets defined")}if(!this._ruleSets){return false}this._rulePacks=[];this._shadowRulePacks=[];for(rsi=0;rsi<this._ruleSets.length;rsi++){ruleSet=this._ruleSets[rsi];groups=null;try{if(typeof ruleSet.enabled==="boolean"&&!ruleSet.enabled){s+=(rsi?"\n":"")+" "+(rsi+1)+") "+"Disabled ruleSet at '"+ruleSet.path;continue}if(!ruleSet.status){ruleSet.status=["all"]}if(!this._isAMD){if(this._debugMode){let rname=this._nd.path.basename(ruleSet.path);switch(rname){case"jaf":case"jet":case"spoc":rname=rname.toUpperCase();break;default:rname=ruleSet.name;break;}this._debug(`Ruleset ${rname?"'rname'":""}path->'${ruleSet.path}'`)}if(ruleSet.path.endsWith(".zip")){ruleSet.container=ruleSet.path;let tmpFile=this._fsUtils.getUniqueFileName(TEMP_FILE_TEMPLATE);let tmpDir=this._nd.path.join(this._tmpDir,tmpFile);rc=this._fsUtils.createFolder(tmpDir);if(typeof rc!=="boolean"){this._error(`Unable to create folder ${rc.message}`);break}var zipUtils=new this._nd.zipUtils;;rc=zipUtils.extractAll(tmpDir,ruleSet.container,true);if(typeof rc!=="boolean"){this._error(`Unable to extract from zip ('${rc.message}') : "${ruleSet.container}"`);break}ruleSet.path=tmpDir}rulePath=this._nd.path.join(ruleSet.path,RULE_FILE);rulesJson=this._loadJson(rulePath)}else{if(ruleSet.builtin){rulesJson=this._nd.AmdRulePackLoader(this._nd,rsi,ruleSet,this._error)}else if(ruleSet.amdpack){rulesJson=ruleSet.amdpack.rulesJson;rulesJson=JSON.parse(JSON.stringify(rulesJson))}}if(!rulesJson){continue}if(!rulesJson.title){rulesJson.title="unknown"}if(!rulesJson.version){rulesJson.version="0.0.0"}prefix=rulesJson.prefix;ruleSet.prefix=prefix;s+=(rsi?"\n":"")+" "+(rsi+1)+") "+rulesJson.title+"\n "+rulesJson.version+" : "+prefix+(ruleSet.builtin||ruleSet.amdpack?"":" -> "+(ruleSet.container?ruleSet.container:ruleSet.path));if(this._appCtx.isUnitTest&&!spocFound&&prefix==="SPOC"){ruleSet.builtin=true;if(prefix==="SPOC"){spocFound=true}if(prefix==="DEMO"){demoFound=true}}if(!demoFound&&prefix==="DEMO"){ruleSet.builtin=true;if(prefix==="DEMO"){demoFound=true}}if(!ruleSet.builtin){if(RESERVED_PACK_PREFIX.includes(prefix)){this._error("Rule pack at '"+rulePath+"' cannot use use reserved prefix '"+prefix+"'!");break}}for(j=0;j<this._rulesetSummary.length;j++){if(this._rulesetSummary[j].prefix===prefix){this._error("Rule pack prefix '"+prefix+"' at '"+rulePath+"' ignored - previously defined at '"+rulePack.path+"'");break}}if(j<this._rulesetSummary.length){continue}this._rulesetSummary.push({title:rulesJson.title,path:ruleSet.path,version:rulesJson.version,prefix:rulesJson.prefix,status:ruleSet.status,packData:ruleSet.packData});++rulesetSummaryIndex;var reorder,nonReq,reqList=[];reorder=nonReq=false;reqList.length=0;for(ruleName in rulesJson.rules){rule=rulesJson.rules[ruleName];rule._rsi=rulesetSummaryIndex;if(this._ruleSets[rulesetSummaryIndex].builtin){rule[PROP_$BUILTIN]=true;if(!rule.hasOwnProperty("inservice")||rule.inservice){if(!Array.isArray(rule.group)){rule.group=[rule.group]}rule.group.push("jet-inservice")}}if(rule[PROP_$REQUIRED]){if(!reorder){reorder=nonReq}reqList.push(ruleName)}else{nonReq=true}if(rule.group){groups=groups||{};let rg=rule.group;if(typeof rg==="string"){arules=groups[rg];if(!arules){groups[rg]=arules=[]}arules.push(ruleName)}else if(Array.isArray(rg)){for(k=0;k<rg.length;k++){gname=rg[k];arules=groups[gname];if(!arules){groups[gname]=arules=[]}arules.push(ruleName)}}}}if(reorder){rulesJson.rules=this._promoteRequired(rulesJson.rules,rulesJson.prefix,reqList)}this._rulePacks.push({path:ruleSet.path,rulesJson:rulesJson});ruleSet.groupMap=groups;this._mergeRuleOptions(rulesJson,ruleSet.builtin)}catch(e){this._error(`Failure processing ruleset at '${rulePath}' (${e.message})`);errors=true}}if(s.length){this._info("[info]: ------ Built-in Rulepacks loaded: --------");this._info(s)}if(this._debugMode){this._debug("------ group mappings : --------");let self=this;this._ruleSets.forEach(s=>{self._debug(s.prefix+": "+(s.groupMap?JSON.stringify(s.groupMap,null,3):"none"))})}if(errors){return false}this._registry=new Registry(this._appCtx);this._postProcess_RuleMods();this._postProcess_RuleNames();if(!this._processRuleSets()){return false}if(config.options.debug&&!isRuleDump||config.options.verbose&&!isRuleDump||isDryRun){var f=isDryRun||config.options.verbose?this._info:this._debug;var rules,opts;if(this._ruleCount){f("\n-------- Active Rule Summmary --------");for(rsi=0;rsi<this._rulePacks.length;rsi++){rulePack=this._rulePacks[rsi];f("\n ["+(rsi+1)+"] Rule Set '"+rulePack.rulesJson.title+"'");rules=rulePack.rulesJson.rules;let n=0;for(ruleName in rules){opts=rules[ruleName];if(opts.enabled){f("\n "+ruleName+" : "+JSON.stringify(this._utils.extend(opts)));n++}}if(!n){f("\n "+"No rules enabled in pack.")}}}}return!errors};RuleSet.prototype._postProcess_RuleMods=function(){var rs,rm,are,ard,count=0,n;rm=this._config.ruleMods;if(rm&&(rm.enable||rm.disable)){rs=this._ruleSets;are=rm.enable;if(are){n=_replaceGroups(are,rs);if(n){are=_removeDups(are);count+=n}}ard=rm.disable;if(ard){n=_replaceGroups(ard,rs);if(n){ard=_removeDups(ard);count+=n}}this._enableDisableGroupRules(are,ard)}return count};RuleSet.prototype._enableDisableGroupRules=function(are,ard){var ar,rname,packs,rules,rule,enable,m1,i,j,k;if(this._verboseMode||this._debugMode){this._info("\n[Info]: --- Enabling rules found in ruleMods.enable ---");if(!are){this._info("* None found")}}packs=this._rulePacks;i=2;ar=are;enable=true;m1="enabled";while(i){if(ar){for(j=0;j<ar.length;j++){rname=ar[j];for(k=0;k<packs.length;k++){rules=packs[k];if(rules){rules=rules.rulesJson;if(rules){rule=rules.rules[rname];if(rule){if(!enable&&rule.$required){this._error(`rule '${rname}' is mandatory and cannot be disabled using config 'ruleMods.disable' property.`);continue}rule.enabled=enable;if(this._verboseMode||this._debugMode){this._info(` Rule ${rname} ${m1}`)}break}}}}}}if(enable){ar=ard;if(this._verboseMode||this._debugMode){this._info("\n[Info]: --- Disabling rules found in ruleMods.disable ---");m1="disabled";if(!ard){this._info("* None found")}}if(!ard){return}}enable=false;i--}};RuleSet.prototype._postProcess_RuleNames=function(){var ret=0;if(this._verboseMode||this._debugMode){this._info("\n[Info]: --- Processing config ruleNames entries ---")}if(this._config.ruleNames){ret=_replaceGroups(this._config.ruleNames,this._ruleSets);this._config.ruleNames=_removeDups(this._config.ruleNames)}if(this._verboseMode||this._debugMode){this._info(`\n[Info]: ${ret} ruleNames group entr${ret===1?"y":"ies"} replaced ---`)}return ret};function _replaceGroups(ar,rs){var val,o,group,grules,rc=0,rsi,i;var replaced=[];for(i=0;i<ar.length;i++){val=ar[i];replaced.length=0;for(rsi=0;rsi<rs.length;rsi++){o=rs[rsi];if(o.groupMap){for(group in o.groupMap){if(group===val){grules=o.groupMap[group];replaced.push(...grules);break}}}}if(replaced.length){ar.splice(i,1,...replaced);i+=replaced.length-1;rc++}}return rc};RuleSet.prototype._promoteRequired=function(rules,prefix,reqList){var ret={},keys,rule,n;for(rule of reqList){ret[rule]=rules[rule]}keys=Object.keys(rules);for(rule of keys){if(!rules[rule][PROP_$REQUIRED]){ret[rule]=rules[rule]}}if(this._debugMode||this._verboseMode){this._info(`\n[Info]: Rulepack '${prefix}' - ${reqList.length} rule${reqList.length===1?"":"s"} promoted to top for early $required loading`);let s="";for(n=0;n<reqList.length;n++){s+=" "+(n+1)+"] "+reqList[n]+"\n"}this._info(s+"\n");if(this._debugMode){this._info(`\n[Info]: Rulepack '${prefix}' - Loading Order`);n=0;s="";for(rule in ret){s+=" "+(n+1)+"] "+rule+"\n";n++}this._info(s+"\n")}}return ret?ret:rules};function _removeDups(ar){return[...new Set(ar)]};RuleSet.prototype.dumpRegistry=function(){if(this._registry.isEmpty()){console.log("\n--reg : Nothing to report, no rules active")}else{console.log("\n-------- Active Rule Type Listener Types --------");console.log(this._registry.dump())}};RuleSet.prototype.getRulePacks=function(){return this._rulePacks};RuleSet.prototype.getRuleSets=function(){return this._ruleSets};RuleSet.prototype.getRulePacksSummary=function(){return this._rulesetSummary};RuleSet.prototype.getShadowRulePacks=function(){return this._shadowRulePacks};RuleSet.prototype.getActiveRuleCount=function(){return this._ruleCount};RuleSet.prototype.getActiveFiletypes=function(){return this._targFiletypes?this._targFiletypes:[]};RuleSet.prototype.getRegistry=function(){return this._registry};RuleSet.prototype.getRulesetSummary=function(){return this._rulesetSummary};RuleSet.prototype.getRsiFromMsgId=function(msgId){var i,prefix,ret=-1;i=msgId.indexOf("-");prefix=i>=0?msgId.substring(0,i):msgId;if(this._rulesetSummary){for(i=0;i<this._rulesetSummary.length;i++){if(this._rulesetSummary[i].prefix===prefix){ret=i;break}}}return ret};RuleSet.prototype.loadMsgIds=function(){var msgObj,rp,rs,o,rsi,fpath,err;if(this._msgIds){return this._msgIds}if(this._rulePacks&&this._rulePacks.length){for(rsi=0;rsi<this._rulePacks.length;rsi++){rp=this._rulePacks[rsi];rs=this._ruleSets[rsi];if(rs.builtin&&NO_MSGID_PACKS.includes(rs.prefix)){continue}if(rs.enabled){if(!msgObj){msgObj={}}o=null;try{if(this._isCliOrApi){fpath=this._nd.path.join(rp.path,"msgid.json");if(rs.builtin||this._fsUtils.fileExists(fpath)){o=this._nd.msgidLoader(fpath,this._nd,this._appCtx)}}else{if(rs.builtin){o=this._nd.msgidLoader(this._nd,rsi,this._ruleSets[rsi],this._error)}else if(rs.amdpack&&rs.amdpack.msgid){o=rs.amdpack.msgid}}}catch(e){this._error(`'Failed to load ${rs.builtin?"built-in":"external"} rulepack msgid file : ${e.message}`);err=true;o=null}msgObj[rp.rulesJson.prefix]=o}}}return err?-1:this._msgIds=msgObj};RuleSet.prototype.getMsgIds=function(){return this._msgIds};RuleSet.prototype.getLoadedRule=function(rsi,ruleName){return this._shadowRulePacks[rsi][ruleName]};RuleSet.prototype.getSemVer=function(){return this._semVer};RuleSet.prototype._processRuleSets=function(){var ruleName,ruleNamesWild,rulePack,rules,opts,ruleJS,rule,rulePath,packStat,rset,callbacks,callback,atLine,rn,rsi,temp,s,i,j;for(rsi=0;rsi<this._rulePacks.length;rsi++){rulePack=this._rulePacks[rsi];rules=rulePack.rulesJson.rules;rulePack.rulePack=new RulePack(this._rulesetSummary,this._rulePacks,this._shadowRulePacks,rsi,this._appCtx);this._registerCtx.rulePack=rulePack.rulePack;packStat=this._rulesetSummary[rsi].status;for(ruleName in rules){opts=rules[ruleName];if(this._debugMode){this._debug(`Loading rule '${ruleName}'`)}if(opts.hasOwnProperty("inservice")){if(!opts.inservice){this._showIgnoredRule(`rule '${ruleName}' is not in service - ignored`);opts.enabled=false;continue}}try{if(this._isAMD){if(!_isAMDRule(opts)){this._showIgnoredRule(`rule '${ruleName}' is not supported in AMD mode - ignored`);opts.enabled=false;continue}}opts.enabled=typeof opts.enabled==="boolean"?opts.enabled:true;if(!opts.enabled){this._showIgnoredRule(`rule '${ruleName}' is disabled - ignored`);continue}if(opts._rsi===undefined){this._showIgnoredRule(`rule '${ruleName}' does not belong to an active ruleset - ignored`);opts.enabled=false;continue}if(opts.severity){if(typeof opts.severity!=="string"||!this._severity.isValidRuleSeverity(opts.severity)){this._showIgnoredRule(`rule '${ruleName}' has invalid 'severity' of ${opts.severity} - assuming default of '${this._severity.DEFAULT}'`,true);opts.severity=this._severity.DEFAULT;opts.enabled=false}}else{opts.severity=this._severity.DEFAULT}if(opts.group){if(rsi&&!this._isGroupActive(opts.group)){this._showIgnoredRule(`rule '${ruleName}' ignored by group`);opts.enabled=false;continue}}if(!opts.status){opts.status="production"}if(!RULE_STATUS.includes(opts.status)){this._showIgnoredRule(`rule '${ruleName}' invalid 'status' (i.e. not 'production', 'prod', 'ready', 'deprecated', 'beta', 'alpha'`,true);opts.enabled=false;continue}if(!_isStatEnabledByPack(packStat,opts.status)){this._showIgnoredRule(`rule '${ruleName}' status does not match rulepack status - ignored`);opts.enabled=false;continue}if(opts.filetype){if(Array.isArray(opts.filetype)){for(j=0;j<opts.filetype.length;j++){opts.filetype[j]=opts.filetype[j].toLowerCase();if(!FILETYPE.isFileTypeSupported(opts.filetype[j])){this._showIgnoredRule(`rule '${ruleName}' ignored by 'filetype' value '${opts.filetype[j]}'`);opts.enabled=false;continue}}}else{if(!FILETYPE.isFileTypeSupported(opts.filetype)){this._showIgnoredRule(`rule '${ruleName}' ignored by 'filetype' value '${opts.filetype}'`);opts.enabled=false;continue}}}if(!ruleName.startsWith("jaf-")&&this._confNamedRules&&this._confNamedRules.length){if(!ruleNamesWild){ruleNamesWild=[];for(j=0;j<this._confNamedRules.length;j++){rn=this._confNamedRules[j];ruleNamesWild.push(_isRE(rn)?new RegExp(rn):null)}}for(j=0;j<this._confNamedRules.length;j++){if(this._confNamedRules.includes(ruleName)){break}rn=ruleNamesWild[j];if(rn){if(rn.test(ruleName)){break}}}if(j>=this._confNamedRules.length){if(opts.$required){this._showIgnoredRule(`rule '${ruleName}' not excluded by config 'ruleNames'- rule is mandatory`)}else{this._showIgnoredRule(`rule '${ruleName}' ignored - excluded by config 'ruleNames'`);opts.enabled=false}continue}}if(opts.jetver){if(!this._semVer.match(opts.jetver)){this._showIgnoredRule(`rule '${ruleName}' ignored : 'jetVer' option is '${opts.jetver}' but metadata is '${this._semVer.getReference()}'`);opts.enabled=false;continue}}if(opts.theme){temp=opts.theme;if(typeof temp==="string"){temp=opts.theme.toLowerCase();if(temp==="redwood"||temp==="alta"){opts.theme=temp.charAt(0).toUpperCase()+temp.substring(1);if(this._config.theme!==opts.theme){this._showIgnoredRule(`rule '${ruleName}' ignored : 'theme' option '${opts.theme}' excluded by config '${this._config.theme}'`);opts.enabled=false;continue}}else{this._showIgnoredRule(`rule '${ruleName}' theme option '${opts.theme}' - must be 'Redwood' or 'Alta'`,true);opts.enabled=false}}else{if(!Array.isArray(temp)){this._showIgnoredRule(`rule '${ruleName}' theme option - must be a string or a string array`,true);opts.enabled=false;continue}temp.forEach((theme,idx)=>{theme=theme.toLowerCase();if(theme==="redwood"||theme==="alta"){theme=theme.charAt(0).toUpperCase()+theme.substring(1);temp[idx]=theme}else{this._showIgnoredRule(`rule '${ruleName}' theme option '${theme}' - must be 'Redwood' or 'Alta'`,true);opts.enabled=false}});if(opts.enabled&&!opts.theme.includes(this._config.theme)){this._showIgnoredRule(`rule '${ruleName}' ignored : 'theme' option '${opts.theme}' excluded by config '${this._config.theme}'`);opts.enabled=false}}}if(this._isCliOrApi){rulePath=this._rulesetSummary[opts._rsi].path;rulePath=this._nd.path.join(rulePath,ruleName+".js");ruleJS=this._nd.ruleLoader(rulePath)}else{rset=this._ruleSets[opts._rsi];if(rset.builtin){ruleJS=this._nd.ruleLoader(ruleName,opts._rsi,this._error)}else if(rset.amdpack){ruleJS=rset.amdpack.rules[ruleName]}}if(!ruleJS){continue}rule=ruleJS;if(rset&&rset.amdpack){try{rule=new ruleJS.default}catch(e){this._showIgnoredRule(`AMD rule '${ruleName}' ${e.message}`,true);rule=null;continue}}else{if(ruleJS.prototype||!ruleJS.getName){try{rule=new ruleJS}catch(e){this._showIgnoredRule(`rule '${ruleName}' ${e.message}`,true);rule=null;continue}}}if(!opts.$internal){if(typeof rule.register!==FUNCTION){this._showIgnoredRule(`rule '${ruleName}' ignored - has no register() method`,true);opts.enabled=false;continue}}if(typeof rule.getName!==FUNCTION){this._showIgnoredRule(`rule '${ruleName}' ignored - has no getName() method`,true);opts.enabled=false;continue}if(typeof rule.getDescription!==FUNCTION){this._showIgnoredRule(`rule '${ruleName}' ignored - has no getDescription() method`,true);opts.enabled=false;continue}if(typeof rule.getShortDescription!==FUNCTION){this._showIgnoredRule(`rule '${ruleName}' ignored - has no getShortDescription() method`,true);opts.enabled=false;continue}if(ruleName!==rule.getName()){this._showIgnoredRule(`rule '${ruleName}' ignored - name '${rule.getName()}' does not match external name '${ruleName}`,true);opts.enabled=false;continue}if(!opts.$internal){this._registerCtx.ruleOpts=clone.cloneOptions(opts);if(opts.filetype){if(typeof opts.filetype==="string"&&opts.filetype==="js"||opts.filetype.includes("js")){this._registerCtx.jsNodeTypes=AstNodeTypes}else if(typeof opts.filetype==="string"&&opts.filetype==="ts"||opts.filetype.includes("ts")){this._registerCtx.tsNodeTypes=AstNodeTypes}}if(this._isCliOrApi){this._registerCtx.utils.fsUtils=this._fsUtils;if(ruleName==="oj-html-cspexpr"){this._registerCtx.decache=this._nd.decache}}this._registerCtx.ruleName=ruleName;this._registerCtx.rulePack._setCBCtx(this._registerCtx);callbacks=rule.register(this._registerCtx);if(!callbacks){this._showIgnoredRule(`rule '${ruleName}' has disabled itself during registration`);opts.enabled=false;continue}for(callback in callbacks){if(callbacks[callback]){callbacks[callback]=callbacks[callback].bind(rule)}else{s=`rule '${ruleName}': listener for '${callback}' in register() is not defined - rule is disabled`;this._error(s);this._showIgnoredRule(s);opts.enabled=false;continue}}if(_isHookRule(callbacks)){opts.$hook=true}else{if(!this._checkRuleSeverity(opts)){this._showIgnoredRule(`rule '${ruleName}' ignored by severity`);opts.enabled=false;continue}}}this._addToShadowRulePacks(ruleName,rule,opts);if(!opts.$internal){this._registry.setRuleCallback(ruleName,callbacks,opts._rsi)}this._ruleCount++;this._updateTargetFiletypes(opts)}catch(e){atLine=e.stack.replace(rulePath,"").trim();i=NaN;if(atLine.startsWith(COLON)){i=parseInt(atLine.substr(1))}if(!isNaN(i)){atLine=" line "+i+": "}else{i=atLine.indexOf(COLON);if(i<0){atLine=""}else{atLine=this._utils.eatLine(atLine,i);i=atLine.indexOf(COLON);if(i>=0){atLine=atLine.substring(i+1);i=atLine.indexOf(")");if(i>=0){atLine="("+atLine.substring(0,i).replace(COLON,",")+") - "}}else{atLine=""}};}this._showIgnoredRule(`Cannot load rule ${ruleName} [${atLine} '${e.message}']`,true)}}}this._showIgnoredRule(null);return true};RuleSet.prototype._showIgnoredRule=function(msg,isError){if(msg){if(!this._ignoredRulesShown){this._info("\n--------- Start-up Rule analysis ---------");this._ignoredRulesShown=true}isError?this._error(msg):this._info(msg)}else if(this._ignoredRulesShown){this._info("------------ End Rule analysis -------------")}};RuleSet.prototype._mergeRuleOptions=function(rulesJson,isBuiltinRules){var prefix,rules,overrides,ruleName,opts,error,x;this._debug("Augmenting config defined rules in rulePack from ruleMods...");prefix=rulesJson.prefix;rules=rulesJson.rules;overrides=this._getRuleModsByPrefix(prefix);for(ruleName in rules){error=false;if(!isBuiltinRules){x=RESERVED_RULE_PREFIX.indexOf(ruleName.toLowerCase());if(x>=0){this._showIgnoredRule(`rule '${ruleName}' in rulepack (prefix: '${prefix}') must not use JET reserved prefix '${RESERVED_RULE_PREFIX[x]}'`,true);error=true}}if(overrides){if(error){continue}if(overrides.hasOwnProperty(ruleName)&&rules[ruleName]){if(this._isAMD){opts=rules[ruleName];if(!_isAMDRule(opts)){if(this._debugMode){this._debug(`Rule options override ignored for non-AMD ${ruleName} in AMD mode`)}continue}if(!this._nd.ruleLoader(ruleName,opts._rsi,this._error)){continue}}if(this._debugMode){this._debug(`Merging rule props of ${ruleName}`)}this._mergeOverrideProps(ruleName,overrides[ruleName],rules[ruleName],isBuiltinRules)}}}};RuleSet.prototype._mergeOverrideProps=function(ruleName,configOpts,ruleOpts){var prop;for(prop in configOpts){if(prop.charAt(0)==="$"){delete configOpts[prop];this._showIgnoredRule(`rule '${ruleName}' : '${prop}' in config 'rulesMod' cannot use reserved '$' prefix`,true);continue}if(prop==="enabled"&&!configOpts[prop]&&ruleOpts["$required"]){this._showIgnoredRule(`rule '${ruleName}' is mandatory and cannot be disabled using config 'ruleMods' property.`,true);continue}ruleOpts[prop]=configOpts[prop]}};RuleSet.prototype._addToShadowRulePacks=function(ruleName,loadedRule,ruleOpts){var rsi=ruleOpts._rsi;var srp=this._shadowRulePacks;while(rsi>=srp.length){srp.push({})}srp[rsi][ruleName]=loadedRule};RuleSet.prototype._updateTargetFiletypes=function(opts){var ft=opts.filetype;if(ft){if(typeof ft==="string"){ft=[ft]}ft.forEach(t=>{if(!opts.$internal){if(!this._targFiletypes.includes(t)){this._targFiletypes.push(t)}}},this)}};RuleSet.prototype._getRuleModsByPrefix=function(prefix){var modPrefix,ret;if(this._ruleMods){prefix=prefix.toLowerCase();for(modPrefix in this._ruleMods){if(prefix===modPrefix.toLowerCase()){ret=this._ruleMods[modPrefix];break}}}return ret};RuleSet.prototype._isGroupActive=function(group){var groups,defs,def,i;groups=this._config.groups;defs=this._config.defGroups;if(this._checkGroups(groups,group)){return true}if(!defs){return false}for(i=0;i<groups.length;i++){def=groups[i];if(this._checkDefGroup(defs,def,group)){return true}}return false};RuleSet.prototype._checkGroups=function(cfgGroups,ruleGroup){var theGroup,i;if(Array.isArray(ruleGroup)){for(i=0;i<ruleGroup.length;i++){theGroup=ruleGroup[i];if(this._checkGroup(cfgGroups,theGroup)){return true}}}else if(this._checkGroup(cfgGroups,ruleGroup)){return true}return false};RuleSet.prototype._checkGroup=function(cfgGroups,group){return!cfgGroups||cfgGroups.includes(group)||cfgGroups.includes(this._severity.ALL)};RuleSet.prototype._isJetInRuleSet=function(jetPrefix){var i,ret=false;if(this._ruleSets&&this._ruleSets.length){for(i=0;i<this._ruleSets.length;i++){if(this._ruleSets[i].prefix===jetPrefix){ret=true;break}}}return ret};RuleSet.prototype._checkRuleSeverity=function(opts){var severities,severity,_sev,i,ret=false;severities=this._config.severity;severity=opts.severity;if(typeof severities==="string"){_sev=this._severity.getConfigSevExpr();if(_sev){ret=true}else{ret=severity===severities||severities===this._severity.ALL}}else{for(var i=0;i<severities.length;i++){if(severity===severities[i]||severities[i]===this._severity.ALL){ret=true;break}}}return ret};RuleSet.prototype._loadJson=function(filepath){var data,stats,msg;try{stats=this._nd.fs.lstatSync(filepath);if(!stats.isFile()){this._error(`RuleSet '${filepath}' not found!`);return null}else{data=this._nd.fs.readFileSync(filepath,"utf8");data=JSON.parse(this._nd.decomment(data))}}catch(e){if(e.code){if(e.message.startsWith("ENOENT:")){this._error(`RuleSet error - '${filepath}' not found!`)}}else if(e.toString().startsWith("SyntaxError")){msg=_convertMsgToRowCol(e.message,data,this._utils)}else{msg=e.message}if(msg){this._error(`JSON load error '${filepath}' - ${msg}`)}data=null}return data};function _isStatEnabledByPack(pstat,rstat){var ret=false;if(pstat.includes("all")||pstat.includes(rstat)){ret=true}else{if(rstat==="ready"||rstat.startsWith("prod")){ret=pstat.includes("ready")||pstat.includes("production")||pstat.includes("prod")}}return ret};function _isHookRule(callbacks){return callbacks[REG.PHASE_STARTUP]||callbacks[REG.PHASE_CLOSEDOWN]||callbacks[REG.PHASE_FILE]?true:false};function _isAMDRule(opts){return opts.hasOwnProperty("amd")?!!opts.amd:true};function _convertMsgToRowCol(msg,data,utils){var x,n,rc;x=msg.indexOf("position");if(x<0){return msg}n=parseInt(msg.substr(x+8).trim());rc=utils.getRowColFromIndex(data,n);return msg.substr(0,x)+"line "+rc.row+", col "+rc.col};function _isRE(s){return RULE_RE.test(s)};module.exports=RuleSet;
|