@oracle/oraclejet-audit 12.0.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/AST_Ts.js +1 -1
- package/lib/AstJson.js +1 -1
- package/lib/AstMd.js +1 -1
- package/lib/AstNodeTypes.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/DomUtils.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/lib/scopewalker.js +1 -1
- package/meta/12.1.0/jetauditmeta.js +9 -0
- 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/jetwc-lib/jetwcutils-preCompiler.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/jaf-ts-walk.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-style-override.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 +38 -9
- package/lib/colors.js +0 -6
package/lib/ConfigLib.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 GROUPS=require("./groups");const DEFAULTS=require("./defaults");const SemVer=require("semver");const COMPOSITES="jet-composites";const TYPE_STRING="string";const TYPE_BOOLEAN="boolean";const AUTO="auto";const ERRORS="errors";const UNDEF="undefined";const NUMBER="number";const TOP_PROPS=["rulePacks","ruleMods","builtinJetRules","builtinCspRules","builtinSpocRules","builtinJetWcRules","builtinJetWcOracleRules","builtinOjcMigrationRules","builtinWebDriverTestRules","severity","groups","defGroups","ruleNames","base","files","exclude","typescript","jetPagesOnly","format","proseFormat","lineFormat","outPath","tabs","messages","addFileList","title","jetVer","components","componentUrls","componentOptions","stylesets","ecmaVer","ruleDescriptions","rulesFired","userDefs","options","comments","extends","extendOptions","nameSpaces","followLinks","tempDir","tokens","common","$JetCore","sevMap","theme","ojet","appendFileList"];const NOT_AMD=["addFileList","base","builtinJetWcRules","builtinJetWcOracleRules","builtinOjcMigrationRules","builtinWebDriverTestRules","components","componentOptions","componentUrls","extends","extendOptions","files","exclude","followLinks","outPath","rulePacks","tempDir","tokens","typescript"];const OPTIONS_PROPS=["debug","verbose","color","msgid","ruleName","retCode","rc","ojetUpdate","$unittest"];const THEMES=["redwood","alta","none"];const DEF_COMMENTS=false;const DEF_RULE_DESCRIPT="none";const DEF_GROUPS=["all"];const DEF_RETCODE="auto";const ECMA_VER=[5,6,7,8,9,10,11];const ECMA_YEAR=[-1,2015,2016,2017,2018,2019,2020];function CfgLib(oConfig,nodeDeps,sevLib,utils,msgCtx,modeCtx){this._oConfig=oConfig;this._config=null;this._dir=null;this._sevLib=sevLib;this._utils=utils;this._nd=nodeDeps;this._msgCtx=msgCtx;this._modeCtx=modeCtx;this._isVerbose=msgCtx.isVerbose;this._isCLI=modeCtx.isCLI||modeCtx.isOJETCLI;this._error=msgCtx.error;this._warn=msgCtx.warn;this._info=msgCtx.info};CfgLib.prototype.setDebugStatus=function(verbose,debug){this._isVerbose=this._msgCtx.isVerbose=verbose};CfgLib.prototype.processWebComponents=function(){var dir,o,t,i;var config=this._config;if(config.componentUrlBase){if(!typeof config.componentUrlBase===TYPE_STRING){this._error("Config entry 'componentUrlBase' must be a string!");return false}}if(config.componentUrls){if(typeof config.componentUrls===TYPE_STRING){config.componentUrls=[config.componentUrls]}else if(!Array.isArray(config.componentUrls)){this._error("Config entry 'componentUrls' must be a string or an aray of strings!");return false}for(i=0;i<this._config.componentUrls.length;i++){config.componentUrls[i]=config.componentUrls[i].trim();if(config.componentUrls[i].length===0){config.componentUrls.splice(i,1);i--}}}if(!config.components){if(this._isCLI&&!this._isOJET&&this._experimentalSet){dir=this._findCompositesDir(config.base);if(dir){config.components=[];config.components.push(this._nd.path.join(dir,COMPOSITES))}}}if(config.components){if(typeof config.components===TYPE_STRING){config.components=[config.components]}else if(!Array.isArray(config.components)){this._error("Config entry 'components' must be a string or an array of strings!");return false}for(i=0;i<config.components.length;i++){config.components[i]=config.components[i].trim();if(config.components[i].length===0){config.components.splice(i,1);i--}}}if(config.components&&config.components.length||config.componentUrls&&config.componentUrls.length){o=config.componentOptions;if(o){if(!this._utils.isObject(o)){this._error("Config 'components' sub-property 'componentOptions' must be an Object!");return false}t=typeof o.applySchema;if(t==="undefined"){o.applySchema=true}else if(t!=="boolean"){this._error("Config 'components' sub-property 'componentOptions' must be an Object!");return false}}}return true};CfgLib.prototype.processTypeScript=function(){var ts,ret=true;if(this._config.hasOwnProperty("typescript")){ts=this._config.typescript;if(!this._utils.isObject(ts)){this._error("Config 'typescript' property is not an object!");ret=false}if(ts.hasOwnProperty("compile")){if(typeof ts.compile!=="boolean"){this._error("Config 'typescript' sub-property 'compile' is not a boolean!");ret=false}}if(ts.hasOwnProperty("tsconfig")){if(typeof ts.tsconfig!=="string"){this._error("Config 'typescript' sub-property 'tsconfig' must be a directory string!");ret=false}}}return ret};CfgLib.prototype.processRulePacks=function(){var packs,pack,i;var config=this._config;if(config.rulePacks){packs=this._config.rulePacks;if(!Array.isArray(packs)){this._error("Config entry 'rulePacks' is not an array!");return false}for(i=0;i<packs.length;i++){pack=packs[i];if(typeof pack!==TYPE_BOOLEAN){pack.enabled=true}if(!pack.path){this._error(`Config entry 'rulePacks' (entry ${i+1}) does not have a 'path' entry!`);return false}else{pack.path=pack.path.trim()}if(pack.status&&!Array.isArray(pack)){this._error(`Config entry 'rulePacks' (entry ${i+1}) 'status' property is not an array!`);return false}}}else{config.rulePacks=[]}return true};CfgLib.prototype.processRuleMods=function(){var mods,mod,val;var config=this._config;const MSG="Config 'ruleMods' sub-property '${mod}' is not an array of rule names or group names!";var b;if(config.ruleMods){mods=config.ruleMods;for(mod in mods){val=mods[mod];if(mod==="enabled"){this._error("'ruleMods' : invalid sub-property 'enabled' - did you mean 'enable'?");b=true}else if(mod==="disabled"){this._error("'ruleMods' : invalid sub-property 'disabled' - did you mean 'disable'?");b=true}if(b){return!b}if(mod==="enable"||mod==="disable"){if(!Array.isArray(val)){this._error(this._utils.format(MSG,{mod:mod}));b=true}if(!this._utils.isArrayContentsType(val,"string")){this._error(this._utils.format(MSG,{mod:mod}));b=true}}else if(!this._utils.isObject(val)){this._error(`Config 'ruleMods' sub-property '${mod}' is not an object!`);b=true}}if(!b&&mods.enable&&mods.disable){let self=this;mods.enable.forEach(function(r){if(mods.disable.includes(r)){self._error(`Config 'ruleMods': 'enable' & 'disable' conflicting entry '${r}'!`);b=true}})}}return!b};CfgLib.prototype.processFormat=function(){var config=this._config;if(config.format){if(config.format!=="json"&&config.format!=="prose"&&config.format!=="line"){this._error(`Config entry 'format' '${config.format}' not valid. Must be 'json', 'prose' or 'line'!`);return false}}return true};CfgLib.prototype.processProseFormat=function(){var config=this._config;if(config.proseFormat){if(typeof config.proseFormat==="string"){if(config.format!=="prose"){this._warn("Config entry 'proseFormat' ignored - not applicable if 'format is not 'prose'!")}}else{this._error(`Config entry 'proseFormat' '${config.proseFormat}' is not valid!`);return false}}return true};CfgLib.prototype.processLineFormat=function(){var config=this._config;if(config.lineFormat){if(typeof config.lineFormat==="string"){if(config.format!=="line"){this._warn("Config entry 'lineFormat' ignored - not applicable if 'format is not 'line'!")}}else{this._error(`Config entry 'lineFormat' '${config.lineFormat}' is not valid!`);return false}}return true};CfgLib.prototype.processRuleDescriptions=function(){var val,valType;var config=this._config;if(config.ruleDescriptions){val=config.ruleDescriptions;valType=typeof val;if(valType!=="string"||val!="all"&&val!=="short"&&val!=="long"&&val!=="none"){this._error(`Config entry 'ruleDescriptions' '${val}' is not valid!`);return false}}else{config.ruleDescriptions=DEF_RULE_DESCRIPT}return true};CfgLib.prototype.processRulesFired=function(){var config=this._config;if(config.rulesFired){if(!this._modeCtx.isAPI&&!this._modeCtx.isAMD&&(!config.format||config.format!=="json")){this._error(`Config entry 'rulesFired' - API/AMD mode required, or 'format' property set to 'json' for CLI mode!`);return false}}return true};CfgLib.prototype.processSevMap=function(){var config=this._config;var set,sev,msgs,inv,mapped,val,b,error;if(!config.sevMap){return true}set=config.sevMap.sevSet;if(set){b=error=false;for(val in set){if(!this._sevLib.isValidConfigSeverity(val)){this._error(`Config entry 'sevMap' sub-property 'sevSet' value '${val}' is not 'major/minor/blocker/critical/info'!`);error=true;continue}if(val==="all"){this._error("Config entry 'sevMap' sub-property 'sevSet' - pseudo severity 'all' cannot be remapped!");error=true;continue}if(typeof set[val]!=="string"){this._error(`Config entry 'sevMap' sub-property 'sevSet' value '${val}' is not a string!`);error=true;continue}b=true}if(error){return false}if(b){inv={};for(sev in set){mapped=set[sev];if(inv[mapped]){if(!Array.isArray(inv[mapped])){inv[mapped]=[inv[mapped]]}inv[mapped].push(sev)}else{inv[mapped]=sev}}this._sevLib.setSevMap(config.sevMap,inv)}else{config.sevMap.sevSet=null}}msgs=config.sevMap.sevMsg;if(msgs){if(!this._utils.isObject(msgs)){this._error("Config entry 'sevMap' sub-property 'sevMsg' is not an object!");return false}b=error=false;for(val in msgs){sev=msgs[val];if(typeof sev!=="string"){this._error(`Config entry 'sevMap' sub-property 'sevMsg' : '${val}' is not a string!`);error=true;continue}if(!this._sevLib.isSev(sev)){this._error(`Config entry 'sevMap' sub-property 'sevMsg' : '${sev}' is ${UNDEF}!`);error=true;continue}b=true}if(error){return false}if(b){this._sevLib.setSevMsg(msgs)}else{config.sevMap.sevMsg=null}}else{b=true;for(val in config.sevMap){if(val!=="sevSet"&&val!=="sevMsg"){this._error(`Config entry 'sevMap' unknown sub-property '${val}'!`);b=false}}if(!b){return false}}return true};CfgLib.prototype.processSeverity=function(cliSev){var config=this._config;var val,se,i;if(cliSev){config.severity=cliSev}if(config.severity){val=config.severity;if(typeof val==="string"){se=this._sevLib.getSevExpr(val);if(!this._sevLib.isValidConfigSeverity(val)){if(se.op&&se.sev==="all"){this._error(`Config entry 'severity' ('${val}') : 'all' cannot be used with a severity expression !`)}else if(cliSev){this._error(`command line --severity '${val}' is not 'major/minor/blocker/critical/info', 'all', or a remapped severity!`)}else{this._error(`Config entry 'severity' ('${val}') is not 'major/minor/blocker/critical/info', 'all', or a remapped severity!`)}return false}this._sevLib.setSevExpr(se)}else if(Array.isArray(val)&&this._utils.isArrayContentsType(val,"string")){for(i=0;i<val.length;i++){if(!this._sevLib.isValidConfigSeverity(val[i])){this._error(`Config entry 'severity' ('${val[i]}') is not 'major/minor/blocker/critical/info', 'all', or a remapped severity!`);return false}}}else{this._error("Config entry 'severity' is invalid!");return false}}else{config.severity=this._sevLib.ALL;this._sevLib.setSevExpr(this._sevLib.getSevExpr(this._sevLib.ALL))}return true};CfgLib.prototype.processGroups=function(cliGroups){var group,i;var config=this._config;if(cliGroups){config.groups=cliGroups}if(!config.groups){config.groups=DEF_GROUPS;return true}if(!Array.isArray(config.groups)){config.groups=[config.groups]}if(config.groups.length===0){config.groups.push("all")}else{for(i=0;i<config.groups.length;i++){group=config.groups[i];if(!GROUPS.isGroup(group)){if(group.startsWith("jet-")||group.startsWith("htm")){this._error(`Config 'groups' entry '${group}' is not defined!`);return false}}}}return true};CfgLib.prototype.processDefGroups=function(){var config=this._config;if(config.defGroups){if(!this._utils.isObject(config.defGroups)){this._error("Config entry 'defGroups' is not an object!");return false}}else{config.defGroups=null}return true};CfgLib.prototype.processRuleNames=function(){var config=this._config;if(config.ruleNames){if(!Array.isArray(config.ruleNames)){this._error("Config entry 'ruleNames' is not an array!");return false}}return true};CfgLib.prototype.processTheme=function(){var t,config=this._config;t=config.theme;if(t){t=t.toLowerCase();if(typeof t==="string"){if(!THEMES.includes(t)){this._error(`Invalid config theme '${t}' : must be 'Redwood' or 'Alta' (or 'none')`);return false}}else{this._error("Config entry 'theme' is not a string!");return false}config.theme=t.charAt(0).toUpperCase()+t.substring(1)}else{config.theme=SemVer.gte(config.jetVer,"12.0.0")?"Redwood":DEFAULTS.THEME;if(this._isVerbose){this._info(`[Info]: Default theme '${config.theme}' applied for jetVer ${config.jetVer}`)}}return true};CfgLib.prototype.processComments=function(){var t,config=this._config;t=typeof config.comments;if(t===UNDEF){config.comments=DEF_COMMENTS}else if(t!=="boolean"){this._error("Invalid 'comments' property - expected a boolean");return false}return true};CfgLib.prototype.processEcmaVer=function(){var val,config=this._config;if(config.ecmaVer){val=config.ecmaVer;if(typeof val==="string"){val=parseInt(val);if(isNaN(val)){val=0}}if(typeof val===NUMBER){if(!(ECMA_VER.includes(val)||ECMA_YEAR.includes(val))){this._error(`Config 'ecmaVer: ${config.ecmaVer}' is not in the version range 5-10 or the year range 2015-2019!`);return false}}if(val>=2015){val=ECMA_YEAR.indexOf(val);config.ecmaVer=ECMA_VER[val]}else{config.ecmaVer=val}}else{config.ecmaVer=DEFAULTS.ECMAVER}return true};CfgLib.prototype.processMessages=function(){var val,config=this._config;if(config.messages){val=config.messages;if(!this._utils.isObject(val)){this._error("Config entry 'messages' is not an object!");return false}if(val.accept&&val.reject){this._error("Config entry 'messages' - 'accept' and 'reject' are mutually exclusive!");return false}if(val.accept){if(!Array.isArray(val.accept)){this._error("Config entry 'messages.accept' is not an array!");return false}else if(!this._utils.isArrayContentsType(val.accept,"string")){this._error("Config entry 'messages.accept' property array does not contain all strings");return false}}if(val.reject){if(!Array.isArray(val.reject)){this._error("Config entry 'messages.reject' is not an array!");return false}else if(!this._utils.isArrayContentsType(val.reject,"string")){this._error("Config entry 'messages.reject' property array does not contain all strings");return false}}}return true};CfgLib.prototype.processAddFileList=function(){var config=this._config;if(config.appendFileList){this._appendFileList=true;this._warn("Configuration property 'appendFileList' : change to 'addFileList'")}else if(config.addFileList){this._addFileList=true}return true};CfgLib.prototype.processNameSpaces=function(){var config,nsp,ns,e;config=this._config;if(!config.nameSpaces){return true}if(!Array.isArray(config.nameSpaces)){config.nameSpaces=[config.nameSpaces]}nsp=config.nameSpaces;for(let i=0;i<nsp.length;i++){ns=nsp[i];if(!ns||typeof ns!=="string"){this._error(`Config 'nameSpaces' entry "${ns}" at index ${i} is not a valid namespace`);e=true}else if(ns.startsWith("oj-")||ns.startsWith("ns-")){this._error(`Config 'nameSpaces' entry '${ns}' must not use reserved JET prefix ${ns.substring(0,3)}`);e=true}}return e?false:true};CfgLib.prototype.processOptions=function(){var prop,opts,config=this._config,isCLI=this._modeCtx.isCLI||this._modeCtx.isOJETCLI;if(config.options){opts=config.options;for(prop in opts){if(!OPTIONS_PROPS.includes(prop)){this._error(`Config - unknown 'options' sub-property '${prop}'`);return false}else if((prop==="retCode"||prop==="rc")&&!isCLI){this._error(`Config - 'options' property '${prop}' is valid in CLI mode only`);return false}}}return true};CfgLib.prototype.processExtends=function(oCfg){if(this._config.extendOptions){if(!this._utils.isObject(this._config.extendOptions)){this._error("Config 'extendOptions' is not an object.");return false}}var extLib=new this._nd.extends(this,this._oConfig,oCfg,this._path,this._nd,this._msgCtx,this._utils);var cfg=extLib.extend();return cfg};CfgLib.prototype.processTitle=function(){var t,config=this._config;if(config.title){t=this._utils.getType(config.title);if(t!=="string"&&t!=="array"){this._error(`Config entry 'title has incorrect type ('${t}')`);return false}}return true};CfgLib.prototype.processRetCode=function(){var rc,prop,ret,config=this._config;if(config.options){prop=typeof config.options.retCode!==UNDEF?"retCode":typeof config.options.rc!==UNDEF?"rc":null;if(prop){rc=config.options[prop];ret=this.validateRetCode(rc,sev=>{this._error(`Config entry 'options.${prop}' : unknown severity '${sev}'`)});if(ret||typeof ret==="number"){config.options[prop]=ret}else{config.options[prop]=AUTO;return false}}}if(!prop){if(!config.options){config.options={}}config.options.retCode=DEF_RETCODE}return true};CfgLib.prototype.validateFileList=function(aFiles){var i,j,f,msg,ret=true;;for(i=0;i<aFiles.length;i++){f=aFiles[i];if(typeof f==="string"){continue}if(!this._utils.isObject(f)){msg=" property entry "+(i+1)+" is not a string or an object";break}if(f.files){if(!(Array.isArray(f.files)&&this._utils.isArrayContentsType(f.files,"string"))){msg=" property entry "+(i+1)+" does not contain a 'files' property array, or not all elements are strings";break}}else{msg=" property entry "+(i+1)+", does not contain a 'files' property";break}if(!f.base){msg=" property entry "+(i+1)+" does not contain a 'base' property";break}for(j=0;j<f.files.length;j++){f.files[j]=this._nd.path.join(f.base,f.files[j])}}if(!msg){for(i=0;i<aFiles.length;i++){f=aFiles[i];if(this._utils.isObject(f)){aFiles.splice(i,1,...f.files)}}}if(msg){this._error(msg);ret=false}return ret};CfgLib.prototype.validateRetCode=function(val,cb){var t,i,b;t=typeof val;if(t==="number"||t==="string"&&val===DEF_RETCODE||val===ERRORS){return val}if(t==="string"){if(!this._sevLib.isSev(val)){cb(val);return false}else{return this._sevLib.unmap(val)}}if(Array.isArray(val)){b=true;for(i=0;i<val.length;i++){if(!this._sevLib.isSev(val[i])){cb(val[i]);b=false}else{val[i]=this._sevLib.unmap(val[i])}}if(b){for(i=0;i<val.length;i++){if(Array.isArray(val[i])){let ar=[];for(i=0;i<val.length;i++){ar=ar.concat(val[i])}val=ar;break}}return val}}return false};CfgLib.prototype.setMessages=function(msgid,state){var accept,reject,msgs,target,changed=false,i;var config=this._config;msgs=config.messages;state=!!state;if(!msgs){if(!state){config.messages={reject:[msgid]};changed=true}}else{reject=msgs.reject;accept=msgs.accept;target=accept||reject;i=target?target.indexOf(msgid):-1;if(state){if(!accept&&!reject){msgs.accept=accept=[]}if(reject){if(i>=0){reject.splice(i,1);changed=true;if(reject.length===0){delete msgs.reject}}}else if(accept){if(i<0){accept.push(msgid);changed=true}}}else{if(!accept&&!reject){msgs.reject=reject=[]}if(reject){if(i<0){reject.push(msgid);changed=true}}else if(accept){if(i>=0){accept.splice(i,1);if(accept.length===0){delete msgs.accept}changed=true}}}}return changed};CfgLib.prototype.getAddFileList=function(){return!!(this._addFileList||this._appendFileList)};CfgLib.prototype.checkPropNames=function(cfg,path){var prop,ret=true,config=cfg?cfg:this._config;for(prop in config){if(!TOP_PROPS.includes(prop)){if(prop.charAt(0)==="_"){delete config[prop];continue}this._error(`Config - unknown property '${prop}' ${path?path:""}!`);ret=false}else if(this._modeCtx.isAMD&&NOT_AMD.includes(prop)){this._error(`Config - property '${prop}' is not available in AMD mode!`);ret=false}}return ret};CfgLib.prototype.setConfig=function(cfg,cfgPath,dir){this._config=cfg;this._path=cfgPath;this._dir=dir};CfgLib.prototype._findCompositesDir=function(base){return this._nd.fsUtils.findFile(base,COMPOSITES)};module.exports=CfgLib;
|
|
6
|
+
const GROUPS=require("./groups");const DEFAULTS=require("./defaults");const SemVer=require("semver");const COMPOSITES="jet-composites";const TYPE_STRING="string";const TYPE_BOOLEAN="boolean";const AUTO="auto";const ERRORS="errors";const UNDEF="undefined";const NUMBER="number";const TOP_PROPS=["rulePacks","ruleMods","builtinJetRules","builtinCspRules","builtinSpocRules","builtinJetWcRules","builtinJetWcOracleRules","builtinOjcMigrationRules","builtinWebDriverTestRules","severity","groups","defGroups","ruleNames","base","files","exclude","typescript","jetPagesOnly","format","proseFormat","lineFormat","outPath","tabs","messages","addFileList","title","jetVer","components","componentUrls","componentOptions","jetCorePack","markdownOptions","stylesets","ecmaVer","ruleDescriptions","rulesFired","userDefs","options","comments","extends","extendOptions","nameSpaces","followLinks","tempDir","tokens","common","$JetCore","sevMap","theme","ojet","appendFileList"];const NOT_AMD=["addFileList","base","builtinJetWcRules","builtinJetWcOracleRules","builtinOjcMigrationRules","builtinWebDriverTestRules","components","componentOptions","componentUrls","extendOptions","files","exclude","followLinks","outPath","rulePacks","tempDir","tokens","typescript"];const OPTIONS_PROPS=["debug","verbose","color","msgid","ruleName","retCode","rc","ojetUpdate","$unittest"];const THEMES=["redwood","alta","stable","none"];const DEF_COMMENTS=false;const DEF_RULE_DESCRIPT="none";const DEF_GROUPS=["all"];const DEF_RETCODE="auto";const ECMA_VER=[5,6,7,8,9,10,11];const ECMA_YEAR=[-1,2015,2016,2017,2018,2019,2020];function CfgLib(oConfig,nodeDeps,sevLib,utils,fsUtils,msgCtx,modeCtx){this._oConfig=oConfig;this._config=null;this._dir=null;this._sevLib=sevLib;this._utils=utils;this._fsUtils=fsUtils;this._nd=nodeDeps;this._msgCtx=msgCtx;this._modeCtx=modeCtx;this._isVerbose=msgCtx.isVerbose;this._isCLI=modeCtx.isCLI||modeCtx.isOJETCLI;this._error=msgCtx.error;this._warn=msgCtx.warn;this._info=msgCtx.info};CfgLib.prototype.setDebugStatus=function(verbose,debug){this._isVerbose=this._msgCtx.isVerbose=verbose};CfgLib.prototype.processWebComponents=function(){var dir,o,t,i;var config=this._config;if(config.componentUrlBase){if(!typeof config.componentUrlBase===TYPE_STRING){this._error("Config entry 'componentUrlBase' must be a string!");return false}}if(config.componentUrls){if(typeof config.componentUrls===TYPE_STRING){config.componentUrls=[config.componentUrls]}else if(!Array.isArray(config.componentUrls)){this._error("Config entry 'componentUrls' must be a string or an aray of strings!");return false}for(i=0;i<this._config.componentUrls.length;i++){config.componentUrls[i]=config.componentUrls[i].trim();if(config.componentUrls[i].length===0){config.componentUrls.splice(i,1);i--}}}if(!config.components){if(this._isCLI&&!this._isOJET&&this._experimentalSet){dir=this._findCompositesDir(config.base);if(dir){config.components=[];config.components.push(this._nd.path.join(dir,COMPOSITES))}}}if(config.components){if(typeof config.components===TYPE_STRING){config.components=[config.components]}else if(!Array.isArray(config.components)){this._error("Config entry 'components' must be a string or an array of strings!");return false}for(i=0;i<config.components.length;i++){config.components[i]=config.components[i].trim();if(config.components[i].length===0){config.components.splice(i,1);i--}}}if(config.components&&config.components.length||config.componentUrls&&config.componentUrls.length){o=config.componentOptions;if(o){if(!this._utils.isObject(o)){this._error("Config 'components' sub-property 'componentOptions' must be an Object!");return false}t=typeof o.applySchema;if(t==="undefined"){o.applySchema=true}else if(t!=="boolean"){this._error("Config 'components' sub-property 'componentOptions' must be an Object!");return false}}}return true};CfgLib.prototype.processJetCorePack=function(){var config=this._config;var ret=true;if(!config.hasOwnProperty("jetCorePack")){return ret}let t=typeof config.jetCorePack;if(t===TYPE_BOOLEAN){if(config.jetCorePack){this._error("Config 'jetCorePack' property value cannot be boolean true!");ret=false}return ret}if(SemVer.lt(config.jetVer,"13.0.0")){this._error("Config 'jetCorePack' is valid for 'jetVer' values >= 13.0.0 only");ret=false}if(t!==TYPE_STRING){this._error("Config 'jetCorePack' property is not a string or a boolean!");ret=false}return ret};CfgLib.prototype.processTypeScript=function(){var ts,ret=true;if(this._config.hasOwnProperty("typescript")){ts=this._config.typescript;if(!this._utils.isObject(ts)){this._error("Config 'typescript' property is not an object!");ret=false}if(ts.hasOwnProperty("compile")){if(typeof ts.compile!=="boolean"){this._error("Config 'typescript' sub-property 'compile' is not a boolean!");ret=false}}if(ts.hasOwnProperty("tsconfig")){if(typeof ts.tsconfig!=="string"){this._error("Config 'typescript' sub-property 'tsconfig' must be a directory string!");ret=false}}}return ret};CfgLib.prototype.processRulePacks=function(){var packs,pack,i;var config=this._config;if(config.rulePacks){packs=this._config.rulePacks;if(!Array.isArray(packs)){this._error("Config entry 'rulePacks' is not an array!");return false}for(i=0;i<packs.length;i++){pack=packs[i];if(typeof pack!==TYPE_BOOLEAN){pack.enabled=true}if(!pack.path){this._error(`Config entry 'rulePacks' (entry ${i+1}) does not have a 'path' entry!`);return false}else{pack.path=pack.path.trim()}if(pack.status&&!Array.isArray(pack)){this._error(`Config entry 'rulePacks' (entry ${i+1}) 'status' property is not an array!`);return false}}}else{config.rulePacks=[]}return true};CfgLib.prototype.processRuleMods=function(cfg,fp){var mods,mod,val;var config=cfg?cfg:this._config;const MSG="Config 'ruleMods' sub-property '${mod}' is not an array of rule names or group names";var self=this,b;if(!config.ruleMods){return true}function _emitRMError(s){s+=fp?` - in ${fp}`:"";self._error(s);b=true}mods=config.ruleMods;if(!this._utils.isObject(mods)){_emitRMError("Configuration property 'ruleMods' is not an object");return false}for(mod in mods){if(mod==="enabled"){_emitRMError("Config 'ruleMods' : invalid sub-property 'enabled' - did you mean 'enable'?")}else if(mod==="disabled"){_emitRMError("Config 'ruleMods' : invalid sub-property 'disabled' - did you mean 'disable'?")}if(b){return!b}val=mods[mod];if(mod==="enable"||mod==="disable"){if(!Array.isArray(val)){_emitRMError(this._utils.format(MSG,{mod:mod}))}if(!this._utils.isArrayContentsType(val,"string")){_emitRMError(this._utils.format(MSG,{mod:mod}))}}else if(!this._utils.isObject(val)){_emitRMError(`Config 'ruleMods' sub-property '${mod}' is not an object!`)}}if(!b&&mods.enable&&mods.disable){mods.enable.forEach(function(r){if(mods.disable.includes(r)){_emitRMError(`Config 'ruleMods': 'enable' & 'disable' conflicting entry '${r}'`)}})}return!b};CfgLib.prototype.processFormat=function(){var config=this._config;if(config.format){if(config.format!=="json"&&config.format!=="prose"&&config.format!=="line"){this._error(`Config entry 'format' '${config.format}' not valid. Must be 'json', 'prose' or 'line'!`);return false}}return true};CfgLib.prototype.processProseFormat=function(){var config=this._config;if(config.proseFormat){if(typeof config.proseFormat==="string"){if(config.format!=="prose"){this._warn("Config entry 'proseFormat' ignored - not applicable if 'format is not 'prose'!")}}else{this._error(`Config entry 'proseFormat' '${config.proseFormat}' is not valid!`);return false}}return true};CfgLib.prototype.processLineFormat=function(){var config=this._config;if(config.lineFormat){if(typeof config.lineFormat==="string"){if(config.format!=="line"){this._warn("Config entry 'lineFormat' ignored - not applicable if 'format is not 'line'!")}}else{this._error(`Config entry 'lineFormat' '${config.lineFormat}' is not valid!`);return false}}return true};CfgLib.prototype.processRuleDescriptions=function(){var val,valType;var config=this._config;if(config.ruleDescriptions){val=config.ruleDescriptions;valType=typeof val;if(valType!=="string"||val!="all"&&val!=="short"&&val!=="long"&&val!=="none"){this._error(`Config entry 'ruleDescriptions' '${val}' is not valid!`);return false}}else{config.ruleDescriptions=DEF_RULE_DESCRIPT}return true};CfgLib.prototype.processRulesFired=function(){var config=this._config;if(config.rulesFired){if(!this._modeCtx.isAPI&&!this._modeCtx.isAMD&&(!config.format||config.format!=="json")){this._error(`Config entry 'rulesFired' - API/AMD mode required, or 'format' property set to 'json' for CLI mode!`);return false}}return true};CfgLib.prototype.processSevMap=function(){var config=this._config;var set,sev,msgs,inv,mapped,val,b,error;if(!config.sevMap){return true}set=config.sevMap.sevSet;if(set){b=error=false;for(val in set){if(!this._sevLib.isValidConfigSeverity(val)){this._error(`Config entry 'sevMap' sub-property 'sevSet' value '${val}' is not 'blocker/critical/major/minor/info'!`);error=true;continue}if(val==="all"){this._error("Config entry 'sevMap' sub-property 'sevSet' - pseudo severity 'all' cannot be remapped!");error=true;continue}if(typeof set[val]!=="string"){this._error(`Config entry 'sevMap' sub-property 'sevSet' value '${val}' is not a string!`);error=true;continue}b=true}if(error){return false}if(b){inv={};for(sev in set){mapped=set[sev];if(inv[mapped]){if(!Array.isArray(inv[mapped])){inv[mapped]=[inv[mapped]]}inv[mapped].push(sev)}else{inv[mapped]=sev}}this._sevLib.setSevMap(config.sevMap,inv)}else{config.sevMap.sevSet=null}}msgs=config.sevMap.sevMsg;if(msgs){if(!this._utils.isObject(msgs)){this._error("Config entry 'sevMap' sub-property 'sevMsg' is not an object!");return false}b=error=false;for(val in msgs){sev=msgs[val];if(typeof sev!=="string"){this._error(`Config entry 'sevMap' sub-property 'sevMsg' : '${val}' is not a string!`);error=true;continue}if(!this._sevLib.isSev(sev)){this._error(`Config entry 'sevMap' sub-property 'sevMsg' : '${sev}' is ${UNDEF}!`);error=true;continue}b=true}if(error){return false}if(b){this._sevLib.setSevMsg(msgs)}else{config.sevMap.sevMsg=null}}else{b=true;for(val in config.sevMap){if(val!=="sevSet"&&val!=="sevMsg"){this._error(`Config entry 'sevMap' unknown sub-property '${val}'!`);b=false}}if(!b){return false}}return true};CfgLib.prototype.processSeverity=function(cliSev){var config=this._config;var val,se,i;if(cliSev){config.severity=cliSev}if(config.severity){val=config.severity;if(typeof val==="string"){se=this._sevLib.getSevExpr(val);if(!this._sevLib.isValidConfigSeverity(val)){if(se.op&&se.sev==="all"){this._error(`Config entry 'severity' ('${val}') : 'all' cannot be used with a severity expression !`)}else if(cliSev){this._error(`command line --severity '${val}' is not 'major/minor/blocker/critical/info', 'all', or a remapped severity!`)}else{this._error(`Config entry 'severity' ('${val}') is not 'major/minor/blocker/critical/info', 'all', or a remapped severity!`)}return false}this._sevLib.setSevExpr(se)}else if(Array.isArray(val)&&this._utils.isArrayContentsType(val,"string")){for(i=0;i<val.length;i++){if(!this._sevLib.isValidConfigSeverity(val[i])){this._error(`Config entry 'severity' ('${val[i]}') is not 'major/minor/blocker/critical/info', 'all', or a remapped severity!`);return false}}}else{this._error("Config entry 'severity' is invalid!");return false}}else{config.severity=this._sevLib.ALL;this._sevLib.setSevExpr(this._sevLib.getSevExpr(this._sevLib.ALL))}return true};CfgLib.prototype.processGroups=function(cliGroups){var group,i;var config=this._config;if(cliGroups){config.groups=cliGroups}if(!config.groups){config.groups=DEF_GROUPS;return true}if(!Array.isArray(config.groups)){config.groups=[config.groups]}if(config.groups.length===0){config.groups.push("all")}else{for(i=0;i<config.groups.length;i++){group=config.groups[i];if(!GROUPS.isGroup(group)){if(group.startsWith("jet-")||group.startsWith("htm")){this._error(`Config 'groups' entry '${group}' is not defined!`);return false}}}}return true};CfgLib.prototype.processDefGroups=function(){var config=this._config;if(config.defGroups){if(!this._utils.isObject(config.defGroups)){this._error("Config entry 'defGroups' is not an object!");return false}}else{config.defGroups=null}return true};CfgLib.prototype.processRuleNames=function(){var config=this._config;if(config.ruleNames){if(!Array.isArray(config.ruleNames)){this._error("Config entry 'ruleNames' is not an array!");return false}}return true};CfgLib.prototype.processTheme=function(){var t,config=this._config;t=config.theme;if(t){t=t.toLowerCase();if(typeof t==="string"){if(!THEMES.includes(t)){this._error(`Invalid config theme '${t}' : must be 'Redwood', 'Alta', 'Stable' or 'none'`);return false}}else{this._error("Config entry 'theme' is not a string!");return false}if(t==="stable"){t="redwood"};config.theme=t.charAt(0).toUpperCase()+t.substring(1)}else{config.theme=SemVer.gte(config.jetVer,"12.0.0")?"Redwood":DEFAULTS.THEME;if(this._isVerbose){this._info(`[Info]: Default theme '${config.theme}' applied for jetVer ${config.jetVer}`)}}return true};CfgLib.prototype.processComments=function(){var t,config=this._config;t=typeof config.comments;if(t===UNDEF){config.comments=DEF_COMMENTS}else if(t!=="boolean"){this._error("Invalid 'comments' property - expected a boolean");return false}return true};CfgLib.prototype.processMarkdownOpts=function(){var config=this._config;var val=config.markdownOptions;var t=typeof val;if(t===UNDEF){config.markdownOptions={linkify:true}}else if(Array.isArray(val)||t!=="object"){this._error("Invalid 'markdownOptions' property - expected an object");return false}else{t=typeof val.linkify;if(t==="undefined"){val.linkify=true}else if(typeof val.linkify!=="boolean"){this._error("Invalid 'markdownOptions.linkify' - expected a boolean");return false}let n=Object.keys(val);if(!val.hasOwnProperty("linkify")){if(n.length){this._error("Invalid 'markdownOptions.linkify' - expected a boolean");return false}else{val.linkify=true}}else if(n.length>1){this._error("Invalid 'markdownOptions' properties found");return false}}return true};CfgLib.prototype.processEcmaVer=function(){var val,config=this._config;if(config.ecmaVer){val=config.ecmaVer;if(typeof val==="string"){val=parseInt(val);if(isNaN(val)){val=0}}if(typeof val===NUMBER){if(!(ECMA_VER.includes(val)||ECMA_YEAR.includes(val))){this._error(`Config 'ecmaVer: ${config.ecmaVer}' is not in the version range ${ECMA_VER[0]}-${ECMA_VER[ECMA_VER.length-1]} or the year range ${ECMA_YEAR[1]}-${ECMA_YEAR[ECMA_YEAR.length-1]}!`);return false}}if(val>=2015){val=ECMA_YEAR.indexOf(val);config.ecmaVer=ECMA_VER[val]}else{config.ecmaVer=val}}else{config.ecmaVer=DEFAULTS.ECMAVER}return true};CfgLib.prototype.processMessages=function(){var val,config=this._config;if(config.messages){val=config.messages;if(!this._utils.isObject(val)){this._error("Config entry 'messages' is not an object!");return false}if(val.accept&&val.reject){this._error("Config entry 'messages' - 'accept' and 'reject' are mutually exclusive!");return false}if(val.accept){if(!Array.isArray(val.accept)){this._error("Config entry 'messages.accept' is not an array!");return false}else if(!this._utils.isArrayContentsType(val.accept,"string")){this._error("Config entry 'messages.accept' property array does not contain all strings");return false}}if(val.reject){if(!Array.isArray(val.reject)){this._error("Config entry 'messages.reject' is not an array!");return false}else if(!this._utils.isArrayContentsType(val.reject,"string")){this._error("Config entry 'messages.reject' property array does not contain all strings");return false}}}return true};CfgLib.prototype.processAddFileList=function(){var config=this._config;if(config.appendFileList){this._appendFileList=true;this._warn("Configuration property 'appendFileList' : change to 'addFileList'")}else if(config.addFileList){this._addFileList=true}return true};CfgLib.prototype.processNameSpaces=function(){var config,nsp,ns,e;config=this._config;if(!config.nameSpaces){return true}if(!Array.isArray(config.nameSpaces)){config.nameSpaces=[config.nameSpaces]}nsp=config.nameSpaces;for(let i=0;i<nsp.length;i++){ns=nsp[i];if(!ns||typeof ns!=="string"){this._error(`Config 'nameSpaces' entry "${ns}" at index ${i} is not a valid namespace`);e=true}else if(ns.startsWith("oj-")||ns.startsWith("ns-")){this._error(`Config 'nameSpaces' entry '${ns}' must not use reserved JET prefix ${ns.substring(0,3)}`);e=true}}return e?false:true};CfgLib.prototype.processOptions=function(){var prop,opts,config=this._config,isCLI=this._modeCtx.isCLI||this._modeCtx.isOJETCLI;if(config.options){opts=config.options;for(prop in opts){if(!OPTIONS_PROPS.includes(prop)){this._error(`Config - unknown 'options' sub-property '${prop}'`);return false}else if((prop==="retCode"||prop==="rc")&&!isCLI){this._error(`Config - 'options' property '${prop}' is valid in CLI mode only`);return false}}}return true};CfgLib.prototype.processExtends=function(){var config=this._config;var ext;if(this._modeCtx.isAMD){if(ext=config.extends){if(typeof ext==="string"){this._error("Config use of non-profile 'extends' property is not supported in AMD mode.");return false}}if(config.extendOptions){this._error("Config use of 'extendOptions' property is not supported in AMD mode.");return false}}if(this._config.extendOptions){if(!this._utils.isObject(this._config.extendOptions)){this._error("Config 'extendOptions' is not an object.");return false}}var extLib=new this._nd.extends(this,this._oConfig,config,this._path,this._nd,this._msgCtx,this._utils,this._fsUtils,this._modeCtx.isAMD);var cfg=extLib.extend();return cfg};CfgLib.prototype.processTitle=function(){var t,config=this._config;if(config.title){t=this._utils.getType(config.title);if(t!=="string"&&t!=="array"){this._error(`Config entry 'title has incorrect type ('${t}')`);return false}}return true};CfgLib.prototype.processRetCode=function(){var rc,prop,ret,config=this._config;if(config.options){prop=typeof config.options.retCode!==UNDEF?"retCode":typeof config.options.rc!==UNDEF?"rc":null;if(prop){rc=config.options[prop];ret=this.validateRetCode(rc,sev=>{this._error(`Config entry 'options.${prop}' : unknown severity '${sev}'`)});if(ret||typeof ret==="number"){config.options[prop]=ret}else{config.options[prop]=AUTO;return false}}}if(!prop){if(!config.options){config.options={}}config.options.retCode=DEF_RETCODE}return true};CfgLib.prototype.validateFileList=function(aFiles){var i,j,f,msg,ret=true;;for(i=0;i<aFiles.length;i++){f=aFiles[i];if(typeof f==="string"){continue}if(!this._utils.isObject(f)){msg=" property entry "+(i+1)+" is not a string or an object";break}if(f.files){if(!(Array.isArray(f.files)&&this._utils.isArrayContentsType(f.files,"string"))){msg=" property entry "+(i+1)+" does not contain a 'files' property array, or not all elements are strings";break}}else{msg=" property entry "+(i+1)+", does not contain a 'files' property";break}if(!f.base){msg=" property entry "+(i+1)+" does not contain a 'base' property";break}for(j=0;j<f.files.length;j++){f.files[j]=this._nd.path.join(f.base,f.files[j])}}if(!msg){for(i=0;i<aFiles.length;i++){f=aFiles[i];if(this._utils.isObject(f)){aFiles.splice(i,1,...f.files)}}}if(msg){this._error(msg);ret=false}return ret};CfgLib.prototype.validateRetCode=function(val,cb){var t,i,b;t=typeof val;if(t==="number"||t==="string"&&val===DEF_RETCODE||val===ERRORS){return val}if(t==="string"){if(!this._sevLib.isSev(val)){cb(val);return false}else{return this._sevLib.unmap(val)}}if(Array.isArray(val)){b=true;for(i=0;i<val.length;i++){if(!this._sevLib.isSev(val[i])){cb(val[i]);b=false}else{val[i]=this._sevLib.unmap(val[i])}}if(b){for(i=0;i<val.length;i++){if(Array.isArray(val[i])){let ar=[];for(i=0;i<val.length;i++){ar=ar.concat(val[i])}val=ar;break}}return val}}return false};CfgLib.prototype.setMessages=function(msgid,state){var accept,reject,msgs,target,changed=false,i;var config=this._config;msgs=config.messages;state=!!state;if(!msgs){if(!state){config.messages={reject:[msgid]};changed=true}}else{reject=msgs.reject;accept=msgs.accept;target=accept||reject;i=target?target.indexOf(msgid):-1;if(state){if(!accept&&!reject){msgs.accept=accept=[]}if(reject){if(i>=0){reject.splice(i,1);changed=true;if(reject.length===0){delete msgs.reject}}}else if(accept){if(i<0){accept.push(msgid);changed=true}}}else{if(!accept&&!reject){msgs.reject=reject=[]}if(reject){if(i<0){reject.push(msgid);changed=true}}else if(accept){if(i>=0){accept.splice(i,1);if(accept.length===0){delete msgs.accept}changed=true}}}}return changed};CfgLib.prototype.getAddFileList=function(){return!!(this._addFileList||this._appendFileList)};CfgLib.prototype.checkPropNames=function(cfg,path){var prop,ret=true,config=cfg?cfg:this._config;path=path||this._path;for(prop in config){if(!TOP_PROPS.includes(prop)){if(prop.charAt(0)==="_"){delete config[prop];continue}this._error(`Config - unknown property '${prop}' ${path?"- "+path:""}`);ret=false}else if(this._modeCtx.isAMD&&NOT_AMD.includes(prop)){this._error(`Config - property '${prop}' is not available in AMD mode!`);ret=false}}return ret};CfgLib.prototype.setConfig=function(cfg,cfgPath,dir){this._config=cfg;this._path=cfgPath;this._dir=dir};CfgLib.prototype._findCompositesDir=function(base){return this._fsUtils.findFile(base,COMPOSITES)};module.exports=CfgLib;
|
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/DomUtils.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 jsonParser=require('really-relaxed-json').createParser();const HtmlUtils=require('./HtmlUtils');const NodeType=require('./NodeTypes');const OJCOMPONENT='ojComponent';const COMPONENT='component';const SVG_PATH_COMMANDS=['M','m','L','I','H','h','V','v','C','c','S','s','Q','q','T','t','A','a','Z','z'];const DOT='.';const ON_DASH='on-';function DomUtils(nodeDeps,appContext,oTabs,fileIndex){this._tree=null;this._nodeDeps=nodeDeps;this._appContext=appContext;this._tabs=oTabs;this._utils=appContext.utils;this._fileIndex=fileIndex};DomUtils.prototype.getFirst=function(){return this._tree.length?this._tree[0]:null};DomUtils.prototype.getLast=function(){var node;node=this._tree.length?this._tree[this._tree.length-1]:null;while(node&&node.children&&node.children.length){node=node.children[node.children.length-1]}return node};DomUtils.prototype.getFirstElem=function(){var node=this.getFirst();while(node){if(node.type===NodeType.TAG){break};node=node.next}return node};DomUtils.prototype.getChildren=function(node){return node.children};DomUtils.prototype.getParent=function(node){return node.parent};DomUtils.prototype.getSiblings=function(node){var parent;if(parent=this.getParent(node)){return this.getChildren(parent)}else{return this._tree}};DomUtils.prototype.getNext=function(node){return node.next||null};DomUtils.prototype.getAttribs=function(node){return node.attribs||null};DomUtils.prototype.getAttribValue=function(node,name){return node.attribs?node.attribs[name]:undefined};DomUtils.prototype.getAttribRawValue=function(ruleCtx,name){var val,pos;if(ruleCtx.tagNode.attribs){if(typeof(val=ruleCtx.tagNode.attribs[name])==='string'){pos=this.getAttrPosition(ruleCtx.data,ruleCtx.tagNode,name);return _getAttrRawValue(ruleCtx.data,pos.start,name,val,ruleCtx.utils.utils)}}};DomUtils.prototype.hasAttrib=function(node,name){return!!node.attribs&&hasOwnProperty.call(node.attribs,name)};DomUtils.prototype.hasChildren=function(node){return!!node.children};DomUtils.prototype.hasNext=function(node){return!!node.next};DomUtils.prototype.getName=function(node){return node.name};DomUtils.prototype.getType=function(node){return node.type};DomUtils.prototype.getElemsByName=function(name){var a=[],i,names;if(!this._tree){return a}names=typeof name==='string'?[name]:name;for(i=0;i<names.length;i++){names[i]=names[i].toLowerCase()}for(i=0;i<this._tree.length;i++){_getElemsByName2(this._tree[i],a,names)}return a};function _getElemsByName2(node,a,names){var children,i;if((node.type===NodeType.TAG||node.type===NodeType.SCRIPT)&&names.indexOf(node.name.toLowerCase())>=0){a.push(node)}if(node.children){children=node.children;for(i=0;i<children.length;i++){_getElemsByName2(children[i],a,names)}}};DomUtils.prototype.getElemById=function(id,labelId){var node,i;if(!this._tree){return null}for(i=0;i<this._tree.length;i++){node=this._tree[i];if(node.type===NodeType.TAG||_isHtmlScript(node)){node=this._getElemById2(node,id,labelId);if(node){return node}}}return null};DomUtils.prototype._getElemById2=function(node,id,labelId){var curNode,attrib,attr,attribLower,i;if((node.type===NodeType.TAG||_isHtmlScript(node))&&node.attribs){for(attrib in node.attribs){attribLower=attrib.toLowerCase();if(attribLower==='id'||labelId&&attribLower==='label-id'){if(node.attribs[attrib]===id){return node}}else if(attrib==='data-bind'){attr=this.extractAttribsFromDataBind(node.attribs[attrib]);if(attr&&attr['id']===id){return node}}}}if(node.children){for(i=0;i<node.children.length;i++){curNode=this._getElemById2(node.children[i],id,labelId);if(curNode){return curNode}}}return null};DomUtils.prototype.getElems=function(){var a=[],i;if(!this._tree){return a}for(i=0;i<this._tree.length;i++){_getElems2(this._tree[i],a)}return a};function _getElems2(node,a){var children,i;if(node.type===NodeType.TAG||node.type===NodeType.SCRIPT){a.push(node)}if(node.children){children=node.children;for(i=0;i<children.length;i++){_getElems2(children[i],a)}}};DomUtils.prototype.getScripts=function(){var head,ch,a=[];if(head=this.getHead()){if(ch=head.children){ch.forEach(elem=>{if(elem.type===NodeType.TAG&&elem.name==='script'){a.push(elem)}})}}return a};DomUtils.prototype.getLinks=function(){var head,ch,a=[];if(head=this.getHead()){if(ch=head.children){ch.forEach(elem=>{if(elem.type===NodeType.TAG&&elem.name==='link'){a.push(elem)}})}}return a};DomUtils.prototype.getHead=function(){var elem,ch,i;if(!this._tree){return null}for(i=0;i<this._tree.length;i++){elem=this._tree[i];if(elem.type===NodeType.TAG&&elem.name==='html'){if(ch=elem.children){for(i=0;i<ch.length;i++){elem=ch[i];if(elem.type===NodeType.TAG&&elem.name==='head'){return elem}}}break}}return null};DomUtils.prototype.getBody=function(){var elem,ch,i;if(!this._tree){return null}for(i=0;i<this._tree.length;i++){elem=this._tree[i];if(elem.type===NodeType.TAG&&elem.name==='html'){if(ch=elem.children){for(i=0;i<ch.length;i++){elem=ch[i];if(elem.type===NodeType.TAG&&elem.name==='body'){return elem}}}break}}return null};DomUtils.prototype.getComponentElems=function(){var a=[],i;if(!this._tree){return a}for(i=0;i<this._tree.length;i++){this._getComponentElems2(this._tree[i],a)}return a};DomUtils.prototype._getComponentElems2=function(node,a){var children,i;if(node.type===NodeType.TAG&&this._appContext.metaLib.isWCTag(node.name)){a.push(node)}if(node.children){children=node.children;for(i=0;i<children.length;i++){this._getComponentElems2(children[i],a)}}};DomUtils.prototype.isCommonAttr=function(attrName){attrName=attrName.toLowerCase();attrName=attrName.charAt(0)===':'?attrName.substr(1):attrName;return HtmlUtils.isCommonAttr(attrName)};DomUtils.prototype.isCommonEventAttr=function(attrName){attrName=attrName.toLowerCase();attrName=attrName.charAt(0)===':'?attrName.substr(1):attrName;if(attrName.startsWith('on-oj-')){return false}if(attrName.startsWith('on-')){attrName=attrName.substring(0,2)+attrName.substring(3)}return HtmlUtils.isCommonEventAttr(attrName)};DomUtils.prototype.isCommonElem=function(elem){return HtmlUtils.isCommonElem(elem)};DomUtils.prototype.isSvgElem=function(elem){return HtmlUtils.isSvgElem(elem)};DomUtils.prototype.isHtml5ObsoleteElem=function(tag){return HtmlUtils.isHtml5ObsoleteElem(tag)};DomUtils.prototype.isHtml5ObsoleteAttr=function(tagName,attrName){return HtmlUtils.isHtml5ObsoleteAttr(tagName,attrName)};DomUtils.prototype.isSelfClosingTag=function(tag){return HtmlUtils.isSelfClosingTag(tag)};DomUtils.prototype.isNamespaceTag=function(tagName){if(this._appContext.metaLib.isJetTag(tagName)){return true}return HtmlUtils.isNamespaceTag(tagName)};DomUtils.prototype.isNamespacePrefix=function(tagPrefix){return!!HtmlUtils.isNamespacePrefix(tagPrefix)};DomUtils.prototype.isChildOfElem=function(elemName,node){return!!this.isChildOfElemNode(elemName,node)};DomUtils.prototype.isChildOfElemNode=function(elemName,node){var ret=null;while(node.parent){if(node.parent.name===elemName){ret=node.parent;break}node=node.parent}return ret};DomUtils.prototype.getDataBindComponent=function(context){var node,val,attrVal,ret=null;node=context.tagNode;if(this.getAttribs(node)){attrVal=this.getAttribValue(node,'data-bind');if(attrVal){val=this.extractComponentFromDataBind(attrVal);if(val){ret='oj.'+val}}}return ret};DomUtils.prototype.getDataBindAttr=function(context){return this.getDataBindAttrsFromNode(context,context.node)};DomUtils.prototype.getDataBindAttrs=function(context){return this.getDataBindAttrsFromNode(context,context.node)};DomUtils.prototype.getDataBindAttrsFromNode=function(context,node){var attrVal,ret=null;if(this.getAttribs(node)){attrVal=this.getAttribValue(node,'data-bind');if(attrVal){ret=this.extractAttribsFromDataBind(attrVal)}}return ret};DomUtils.prototype.extractComponentFromDataBind=function(attrValue){var dataBind,componentName,x;x=attrValue.indexOf(OJCOMPONENT);if(x<0){return}componentName=null;if(attrValue.length>OJCOMPONENT.length){dataBind=attrValue.substring(x+OJCOMPONENT.length);x=dataBind.indexOf(COMPONENT);if(x>=0){dataBind=dataBind.substring(x+COMPONENT.length).trim();if(dataBind.charAt(0)===':'){x=dataBind.indexOf('oj');if(x>=0){dataBind=dataBind.substring(x);componentName=_extractComponentName(dataBind,this._utils)}}}}return componentName};function _extractComponentName(s,utils){var componentName,i,c;for(i=0;i<s.length;i++){c=s.charAt(i);if(c==='\''||c==='"'||utils.isWhitespace(c)){componentName=s.substring(0,i);break}}return componentName};DomUtils.prototype.extractAttribsFromDataBind=function(attrValue){var s,a,nextAttr,val,i,j,x,ret=null;if(attrValue.indexOf(':')<0){return ret}a=attrValue.split('attr');if(a.length<2){return ret}for(i=0;i<a.length;i++){a[i]=s=a[i].trim();if(s.charAt(0)===':'){s=s.substr(1).trim();if(s.charAt(0)==='{'){try{ret=jsonParser.stringToJson(s);ret=JSON.parse(ret)}catch(e){s=s.substring(1).trim();a=s.split(':');for(j=0;j<a.length;j++){if(nextAttr){if(!ret){ret={}}ret[nextAttr]=val=a[j].replace(/['\"]/g,'').trim();x=val.lastIndexOf('}');if(x>=0){ret[nextAttr]=val.substring(0,x).trim();break}nextAttr=null}if(j+1===a.length){break}a[j]=s=a[j].trim();s=s.replace(/['\"]/g,'').trim();if(s.length===0)continue;if(!ret){ret={}}ret[s]=val=a[++j].trim();x=val.indexOf(',');if(x>=0){ret[s]=val.substring(0,x).replace(/['\"]/g,'').trim();nextAttr=val.substring(x+1).trim();nextAttr=nextAttr.replace(/['\"]/g,'').trim();val=val.substring(0,x).replace(/['\"]/g,'').trim()}else{ret[s]=val.replace(/['\"]/g,'').trim()}x=val.lastIndexOf('}');if(x>=0){ret[s]=val.substring(0,x).trim();break}}}}break}}return ret};DomUtils.prototype.getAttrPosition=function(data,node,attrName){var startIndex=this.getAttrIndex(data,node,attrName);var endIndex=startIndex+attrName.length-1;var rowCol=this._utils.getRowColFromIndex(data,startIndex,'html');rowCol.start=startIndex;rowCol.end=endIndex;return rowCol};DomUtils.prototype.getAttrValuePosition=function(data,node,attrName){var attrPos,pos,endPos,ws,ret,good;var isDouble,isSingle,isUnquoted;attrPos=this.getAttrPosition(data,node,attrName);if(!attrPos||attrPos.start===node.startIndex){return}if((pos=this._utils.eatWhitespace(data,attrPos.end+1))>=0){if(data.charAt(pos++)==='='){if((endPos=this._utils.eatWhitespace(data,pos))>=0){isDouble=data.charAt(endPos)==='"';isSingle=data.charAt(endPos)==='\'';isUnquoted=!(isSingle||isDouble);if(isDouble){if((endPos=data.indexOf('"',pos+1))>=0){good=true}}else if(isSingle){if((endPos=data.indexOf('\'',pos+1))>=0){good=true}}else if(isUnquoted){ws=this._utils.getIndexToWhitespace(data,pos);endPos=data.indexOf('>',pos);if(ws>=0&&endPos>=0){endPos=(endPos<ws?endPos:ws)-1;good=true}}if(good){attrPos=this.getLineCol(data,pos);ret={row:attrPos.row,col:attrPos.col,start:pos,end:endPos}}}}}return ret};DomUtils.prototype.getLineCol=function(data,index){return this._fileIndex.getRowCol(data,{start:index},'html')};DomUtils.prototype.getAttrIndex=function(data,node,attrName){var attribs,index,temp,c,i,isQuote=attrName==='"'||attrName==='\'';attribs=node.attribs;if(!attribs){this._appContext.assert('no attrs in tag '+node.name+'(expected attr \''+attrName+')');return node.startIndex}if(!attribs.hasOwnProperty(attrName)&&!attribs.hasOwnProperty(':'+attrName)){this._appContext.assert('expected attr \''+attrName+'\' in tag '+node.name);return node.startIndex}index=data.indexOf(attrName,node.startIndex);while(true){index=data.indexOf(attrName,index);if(index>=0){temp=data.substring(index+attrName.length,index+100);i=this._utils.eatWhitespace(temp);if(i<0){return node.startIndex}c=temp.charAt(i);if(c==='='||c==='>'||!isQuote&&this._utils.isWhitespace(temp.charAt(0))){return index}index+=i+1;continue}this._appContext.assert('expected attr \''+attrName+'\' in tag '+node.name);return node.startIndex}};DomUtils.prototype.isNonFragmentJetPage=function(context){return this.hasBody(context)&&this.isJetPage(context)};DomUtils.prototype.hasBody=function(context){var i,siblings,ret=false;siblings=this.getSiblings(context.node);for(i=0;i<siblings.length;i++){if(this._hasBody2(siblings[i])){ret=true;break}}return ret};DomUtils.prototype._hasBody2=function(node){var i,children,ret=false;if(node.type===NodeType.TAG&&node.name.toLowerCase()==='body'){return true}if(node.children){children=node.children;for(i=0;i<children.length;i++){if(this._hasBody2(children[i])){ret=true;break}}}return ret};DomUtils.prototype.isJetPage=function(context){var i,siblings,ret=false;siblings=this.getSiblings(context.node);for(i=0;i<siblings.length;i++){if(this._isJetPage2(siblings[i])){ret=true;break}}return ret};DomUtils.prototype._isJetPage2=function(node){var i,children,ret=false;if(node.type===NodeType.TAG&&node.name.toLowerCase().startsWith('oj-')){return true}if(node.children){children=node.children;for(i=0;i<children.length;i++){if(this._isJetPage2(children[i])){ret=true;break}}}return ret};DomUtils.prototype.isValidJson=function(value,data){var data,ret;if(value.charAt(0)!=='{'){return true}try{data=JSON.parse(this._nodeDeps.decomment(value));ret=!!data}catch(e){if(typeof data==='string'&&e.toString().startsWith('SyntaxError')){var obj=_convertMsgToRowCol(e.message,data,this._utils);ret.msg=obj.msg;ret.line=obj.row;ret.col=obj.col;ret.position=obj.position}else{ret=e.message}}return ret};DomUtils.prototype.isAttrExprConstant=function(expr){return HtmlUtils.isAttrExprConstant(expr)};const RE_EXPRESSION=/^(?:\[{2})(.*)(?:\]{2})$|^(?:\{{2})(.*)(?:\}{2})$/;DomUtils.prototype.isExpression=function(s){var ret=false;if(s){ret=RE_EXPRESSION.test(s.trim())}return ret};DomUtils.prototype.getExpression=function(s){var ret=null;if(this.isExpression(s)){ret=s.substring(2,s.length-2).trim()}return ret};DomUtils.prototype.isSvgPath=function(s){var c=s.trim().charAt(0);return SVG_PATH_COMMANDS.indexOf(c)>=0};DomUtils.prototype.camelCase=function(str){var parts,i;function _camelCase(str){return str.replace(/(?:^\w|[A-Z]|\b\w)/g,function(word,index){return index==0?word.toLowerCase():word.toUpperCase()}).replace(/-|\s+/g,'')};parts=str.split(DOT);for(i=0;i<parts.length;i++){parts[i]=_camelCase(parts[i])}return parts.join(DOT)};DomUtils.prototype.kebabCase=function(str){return str.replace(/([a-zA-Z])(?=[A-Z])/g,'$1-').toLowerCase()};DomUtils.prototype.kekabCaseEvent=function(str){return ON_DASH+this.kebabCase(str)};function _isHtmlScript(node){var attribs=node.attribs;return node.type&&node.type===NodeType.SCRIPT&&attribs&&attribs.type&&attribs.type.indexOf('html')>=0};function _convertMsgToRowCol(msg,data,utils){var x,n,obj;x=msg.indexOf('position');if(x<0){return null}n=parseInt(msg.substr(x+8).trim());obj=utils.getRowColFromIndex(data,n);obj.msg=msg.substr(0,x)+'line '+obj.row+', col '+obj.col+' (position '+n+')';obj.position=n;return obj};function _getAttrRawValue(data,index,attrName,attrValue,utils){var ret=null,delim,i;i=index+attrName.length;if(data.charAt(i)==='='){i=utils.eatWhitespace(data,i+1);delim=data.substr(i,1);delim=delim==='\''||delim==='"'?delim:'"';ret=delim+attrValue+data.charAt(i+attrValue.length+1)}else{ret=attrValue}return ret};DomUtils.prototype.setDom=function(oDom){this._tree=oDom};module.exports=DomUtils;
|
|
6
|
+
const jsonParser=require('really-relaxed-json').createParser();const HtmlUtils=require('./HtmlUtils');const NodeType=require('./NodeTypes');const OJCOMPONENT='ojComponent';const COMPONENT='component';const SVG_PATH_COMMANDS=['M','m','L','I','H','h','V','v','C','c','S','s','Q','q','T','t','A','a','Z','z'];const DOT='.';const ON_DASH='on-';function DomUtils(nodeDeps,appContext,oTabs,fileIndex){this._tree=null;this._nodeDeps=nodeDeps;this._appContext=appContext;this._tabs=oTabs;this._utils=appContext.utils;this._fileIndex=fileIndex};DomUtils.prototype.getFirst=function(){return this._tree.length?this._tree[0]:null};DomUtils.prototype.getLast=function(){var node;node=this._tree.length?this._tree[this._tree.length-1]:null;while(node&&node.children&&node.children.length){node=node.children[node.children.length-1]}return node};DomUtils.prototype.getFirstElem=function(){var node=this.getFirst();while(node){if(node.type===NodeType.TAG){break};node=node.next}return node};DomUtils.prototype.getChildren=function(node){return node.children};DomUtils.prototype.getParent=function(node){return node.parent};DomUtils.prototype.getSiblings=function(node){var parent;if(parent=this.getParent(node)){return this.getChildren(parent)}else{return this._tree}};DomUtils.prototype.getNext=function(node){return node.next||null};DomUtils.prototype.getAttribs=function(node){return node.attribs||null};DomUtils.prototype.getAttribValue=function(node,name){return node.attribs?node.attribs[name]:undefined};DomUtils.prototype.getAttribRawValue=function(ruleCtx,name){var val,pos;if(ruleCtx.tagNode.attribs){if(typeof(val=ruleCtx.tagNode.attribs[name])==='string'){pos=this.getAttrPosition(ruleCtx.data,ruleCtx.tagNode,name);return _getAttrRawValue(ruleCtx.data,pos.start,name,val,ruleCtx.utils.utils)}}};DomUtils.prototype.hasAttrib=function(node,name){return!!node.attribs&&hasOwnProperty.call(node.attribs,name)};DomUtils.prototype.hasChildren=function(node){return!!node.children};DomUtils.prototype.hasNext=function(node){return!!node.next};DomUtils.prototype.getName=function(node){return node.name};DomUtils.prototype.getType=function(node){return node.type};DomUtils.prototype.getElemsByName=function(name){var a=[],i,names;if(!this._tree){return a}names=typeof name==='string'?[name]:name;for(i=0;i<names.length;i++){names[i]=names[i].toLowerCase()}for(i=0;i<this._tree.length;i++){_getElemsByName2(this._tree[i],a,names)}return a};function _getElemsByName2(node,a,names){var children,i;if((node.type===NodeType.TAG||node.type===NodeType.SCRIPT)&&names.indexOf(node.name.toLowerCase())>=0){a.push(node)}if(node.children){children=node.children;for(i=0;i<children.length;i++){_getElemsByName2(children[i],a,names)}}};DomUtils.prototype.getElemById=function(id,labelId){var node,i;if(!this._tree){return null}for(i=0;i<this._tree.length;i++){node=this._tree[i];if(node.type===NodeType.TAG||_isHtmlScript(node)){node=this._getElemById2(node,id,labelId);if(node){return node}}}return null};DomUtils.prototype._getElemById2=function(node,id,labelId){var curNode,attrib,attr,attribLower,i;if((node.type===NodeType.TAG||_isHtmlScript(node))&&node.attribs){for(attrib in node.attribs){attribLower=attrib.toLowerCase();if(attribLower==='id'||labelId&&attribLower==='label-id'){if(node.attribs[attrib]===id){return node}}else if(attrib==='data-bind'){attr=this.extractAttribsFromDataBind(node.attribs[attrib]);if(attr&&attr['id']===id){return node}}}}if(node.children){for(i=0;i<node.children.length;i++){curNode=this._getElemById2(node.children[i],id,labelId);if(curNode){return curNode}}}return null};DomUtils.prototype.getElems=function(){var a=[],i;if(!this._tree){return a}for(i=0;i<this._tree.length;i++){_getElems2(this._tree[i],a)}return a};function _getElems2(node,a){var children,i;if(node.type===NodeType.TAG||node.type===NodeType.SCRIPT){a.push(node)}if(node.children){children=node.children;for(i=0;i<children.length;i++){_getElems2(children[i],a)}}};DomUtils.prototype.getScripts=function(){var head,ch,a=[];if(head=this.getHead()){if(ch=head.children){ch.forEach(elem=>{if(elem.type===NodeType.TAG&&elem.name==='script'){a.push(elem)}})}}return a};DomUtils.prototype.getLinks=function(){var head,ch,a=[];if(head=this.getHead()){if(ch=head.children){ch.forEach(elem=>{if(elem.type===NodeType.TAG&&elem.name==='link'){a.push(elem)}})}}return a};DomUtils.prototype.getHead=function(){var elem,ch,i;if(!this._tree){return null}for(i=0;i<this._tree.length;i++){elem=this._tree[i];if(elem.type===NodeType.TAG&&elem.name==='html'){if(ch=elem.children){for(i=0;i<ch.length;i++){elem=ch[i];if(elem.type===NodeType.TAG&&elem.name==='head'){return elem}}}break}}return null};DomUtils.prototype.getBody=function(){var elem,ch,i;if(!this._tree){return null}for(i=0;i<this._tree.length;i++){elem=this._tree[i];if(elem.type===NodeType.TAG&&elem.name==='html'){if(ch=elem.children){for(i=0;i<ch.length;i++){elem=ch[i];if(elem.type===NodeType.TAG&&elem.name==='body'){return elem}}}break}}return null};DomUtils.prototype.getComponentElems=function(){var a=[],i;if(!this._tree){return a}for(i=0;i<this._tree.length;i++){this._getComponentElems2(this._tree[i],a)}return a};DomUtils.prototype._getComponentElems2=function(node,a){var children,i;if(node.type===NodeType.TAG&&this._appContext.metaLib.isWCTag(node.name)){a.push(node)}if(node.children){children=node.children;for(i=0;i<children.length;i++){this._getComponentElems2(children[i],a)}}};DomUtils.prototype.isCommonAttr=function(attrName){attrName=attrName.toLowerCase();attrName=attrName.charAt(0)===':'?attrName.substr(1):attrName;return HtmlUtils.isCommonAttr(attrName)};DomUtils.prototype.isCommonEventAttr=function(attrName){attrName=attrName.toLowerCase();attrName=attrName.charAt(0)===':'?attrName.substr(1):attrName;if(attrName.startsWith('on-oj-')){return false}if(attrName.startsWith('on-')){attrName=attrName.substring(0,2)+attrName.substring(3)}return HtmlUtils.isCommonEventAttr(attrName)};DomUtils.prototype.isCommonElem=function(elem){return HtmlUtils.isCommonElem(elem)};DomUtils.prototype.isSvgElem=function(elem){return HtmlUtils.isSvgElem(elem)};DomUtils.prototype.isHtml5ObsoleteElem=function(tag){return HtmlUtils.isHtml5ObsoleteElem(tag)};DomUtils.prototype.isHtml5ObsoleteAttr=function(tagName,attrName){return HtmlUtils.isHtml5ObsoleteAttr(tagName,attrName)};DomUtils.prototype.isSelfClosingTag=function(tag){return HtmlUtils.isSelfClosingTag(tag)};DomUtils.prototype.isNamespaceTag=function(tagName){if(this._appContext.metaLib.isJetTag(tagName)){return true}return HtmlUtils.isNamespaceTag(tagName)};DomUtils.prototype.isNamespacePrefix=function(tagPrefix){return!!HtmlUtils.isNamespacePrefix(tagPrefix)};DomUtils.prototype.isChildOfElem=function(elemName,node){return!!this.isChildOfElemNode(elemName,node)};DomUtils.prototype.isChildOfElemNode=function(elemName,node){var ret=null;while(node.parent){if(node.parent.name===elemName){ret=node.parent;break}node=node.parent}return ret};DomUtils.prototype.getDataBindComponent=function(context){var node,val,attrVal,ret=null;node=context.tagNode;if(this.getAttribs(node)){attrVal=this.getAttribValue(node,'data-bind');if(attrVal){val=this.extractComponentFromDataBind(attrVal);if(val){ret='oj.'+val}}}return ret};DomUtils.prototype.getDataBindAttr=function(context){return this.getDataBindAttrsFromNode(context,context.node)};DomUtils.prototype.getDataBindAttrs=function(context){return this.getDataBindAttrsFromNode(context,context.node)};DomUtils.prototype.getDataBindAttrsFromNode=function(context,node){var attrVal,ret=null;if(this.getAttribs(node)){attrVal=this.getAttribValue(node,'data-bind');if(attrVal){ret=this.extractAttribsFromDataBind(attrVal)}}return ret};DomUtils.prototype.extractComponentFromDataBind=function(attrValue){var dataBind,componentName,x;x=attrValue.indexOf(OJCOMPONENT);if(x<0){return}componentName=null;if(attrValue.length>OJCOMPONENT.length){dataBind=attrValue.substring(x+OJCOMPONENT.length);x=dataBind.indexOf(COMPONENT);if(x>=0){dataBind=dataBind.substring(x+COMPONENT.length).trim();if(dataBind.charAt(0)===':'){x=dataBind.indexOf('oj');if(x>=0){dataBind=dataBind.substring(x);componentName=_extractComponentName(dataBind,this._utils)}}}}return componentName};function _extractComponentName(s,utils){var componentName,i,c;for(i=0;i<s.length;i++){c=s.charAt(i);if(c==='\''||c==='"'||utils.isWhitespace(c)){componentName=s.substring(0,i);break}}return componentName};DomUtils.prototype.extractAttribsFromDataBind=function(attrValue){var s,a,nextAttr,val,i,j,x,ret=null;if(attrValue.indexOf(':')<0){return ret}a=attrValue.split('attr');if(a.length<2){return ret}for(i=0;i<a.length;i++){a[i]=s=a[i].trim();if(s.charAt(0)===':'){s=s.substr(1).trim();if(s.charAt(0)==='{'){try{ret=jsonParser.stringToJson(s);ret=JSON.parse(ret)}catch(e){s=s.substring(1).trim();a=s.split(':');for(j=0;j<a.length;j++){if(nextAttr){if(!ret){ret={}}ret[nextAttr]=val=a[j].replace(/['\"]/g,'').trim();x=val.lastIndexOf('}');if(x>=0){ret[nextAttr]=val.substring(0,x).trim();break}nextAttr=null}if(j+1===a.length){break}a[j]=s=a[j].trim();s=s.replace(/['\"]/g,'').trim();if(s.length===0)continue;if(!ret){ret={}}ret[s]=val=a[++j].trim();x=val.indexOf(',');if(x>=0){ret[s]=val.substring(0,x).replace(/['\"]/g,'').trim();nextAttr=val.substring(x+1).trim();nextAttr=nextAttr.replace(/['\"]/g,'').trim();val=val.substring(0,x).replace(/['\"]/g,'').trim()}else{ret[s]=val.replace(/['\"]/g,'').trim()}x=val.lastIndexOf('}');if(x>=0){ret[s]=val.substring(0,x).trim();break}}}}break}}return ret};DomUtils.prototype.getAttribPosition=function(data,node,attrName){var startIndex=this.getAttrIndex(data,node,attrName);var endIndex=startIndex+attrName.length-1;var pos=this._utils.getRowColFromIndex(data,startIndex,'html');pos.start=startIndex;pos.end=endIndex;return pos};DomUtils.prototype.getAttrPosition=function(data,node,attrName){return this.getAttribPosition(data,node,attrName)};DomUtils.prototype.getAttribValuePosition=function(data,node,attrName){var attrPos,pos,endPos,ws,ret,good;var isDouble,isSingle,isUnquoted;attrPos=this.getAttrPosition(data,node,attrName);if(!attrPos||attrPos.start===node.startIndex){return}if((pos=this._utils.eatWhitespace(data,attrPos.end+1))>=0){if(data.charAt(pos++)==='='){if((endPos=this._utils.eatWhitespace(data,pos))>=0){isDouble=data.charAt(endPos)==='"';isSingle=data.charAt(endPos)==='\'';isUnquoted=!(isSingle||isDouble);if(isDouble){if((endPos=data.indexOf('"',pos+1))>=0){good=true}}else if(isSingle){if((endPos=data.indexOf('\'',pos+1))>=0){good=true}}else if(isUnquoted){ws=this._utils.getIndexToWhitespace(data,pos);endPos=data.indexOf('>',pos);if(ws>=0&&endPos>=0){endPos=(endPos<ws?endPos:ws)-1;good=true}}if(good){attrPos=this.getLineCol(data,pos);ret={row:attrPos.row,col:attrPos.col,start:pos,end:endPos}}}}}return ret};DomUtils.prototype.getAttrValuePosition=function(data,node,attrName){return this.getAttribValuePosition(data,node,attrName)};DomUtils.prototype.getLineCol=function(data,index){return this._fileIndex.getRowCol(data,{start:index},'html')};DomUtils.prototype.getAttribIndex=function(data,node,attrName){var attribs,index,temp,c,i,isQuote=attrName==='"'||attrName==='\'';attribs=node.attribs;if(!attribs){this._appContext.assert('no attrs in tag '+node.name+'(expected attr \''+attrName+')');return node.startIndex}if(!attribs.hasOwnProperty(attrName)&&!attribs.hasOwnProperty(':'+attrName)){this._appContext.assert('expected attr \''+attrName+'\' in tag '+node.name);return node.startIndex}index=data.indexOf(attrName,node.startIndex);while(true){index=data.indexOf(attrName,index);if(index>=0){temp=data.substring(index+attrName.length,index+100);i=this._utils.eatWhitespace(temp);if(i<0){return node.startIndex}c=temp.charAt(i);if(c==='='||c==='>'||!isQuote&&this._utils.isWhitespace(temp.charAt(0))){return index}index+=i+1;continue}this._appContext.assert('expected attr \''+attrName+'\' in tag '+node.name);return node.startIndex}};DomUtils.prototype.getAttrIndex=function(data,node,attrName){return this.getAttribIndex(data,node,attrName)};DomUtils.prototype.isNonFragmentJetPage=function(context){return this.hasBody(context)&&this.isJetPage(context)};DomUtils.prototype.hasBody=function(context){var i,siblings,ret=false;siblings=this.getSiblings(context.node);for(i=0;i<siblings.length;i++){if(this._hasBody2(siblings[i])){ret=true;break}}return ret};DomUtils.prototype._hasBody2=function(node){var i,children,ret=false;if(node.type===NodeType.TAG&&node.name.toLowerCase()==='body'){return true}if(node.children){children=node.children;for(i=0;i<children.length;i++){if(this._hasBody2(children[i])){ret=true;break}}}return ret};DomUtils.prototype.isJetPage=function(context){var i,siblings,ret=false;siblings=this.getSiblings(context.node);for(i=0;i<siblings.length;i++){if(this._isJetPage2(siblings[i])){ret=true;break}}return ret};DomUtils.prototype._isJetPage2=function(node){var i,children,ret=false;if(node.type===NodeType.TAG&&node.name.toLowerCase().startsWith('oj-')){return true}if(node.children){children=node.children;for(i=0;i<children.length;i++){if(this._isJetPage2(children[i])){ret=true;break}}}return ret};DomUtils.prototype.isValidJson=function(value,data){var data,ret;if(value.charAt(0)!=='{'){return true}try{data=JSON.parse(this._nodeDeps.decomment(value));ret=!!data}catch(e){if(typeof data==='string'&&e.toString().startsWith('SyntaxError')){var obj=_convertMsgToRowCol(e.message,data,this._utils);ret.msg=obj.msg;ret.line=obj.row;ret.col=obj.col;ret.position=obj.position}else{ret=e.message}}return ret};DomUtils.prototype.isAttrExprConstant=function(expr){return HtmlUtils.isAttrExprConstant(expr)};const RE_EXPRESSION=/^(?:\[{2})(.*)(?:\]{2})$|^(?:\{{2})(.*)(?:\}{2})$/;DomUtils.prototype.isExpression=function(s){var ret=false;if(s){ret=RE_EXPRESSION.test(s.trim())}return ret};DomUtils.prototype.getExpression=function(s){var ret=null;if(this.isExpression(s)){ret=s.substring(2,s.length-2).trim()}return ret};DomUtils.prototype.isSvgPath=function(s){var c=s.trim().charAt(0);return SVG_PATH_COMMANDS.indexOf(c)>=0};DomUtils.prototype.camelCase=function(str){var parts,i;function _camelCase(str){return str.replace(/(?:^\w|[A-Z]|\b\w)/g,function(word,index){return index==0?word.toLowerCase():word.toUpperCase()}).replace(/-|\s+/g,'')};parts=str.split(DOT);for(i=0;i<parts.length;i++){parts[i]=_camelCase(parts[i])}return parts.join(DOT)};DomUtils.prototype.kebabCase=function(str){return str.replace(/([a-zA-Z])(?=[A-Z])/g,'$1-').toLowerCase()};DomUtils.prototype.kekabCaseEvent=function(str){return ON_DASH+this.kebabCase(str)};function _isHtmlScript(node){var attribs=node.attribs;return node.type&&node.type===NodeType.SCRIPT&&attribs&&attribs.type&&attribs.type.indexOf('html')>=0};function _convertMsgToRowCol(msg,data,utils){var x,n,obj;x=msg.indexOf('position');if(x<0){return null}n=parseInt(msg.substr(x+8).trim());obj=utils.getRowColFromIndex(data,n);obj.msg=msg.substr(0,x)+'line '+obj.row+', col '+obj.col+' (position '+n+')';obj.position=n;return obj};function _getAttrRawValue(data,index,attrName,attrValue,utils){var ret=null,delim,i;i=index+attrName.length;if(data.charAt(i)==='='){i=utils.eatWhitespace(data,i+1);delim=data.substr(i,1);delim=delim==='\''||delim==='"'?delim:'"';ret=delim+attrValue+data.charAt(i+attrValue.length+1)}else{ret=attrValue}return ret};DomUtils.prototype.setDom=function(oDom){this._tree=oDom};module.exports=DomUtils;
|
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;
|