@oracle/oraclejet-audit 18.1.4 → 19.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/corePackMigrator/corePackMigrator.js +1 -1
- package/corePackMigrator/metadata/badgeMetadata.json +66 -0
- package/corePackMigrator/metadata/checkboxsetMetadata.json +101 -0
- package/corePackMigrator/metadata/inputNumberMetadata.json +0 -3
- package/corePackMigrator/metadata/inputTextMetadata.json +0 -3
- package/corePackMigrator/metadata/labelMetadata.json +285 -222
- package/corePackMigrator/metadata/labelValueMetadata.json +226 -137
- package/corePackMigrator/metadata/listviewMetadata.json +7 -0
- package/corePackMigrator/metadata/radiosetMetadata.json +20 -9
- package/corePackMigrator/metadata/selectorMetadata.json +6 -0
- package/corePackMigrator/resource/astUtils.js +1 -1
- package/corePackMigrator/resource/componentMigrator.js +1 -1
- package/corePackMigrator/resource/fileScanner.js +1 -1
- package/corePackMigrator/resource/htmlUtils.js +1 -1
- package/corePackMigrator/resource/manifest.json +57 -49
- package/corePackMigrator/resource/migrationConfig.json +1 -1
- package/corePackMigrator/utilities/logging.js +2 -2
- package/jaf-amd.js +1 -1
- package/lib/Components.js +1 -1
- package/lib/Config.js +1 -1
- package/lib/FsUtils.js +1 -1
- package/lib/HtmlUtils.js +1 -1
- package/lib/JafLib.js +1 -1
- package/lib/MetaLib.js +1 -1
- package/lib/OjCPack.js +1 -1
- package/lib/RegTypes.js +1 -1
- package/lib/Registry.js +1 -1
- package/lib/Rules.js +1 -1
- package/lib/Ts.js +1 -1
- package/lib/TsUtils.js +1 -1
- package/lib/TsxUtils.js +1 -1
- package/lib/checkage.js +1 -1
- package/lib/defaults.js +1 -1
- package/lib/extends.js +1 -1
- package/lib/ns.js +1 -1
- package/lib/scaffold.js +1 -1
- package/lib/scopewalker.js +1 -1
- package/lib/sublib/precomp/Precompiler.js +1 -1
- package/libext/expparser.js +1 -1
- package/meta/18.0.0/jetauditmeta.js +1 -1
- package/meta/18.1.0/jetauditmeta.js +1 -1
- package/meta/19.0.0/jetauditmeta.js +9 -0
- package/meta/metaverlist.json +1 -1
- package/package.json +4 -4
- package/profiles/best-practice.json +3 -0
- package/profiles/redwood-strict.json +10 -1
- package/rulepacks/jetwc/jetwc-use-public-apis.js +6 -0
- package/rulepacks/jetwc/msgid.json +1 -1
- package/rulepacks/jetwc/rules.json +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-componentAuditUtils.js +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-componentFinder.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-properties.js +1 -1
- package/rulepacks/jetwco/rules.json +1 -1
- package/rules/jet/msgid.json +1 -1
- package/rules/jet/oj-acc-aria-accessible.js +1 -1
- package/rules/jet/oj-acc-aria-prop.js +1 -1
- package/rules/jet/oj-acc-navigable-link.js +6 -0
- package/rules/jet/oj-acc-select-aria-label.js +1 -1
- package/rules/jet/oj-cca-compjson-prop-conflict.js +6 -0
- package/rules/jet/oj-css-bp-zindex.js +7 -0
- package/rules/jet/oj-html-badge-maintenance.js +6 -0
- package/rules/jet/oj-html-binding-as-slot-child.js +1 -1
- package/rules/jet/oj-html-corequired.js +6 -0
- package/rules/jet/oj-html-nav-tab-nointeractive.js +6 -0
- package/rules/jet/oj-html-oj-ux-ico-slot.js +6 -0
- package/rules/jet/oj-html-ojtag-id.js +1 -1
- package/rules/jet/oj-html-redwood-ojoption-disabled.js +6 -0
- package/rules/jet/oj-html-slot-pref-content.js +1 -1
- package/rules/jet/oj-html-tabbar-progressive-popup.js +1 -1
- package/rules/jet/oj-html-wctag-for.js +1 -1
- package/rules/jet/oj-html-wctag-id.js +1 -1
- package/rules/jet/oj-html-wctag-maintenance.js +1 -1
- package/rules/jet/oj-html-wctag-packprivate.js +1 -1
- package/rules/jet/oj-js-poly-promise.js +1 -1
- package/rules/jet/oj-ts-poly-promise.js +1 -1
- package/rules/jet/oj-tsx-acc-navigable-link.js +6 -0
- package/rules/jet/oj-tsx-aria-prop.js +1 -1
- package/rules/jet/oj-tsx-corequired.js +6 -0
- package/rules/jet/oj-tsx-prop-ko-binding.js +6 -0
- package/rules/jet/oj-tsx-tabbar-progressive-popup.js +6 -0
- package/rules/jet/oj-tsx-wctag-packprivate.js +1 -1
- package/rules/jet/rules.json +1 -1
- package/schema/component-schema.json +1 -1
- package/src/JafCore.js +1 -1
- package/types/index.d.ts +5 -0
- package/corePackMigrator/metadata/messagesMetadata.json +0 -41
package/lib/Components.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 COMPONENT_JSON="component.json";const PROPERTIES="properties";const PROP_SLOTS="slots";const PROP_DYNAMIC_SLOTS="dynamicSlots";const PROP_PROPS="props";const PROP_EVENTS="events";const PROP_STYLECLASSES="styleClasses";const PROP_IMPLEMENTS="implements";const PROP_REQUIRED="required";const PROP_FOLDER="folder";const PROP_VERSION="version";const PROP_UNSUP_THEME="unsupTheme";const PROP_STATUS="status";const PROP_SUBCOMPONENT_TYPE="subcomponentType";const PROP_DEPENDENCIES="dependencies";const PROP_TYPE="type";const PROP_PACK="pack";const PROPERTY_VALUE="propertyValue";const PROPERTY_TYPE="propertyType";const PACK_PRIVATE="packPrivate";const DEPRECATED="deprecated";const MAINTENANCE="maintenance";const SUPERSEDES="supersedes";const ANTIPATTERN="antiPattern";const DYNAMIC_FORM_ELEM="DynamicFormElement";const DYNAMIC_TABLE_ELEM="DynamicTableElement";const VB_FRAGMENT_ELEM="VbFragmentElement";const CUSTOM_ELEMENT="@customElement";const REGISTER_CUSTOM_ELEMENT="registerCustomElement";const OJ_C="oj-c";const DOT=".";const CHANGED="Changed";const FT_HTML="html";const FT_TSX="tsx";const REGXPR=/string|number|object|array|boolean|[\|.<>]/gi;function Components(nd,runMode,cwd,compSvcs,urlBase,urls,filePaths,metaLib,ojcPack,jetCore,runOpts,msgCtx,appCtx){this._nd=nd;this._tagLookup={};this._jetTagLookup={};this._VCompLookup={};this._styleLookup={};this._ojcPathLookup={};this._packs={};this._meta={};this._resources={};this._ignored={};this._maintenance=null;this._supersedes=null;this._antiPattern=null;this._meta={};this._path=null;this._reqAttrs=null;this._metaLib=metaLib;this._ojcPack=ojcPack;this._utils=appCtx.utils;this._fsUtils=appCtx.fsUtils;this._tsUtils=appCtx.tsUtils;this._curFileType=null;this._oConfig=appCtx.config;this._VFilesInspected=null;this._VTypes=null;this._compSvcs=compSvcs;this._isAMD=runMode==="amd";this._cwd=cwd;this._error=msgCtx.error;this._warn=msgCtx.warn;this._debug=msgCtx.debug;this._info=msgCtx.info;this._msg=msgCtx.msg;this._console=msgCtx.console;this._jafMsg=msgCtx.jafMsg;this._isDebug=msgCtx.isDebug;this._isVerbose=msgCtx.isVerbose;this._count=0;this._isOk=true;this._runOpts=runOpts;this._init(urlBase,urls,filePaths,jetCore);if(this._tsUtils){this._initVComponents()}};Components.prototype.isUserTag=function(tagName){var tag=_removeChevrons(tagName);return!!(this._tagLookup[tag]||this._VCompLookup[tag])};Components.prototype.isJetCoreTag=function(tagName){return!!this._jetTagLookup[_removeChevrons(tagName)]};Components.prototype.isVComponentTag=function(tagName){return!!this._VCompLookup[_removeChevrons(tagName)]};Components.prototype.isKnownTag=function(tagName){return!!this._lookupTag(tagName)};Components.prototype._lookupTag=function(tagName){tagName=_removeChevrons(tagName);return this._jetTagLookup[tagName]||this._tagLookup[tagName]||this._VCompLookup[tagName]};Components.prototype.isTagAttr=function(tagName,attrName){return this.isTagProp(tagName,attrName)||this.isJetTagProp(tagName,attrName)};Components.prototype.isJetTagAttr=function(tagName,attrName){return this.isJetTagProp(tagName,attrName)};Components.prototype.isTagDeprecated=function(tag){var comp,stats,status,ret=null;if(comp=this._lookupTag(_removeChevrons(tag))){if(stats=comp.status){for(status of stats){if((!status.type||status.type===DEPRECATED)&&!status.hasOwnProperty("target")){ret=status;if(ret.description){ret.description=this._utils.removeLink(ret.description)}break}}}}return ret};Components.prototype.isTagAttrDeprecated=function(tagName,attrName){var prop,status,stats,o,ret=null;if((prop=this.getAnyTagProp(tagName,attrName))&&(stats=prop.status)){ret=[];for(status of stats){if(!status.type||status.type===DEPRECATED){o={type:DEPRECATED};if(status.hasOwnProperty("target")){o.target=status.target}if(status.hasOwnProperty("description")){o.description=status.description}if(status.hasOwnProperty("since")){o.since=status.since}if(status.hasOwnProperty("value")){o.value=status.value}ret.push(o)}}ret=ret.length?ret:null}return ret};Components.prototype.isTagEventDeprecated=function(tagName,eventName){var event,stats,ret=null;if(event=this.getAnyTagEvent(tagName,eventName)){if(stats=event.status){stats.forEach(stat=>{if(!stat.type||stat.type===DEPRECATED){if(!ret){ret=[]}ret.push(stat)}})}}return ret};Components.prototype.getTagPropertyFromEvent=function(tagName,eventName){var o,ret;if(o=this.getTagEventName(tagName,eventName)){ret=o.name}return ret?ret:null};Components.prototype.isTagAttrTranslatable=function(tag,attr){var prop=this.getAnyTagProp(tag,attr);return prop&&prop.translatable};Components.prototype.isTagAttrReadOnly=function(tag,attr){var prop=this.getAnyTagProp(tag,attr);return prop&&prop.readonly};Components.prototype.isTagAttrWriteback=function(tag,attr){var prop=this.getAnyTagProp(tag,attr);return prop&&prop.writeback};Components.prototype.isTagProp=function(tagName,propName){return!!this.getTagProp(tagName,propName)};Components.prototype.isJetTagProp=function(tagName,propName){return!!this.getJetTagProp(tagName,propName)};Components.prototype.getTagProp=function(tagName,propName){var ret;if(this.isUserTag(tagName)){ret=this._getTagProp(tagName,propName,false)}return ret?ret:null};Components.prototype.getJetTagProp=function(tagName,propName){var ret;if(this.isJetCoreTag(tagName)){ret=this._getTagProp(tagName,propName,true)}return ret?ret:null};Components.prototype.getAnyTagProp=function(tagName,propName){return this._getTagProp(tagName,propName,true)||this._getTagProp(tagName,propName,false)};Components.prototype._getTagProp=function(tagName,propName,isOJC){var tag,props,list;tagName=_removeChevrons(tagName);if(isOJC){tag=this._jetTagLookup[tagName]}else{tag=this._tagLookup[tagName]||this._VCompLookup[tagName]};props=tag?tag[PROP_PROPS]:null;if(props){propName=propName.charAt(0)===":"?propName.substring(1):propName;if(this._curFileType!=="tsx"){propName=_propToCamelCase(propName)}}return props?props[propName]:null};Components.prototype.getTagPropType=function(tagName,propName){var prop,ret;if(prop=this.getTagProp(tagName,propName)){ret=prop?prop.type:undefined}return ret};Components.prototype.getAnyTagEvent=function(tag,event){return this._getTagEvent(tag,event,true)||this._getTagEvent(tag,event,false)};Components.prototype._getTagEvent=function(tagName,eventName,isOJC){var tagObj,events,event;if(!eventName.startsWith("on")){return null}tagName=_removeChevrons(tagName);if(isOJC){tagObj=this._jetTagLookup[tagName]}else{tagObj=this._tagLookup[tagName]||this._VCompLookup[tagName]}if(!tagObj){return null}if(!(events=tagObj[PROP_EVENTS])){return null}if(eventName.includes("-")){eventName=eventName.substring(3);eventName=_propToCamelCase(eventName)}else{eventName=eventName.substring(2)}event=events[eventName];return event?event:null};Components.prototype.getComponentPropMetadata=function(tagName,propName){var comp,sofar,props;tagName=_removeChevrons(tagName);if(!(comp=this._meta[tagName])||!(props=comp.properties)){return null}let subprops=propName.split(DOT);if(this._curFileType===FT_HTML){subprops.forEach((subprop,i,ar)=>{ar[i]=_propToCamelCase(subprop)})}if(subprops.length===1){return props[propName]||null}sofar=comp;let nextprop,i;for(i=0;i<subprops.length;i++){nextprop=subprops[i];if(sofar.hasOwnProperty(PROPERTIES)){sofar=sofar.properties[nextprop]||null;if(!sofar){break}}else{sofar=null;break}}return sofar};Components.prototype.getComponentMetadata=function(tag){return this._meta[tag]||null};Components.prototype.getAllCustomMetadata=function(){var name,comp,obj;var ret={};var i=2;var lookup=this._tagLookup;while(i){for(name in lookup){ret[name]=obj={};comp=lookup[name];obj.folder=comp.folder;obj.json=this.getComponentMetadata(name);if(i===1){obj.VCType=this._VTypes[name]}}i--;lookup=this._VCompLookup}return ret};Components.prototype.getJetTag=function(tag){var o;return(o=this._jetTagLookup[tag])?o:null};Components.prototype.getMaintenanceTags=function(){return this._maintenance};Components.prototype.isTagEvent=function(tagName,eventName){return!!this.getTagEventName(tagName,eventName)};Components.prototype.getTagEventName=function(tagName,eventName){var propName,tagObj,events,impls;tagObj=this._lookupTag(_removeChevrons(tagName));if(!tagObj||!eventName.startsWith("on")){return null}if(eventName.includes("-")){eventName=eventName.substring(3);eventName=_propToCamelCase(eventName)}else{eventName=eventName.substring(2)}if(tagObj.events&&tagObj.events[eventName]){return{type:"event",name:eventName}}if((impls=tagObj.implements)&&(impls.includes(DYNAMIC_FORM_ELEM)||impls.includes(DYNAMIC_TABLE_ELEM)||impls.includes(VB_FRAGMENT_ELEM))){return{type:"dynamic",name:eventName}}if(eventName.endsWith(CHANGED)&&tagObj.props){propName=eventName.replace(CHANGED,"");if(tagObj.props[propName]){return{type:"property",name:propName}};}return null};Components.prototype.isTagStyle=function(tag,style){var tagObj,ret=false;if(tagObj=this._lookupTag(_removeChevrons(tag))){let styles;if(styles=tagObj.styleClasses){ret=!!styles[style]}}return ret};Components.prototype.isJetStyle=function(style){var tag,ret=false;if(tag=this._styleLookup[style]){ret=!!this._jetTagLookup[tag]}return ret};Components.prototype.isStyle=function(style){return!!this._styleLookup[style]};Components.prototype.getStyleMetadata=function(style){var tag,styles,sc,ret=null;if(tag=this._styleLookup[style]){if(styles=this._tagLookup[tag].styleClasses){if(sc=styles[style]){ret={tag:tag,meta:sc}}}}return ret};Components.prototype.getStyleSelector=function(style){var sm=this.getStyleMetadata(style);return sm&&sm.meta?sm.meta.styleSelector:null};Components.prototype.hasTagSlotName=function(tagName,slotName){var o=this._lookupTag(_removeChevrons(tagName));return!!(o&&o.slots&&o.slots[slotName])};Components.prototype.getPreferredSlotContent=function(tag,slotName,impls){var o,slot,prefContent=null,comps=null,content;if(this._utils.hasAnyProps(impls)){if(o=this._lookupTag(_removeChevrons(tag))){if(o.slots){slotName=slotName?slotName:"";if(slot=o.slots[slotName]){if((prefContent=slot.preferredContent)&&prefContent.length){prefContent.forEach(impl=>{if(content=impls[impl]){if(!comps){comps=[]}comps.push(...content)}})}else{prefContent=null}}}}}return prefContent||comps?{interfaces:prefContent,components:comps}:null};Components.prototype.getTagSlotMetadata=function(tag,slot){var o,ret;if(o=this._lookupTag(_removeChevrons(tag))){if(o.slots){slot=slot?slot:"";if(slot=o.slots[slot]){ret=slot}}}return ret};Components.prototype.getPackPaths=function(){return Object.keys(this._packs)};Components.prototype.getPackMetadata=function(packName){return this._packs[packName]||null};Components.prototype.getAllPackMetadata=function(){return this._packs||null};Components.prototype.getResourcePaths=function(){return Object.keys(this._resources)};Components.prototype.getAllResourceMetadata=function(){return this._resources||null};Components.prototype.getResourceMetadata=function(path){return this._resources[path]||null};Components.prototype.getOjcMetadataByPath=function(path){return this._ojcPathLookup[path]||null};Components.prototype.hasTagDynamicSlot=function(tag){var o,ret=false;if(o=this._lookupTag(_removeChevrons(tag))){ret=o.hasOwnProperty(PROP_DYNAMIC_SLOTS)}return ret};Components.prototype.hasTagAttrValues=function(tagName,attrName){var prop,ret=false;if((prop=this.getTagProp(tagName,attrName))||(prop=this.getJetTagProp(tagName,attrName))){ret=!!prop.enumValues}return ret};Components.prototype.isTagAttrValue=function(tagName,attrName,value){var prop,ret;if((prop=this.getTagProp(tagName,attrName))||(prop=this.getJetTagProp(tagName,attrName))){if(prop&&prop.enumValues){ret=prop.enumValues.indexOf(value)>=0}}return!!ret};Components.prototype.isTagAttrEnumDeprecated=function(tag,attr,val){var prop,stats,status,ret=null;if(prop=this.getAnyTagProp(tag,attr)){if(stats=prop.status){for(status of stats){if((!status.type||status.type===DEPRECATED)&&status.target===PROPERTY_VALUE){if(status.value&&status.value.includes(val)){ret={type:DEPRECATED};if(status.hasOwnProperty("target")){ret.target=status.target}if(status.hasOwnProperty("description")){ret.description=status.description}if(status.hasOwnProperty("since")){ret.since=status.since}if(status.hasOwnProperty("value")){ret.value=status.value}break}}}}}return ret};Components.prototype.isTagSupportedInTheme=function(tag,theme){var o,unsup,ret=true;if(o=this._lookupTag(tag)){if(unsup=o[PROP_UNSUP_THEME]){ret=!unsup.includes(theme)}}return ret};Components.prototype.isAttrSupportedInTheme=function(tag,attr,theme){var prop,unsup,ret=true;if(prop=this.getAnyTagProp(tag,attr)){if(unsup=prop[PROP_UNSUP_THEME]){ret=!unsup.includes(theme)}}return ret};Components.prototype.isTagPackPrivate=function(tag){var o,ret=false;if(o=this._lookupTag(_removeChevrons(tag))){ret=o[PROP_SUBCOMPONENT_TYPE]===PACK_PRIVATE}return ret};Components.prototype.getSubcomponentType=function(tag){var o,ret;if(o=this._lookupTag(_removeChevrons(tag))){ret=o[PROP_SUBCOMPONENT_TYPE]}return ret||null};Components.prototype.getRequiredProps=function(tagName){var tag,props,prop,propName,obj,ret=null;tagName=_removeChevrons(tagName);if(this._reqAttrs){let r=this._reqAttrs[tagName];if(r){return typeof r==="boolean"?null:r}}tag=this._lookupTag(tagName);if(tag&&tag.props){if(!this._reqAttrs){this._reqAttrs={}}if(!this._reqAttrs[tagName]){this._reqAttrs[tagName]=true}props=tag.props;for(propName in props){prop=props[propName];if(prop.required){if(!obj){obj=[]}obj.push(propName)}}}if(obj&&obj.length){let i,j,p;for(i=0;i<obj.length;i++){if(p=obj[i]){p+=".";for(j=i+1;j<obj.length;j++){if(obj[j].startsWith(p)){obj.splice(i,1);i--;break}}}}this._reqAttrs[tagName]=obj;ret=obj}return ret};Components.prototype.getRequiredAttrs=function(tagName){return this.getRequiredProps(tagName)};Components.prototype.getInterfaces=function(tag){var o,ret;if(o=this._lookupTag(_removeChevrons(tag))){ret=o.implements}return ret?ret:null};Components.prototype.getCount=function(){return this._count};Components.prototype.isTagStatus=function(tag,statType){return!!this._getTagStatus(tag,statType)};Components.prototype.getTagStatus=function(tag,statType){var ret=null,omitted=statType===undefined;var comp,arStat,stat,stType,i;if(comp=this._lookupTag(_removeChevrons(tag))){if(arStat=comp.status){for(i=0;i<arStat.length;i++){stat=arStat[i];stType=stat.type||DEPRECATED;if(omitted||stType===statType){if(!ret){ret=[]}ret.push(stat)}}}}return ret};Components.prototype.getPropStatus=function(tagName,propName,statType){let comp,arStat,ret;if(comp=this._lookupTag(_removeChevrons(tagName))){if(comp.props&&(arStat=comp.props[propName]?.status)){let stat,stType,i,omitted=statType===undefined;for(i=0;i<arStat.length;i++){stat=arStat[i];stType=stat.type||DEPRECATED;if(omitted||stType===statType){if(!ret){ret=[]}ret.push(stat)}}}}return ret?ret:null};Components.prototype.isRuleIgnored=function(compName,ruleName){var ret,ar;if(ar=this._ignored[compName]){ret=ar.includes(ruleName)}return!!ret};Components.prototype.isOk=function(){return this._isOk};Components.prototype.setCurFileType=function(ft){this._curFileType=ft};Components.prototype._init=function(base,urls,filePaths,$jetCore){if(this._isAMD){this._processJetCorePack();return}if(base){base=base.trim();if(base.charAt(base.length-1)!=="/"){base=base+"/"}}else{base=""}this._processFilePaths(filePaths);this._processUrls(base,urls);this._processJetCorePack();this._createStyleLookup();this._processJetCore($jetCore)};Components.prototype._processFilePaths=function(filePaths){var obj,compEntry,fpath,i,j;if(!filePaths){return}this._console("\nPre-processing user-declared web component metadata...");for(i=0;i<filePaths.length;i++){compEntry=filePaths[i];var dirStack=this._nd.glob.sync(compEntry);for(j=0;j<dirStack.length;j++){fpath=dirStack[j];if(this._runOpts.isDryRun||this._runOpts.isDebug){let msg="-".repeat(70)+"\n"+(this._runOpts.isDryRun?"* ":"")+"processing component path '"+fpath+"' ...";if(this._runOpts.isDryRun){console.log(msg)}else{this._debug(msg)}}if(fpath.toLowerCase().endsWith(".zip")){obj=this._compSvcs._extractComponentJsonFromZip(fpath);if(obj.obj){this.processComponentJson(obj.obj,fpath)}else if(obj.msg){this._error("Failed to parse component.json : "+obj.msg+" - "+fpath)}else if(obj.error){this._error("Failed to unzip '"+fpath+"'")}continue}if(this._isComponentJsonPath(fpath)){if(obj=this._readComponentJson(fpath)){if(obj.type&&obj.type==="pack"){continue}this.processComponentJson(obj,this._nd.path.dirname(fpath))}continue}this._recurse(fpath)}}if(this._isDebug){this._debug("-".repeat(70))}};Components.prototype._recurse=function(fpath){var dirs,inFile,inFilePath,obj,i;try{dirs=this._nd.fs.readdirSync(fpath);if(this._isDebug){this._debug(` processing ${fpath} ${dirs.length} component dirs ...`)}for(i=0;i<dirs.length;i++){inFile=dirs[i];if(inFile===COMPONENT_JSON){inFilePath=this._nd.path.join(fpath,COMPONENT_JSON);if(this._isDebug){this._debug(" processing "+inFilePath+"...")}obj=this._readComponentJson(inFilePath);if(obj){if(!obj.type||obj.type==="composite"){this.processComponentJson(obj,fpath)}else if(obj.type==="resource"){this._resources[obj.pack+"/"+obj.name]=obj}else if(obj.type==="pack"){this._packs[obj.name]=obj}}else{return}}var curPath=this._nd.path.join(fpath,inFile);if(this._fsUtils.getFileType(curPath)==="d"){this._recurse(curPath)}}}catch(e){this._error("Component check failed - "+e);this._isOk=false}};Components.prototype._processUrls=function(base,urls){var url,i;if(!urls){return}for(i=0;i<urls.length;i++){url=urls[i];if(this._runOpts.isDryRun||this._runOpts.isDebug){let msg;msg="-".repeat(70)+"\nprocessing URL '"+url+"'";if(this._runOpts.isDryRun){console.log(msg);continue}else{this._debug(msg)}}if(_isRelativeUrl(url)){url=base+url;if(_isRelativeUrl(url)){this._error("component URL incomplete - '"+url+"'");continue}}this._processUrl(url)}};Components.prototype._processUrl=function(url){var resp,obj,rc,tempFile,tmp;try{resp=this._compSvcs.loadUrl(url);if(resp.eCode==="ETIMEDOUT"){this._error("config.componentUrls - request timed-out for '"+url+"'");this._isOk=false;return}try{if(resp.type==="json"){if(resp.body){obj=JSON.parse(resp.body);if(!this.processComponentJson(obj,url)){this._isOk=false}}else{this._error("Server responded with "+resp.statusCode+" URL: '"+url+"'")}}else if(resp.type=="zip"){rc=this._compSvcs.writeZipBufferToFile(resp.body);if(typeof rc==="boolean"&&rc){tempFile=this._compSvcs.getLastZipFilePath();obj=this._compSvcs.extractComponentJsonFromZip(tempFile);if(obj.obj){this.processComponentJson(obj.obj,url)}else if(obj.msg){this._error("Failed to parse component.json : "+obj.msg+" - "+url)}else if(obj.error){this._error("Failed to unzip '"+url+"'")}this._compSvcs.deleteZipFile(tempFile)}else{this._error("Failed to create local temp zip file from URL '"+url+"' : rc.message");this._isOk=false}}else{tmp=typeof resp.type==="string"?resp.type:"?";this._error("Server responded with unexpected data ('"+tmp+"') : '"+url+"'");this._isOk=false}}catch(e){this._error("Invalid JSON - URL '"+url+"' : "+e);this._isOk=false}}catch(e1){this._error("URL access failed "+(e1.message.includes("ENOTFOUND")?"(NOT FOUND)":"")+" - URL '"+url+"'");this._isOk=false}};Components.prototype._processJetCorePack=function(){var comps,comp;if(comps=this._ojcPack.getComponents()){for(comp in comps){this.processComponentJson(comps[comp],"oj-c")}}};Components.prototype.processComponentJson=function(obj,fromLocation,vcomp){var comp,props,events,event,eventName,compName,metaObj;var isOJC;compName=obj.pack?obj.pack+"-"+obj.name:obj.name;isOJC=obj.pack===OJ_C;if(!this._isAMD){if(this._runOpts.isDryRun){console.log(" Would have processed '"+fromLocation+"'");return}if(obj.type&&obj.type==="pack"){return this._processJetPack(obj,fromLocation)}if(!isOJC&&!vcomp){if(!this._compSvcs.validateComponentJson(obj,fromLocation)){this._isOk=false;return false}}if(isOJC){this._ojcPathLookup[obj.main]=obj}}if(this._lookupTag(compName)){this._jafMsg("jaf-sys-dup-component",`Ignoring duplicate component '${compName}' at '${fromLocation}'`,"W");return true}this._meta[compName]=obj;(isOJC?this._jetTagLookup:vcomp?this._VCompLookup:this._tagLookup)[compName]=comp={};comp[PROP_FOLDER]=fromLocation;comp[PROP_VERSION]=obj.version;if(obj.extension&&obj.extension.audit&&obj.extension.audit.ignore){let ar;if((ar=obj.extension.audit.ignore)&&ar.length){this._ignored[compName]=[...ar]}}if(obj.hasOwnProperty(PROP_SLOTS)){comp[PROP_SLOTS]=obj[PROP_SLOTS]}if(obj.hasOwnProperty(PROP_DYNAMIC_SLOTS)){comp[PROP_DYNAMIC_SLOTS]=obj[PROP_DYNAMIC_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){events[event]=obj.events[event];metaObj=obj.events}}if(obj.implements){comp[PROP_IMPLEMENTS]=obj.implements;this._metaLib.processImplements(compName,obj.implements)}if(obj.status){let status,i;metaObj=obj.status;for(i=0;i<metaObj.length;i++){status=metaObj[i];if(status.type===MAINTENANCE){if(!this._maintenance){this._maintenance=new Set}this._maintenance.add(compName)}else if(status.type===SUPERSEDES){if(!this._supercedes){this._supersedes=new Set}this._supersedes.add(compName)}else if(status.type===ANTIPATTERN){if(!this._antiPattern){this._antiPattern=new Set}this._antiPattern.add(compName)}}}if(obj.extension&&obj.extension.theme&&obj.extension.theme.unsupportedThemes){comp[PROP_UNSUP_THEME]=obj.extension.theme.unsupportedThemes}if(obj.hasOwnProperty(PROP_SUBCOMPONENT_TYPE)){comp[PROP_SUBCOMPONENT_TYPE]=obj[PROP_SUBCOMPONENT_TYPE]}if(obj.hasOwnProperty(PROP_DEPENDENCIES)){comp[PROP_DEPENDENCIES]=obj[PROP_DEPENDENCIES]}if(obj.type){comp[PROP_TYPE]=obj.type}if(obj.pack){comp[PROP_PACK]=obj.pack}if(obj.hasOwnProperty("required")){comp[PROP_REQUIRED]=obj.required}if(obj.status){comp[PROP_STATUS]=obj.status}if(obj.styleClasses){comp[PROP_STYLECLASSES]=this._extractStyles(obj.styleClasses)}this._count++;return true};Components.prototype._extractProps=function(propObj,propSoFar,properties,name,rdonly){var prop,thisProp,soFar,obj;for(prop in properties){soFar=(propSoFar?propSoFar+DOT:"")+prop;propObj[soFar]=obj={};thisProp=properties[prop];if(thisProp.hasOwnProperty("enumValues")){if(Array.isArray(thisProp.enumValues)){obj.enumValues=thisProp.enumValues}else{this._error(`Web component '${name}' property '${soFar}' has invalid 'enumValues' in component.json`)}}if(thisProp.hasOwnProperty("status")){obj.status=thisProp.status}if(thisProp.hasOwnProperty("type")){obj.type=thisProp.type}if(thisProp.required){obj.required=true}if(thisProp.extension&&thisProp.extension.theme&&thisProp.extension.theme.unsupportedThemes){obj[PROP_UNSUP_THEME]=thisProp.extension.theme.unsupportedThemes}if(thisProp.hasOwnProperty("translatable")){obj.translatable=true}if(typeof thisProp.readOnly==="boolean"){obj.readOnly=thisProp.readOnly}else{if(rdonly){obj.readOnly=true}}if(thisProp.hasOwnProperty("writeback")){obj.writeback=thisProp.writeback}if(thisProp.hasOwnProperty("properties")){obj.properties=true;this._extractProps(propObj,soFar,thisProp.properties,name,obj.readOnly)}}};Components.prototype._extractStyles=function(styleClasses){var so,si,obj,ret={},i,j;if(!Array.isArray(styleClasses)){return ret}for(i=0;i<styleClasses.length;i++){so=styleClasses[i];if(so.kind==="class"){ret[so.name]=this._extractStyleClass(so)}else if(so.kind==="set"&&so.styleItems&&Array.isArray(so.styleItems)){ret[so.name]=obj={kind:"set"};if(so.status){obj.status=so.status}obj.styleClasses={};for(j=0;j<so.styleItems.length;j++){si=so.styleItems[j];obj.styleClasses[si.name]=this._extractStyleClass(si)}}else if(so.kind==="template"){}}return ret};Components.prototype._extractStyleClass=function(so){var obj={};if(so.styleSelector){obj.styleSelector=so.styleSelector}if(so.status){obj.status=so.status}return obj};Components.prototype._processJetPack=function(obj,fromLocation){var deps,dep,urlKey,depUrl,msg,i;if(this._runOpts.isDryRun||this._runOpts.isDebug){msg="processing JET Pack "+obj.name+" (version: "+obj.version+") : '"+fromLocation+"'";if(this._runOpts.isDryRun){console.log("* "+msg);return}else{this._debug(msg)}}if(!fromLocation.includes("http")){this._error("JET packs loaded via config 'components' property (file based) are currently not supported");return false}i=fromLocation.indexOf(obj.name);if(i>=0){urlKey=fromLocation.substring(0,i)}else{this._error("Cannot handle Jet Pack URL format to load dependencies : "+fromLocation)}deps=obj.dependencies;if(deps){for(dep in deps){depUrl=urlKey+dep+"/versions/"+obj.dependencies[dep]+"/content/component.json";if(this._isDebug){this._debug(` processing dependency ${dep} ${obj.dependencies[dep]}`)}this._processUrls("",[depUrl])}}return false};Components.prototype._processJetCore=function(jetCorePath){var files,file,obj,i;if(!jetCorePath){return}this._console("-".repeat(70)+"\nPerforming schema analysis on JET Core components (dt) using '"+this._compSvcs.getSchemaName()+"'...");try{files=this._nd.fs.readdirSync(jetCorePath);this._console(` processing ${files.length} $jetCore components...`);for(i=0;i<files.length;i++){file=files[i];if(file.endsWith(".json")){file=this._nd.path.join(jetCorePath,file);try{obj=this._readComponentJson(file);if(obj){this._compSvcs.validateComponentJson(obj,file)}}catch(e){}}}}catch(e1){this._error("!!! $JetCore Component check failed - "+e1)}this._console(" processing "+(files?files.length+" ":"")+"$jetCore components completed");this._console("-".repeat(70))};Components.prototype._initVComponents=function(){let precompileCache,tscript;const preComp=this._tsUtils.getPreCompiler();const preCompUtils=this._tsUtils.getUtils();const auditBase=this._fsUtils.toJAFPath(this._oConfig.getBase());const projectPathInfo=preCompUtils.getKeyPathInfo(auditBase);if((tscript=this._oConfig.getTypescript())&&tscript.compile&&projectPathInfo.tsSource){this._console("Pre-processing VComponents...");if(!(precompileCache=preComp.getPrecompileCache(auditBase,projectPathInfo.tsSource,projectPathInfo.componentRootFolder))){return}if(!this._fsUtils.pathExistsSync(precompileCache)){this._debug(`VComponents: precompileCache not created - ${precompileCache}`)}else{this._getVComponentJson(precompileCache)}}};Components.prototype._getVComponentJson=function(jsonDir){var contents;if(contents=this._fsUtils.readDirSync(jsonDir)){let json;this._VFilesInspected=[];this._VTypes={};contents.forEach(file=>{if(file.isFile){json=this._fsUtils.readJsonSync(this._nd.path.join(jsonDir,file.name),false,false);if(typeof json==="string"){this._error(`Compiled metadata for x - ${json}`)}else{if(this._isDebug){this._debug(`Post compilation VComponent found : ${json.name}`)}this.processComponentJson(json,this._getVCompFolder(json.name),true)}}});this._VFilesInspected=null}};Components.prototype._getVCompFolder=function(name){var files,file,folder,ret=null,x,_self=this;const preComp=this._tsUtils.getPreCompiler();const srcFiles=preComp.getVFiles();if(srcFiles){for(file of srcFiles){if(this._VFilesInspected.includes(file)){continue}let src,VType;function _fail(errMsg){_self._warn(`Unexpected read error of '${file}'`)}if(!(src=this._fsUtils.readFileSync(file,_fail))){continue}if(!(VType=this._isVCompSrc(src,name))){continue}this._VFilesInspected.push(file);this._VTypes[name]=VType;ret=this._nd.path.dirname(file);break}}return ret};Components.prototype._isVCompSrc=function(src,name){var ret,start=0,utils=this._utils;function _extractCompName(data,x,closeDelim){let x2,comp,match=false;if((x=utils.eatWhitespace(data,x))>=0){if(data.charAt(x)==="("){if((x=utils.eatWhitespace(data,x+1))>=0){if((x2=data.indexOf(closeDelim,x))>=0){comp=data.substring(x,x2).trim();comp=comp.substring(1,comp.length-1);match=comp===name}}}}return match}while(start<src.length){let i;if((i=src.indexOf(CUSTOM_ELEMENT,start))>=0){start=i+=CUSTOM_ELEMENT.length;if(ret=_extractCompName(src,i,")")){return"class"}continue}else if((i=src.indexOf(REGISTER_CUSTOM_ELEMENT,start))>=0){start=i+=REGISTER_CUSTOM_ELEMENT.length;if(ret=_extractCompName(src,i,",")){return"func"}continue}break}return null};Components.prototype._createStyleLookup=function(){var tag,o,scl,st;for(tag in this._tagLookup){o=this._tagLookup[tag];if(scl=o.styleClasses){for(st in scl){this._styleLookup[st]=tag}}}};Components.prototype._readComponentJson=function(inFile){var obj=null;if(this._isDebug){this._debug(` loading '${inFile}'`)}obj=this._nd.jsonLoader.load(inFile,this._nd,this._error,false,this._utils);if(!obj){this._isOk=false}return obj};Components.prototype._isComponentJsonPath=function(filePath){return filePath.toLowerCase().endsWith(COMPONENT_JSON)};Components.prototype.dumpComponentNames=function(){var names,keys;this._dumpComponentNames(this._tagLookup,"--------- Declared Web Components ---------","No valid user (non-VComponent) components declared!","-------- End Declared Web Components ---------");this._dumpComponentNames(this._VCompLookup,"--------- Discovered VComponents ---------","No VComponents found!","-------- End Discovered VComponents ---------");this._dumpComponentNames(this._jetTagLookup,"--------- Declared JET OJ-C Pack Web Components ---------","No valid user JET Core Pack components declared!","-------- End Declared OJ-C Pack Web Components ---------")};Components.prototype._dumpComponentNames=function(lookup,start,none,end){var keys,meta,impls,isOJC=start.includes("OJ-C");const INFO="[info]";keys=Object.keys(lookup);if(!keys.length){this._console(`${INFO} ${none}\n`,"I");return}this._console(`${INFO} ${start}`,"I");if(isOJC&&this._isVerbose){this._console(`${INFO} ${keys.length} JET CorePack components loaded`,"I")}else{keys.forEach(key=>{meta=lookup[key];this._console(`${INFO} ${key} (${meta.version})`,"I");impls=meta.implements&&meta.implements.length?meta.implements.join(", "):"none declared";this._console(`${INFO} Impls: ${impls}`)})}this._console(`${INFO} ${end}\n`,"I")};function _isTagStatusType(statType){return type===SUPERSEDES||type===MAINTENANCE||type===DEPRECATED||type===ANTIPATTERN};function _propToKebabCase(str){return str.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z])(?=[a-z])/g,"$1-$2").toLowerCase()};function _propToCamelCase(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)};function _isRelativeUrl(url){url=url.toLowerCase();return!(url.indexOf("http://")===0||url.indexOf("https://")===0)};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=Components;
|
|
6
|
+
"use strict";const COMPONENT_JSON="component.json";const PROPERTIES="properties";const PROP_SLOTS="slots";const PROP_DYNAMIC_SLOTS="dynamicSlots";const PROP_PROPS="props";const PROP_EVENTS="events";const PROP_STYLECLASSES="styleClasses";const PROP_IMPLEMENTS="implements";const PROP_REQUIRED="required";const PROP_REQUIREMENTS="requirements";const PROP_FOLDER="folder";const PROP_VERSION="version";const PROP_UNSUP_THEME="unsupTheme";const PROP_STATUS="status";const PROP_SUBCOMPONENT_TYPE="subcomponentType";const PROP_DEPENDENCIES="dependencies";const PROP_TYPE="type";const PROP_PACK="pack";const PROPERTY_VALUE="propertyValue";const PROPERTY_TYPE="propertyType";const PACK_PRIVATE="packPrivate";const DEPRECATED="deprecated";const MAINTENANCE="maintenance";const SUPERSEDES="supersedes";const ANTIPATTERN="antiPattern";const DYNAMIC_FORM_ELEM="DynamicFormElement";const DYNAMIC_TABLE_ELEM="DynamicTableElement";const VB_FRAGMENT_ELEM="VbFragmentElement";const CUSTOM_ELEMENT="@customElement";const REGISTER_CUSTOM_ELEMENT="registerCustomElement";const OJ_C="oj-c";const DOT=".";const CHANGED="Changed";const FT_HTML="html";const FT_TSX="tsx";const REGXPR=/string|number|object|array|boolean|[\|.<>]/gi;function Components(nd,runMode,cwd,compSvcs,urlBase,urls,filePaths,metaLib,ojcPack,jetCore,runOpts,msgCtx,appCtx){this._nd=nd;this._tagLookup={};this._jetTagLookup={};this._VCompLookup={};this._styleLookup={};this._ojcPathLookup={};this._packs={};this._meta={};this._resources={};this._ignored={};this._maintenance=null;this._supersedes=null;this._antiPattern=null;this._meta={};this._path=null;this._reqAttrs=null;this._metaLib=metaLib;this._ojcPack=ojcPack;this._utils=appCtx.utils;this._fsUtils=appCtx.fsUtils;this._tsUtils=appCtx.tsUtils;this._curFileType=null;this._oConfig=appCtx.config;this._VFilesInspected=null;this._VTypes=null;this._compSvcs=compSvcs;this._isAMD=runMode==="amd";this._cwd=cwd;this._error=msgCtx.error;this._warn=msgCtx.warn;this._debug=msgCtx.debug;this._info=msgCtx.info;this._msg=msgCtx.msg;this._console=msgCtx.console;this._jafMsg=msgCtx.jafMsg;this._isDebug=msgCtx.isDebug;this._isVerbose=msgCtx.isVerbose;this._isWindows=msgCtx.isWindows;this._count=0;this._isOk=true;this._runOpts=runOpts;this._init(urlBase,urls,filePaths,jetCore);if(this._tsUtils&&this._ojcPack._isOJet){let doComp;if((doComp=this._oConfig.getTypescript())&&doComp.compile){this._initVComponents()}else if(this._isDebug){this._debug("VComponent support disabled by JAF config 'typescript' property")}}};Components.prototype.isUserTag=function(tagName){var tag=_removeChevrons(tagName);return!!(this._tagLookup[tag]||this._VCompLookup[tag])};Components.prototype.isJetCoreTag=function(tagName){return!!this._jetTagLookup[_removeChevrons(tagName)]};Components.prototype.isVComponentTag=function(tagName){return!!this._VCompLookup[_removeChevrons(tagName)]};Components.prototype.isKnownTag=function(tagName){return!!this._lookupTag(tagName)};Components.prototype._lookupTag=function(tagName){tagName=_removeChevrons(tagName);return this._jetTagLookup[tagName]||this._tagLookup[tagName]||this._VCompLookup[tagName]};Components.prototype.isTagAttr=function(tagName,attrName){return this.isTagProp(tagName,attrName)||this.isJetTagProp(tagName,attrName)};Components.prototype.isJetTagAttr=function(tagName,attrName){return this.isJetTagProp(tagName,attrName)};Components.prototype.isTagDeprecated=function(tag){var comp,stats,status,ret=null;if(comp=this._lookupTag(_removeChevrons(tag))){if(stats=comp.status){for(status of stats){if((!status.type||status.type===DEPRECATED)&&!status.hasOwnProperty("target")){ret=status;if(ret.description){ret.description=this._utils.removeLink(ret.description)}break}}}}return ret};Components.prototype.isTagAttrDeprecated=function(tagName,attrName){var prop,status,stats,o,ret=null;if((prop=this.getAnyTagProp(tagName,attrName))&&(stats=prop.status)){ret=[];for(status of stats){if(!status.type||status.type===DEPRECATED){o={type:DEPRECATED};if(status.hasOwnProperty("target")){o.target=status.target}if(status.hasOwnProperty("description")){o.description=status.description}if(status.hasOwnProperty("since")){o.since=status.since}if(status.hasOwnProperty("value")){o.value=status.value}ret.push(o)}}ret=ret.length?ret:null}return ret};Components.prototype.isTagEventDeprecated=function(tagName,eventName){var event,stats,ret=null;if(event=this.getAnyTagEvent(tagName,eventName)){if(stats=event.status){stats.forEach(stat=>{if(!stat.type||stat.type===DEPRECATED){if(!ret){ret=[]}ret.push(stat)}})}}return ret};Components.prototype.getTagPropertyFromEvent=function(tagName,eventName){var o,ret;if(o=this.getTagEventName(tagName,eventName)){ret=o.name}return ret?ret:null};Components.prototype.isTagAttrTranslatable=function(tag,attr){var prop=this.getAnyTagProp(tag,attr);return prop&&prop.translatable};Components.prototype.isTagAttrReadOnly=function(tag,attr){var prop=this.getAnyTagProp(tag,attr);return prop&&prop.readonly};Components.prototype.isTagAttrWriteback=function(tag,attr){var prop=this.getAnyTagProp(tag,attr);return prop&&prop.writeback};Components.prototype.isTagProp=function(tagName,propName){return!!this.getTagProp(tagName,propName)};Components.prototype.isJetTagProp=function(tagName,propName){return!!this.getJetTagProp(tagName,propName)};Components.prototype.getTagProp=function(tagName,propName){var ret;if(this.isUserTag(tagName)){ret=this._getTagProp(tagName,propName,false)}return ret?ret:null};Components.prototype.getJetTagProp=function(tagName,propName){var ret;if(this.isJetCoreTag(tagName)){ret=this._getTagProp(tagName,propName,true)}return ret?ret:null};Components.prototype.getAnyTagProp=function(tagName,propName){return this._getTagProp(tagName,propName,true)||this._getTagProp(tagName,propName,false)};Components.prototype._getTagProp=function(tagName,propName,isOJC){var tag,props,list;tagName=_removeChevrons(tagName);if(isOJC){tag=this._jetTagLookup[tagName]}else{tag=this._tagLookup[tagName]||this._VCompLookup[tagName]};props=tag?tag[PROP_PROPS]:null;if(props){propName=propName.charAt(0)===":"?propName.substring(1):propName;if(this._curFileType!=="tsx"){propName=_propToCamelCase(propName)}}return props?props[propName]:null};Components.prototype.getTagPropType=function(tagName,propName){var prop,ret;if(prop=this.getTagProp(tagName,propName)){ret=prop?prop.type:undefined}return ret};Components.prototype.getAnyTagEvent=function(tag,event){return this._getTagEvent(tag,event,true)||this._getTagEvent(tag,event,false)};Components.prototype._getTagEvent=function(tagName,eventName,isOJC){var tagObj,events,event;if(!eventName.startsWith("on")){return null}tagName=_removeChevrons(tagName);if(isOJC){tagObj=this._jetTagLookup[tagName]}else{tagObj=this._tagLookup[tagName]||this._VCompLookup[tagName]}if(!tagObj){return null}if(!(events=tagObj[PROP_EVENTS])){return null}if(eventName.includes("-")){eventName=eventName.substring(3);eventName=_propToCamelCase(eventName)}else{eventName=eventName.substring(2)}event=events[eventName];return event?event:null};Components.prototype.getComponentPropMetadata=function(tagName,propName){var comp,sofar,props;tagName=_removeChevrons(tagName);if(!(comp=this._meta[tagName])||!(props=comp.properties)){return null}let subprops=propName.split(DOT);if(this._curFileType===FT_HTML){subprops.forEach((subprop,i,ar)=>{ar[i]=_propToCamelCase(subprop)})}if(subprops.length===1){return props[propName]||null}sofar=comp;let nextprop,i;for(i=0;i<subprops.length;i++){nextprop=subprops[i];if(sofar.hasOwnProperty(PROPERTIES)){sofar=sofar.properties[nextprop]||null;if(!sofar){break}}else{sofar=null;break}}return sofar};Components.prototype.getComponentMetadata=function(tag){return this._meta[tag]||null};Components.prototype.getAllCustomMetadata=function(){var name,comp,obj;var ret={};var i=2;var lookup=this._tagLookup;while(i){for(name in lookup){ret[name]=obj={};comp=lookup[name];obj.folder=comp.folder;obj.json=this.getComponentMetadata(name);if(i===1){obj.VCType=this._VTypes[name]}}i--;lookup=this._VCompLookup}return ret};Components.prototype.getJetTag=function(tag){var o;return(o=this._jetTagLookup[tag])?o:null};Components.prototype.getMaintenanceTags=function(){return this._maintenance};Components.prototype.isTagEvent=function(tagName,eventName){return!!this.getTagEventName(tagName,eventName)};Components.prototype.getTagEventName=function(tagName,eventName){var propName,tagObj,events,impls;tagObj=this._lookupTag(_removeChevrons(tagName));if(!tagObj||!eventName.startsWith("on")){return null}if(eventName.includes("-")){eventName=eventName.substring(3);eventName=_propToCamelCase(eventName)}else{eventName=eventName.substring(2)}if(tagObj.events&&tagObj.events[eventName]){return{type:"event",name:eventName}}if((impls=tagObj.implements)&&(impls.includes(DYNAMIC_FORM_ELEM)||impls.includes(DYNAMIC_TABLE_ELEM)||impls.includes(VB_FRAGMENT_ELEM))){return{type:"dynamic",name:eventName}}if(eventName.endsWith(CHANGED)&&tagObj.props){propName=eventName.replace(CHANGED,"");if(tagObj.props[propName]){return{type:"property",name:propName}};}return null};Components.prototype.isTagStyle=function(tag,style){var tagObj,ret=false;if(tagObj=this._lookupTag(_removeChevrons(tag))){let styles;if(styles=tagObj.styleClasses){ret=!!styles[style]}}return ret};Components.prototype.isJetStyle=function(style){var tag,ret=false;if(tag=this._styleLookup[style]){ret=!!this._jetTagLookup[tag]}return ret};Components.prototype.isStyle=function(style){return!!this._styleLookup[style]};Components.prototype.getStyleMetadata=function(style){var tag,styles,sc,ret=null;if(tag=this._styleLookup[style]){if(styles=this._tagLookup[tag].styleClasses){if(sc=styles[style]){ret={tag:tag,meta:sc}}}}return ret};Components.prototype.getStyleSelector=function(style){var sm=this.getStyleMetadata(style);return sm&&sm.meta?sm.meta.styleSelector:null};Components.prototype.hasTagSlotName=function(tagName,slotName){var o=this._lookupTag(_removeChevrons(tagName));return!!(o&&o.slots&&o.slots[slotName])};Components.prototype.getPreferredSlotContent=function(tag,slotName,impls){var o,slot,prefContent=null,comps=null,content;if(this._utils.hasAnyProps(impls)){if(o=this._lookupTag(_removeChevrons(tag))){if(o.slots){slotName=slotName?slotName:"";if(slot=o.slots[slotName]){if((prefContent=slot.preferredContent)&&prefContent.length){prefContent.forEach(impl=>{if(content=impls[impl]){if(!comps){comps=[]}comps.push(...content)}})}else{prefContent=null}}}}}return prefContent||comps?{interfaces:prefContent,components:comps}:null};Components.prototype.getTagSlotMetadata=function(tag,slot){var o,ret;if(o=this._lookupTag(_removeChevrons(tag))){if(o.slots){slot=slot?slot:"";if(slot=o.slots[slot]){ret=slot}}}return ret};Components.prototype.getTagRequirementsMetadata=function(tagName){var o,ret=null;if(o=this._lookupTag(_removeChevrons(tagName))){ret=o.requirements}return ret};Components.prototype.getPackPaths=function(){return Object.keys(this._packs)};Components.prototype.getPackMetadata=function(packName){return this._packs[packName]||null};Components.prototype.getAllPackMetadata=function(){return this._packs||null};Components.prototype.getResourcePaths=function(){return Object.keys(this._resources)};Components.prototype.getAllResourceMetadata=function(){return this._resources||null};Components.prototype.getResourceMetadata=function(path){return this._resources[path]||null};Components.prototype.getOjcMetadataByPath=function(path){return this._ojcPathLookup[path]||null};Components.prototype.hasTagDynamicSlot=function(tag){var o,ret=false;if(o=this._lookupTag(_removeChevrons(tag))){ret=o.hasOwnProperty(PROP_DYNAMIC_SLOTS)}return ret};Components.prototype.hasTagAttrValues=function(tagName,attrName){var prop,ret=false;if((prop=this.getTagProp(tagName,attrName))||(prop=this.getJetTagProp(tagName,attrName))){ret=!!prop.enumValues}return ret};Components.prototype.isTagAttrValue=function(tagName,attrName,value){var prop,ret;if((prop=this.getTagProp(tagName,attrName))||(prop=this.getJetTagProp(tagName,attrName))){if(prop&&prop.enumValues){ret=prop.enumValues.indexOf(value)>=0}}return!!ret};Components.prototype.isTagAttrEnumDeprecated=function(tag,attr,val){var prop,stats,status,ret=null;if(prop=this.getAnyTagProp(tag,attr)){if(stats=prop.status){for(status of stats){if((!status.type||status.type===DEPRECATED)&&status.target===PROPERTY_VALUE){if(status.value&&status.value.includes(val)){ret={type:DEPRECATED};if(status.hasOwnProperty("target")){ret.target=status.target}if(status.hasOwnProperty("description")){ret.description=status.description}if(status.hasOwnProperty("since")){ret.since=status.since}if(status.hasOwnProperty("value")){ret.value=status.value}break}}}}}return ret};Components.prototype.isTagSupportedInTheme=function(tag,theme){var o,unsup,ret=true;if(o=this._lookupTag(tag)){if(unsup=o[PROP_UNSUP_THEME]){ret=!unsup.includes(theme)}}return ret};Components.prototype.isAttrSupportedInTheme=function(tag,attr,theme){var prop,unsup,ret=true;if(prop=this.getAnyTagProp(tag,attr)){if(unsup=prop[PROP_UNSUP_THEME]){ret=!unsup.includes(theme)}}return ret};Components.prototype.isTagPackPrivate=function(tag){var o,ret=false;if(o=this._lookupTag(_removeChevrons(tag))){ret=o[PROP_SUBCOMPONENT_TYPE]===PACK_PRIVATE}return ret};Components.prototype.getSubcomponentType=function(tag){var o,ret;if(o=this._lookupTag(_removeChevrons(tag))){ret=o[PROP_SUBCOMPONENT_TYPE]}return ret||null};Components.prototype.getRequiredProps=function(tagName){var tag,props,prop,propName,obj,ret=null;tagName=_removeChevrons(tagName);if(this._reqAttrs){let r=this._reqAttrs[tagName];if(r){return typeof r==="boolean"?null:r}}tag=this._lookupTag(tagName);if(tag&&tag.props){if(!this._reqAttrs){this._reqAttrs={}}if(!this._reqAttrs[tagName]){this._reqAttrs[tagName]=true}props=tag.props;for(propName in props){prop=props[propName];if(prop.required){if(!obj){obj=[]}obj.push(propName)}}}if(obj&&obj.length){let i,j,p;for(i=0;i<obj.length;i++){if(p=obj[i]){p+=".";for(j=i+1;j<obj.length;j++){if(obj[j].startsWith(p)){obj.splice(i,1);i--;break}}}}this._reqAttrs[tagName]=obj;ret=obj}return ret};Components.prototype.getRequiredAttrs=function(tagName){return this.getRequiredProps(tagName)};Components.prototype.getInterfaces=function(tag){var o,ret;if(o=this._lookupTag(_removeChevrons(tag))){ret=o.implements}return ret?ret:null};Components.prototype.getCount=function(){return this._count};Components.prototype.isTagStatus=function(tag,statType){return!!this._getTagStatus(tag,statType)};Components.prototype.getTagStatus=function(tag,statType){var ret=null,omitted=statType===undefined;var comp,arStat,stat,stType,i;if(comp=this._lookupTag(_removeChevrons(tag))){if(arStat=comp.status){for(i=0;i<arStat.length;i++){stat=arStat[i];stType=stat.type||DEPRECATED;if(omitted||stType===statType){if(!ret){ret=[]}ret.push(stat)}}}}return ret};Components.prototype.getPropStatus=function(tagName,propName,statType){let comp,arStat,ret;if(comp=this._lookupTag(_removeChevrons(tagName))){if(comp.props&&(arStat=comp.props[propName]?.status)){let stat,stType,i,omitted=statType===undefined;for(i=0;i<arStat.length;i++){stat=arStat[i];stType=stat.type||DEPRECATED;if(omitted||stType===statType){if(!ret){ret=[]}ret.push(stat)}}}}return ret?ret:null};Components.prototype.isRuleIgnored=function(compName,ruleName){var ret,ar;if(ar=this._ignored[compName]){ret=ar.includes(ruleName)}return!!ret};Components.prototype.isOk=function(){return this._isOk};Components.prototype.setCurFileType=function(ft){this._curFileType=ft};Components.prototype._init=function(base,urls,filePaths,$jetCore){if(this._isAMD){this._processJetCorePack();return}if(base){base=base.trim();if(base.charAt(base.length-1)!=="/"){base=base+"/"}}else{base=""}this._processFilePaths(filePaths);this._processUrls(base,urls);this._processJetCorePack();this._createStyleLookup();this._processJetCore($jetCore)};Components.prototype._processFilePaths=function(filePaths){var obj,compEntry,fpath,i,j;if(!filePaths){return}this._console("\nPre-processing user-declared web component metadata...");for(i=0;i<filePaths.length;i++){compEntry=filePaths[i];var dirStack=this._nd.glob.sync(compEntry);for(j=0;j<dirStack.length;j++){fpath=dirStack[j];if(this._runOpts.isDryRun||this._runOpts.isDebug){let msg="-".repeat(70)+"\n"+(this._runOpts.isDryRun?"* ":"")+"processing component path '"+fpath+"' ...";if(this._runOpts.isDryRun){console.log(msg)}else{this._debug(msg)}}if(fpath.toLowerCase().endsWith(".zip")){obj=this._compSvcs._extractComponentJsonFromZip(fpath);if(obj.obj){this.processComponentJson(obj.obj,fpath)}else if(obj.msg){this._error("Failed to parse component.json : "+obj.msg+" - "+fpath)}else if(obj.error){this._error("Failed to unzip '"+fpath+"'")}continue}if(this._isComponentJsonPath(fpath)){if(obj=this._readComponentJson(fpath)){if(obj.type&&obj.type==="pack"){continue}this.processComponentJson(obj,this._nd.path.dirname(fpath))}continue}this._recurse(fpath)}}if(this._isDebug){this._debug("-".repeat(70))}};Components.prototype._recurse=function(fpath){var dirs,inFile,inFilePath,obj,i;try{dirs=this._nd.fs.readdirSync(fpath);if(this._isDebug){this._debug(` processing ${fpath} ${dirs.length} component dirs ...`)}for(i=0;i<dirs.length;i++){inFile=dirs[i];if(inFile===COMPONENT_JSON){inFilePath=this._nd.path.join(fpath,COMPONENT_JSON);if(this._isDebug){this._debug(" processing "+inFilePath+"...")}obj=this._readComponentJson(inFilePath);if(obj){if(!obj.type||obj.type==="composite"){this.processComponentJson(obj,fpath)}else if(obj.type==="resource"){this._resources[obj.pack+"/"+obj.name]=obj}else if(obj.type==="pack"){this._packs[obj.name]=obj}}else{return}}var curPath=this._nd.path.join(fpath,inFile);if(this._fsUtils.getFileType(curPath)==="d"){this._recurse(curPath)}}}catch(e){this._error("Component check failed - "+e);this._isOk=false}};Components.prototype._processUrls=function(base,urls){var url,i;if(!urls){return}for(i=0;i<urls.length;i++){url=urls[i];if(this._runOpts.isDryRun||this._runOpts.isDebug){let msg;msg="-".repeat(70)+"\nprocessing URL '"+url+"'";if(this._runOpts.isDryRun){console.log(msg);continue}else{this._debug(msg)}}if(_isRelativeUrl(url)){url=base+url;if(_isRelativeUrl(url)){this._error("component URL incomplete - '"+url+"'");continue}}this._processUrl(url)}};Components.prototype._processUrl=function(url){var resp,obj,rc,tempFile,tmp;try{resp=this._compSvcs.loadUrl(url);if(resp.eCode==="ETIMEDOUT"){this._error("config.componentUrls - request timed-out for '"+url+"'");this._isOk=false;return}try{if(resp.type==="json"){if(resp.body){obj=JSON.parse(resp.body);if(!this.processComponentJson(obj,url)){this._isOk=false}}else{this._error("Server responded with "+resp.statusCode+" URL: '"+url+"'")}}else if(resp.type=="zip"){rc=this._compSvcs.writeZipBufferToFile(resp.body);if(typeof rc==="boolean"&&rc){tempFile=this._compSvcs.getLastZipFilePath();obj=this._compSvcs.extractComponentJsonFromZip(tempFile);if(obj.obj){this.processComponentJson(obj.obj,url)}else if(obj.msg){this._error("Failed to parse component.json : "+obj.msg+" - "+url)}else if(obj.error){this._error("Failed to unzip '"+url+"'")}this._compSvcs.deleteZipFile(tempFile)}else{this._error("Failed to create local temp zip file from URL '"+url+"' : rc.message");this._isOk=false}}else{tmp=typeof resp.type==="string"?resp.type:"?";this._error("Server responded with unexpected data ('"+tmp+"') : '"+url+"'");this._isOk=false}}catch(e){this._error("Invalid JSON - URL '"+url+"' : "+e);this._isOk=false}}catch(e1){this._error("URL access failed "+(e1.message.includes("ENOTFOUND")?"(NOT FOUND)":"")+" - URL '"+url+"'");this._isOk=false}};Components.prototype._processJetCorePack=function(){var comps,comp;if(comps=this._ojcPack.getComponents()){for(comp in comps){this.processComponentJson(comps[comp],"oj-c")}}};Components.prototype.processComponentJson=function(obj,fromLocation,vcomp){var comp,props,events,event,eventName,compName,metaObj;var isOJC;compName=obj.pack?obj.pack+"-"+obj.name:obj.name;isOJC=obj.pack===OJ_C;if(!this._isAMD){if(this._runOpts.isDryRun){console.log(" Would have processed '"+fromLocation+"'");return}if(obj.type&&obj.type==="pack"){return this._processJetPack(obj,fromLocation)}if(!isOJC&&!vcomp){if(!this._compSvcs.validateComponentJson(obj,fromLocation)){this._isOk=false;return false}}if(isOJC){this._ojcPathLookup[obj.main]=obj}}if(this._lookupTag(compName)){this._jafMsg("jaf-sys-dup-component",`Ignoring duplicate component '${compName}' at '${fromLocation}'`,"W");return true}this._meta[compName]=obj;(isOJC?this._jetTagLookup:vcomp?this._VCompLookup:this._tagLookup)[compName]=comp={};comp[PROP_FOLDER]=fromLocation;comp[PROP_VERSION]=obj.version;if(obj.extension&&obj.extension.audit&&obj.extension.audit.ignore){let ar;if((ar=obj.extension.audit.ignore)&&ar.length){this._ignored[compName]=[...ar]}}if(obj.hasOwnProperty(PROP_SLOTS)){comp[PROP_SLOTS]=obj[PROP_SLOTS]}if(obj.hasOwnProperty(PROP_DYNAMIC_SLOTS)){comp[PROP_DYNAMIC_SLOTS]=obj[PROP_DYNAMIC_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){events[event]=obj.events[event];metaObj=obj.events}}if(obj.implements){comp[PROP_IMPLEMENTS]=obj.implements;this._metaLib.processImplements(compName,obj.implements)}if(obj.status){let status,i;metaObj=obj.status;for(i=0;i<metaObj.length;i++){status=metaObj[i];if(status.type===MAINTENANCE){if(!this._maintenance){this._maintenance=new Set}this._maintenance.add(compName)}else if(status.type===SUPERSEDES){if(!this._supercedes){this._supersedes=new Set}this._supersedes.add(compName)}else if(status.type===ANTIPATTERN){if(!this._antiPattern){this._antiPattern=new Set}this._antiPattern.add(compName)}}}if(obj.requirements){comp[PROP_REQUIREMENTS]=obj.requirements}if(obj.extension&&obj.extension.theme&&obj.extension.theme.unsupportedThemes){comp[PROP_UNSUP_THEME]=obj.extension.theme.unsupportedThemes}if(obj.hasOwnProperty(PROP_SUBCOMPONENT_TYPE)){comp[PROP_SUBCOMPONENT_TYPE]=obj[PROP_SUBCOMPONENT_TYPE]}if(obj.hasOwnProperty(PROP_DEPENDENCIES)){comp[PROP_DEPENDENCIES]=obj[PROP_DEPENDENCIES]}if(obj.type){comp[PROP_TYPE]=obj.type}if(obj.pack){comp[PROP_PACK]=obj.pack}if(obj.hasOwnProperty("required")){comp[PROP_REQUIRED]=obj.required}if(obj.status){comp[PROP_STATUS]=obj.status}if(obj.styleClasses){comp[PROP_STYLECLASSES]=this._extractStyles(obj.styleClasses)}this._count++;return true};Components.prototype._extractProps=function(propObj,propSoFar,properties,name,rdonly){var prop,thisProp,soFar,obj;for(prop in properties){soFar=(propSoFar?propSoFar+DOT:"")+prop;propObj[soFar]=obj={};thisProp=properties[prop];if(thisProp.hasOwnProperty("enumValues")){if(Array.isArray(thisProp.enumValues)){obj.enumValues=thisProp.enumValues}else{this._error(`Web component '${name}' property '${soFar}' has invalid 'enumValues' in component.json`)}}if(thisProp.hasOwnProperty("status")){obj.status=thisProp.status}if(thisProp.hasOwnProperty("type")){obj.type=thisProp.type}if(thisProp.required){obj.required=true}if(thisProp.extension&&thisProp.extension.theme&&thisProp.extension.theme.unsupportedThemes){obj[PROP_UNSUP_THEME]=thisProp.extension.theme.unsupportedThemes}if(thisProp.hasOwnProperty("translatable")){obj.translatable=true}if(typeof thisProp.readOnly==="boolean"){obj.readOnly=thisProp.readOnly}else{if(rdonly){obj.readOnly=true}}if(thisProp.hasOwnProperty("writeback")){obj.writeback=thisProp.writeback}if(thisProp.hasOwnProperty("properties")){obj.properties=true;this._extractProps(propObj,soFar,thisProp.properties,name,obj.readOnly)}}};Components.prototype._extractStyles=function(styleClasses){var so,si,obj,ret={},i,j;if(!Array.isArray(styleClasses)){return ret}for(i=0;i<styleClasses.length;i++){so=styleClasses[i];if(so.kind==="class"){ret[so.name]=this._extractStyleClass(so)}else if(so.kind==="set"&&so.styleItems&&Array.isArray(so.styleItems)){ret[so.name]=obj={kind:"set"};if(so.status){obj.status=so.status}obj.styleClasses={};for(j=0;j<so.styleItems.length;j++){si=so.styleItems[j];obj.styleClasses[si.name]=this._extractStyleClass(si)}}else if(so.kind==="template"){}}return ret};Components.prototype._extractStyleClass=function(so){var obj={};if(so.styleSelector){obj.styleSelector=so.styleSelector}if(so.status){obj.status=so.status}return obj};Components.prototype._processJetPack=function(obj,fromLocation){var deps,dep,urlKey,depUrl,msg,i;if(this._runOpts.isDryRun||this._runOpts.isDebug){msg="processing JET Pack "+obj.name+" (version: "+obj.version+") : '"+fromLocation+"'";if(this._runOpts.isDryRun){console.log("* "+msg);return}else{this._debug(msg)}}if(!fromLocation.includes("http")){this._error("JET packs loaded via config 'components' property (file based) are currently not supported");return false}i=fromLocation.indexOf(obj.name);if(i>=0){urlKey=fromLocation.substring(0,i)}else{this._error("Cannot handle Jet Pack URL format to load dependencies : "+fromLocation)}deps=obj.dependencies;if(deps){for(dep in deps){depUrl=urlKey+dep+"/versions/"+obj.dependencies[dep]+"/content/component.json";if(this._isDebug){this._debug(` processing dependency ${dep} ${obj.dependencies[dep]}`)}this._processUrls("",[depUrl])}}return false};Components.prototype._processJetCore=function(jetCorePath){var files,file,obj,i;if(!jetCorePath){return}this._console("-".repeat(70)+"\nPerforming schema analysis on JET Core components (dt) using '"+this._compSvcs.getSchemaName()+"'...");try{files=this._nd.fs.readdirSync(jetCorePath);this._console(` processing ${files.length} $jetCore components...`);for(i=0;i<files.length;i++){file=files[i];if(file.endsWith(".json")){file=this._nd.path.join(jetCorePath,file);try{obj=this._readComponentJson(file);if(obj){this._compSvcs.validateComponentJson(obj,file)}}catch(e){}}}}catch(e1){this._error("!!! $JetCore Component check failed - "+e1)}this._console(" processing "+(files?files.length+" ":"")+"$jetCore components completed");this._console("-".repeat(70))};Components.prototype._initVComponents=function(){let precompileCache,tscript;const preComp=this._tsUtils.getPreCompiler();const preCompUtils=this._tsUtils.getUtils();const auditBase=this._fsUtils.toJAFPath(this._oConfig.getBase());const projectPathInfo=preCompUtils.getKeyPathInfo(auditBase);if(this._isDebug){this._debug("\n_Precompilation prep - _initVComponents: projectPathInfo=");this._debug(JSON.stringify(projectPathInfo,null,3)+"\n")}if((tscript=this._oConfig.getTypescript())&&tscript.compile&&projectPathInfo.tsSource){this._console("Pre-processing VComponents...");if(!(precompileCache=preComp.getPrecompileCache(auditBase,projectPathInfo.tsSource,projectPathInfo.componentRootFolder))){return}if(!this._fsUtils.pathExistsSync(precompileCache)){this._debug(`VComponents: precompileCache not created - ${precompileCache}`)}else{this._getVComponentJson(precompileCache)}}};Components.prototype._getVComponentJson=function(jsonDir){var contents,jsonCount=0,jsonEntries=0;if(contents=this._fsUtils.readDirSync(jsonDir)){let json,compName;this._VFilesInspected=[];this._VTypes={};contents.forEach(file=>{if(file.isFile){jsonEntries++;json=this._fsUtils.readJsonSync(this._nd.path.join(jsonDir,file.name),false,false);if(typeof json==="string"){this._error(`Compiled metadata for x - ${json}`)}else{compName=json.pack?json.pack+"-"+json.name:json.name;if(this._isDebug){var packCompName=json.pack?" ("+compName+")":"";this._debug(`\nPost-compilation VComponent found : '${json.name}'${packCompName}`);jsonCount++}this._getVCompFolder(compName);this.processComponentJson(json,jsonDir,true)}}});this._VFilesInspected=null}if(this._isDebug){this._debug(`\n_Post-VComponent compilation - ${jsonCount} component.json's processed (out of ${jsonEntries} generated)`)}};Components.prototype._getVCompFolder=function(compName){var files,file,folder,ret=null,x,_self=this,VType;const preComp=this._tsUtils.getPreCompiler();const srcFiles=preComp.getVFiles();if(srcFiles){for(file of srcFiles){if(this._VFilesInspected.includes(file)){continue}let src;function _fail(errMsg){_self._warn(` Unexpected read error of '${file}' - components._getVFolder`)}if((src=this._fsUtils.readFileSync(file,_fail))==null){this._VFilesInspected.push(file);continue}if((VType=this._isVCompSrc(src,compName,file))===null){continue}this._VFilesInspected.push(file);this._VTypes[compName]=VType;ret=this._nd.path.dirname(file);break}}if(!VType){VType="?";this._VTypes[compName]=VType}if(this._isDebug){if(ret){this._debug(` EXTRACTED '${compName}' VType=${VType} -> '${ret}'`)}else{this._debug(` NOT EXTRACTED '${compName}' from source file set`)}}return ret};Components.prototype._isVCompSrc=function(src,name,fileName){var ret,start=0,utils=this._utils;function _extractCompName(data,x,closeDelim){let x2,comp,match=false;if((x=utils.eatWhitespace(data,x))>=0){if(data.charAt(x)==="("){if((x=utils.eatWhitespace(data,x+1))>=0){if((x2=data.indexOf(closeDelim,x))>=0){comp=data.substring(x,x2).trim();comp=comp.substring(1,comp.length-1);match=comp===name}}}}return match};while(start<src.length){let i,first=true;if((i=src.indexOf(CUSTOM_ELEMENT,start))>=0){start=i+=CUSTOM_ELEMENT.length;if(ret=_extractCompName(src,i,")")){return"class"}first=false;continue}else if((i=src.indexOf(REGISTER_CUSTOM_ELEMENT,start))>=0){start=i+=REGISTER_CUSTOM_ELEMENT.length;if(ret=_extractCompName(src,i,",")){return"func"}first=false;continue}else{if(first){if(this._isDebug){this._debug(` NOT EXTRACTABLE '${name}' in '${fileName}'`)}this._VFilesInspected.push(fileName)}}break}return null};Components.prototype._createStyleLookup=function(){var tag,o,scl,st;for(tag in this._tagLookup){o=this._tagLookup[tag];if(scl=o.styleClasses){for(st in scl){this._styleLookup[st]=tag}}}};Components.prototype._readComponentJson=function(inFile){var obj=null;if(this._isDebug){this._debug(` loading '${inFile}'`)}obj=this._nd.jsonLoader.load(inFile,this._nd,this._error,false,this._utils);if(!obj){this._isOk=false}return obj};Components.prototype._isComponentJsonPath=function(filePath){return filePath.toLowerCase().endsWith(COMPONENT_JSON)};Components.prototype.dumpComponentNames=function(){var names,keys;this._dumpComponentNames(this._tagLookup,"--------- Declared Web Components ---------","No valid user (non-VComponent) components declared!","-------- End Declared Web Components ---------");this._dumpComponentNames(this._VCompLookup,"--------- Discovered VComponents ---------","No VComponents found!","-------- End Discovered VComponents ---------");this._dumpComponentNames(this._jetTagLookup,"--------- Declared JET OJ-C Pack Web Components ---------","No valid user JET Core Pack components declared!","-------- End Declared OJ-C Pack Web Components ---------")};Components.prototype._dumpComponentNames=function(lookup,start,none,end){var keys,meta,impls,isOJC=start.includes("OJ-C");const INFO="[info]";keys=Object.keys(lookup);if(!keys.length){this._console(`${INFO} ${none}\n`,"I");return}this._console(`${INFO} ${start}`,"I");if(isOJC&&this._isVerbose){this._console(`${INFO} ${keys.length} JET CorePack components loaded`,"I")}else{keys.forEach(key=>{meta=lookup[key];this._console(`${INFO} ${key} (${meta.version})`,"I");impls=meta.implements&&meta.implements.length?meta.implements.join(", "):"none declared";this._console(`${INFO} Impls: ${impls}`)})}this._console(`${INFO} ${end}\n`,"I")};function _isTagStatusType(statType){return type===SUPERSEDES||type===MAINTENANCE||type===DEPRECATED||type===ANTIPATTERN};function _propToKebabCase(str){return str.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z])(?=[a-z])/g,"$1-$2").toLowerCase()};function _propToCamelCase(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)};function _isRelativeUrl(url){url=url.toLowerCase();return!(url.indexOf("http://")===0||url.indexOf("https://")===0)};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=Components;
|
package/lib/Config.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 Helper=require("./ConfigEx");const ConfigLib=require("./ConfigLib");const MACROS=require("../lib/macros");const DEFAULTS=require("./defaults");var JET_VERSIONS;const TYPE_BOOLEAN="boolean";const AT_INCLUDE="@include(";const QUOTE="\"";const TSCONFIG="tsconfig.json";var Config=function(nd,base,iniPath,fnApplyMacros,rules,severity,cliGroups,cliSev,msgCtx,modeCtx,utils,fsUtils,cbDebug){this._path=iniPath;this._dir=null;this._config=null;this._tsCfgObj=null;this._preBuilt=false;this._isOJET=modeCtx.isOJET;this._isCLI=modeCtx.isCLI;this._isAPI=modeCtx.isAPI;this._isAMD=modeCtx.isAMD;this._isCliMode=modeCtx.isCLI||modeCtx.isOJETCLI;this._rules=rules;this._utils=utils;this._fsUtils=fsUtils;this._severity=severity;this._helper=new Helper(this,nd,severity,utils,fsUtils,msgCtx,modeCtx);this.applyMacros=fnApplyMacros;this._bErrors=false;this._console=msgCtx.console;this._error=msgCtx.error;this._warn=msgCtx.warn;this._info=msgCtx.info;this._debug=msgCtx.debug;this._isDebug=msgCtx.isDebug;this._isVerbose=msgCtx.isVerbose;JET_VERSIONS=nd.jetver.getVersions();this._cliGroups=cliGroups;this._cliSev=cliSev;this._nd=nd;if(iniPath){this._init(base,iniPath,cbDebug)}};Config.prototype.getConfig=function(){var tmp=JSON.parse(JSON.stringify(this._config));if(tmp._sev){delete tmp._sev}return tmp};Config.prototype.getConfigLib=function(){if(this._configLib){return this._configLib}this._configLib=new ConfigLib(this,this._helper);return this._configLib};Config.prototype.getFiles=function(){return this._config.files};Config.prototype.getExclude=function(){return this._config.exclude};Config.prototype.getOptions=function(){return this._config.options};Config.prototype.getJetVer=function(){return this._config.jetVer};Config.prototype.getComponentsBaseUrl=function(){return this._config.componentsBaseUrl};Config.prototype.getComponentsBase=function(){return this._config.componentsBase};Config.prototype.getComponents=function(){return this._config.components};Config.prototype.getComponentUrls=function(){return this._config.componentUrls};Config.prototype.getJetCorePack=function(){return this._config.jetCorePack};Config.prototype.getComponentOptions=function(){return this._config.componentOptions};Config.prototype.getTypescript=function(){return this._config.typescript};Config.prototype.getTsConfig=function(){var ret;if(this._config.typescript){ret=this._config.typescript.tsconfig}return ret};Config.prototype.getMarkdownOptions=function(){return this._config.markdownOptions};Config.prototype.getTsConfigObj=function(){return this._tsCfgObj};Config.prototype.getOutPath=function(){return this._config.outPath};Config.prototype.getRulePacks=function(){return this._config.rulePacks};Config.prototype.getRuleMods=function(){return this._config.ruleMods};Config.prototype.getEnable=function(){return this._config.ruleMods&&this._config.ruleMods.enable?this._config.ruleMods.enable:undefined};Config.prototype.getDisable=function(){return this._config.ruleMods&&this._config.ruleMods.disable?this._config.ruleMods.disable:undefined};Config.prototype.getRuleDescriptions=function(){return this._config.ruleDescriptions};Config.prototype.getRulesFired=function(){return this._config.rulesFired};Config.prototype.getGroups=function(){return this._config.groups};Config.prototype.setGroups=function(groups){this._config.groups=groups};Config.prototype.getDefGroups=function(){return this._config.defGroups};Config.prototype.getRunRuleNames=function(){return this._config.ruleNames};Config.prototype.isBuiltinJetRules=function(){return this._config.builtinJetRules};Config.prototype.isBuiltinCspRules=function(){return this._config.builtinCspRules};Config.prototype.isBuiltinJetWcRules=function(){return this._config.builtinJetWcRules};Config.prototype.isBuiltinJetWcOracleRules=function(){return this._config.builtinJetWcOracleRules};Config.prototype.isBuiltinSpocRules=function(){return this._config.builtinSpocRules};Config.prototype.isBuiltinOjcMigrationRules=function(){return this._config.builtinOjcMigrationRules};Config.prototype.isBuiltinWebDriverTestRules=function(){return this._config.builtinWebDriverTestRules};Config.prototype.getMessages=function(){return this._config.messages};Config.prototype.setMessages=function(msgid,state){return this._helper.setMessages(msgid,state)};Config.prototype.getFollowLinks=function(){return this._config.followLinks};Config.prototype.getFormat=function(){return this._config.format};Config.prototype.getProseFormat=function(){return this._config.proseFormat};Config.prototype.getLineFormat=function(){return this._config.lineFormat};Config.prototype.getBase=function(){return this._config.base};Config.prototype.getStylesets=function(){return this._config.stylesets};Config.prototype.getNameSpaces=function(){return this._config.nameSpaces};Config.prototype.getCommon=function(){return this._config.common||{}};Config.prototype.getSeverity=function(){return this._config.severity};Config.prototype.setSeverity=function(severity){return this._config.severity=severity};Config.prototype.getSevMap=function(){return this._config.sevMap};Config.prototype.getTheme=function(){return this._config.theme};Config.prototype.getComments=function(){return this._config.comments};Config.prototype.getEcmaVer=function(){return this._config.ecmaVer};Config.prototype.getTabs=function(){return this._config.tabs};Config.prototype.getTitle=function(){return this._config.title};Config.prototype.getRetCode=function(){var ret,o;if(this._config&&this._config.options){o=this._config.options;if(o.retCode!==undefined){ret=o.retCode}else if(o.rc!==undefined){ret=o.rc}else{ret="auto"}}else{ret="auto"}return ret};Config.prototype.isOk=function(){return!this._bErrors};Config.prototype.getUserDefs=function(){return this._config.userDefs};Config.prototype.getAppendFileList=function(){return this._helper.getAddFileList()};Config.prototype.getJetPagesOnly=function(){return this._config.jetPagesOnly};Config.prototype.getExtendsProfileName=function(){return this._profile};Config.prototype.getTempDir=function(){return this._config.tempDir};Config.prototype.getOrigConfig=function(){return this._origConfig};Config.prototype.get$JetCore=function(){return this._config.$JetCore};Config.prototype._init=function(base,iniPath,cbDebug){var i,s,val,val2,bUseDefaults=false;if(typeof iniPath==="string"){this._dir=this._nd.path.dirname(iniPath);bUseDefaults=this._loadConfig(iniPath);if(this._bErrors){return}}else{this._config=iniPath;this._dir=this._nd.process.cwd();this._preBuilt=true}this._origConfig=this._config;this._config=_cloneConfig(this._config);this._helper.setConfig(this._config,this._preBuilt?null:iniPath,this._dir);if(this._config.options){this._isVerbose=!!this._config.options.verbose;this._isDebug=!!this._config.options.debug;let opStat=cbDebug(this._isVerbose,this._isDebug);this._isVerbose=opStat.verbose;this._isDebug=opStat.debug;this._helper.setDebugStatus(this._isVerbose,this._isDebug)}if(!this._checkProperties()){this._bErrors=true;return}if(base){this._config.base=base}if(!this._config.base){this._config.base=this._dir}if(this._config.base===MACROS.cwd){this._config.base=this._nd.process.cwd()}if(!this._cleanBase()){return}if(!bUseDefaults&&!this._isOJET){this._info("[Info]: Analyzing "+(typeof iniPath==="string"?"config '"+iniPath+"'":"pre-built config object"),"I",true)}if(this._config.extends){if(!this._helper.processExtends()){this._bErrors=true;return}}if(this._config?.options?.experimental&&this._config.options.experimental!=="tsx"){this._error("Config entry 'experimental' - invalid value!");this._bErrors=true;return}if(typeof this._config.builtinJetRules!==TYPE_BOOLEAN){this._config.builtinJetRules=true}if(typeof this._config.builtinCspRules!==TYPE_BOOLEAN){this._config.builtinCspRules=false}if(typeof this._config.builtinJetWcRules!==TYPE_BOOLEAN){this._config.builtinJetWcRules=false}if(typeof this._config.builtinJetWcOracleRules!==TYPE_BOOLEAN){this._config.builtinJetWcOracleRules=false}if(typeof this._config.builtinWebDriverTestRules!==TYPE_BOOLEAN){this._config.builtinWebDriverTestRules=false}if(this._config.builtinSpocRules){if(typeof this._config.builtinSpocRules!==TYPE_BOOLEAN){this._error("Config entry 'builtinSpocRules' must be a boolean!");this._bErrors=true;return}if(this._config.builtinSpocRules){this._config.builtinJetRules=this._config.builtinJetWcRules=this._config.builtinJetWcOracleRules=false}}if(this._config.builtinOjcMigrationRules){if(typeof this._config.builtinOjcMigrationRules!==TYPE_BOOLEAN){this._error("Config entry 'builtinOjcMigrationRules' must be a boolean!");this._bErrors=true;return}else{this._config.builtinJetRules=this._config.builtinJetWcRules=this._config.builtinJetWcOracleRules=this._config.builtinCspRules=this._config.builtinSpocRules=false}}else{this._config.builtinOjcMigrationRules=false}this._config.jetPagesOnly=!!this._config.jetPagesOnly;if(!this._config.files){this._config.files=[]}if(!this._config.options){this._config.options={}}if(!this._helper.processRuleDiscriminant()){this._bErrors=true;return}if(this._config.jetVer){val=this._config.jetVer;if(typeof val!=="string"){this._error("Config entry 'jetVer' is not a string!");this._bErrors=true;return}val=val.trim();if((i=val.indexOf("-"))>=0){val=val.substring(0,i)}val2=val.split(".");if(val2.length>3){this._error(`Config entry 'jetVer' --> '${val}' is invalid`);this._bErrors=true;return}for(i=0;i<val2.length;i++){if(i===0&&val2[0].charAt(0).toLowerCase()==="v"){val2[0]=val2[0].substring(1)}s=parseInt(val2[i]);if(isNaN(s)){let part=["major","minor","patch"];this._error(`Config entry 'jetVer' --> '${val}' : '${part[i]}' value is invalid`);this._bErrors=true;return}val2[i]=""+s}val=val2.join(".");if(val2.length!==3||val2[2]==="0"){s=val2.length===3;val2=this._nd.jetver.getBestVersion(val,val2);if(!val2){s=s?`Config entry 'jetVer' --> '${val}' cannot be resolved to a supported JET version`:`Config entry 'jetVer' --> '${val}' is not a supported JET version`;this._error(s);this._bErrors=true;return}val=val2}if(!JET_VERSIONS[val]){this._error(`Config entry 'jetVer' --> '${val}' is not a supported JET version!`);this._bErrors=true;return}this._config.jetVer=val}else{this._config.jetVer=DEFAULTS.JETVER}if(!this._helper.processJetCorePack()){this._bErrors=true;return}if(!this._helper.processWebComponents()){this._bErrors=true;return}if(!this._helper.processRulePacks()){this._bErrors=true;return}if(!this._helper.processRuleMods()){this._bErrors=true;return}if(!this._helper.processFormat()){this._bErrors=true;return}if(!this._helper.processProseFormat()){this._bErrors=true;return}if(!this._helper.processLineFormat()){this._bErrors=true;return}if(!this._helper.processRuleDescriptions()){this._bErrors=true;return}if(!this._helper.processRulesFired()){this._bErrors=true;return}if(!this._helper.processSevMap()){this._bErrors=true;return}if(!this._helper.processSeverity(this._cliSev)){this._bErrors=true;return}if(!this._helper.processGroups(this._cliGroups)){this._bErrors=true;return}if(!this._helper.processDefGroups()){this._bErrors=true;return}if(!this._helper.processRuleNames()){this._bErrors=true;return}if(this._config.followLinks==null){this._config.followLinks=true}else{this._config.followLinks=!!this._config.followLinks}if(!Array.isArray(this._config.files)){this._error("Config entry 'files' is not an array!");this._bErrors=true;return}if(!this._helper.validateFileList(this._config.files)){this._bErrors=true;return}if(this._config.exclude){if(!Array.isArray(this._config.exclude)){this._error("Config entry 'exclude' is not an array!");this._bErrors=true;return}if(!this._helper.validateFileList(this._config.exclude)){this._bErrors=true;return}}else if(this._config.excludes){this._error("Config property 'excludes' found - did you mean 'exclude'?");this._bErrors=true;return}if(!this._helper.processAddFileList()){this._bErrors=true;return}if(this._config.stylesets){val=this._config.stylesets;if(!Array.isArray(val)){this._error("Config property 'stylesets' is not an array!");this._bErrors=true;return}}if(this._isAMD&&this._config.tempDir){this._error("Config entry 'tempDir' is not valid in AMD mode!");this._bErrors=true;return}if(this._config.tempDir){if(typeof this._config.tempDir!=="string"){this._error("Config property 'tempDir' is not a string!");this._bErrors=true;return}if(this._config.tempDir.startsWith(".")){this._config.tempDir=this._nd.path.resolve(this._nd.process.cwd(),this._config.tempDir)}}if(!this._helper.processTypeScript()){this._bErrors=true;return}if(!this._helper.processMarkdownOpts()){this._bErrors=true;return}if(!this._helper.processMessages()){this._bErrors=true;return}if(!this._helper.processNameSpaces()){this._bErrors=true;return}if(!this._helper.processTheme()){this._bErrors=true;return}if(!this._helper.processComments()){this._bErrors=true;return}if(!this._helper.processEcmaVer()){this._bErrors=true;return}if(!this._helper.processOptions()){this._bErrors=true;return}if(!this._helper.processTitle()){this._bErrors=true;return}if(!this._helper.processRetCode()){this._bErrors=true;return}if(!this._config.extends){this._cleanConfigPaths()}if(this._config.typescript&&(val=this._config.typescript.tsconfig)){if(!(this._tsCfgObj=this._loadTsConfig(val))){this._bErrors=true;return}}};Config.prototype.validateRetCode=function(val,cb){return this._helper.validateRetCode(val,cb)};Config.prototype._cleanConfigPaths=function(){var src,i,ftype,dir;var nd=this._nd;var base=this._config.base;function _resolve(fp){if(!nd.path.isAbsolute(fp)){fp=nd.path.normalize(fp);fp=nd.path.resolve(base,fp)}return fp};if(!this._config.extends){this._info("[Info]: Using config base '"+this._config.base+"'","I")}if(src=this._config.files){for(i=0;i<src.length;i++){if(!src[i].startsWith("http")){src[i]=_resolve(src[i])}}}if(src=this._config.exclude){for(i=0;i<src.length;i++){src[i]=_resolve(src[i])}}if(src=this._config.components){for(i=0;i<src.length;i++){src[i]=_resolve(src[i])}}src=this._config.outPath;if(src&&src!=="$noout"){this._config.outPath=_resolve(src)}src=this._config.rulePacks;if(src){for(i=0;i<src.length;i++){if(!nd.path.isAbsolute(src[i].path)){dir=nd.path.normalize(src[i].path);src[i].path=nd.path.resolve(this._config.base,dir)}if(src[i].path.endsWith(".zip")){continue}ftype=this._fsUtils.getFileType(src[i].path);if(ftype!=="d"){this._error("'rulePacks (entry "+(i+1)+"): path' is not a directory - \""+src[i].path+"\"");this._bErrors=true;return}}}if(this._config.typescript&&this._config.typescript.tsconfig)src=this._config.typescript.tsconfig;if(src&&typeof src==="string"){if(!nd.path.isAbsolute(src)){dir=nd.path.normalize(src);dir=nd.path.resolve(this._config.base,dir)}else{dir=src}if(!dir.endsWith(TSCONFIG)){dir=nd.path.join(dir,TSCONFIG)}this._config.typescript.tsconfig=dir}if(src=this._config.jetCorePack){this._config.jetCorePack=_resolve(src)}if(this._bErrors){return};};Config.prototype._cleanBase=function(){var p,ft;var nd=this._nd;p=this._config.base;p=nd.path.normalize(p);p=nd.path.resolve(this._dir,p);ft=this._fsUtils.getFileType(p);if(ft!=="d"){this._error(`Config file 'base' is not a directory - '${p}'`);this._bErrors=true;return false}p=nd.path.join(p,"/");this._config.base=p;this._info(`[Info]: Using Config base '${p}'`,"I");return true};Config.prototype._loadConfig=function(iniPath){var data,stats,bUseDefaults=false,msg;var nd=this._nd;try{stats=nd.fs.statSync(iniPath);if(!stats.isFile()){this._warn("\n[Warn]: Config file '"+iniPath+"' not found. Using defaults.\n");bUseDefaults=true}else{data=nd.fs.readFileSync(iniPath,"utf8");data=nd.decomment(data);data=this.processIncludes(data,iniPath);data=this.processTokens(data);if(this._bErrors){return}if(this._isDebug){if(!data){console.log("NO CONFIG DATA")}else{var a=data.split("\n");console.log("------------- Config Raw Text...");for(var i=0;i<a.length;i++){console.log(i+1+"] "+a[i])}console.log("-".repeat(40))}}if(data){this._config=JSON.parse(nd.decomment(data))}else{this._bErrors=true}}}catch(e){this._bErrors=true;if(e.code){if(e.message.startsWith("ENOENT:")){this._warn("\nConfig file \""+iniPath+"\" not found - using defaults.\n");this._bErrors=false;bUseDefaults=true}}else if(e.toString().startsWith("SyntaxError")){msg=_convertMsgToRowCol(e.message,data,this._utils)}else{msg=e.message}if(msg){msg=msg.replace(/\r/g,"");msg=msg.replace(/ +(?= )/g,"");this._error("Config parse error");this._error("Config file '"+iniPath+"' - "+msg)}}if(this._bErrors){return}if(bUseDefaults){this._config={exclude:["./**/*-min.js","./**/*-min.css","./**/node_modules/**/*.*"],builtinJetRules:true,builtinCspRules:false,builtinJetWcRules:false,builtinJetWcOracleRules:false,builtinOjcMigrationRules:false,followLinks:true,severity:this._severity.ALL,format:"prose",ecmaVer:DEFAULTS.ECMAVER,options:{verbose:false,color:true}}}return bUseDefaults};Config.prototype._checkProperties=function(){return this._helper.checkPropNames()};Config.prototype._loadTsConfig=function(fp){return this._nd.jsonLoader.load(fp,this._nd,m=>{this._error(`Error loading tsconfig : ${m}.`);this._bErrors=true},false,this._utils)};function _convertMsgToRowCol(msg,data,utils){var x,n,rc;x=msg.indexOf("position");if(x<0){return msg}n=parseInt(msg.substr(x+8).trim());rc=utils.getRowColFromIndex(data,n);return msg.substr(0,x)+"row "+rc.row+", col "+rc.col};Config.prototype.processTokens=function(data){const TOKENS="\"tokens\"";var token,sub,start,end,json,toks,count,subst,rc,x,n;if(this._isDebug){this._debug("Performing config 'tokens' substitution...")}x=data.indexOf(TOKENS);if(x<0)return data;x+=TOKENS.length;n=this._expect(data,x,":",true);if(n<0){rc=this._utils.getRowColFromIndex(data,x);this._error("Config: expected ':' after property "+TOKENS+" on line "+rc.row+" position "+rc.col+".");this._bErrors=true;return}n=this._expect(data,n,"{");if(n<0){rc=this._utils.getRowColFromIndex(data,n);this._error("Config: expected '{' after property "+TOKENS+" on line "+rc.row+".");this._bErrors=true;return}start=n;end=data.indexOf("}",start);if(end<0){rc=this._utils.getRowColFromIndex(data,x);this._error("Config: "+TOKENS+" property syntax error (on/after line "+rc.row+").");this._bErrors=true;return}json=data.substring(start,end+1);try{toks=JSON.parse(json)}catch(e){rc=this._utils.getRowColFromIndex(data,x);this._error("Config: syntax error "+TOKENS+" property (on/after line "+rc.row+").");this._bErrors=true;return}subst=0;count=0;for(token in toks){if(token.charAt(0)!=="@"){this._error("Config: token '"+token+"' : must be prefixed with '@'");this._bErrors=true;return}sub=toks[token];token=token.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");token=new RegExp(token,"g");if(this._isVerbose||this._isDebug){n=data.match(token).length;subst+=n>1?--n:0}data=data.replace(token,sub);count++}if(count){try{start=data.indexOf(TOKENS);start=this._expect(data,start+TOKENS.length,":",true);start=this._expect(data,start,"{");end=data.indexOf("}",start+1);data=data.substring(0,start)+json+data.substring(end+1);if(this._isVerbose||this._isDebug){this._info("[Info]: "+subst+" config token substitution"+(subst!==1?"s":"")+" performed with "+count+" token"+(count!==1?"s":"")+".")}}catch(e){this._error("Config: \"tokens\" substitution failed - review \"tokens\" property value");this._bErrors=true}}return data};Config.prototype._expect=function(data,x,s,bump){var ret=-1;x=this._utils.eatWhitespace(data,x);if(x>=0&&data.substr(x,s.length)===s){ret=x+(bump?s.length:0)}return ret};Config.prototype.processIncludes=function(data,filepath,chain){var a,i,line,x,path,comma;var inserts,insert,incPath;var nd=this._nd;if(this._isDebug){this._debug("Checking for "+(chain?"sub ":"")+"@include. . .")}if((i=data.indexOf(AT_INCLUDE))<0||data.charAt(i-1)==="_"){if(this._isDebug){this._debug("No "+(chain?"sub ":"")+"@include found")}return data}inserts=[];a=data.split("\n");for(i=0;i<a.length;i++){line=a[i];x=line.indexOf(AT_INCLUDE);if(x<0){continue}path=_extractStringFromLine(line,x+AT_INCLUDE.length,this._utils);if(!path){this._error("Config - @include syntax error"+(chain?" in '"+filepath+"'":"!"));return null}incPath=nd.path.normalize(path);incPath=nd.path.resolve(this._dir,incPath);comma=_isTrailingComma(line,x+AT_INCLUDE.length,this._utils);try{if(this._isDebug){this._debug("Reading @include -> "+incPath)}insert=nd.fs.readFileSync(incPath,"utf8")}catch(e){this._error("Config @include - "+e);return null}if(!insert){this._error("Config - @include '"+incPath+"' not found!");return null}insert=this.processIncludes(insert,incPath,true);if(insert){inserts.push(i);inserts.push(insert+(comma?",":""))}else if(insert===null){return null}}if(inserts&&inserts.length){for(i=0;i<inserts.length;i++){a[inserts[i]]=inserts[++i]}}return a.join("\n")};function _extractStringFromLine(data,start,utils){var c,xEnd,wantQuote,antiQuote;start=utils.eatWhitespace(data,start);if(start<0){return null}c=data.charAt(start);wantQuote=c===QUOTE||c==="'"?c:null;if(wantQuote){antiQuote=c===QUOTE?"'":QUOTE;start++}for(xEnd=start;xEnd<data.length;xEnd++){c=data.charAt(xEnd);if(c===")"||wantQuote&&c===wantQuote){break}else if(c==="\n"||wantQuote&&c===antiQuote||!wantQuote&&(c===QUOTE||c==="'")){xEnd=-1;break}}if(xEnd<0||xEnd>=data.length||wantQuote&&data.charAt(xEnd)!==wantQuote){return null}data=data.substring(start,xEnd).trim();return data?data:null};function _isTrailingComma(s,x,utils){var n,ret=false;n=s.indexOf(")",x);if(n<0){return false}n=utils.eatWhitespace(s,n+1);if(n>=0){ret=s.charAt(n)===","}return ret};function _cloneConfig(o){return JSON.parse(JSON.stringify(o))};module.exports=Config;
|
|
6
|
+
const Helper=require("./ConfigEx");const ConfigLib=require("./ConfigLib");const MACROS=require("../lib/macros");const DEFAULTS=require("./defaults");var JET_VERSIONS;const TYPE_BOOLEAN="boolean";const AT_INCLUDE="@include(";const QUOTE="\"";const TSCONFIG="tsconfig.json";var Config=function(nd,base,iniPath,fnApplyMacros,rules,severity,cliGroups,cliSev,msgCtx,modeCtx,utils,fsUtils,cbDebug){this._path=iniPath;this._dir=null;this._config=null;this._tsCfgObj=null;this._preBuilt=false;this._isOJET=modeCtx.isOJET;this._isCLI=modeCtx.isCLI;this._isAPI=modeCtx.isAPI;this._isAMD=modeCtx.isAMD;this._isCliMode=modeCtx.isCLI||modeCtx.isOJETCLI;this._rules=rules;this._utils=utils;this._fsUtils=fsUtils;this._severity=severity;this._helper=new Helper(this,nd,severity,utils,fsUtils,msgCtx,modeCtx);this.applyMacros=fnApplyMacros;this._bErrors=false;this._console=msgCtx.console;this._error=msgCtx.error;this._warn=msgCtx.warn;this._info=msgCtx.info;this._debug=msgCtx.debug;this._isDebug=msgCtx.isDebug;this._isVerbose=msgCtx.isVerbose;JET_VERSIONS=nd.jetver.getVersions();this._cliGroups=cliGroups;this._cliSev=cliSev;this._nd=nd;if(iniPath){this._init(base,iniPath,cbDebug)}};Config.prototype.getConfig=function(){var tmp=JSON.parse(JSON.stringify(this._config));if(tmp._sev){delete tmp._sev}return tmp};Config.prototype.getConfigLib=function(){if(this._configLib){return this._configLib}this._configLib=new ConfigLib(this,this._helper);return this._configLib};Config.prototype.getFiles=function(){return this._config.files};Config.prototype.getExclude=function(){return this._config.exclude};Config.prototype.getOptions=function(){return this._config.options};Config.prototype.getJetVer=function(){return this._config.jetVer};Config.prototype.getComponentsBaseUrl=function(){return this._config.componentsBaseUrl};Config.prototype.getComponentsBase=function(){return this._config.componentsBase};Config.prototype.getComponents=function(){return this._config.components};Config.prototype.getComponentUrls=function(){return this._config.componentUrls};Config.prototype.getJetCorePack=function(){return this._config.jetCorePack};Config.prototype.getComponentOptions=function(){return this._config.componentOptions};Config.prototype.getTypescript=function(){return this._config.typescript};Config.prototype.getTsConfig=function(){var ret;if(this._config.typescript){ret=this._config.typescript.tsconfig}return ret};Config.prototype.getMarkdownOptions=function(){return this._config.markdownOptions};Config.prototype.getTsConfigObj=function(){return this._tsCfgObj};Config.prototype.getOutPath=function(){return this._config.outPath};Config.prototype.getRulePacks=function(){return this._config.rulePacks};Config.prototype.getRuleMods=function(){return this._config.ruleMods};Config.prototype.getEnable=function(){return this._config.ruleMods&&this._config.ruleMods.enable?this._config.ruleMods.enable:undefined};Config.prototype.getDisable=function(){return this._config.ruleMods&&this._config.ruleMods.disable?this._config.ruleMods.disable:undefined};Config.prototype.getRuleDescriptions=function(){return this._config.ruleDescriptions};Config.prototype.getRulesFired=function(){return this._config.rulesFired};Config.prototype.getGroups=function(){return this._config.groups};Config.prototype.setGroups=function(groups){this._config.groups=groups};Config.prototype.getDefGroups=function(){return this._config.defGroups};Config.prototype.getRunRuleNames=function(){return this._config.ruleNames};Config.prototype.isBuiltinJetRules=function(){return this._config.builtinJetRules};Config.prototype.isBuiltinCspRules=function(){return this._config.builtinCspRules};Config.prototype.isBuiltinJetWcRules=function(){return this._config.builtinJetWcRules};Config.prototype.isBuiltinJetWcOracleRules=function(){return this._config.builtinJetWcOracleRules};Config.prototype.isBuiltinSpocRules=function(){return this._config.builtinSpocRules};Config.prototype.isBuiltinOjcMigrationRules=function(){return this._config.builtinOjcMigrationRules};Config.prototype.isBuiltinWebDriverTestRules=function(){return this._config.builtinWebDriverTestRules};Config.prototype.getMessages=function(){return this._config.messages};Config.prototype.setMessages=function(msgid,state){return this._helper.setMessages(msgid,state)};Config.prototype.getFollowLinks=function(){return this._config.followLinks};Config.prototype.getFormat=function(){return this._config.format};Config.prototype.getProseFormat=function(){return this._config.proseFormat};Config.prototype.getLineFormat=function(){return this._config.lineFormat};Config.prototype.getBase=function(){return this._config.base};Config.prototype.getStylesets=function(){return this._config.stylesets};Config.prototype.getNameSpaces=function(){return this._config.nameSpaces};Config.prototype.getCommon=function(){return this._config.common||{}};Config.prototype.getSeverity=function(){return this._config.severity};Config.prototype.setSeverity=function(severity){return this._config.severity=severity};Config.prototype.getSevMap=function(){return this._config.sevMap};Config.prototype.getTheme=function(){return this._config.theme};Config.prototype.getComments=function(){return this._config.comments};Config.prototype.getEcmaVer=function(){return this._config.ecmaVer};Config.prototype.getTabs=function(){return this._config.tabs};Config.prototype.getTitle=function(){return this._config.title};Config.prototype.getRetCode=function(){var ret,o;if(this._config&&this._config.options){o=this._config.options;if(o.retCode!==undefined){ret=o.retCode}else if(o.rc!==undefined){ret=o.rc}else{ret="auto"}}else{ret="auto"}return ret};Config.prototype.isOk=function(){return!this._bErrors};Config.prototype.getUserDefs=function(){return this._config.userDefs};Config.prototype.getAppendFileList=function(){return this._helper.getAddFileList()};Config.prototype.getJetPagesOnly=function(){return this._config.jetPagesOnly};Config.prototype.getExtendsProfileName=function(){return this._profile};Config.prototype.getTempDir=function(){return this._config.tempDir};Config.prototype.getOrigConfig=function(){return this._origConfig};Config.prototype.get$JetCore=function(){return this._config.$JetCore};Config.prototype._init=function(base,iniPath,cbDebug){var i,s,val,val2,bUseDefaults=false;if(typeof iniPath==="string"){this._dir=this._nd.path.dirname(iniPath);bUseDefaults=this._loadConfig(iniPath);if(this._bErrors){return}}else{this._config=iniPath;this._dir=this._nd.process.cwd();this._preBuilt=true}this._origConfig=this._config;this._config=_cloneConfig(this._config);this._helper.setConfig(this._config,this._preBuilt?null:iniPath,this._dir);if(this._config.options){this._isVerbose=!!this._config.options.verbose;this._isDebug=!!this._config.options.debug;let opStat=cbDebug(this._isVerbose,this._isDebug);this._isVerbose=opStat.verbose;this._isDebug=opStat.debug;this._helper.setDebugStatus(this._isVerbose,this._isDebug)}if(!this._checkProperties()){this._bErrors=true;return}if(base){this._config.base=base}if(!this._config.base){this._config.base=this._dir}if(this._config.base===MACROS.cwd){this._config.base=this._nd.process.cwd()}if(!this._cleanBase()){return}if(!bUseDefaults&&!this._isOJET){this._info("[Info]: Analyzing "+(typeof iniPath==="string"?"config '"+iniPath+"'":"pre-built config object"),"I",true)}if(this._config.extends){if(!this._helper.processExtends()){this._bErrors=true;return}}if(this._config?.options?.experimental){this._warn("Config property 'experimental' is not a valid option in this version of JAF!")}if(typeof this._config.builtinJetRules!==TYPE_BOOLEAN){this._config.builtinJetRules=true}if(typeof this._config.builtinCspRules!==TYPE_BOOLEAN){this._config.builtinCspRules=false}if(typeof this._config.builtinJetWcRules!==TYPE_BOOLEAN){this._config.builtinJetWcRules=false}if(typeof this._config.builtinJetWcOracleRules!==TYPE_BOOLEAN){this._config.builtinJetWcOracleRules=false}if(typeof this._config.builtinWebDriverTestRules!==TYPE_BOOLEAN){this._config.builtinWebDriverTestRules=false}if(this._config.builtinSpocRules){if(typeof this._config.builtinSpocRules!==TYPE_BOOLEAN){this._error("Config entry 'builtinSpocRules' must be a boolean!");this._bErrors=true;return}if(this._config.builtinSpocRules){this._config.builtinJetRules=this._config.builtinJetWcRules=this._config.builtinJetWcOracleRules=false}}if(this._config.builtinOjcMigrationRules){if(typeof this._config.builtinOjcMigrationRules!==TYPE_BOOLEAN){this._error("Config entry 'builtinOjcMigrationRules' must be a boolean!");this._bErrors=true;return}else{this._config.builtinJetRules=this._config.builtinJetWcRules=this._config.builtinJetWcOracleRules=this._config.builtinCspRules=this._config.builtinSpocRules=false}}else{this._config.builtinOjcMigrationRules=false}this._config.jetPagesOnly=!!this._config.jetPagesOnly;if(!this._config.files){this._config.files=[]}if(!this._config.options){this._config.options={}}if(!this._helper.processRuleDiscriminant()){this._bErrors=true;return}if(this._config.jetVer){val=this._config.jetVer;if(typeof val!=="string"){this._error("Config entry 'jetVer' is not a string!");this._bErrors=true;return}val=val.trim();if((i=val.indexOf("-"))>=0){val=val.substring(0,i)}val2=val.split(".");if(val2.length>3){this._error(`Config entry 'jetVer' --> '${val}' is invalid`);this._bErrors=true;return}for(i=0;i<val2.length;i++){if(i===0&&val2[0].charAt(0).toLowerCase()==="v"){val2[0]=val2[0].substring(1)}s=parseInt(val2[i]);if(isNaN(s)){let part=["major","minor","patch"];this._error(`Config entry 'jetVer' --> '${val}' : '${part[i]}' value is invalid`);this._bErrors=true;return}val2[i]=""+s}val=val2.join(".");if(val2.length!==3||val2[2]==="0"){s=val2.length===3;val2=this._nd.jetver.getBestVersion(val,val2);if(!val2){s=s?`Config entry 'jetVer' --> '${val}' cannot be resolved to a supported JET version`:`Config entry 'jetVer' --> '${val}' is not a supported JET version`;this._error(s);this._bErrors=true;return}val=val2}if(!JET_VERSIONS[val]){this._error(`Config entry 'jetVer' --> '${val}' is not a supported JET version!`);this._bErrors=true;return}this._config.jetVer=val}else{this._config.jetVer=DEFAULTS.JETVER}if(!this._helper.processJetCorePack()){this._bErrors=true;return}if(!this._helper.processWebComponents()){this._bErrors=true;return}if(!this._helper.processRulePacks()){this._bErrors=true;return}if(!this._helper.processRuleMods()){this._bErrors=true;return}if(!this._helper.processFormat()){this._bErrors=true;return}if(!this._helper.processProseFormat()){this._bErrors=true;return}if(!this._helper.processLineFormat()){this._bErrors=true;return}if(!this._helper.processRuleDescriptions()){this._bErrors=true;return}if(!this._helper.processRulesFired()){this._bErrors=true;return}if(!this._helper.processSevMap()){this._bErrors=true;return}if(!this._helper.processSeverity(this._cliSev)){this._bErrors=true;return}if(!this._helper.processGroups(this._cliGroups)){this._bErrors=true;return}if(!this._helper.processDefGroups()){this._bErrors=true;return}if(!this._helper.processRuleNames()){this._bErrors=true;return}if(this._config.followLinks==null){this._config.followLinks=true}else{this._config.followLinks=!!this._config.followLinks}if(!Array.isArray(this._config.files)){this._error("Config entry 'files' is not an array!");this._bErrors=true;return}if(!this._helper.validateFileList(this._config.files)){this._bErrors=true;return}if(this._config.exclude){if(!Array.isArray(this._config.exclude)){this._error("Config entry 'exclude' is not an array!");this._bErrors=true;return}if(!this._helper.validateFileList(this._config.exclude)){this._bErrors=true;return}}else if(this._config.excludes){this._error("Config property 'excludes' found - did you mean 'exclude'?");this._bErrors=true;return}if(!this._helper.processAddFileList()){this._bErrors=true;return}if(this._config.stylesets){val=this._config.stylesets;if(!Array.isArray(val)){this._error("Config property 'stylesets' is not an array!");this._bErrors=true;return}}if(this._isAMD&&this._config.tempDir){this._error("Config entry 'tempDir' is not valid in AMD mode!");this._bErrors=true;return}if(this._config.tempDir){if(typeof this._config.tempDir!=="string"){this._error("Config property 'tempDir' is not a string!");this._bErrors=true;return}if(this._config.tempDir.startsWith(".")){this._config.tempDir=this._nd.path.resolve(this._nd.process.cwd(),this._config.tempDir)}}if(!this._helper.processTypeScript()){this._bErrors=true;return}if(!this._helper.processMarkdownOpts()){this._bErrors=true;return}if(!this._helper.processMessages()){this._bErrors=true;return}if(!this._helper.processNameSpaces()){this._bErrors=true;return}if(!this._helper.processTheme()){this._bErrors=true;return}if(!this._helper.processComments()){this._bErrors=true;return}if(!this._helper.processEcmaVer()){this._bErrors=true;return}if(!this._helper.processOptions()){this._bErrors=true;return}if(!this._helper.processTitle()){this._bErrors=true;return}if(!this._helper.processRetCode()){this._bErrors=true;return}if(!this._config.extends){this._cleanConfigPaths()}if(this._config.typescript&&(val=this._config.typescript.tsconfig)){if(!(this._tsCfgObj=this._loadTsConfig(val))){this._bErrors=true;return}}};Config.prototype.validateRetCode=function(val,cb){return this._helper.validateRetCode(val,cb)};Config.prototype._cleanConfigPaths=function(){var src,i,ftype,dir;var nd=this._nd;var base=this._config.base;function _resolve(fp){if(!nd.path.isAbsolute(fp)){fp=nd.path.normalize(fp);fp=nd.path.resolve(base,fp)}return fp};if(!this._config.extends){this._info(`[Info]: Processing paths in config (at base '${this._config.base}'`,"I")}if(src=this._config.files){for(i=0;i<src.length;i++){if(!src[i].startsWith("http")){src[i]=_resolve(src[i])}}}if(src=this._config.exclude){for(i=0;i<src.length;i++){src[i]=_resolve(src[i])}}if(src=this._config.components){for(i=0;i<src.length;i++){src[i]=_resolve(src[i])}}src=this._config.outPath;if(src&&src!=="$noout"){this._config.outPath=_resolve(src)}src=this._config.rulePacks;if(src){for(i=0;i<src.length;i++){if(!nd.path.isAbsolute(src[i].path)){dir=nd.path.normalize(src[i].path);src[i].path=nd.path.resolve(this._config.base,dir)}if(src[i].path.endsWith(".zip")){continue}ftype=this._fsUtils.getFileType(src[i].path);if(ftype!=="d"){this._error(`'rulePacks (entry ${i+1}"): path' is not a directory - "${src[i].path}"`);this._bErrors=true;return}}}if(this._config.typescript&&this._config.typescript.tsconfig)src=this._config.typescript.tsconfig;if(src&&typeof src==="string"){if(!nd.path.isAbsolute(src)){dir=nd.path.normalize(src);dir=nd.path.resolve(this._config.base,dir)}else{dir=src}if(!dir.endsWith(TSCONFIG)){dir=nd.path.join(dir,TSCONFIG)}this._config.typescript.tsconfig=dir}if(src=this._config.jetCorePack){this._config.jetCorePack=_resolve(src)}if(this._bErrors){return};};Config.prototype._cleanBase=function(){var p,ft;var nd=this._nd;p=this._config.base;p=nd.path.normalize(p);p=nd.path.resolve(this._dir,p);ft=this._fsUtils.getFileType(p);if(ft!=="d"){this._error(`Config file 'base' is not a directory - '${p}'`);this._bErrors=true;return false}p=nd.path.join(p,"/");this._config.base=p;this._info(`[Info]: Using Config base '${p}'`,"I");return true};Config.prototype._loadConfig=function(iniPath){var data,stats,bUseDefaults=false,msg;var nd=this._nd;try{stats=nd.fs.statSync(iniPath);if(!stats.isFile()){this._warn("\n[Warn]: Config file '"+iniPath+"' not found. Using defaults.\n");bUseDefaults=true}else{data=nd.fs.readFileSync(iniPath,"utf8");data=nd.decomment(data);data=this.processIncludes(data,iniPath);data=this.processTokens(data);if(this._bErrors){return}if(this._isDebug){if(!data){console.log("NO CONFIG DATA")}else{var a=data.split("\n");console.log("------------- Config Raw Text...");for(var i=0;i<a.length;i++){console.log(i+1+"] "+a[i])}console.log("-".repeat(40))}}if(data){this._config=JSON.parse(nd.decomment(data))}else{this._bErrors=true}}}catch(e){this._bErrors=true;if(e.code){if(e.message.startsWith("ENOENT:")){this._warn("\nConfig file \""+iniPath+"\" not found - using defaults.\n");this._bErrors=false;bUseDefaults=true}}else if(e.toString().startsWith("SyntaxError")){msg=_convertMsgToRowCol(e.message,data,this._utils)}else{msg=e.message}if(msg){msg=msg.replace(/\r/g,"");msg=msg.replace(/ +(?= )/g,"");this._error("Config parse error");this._error("Config file '"+iniPath+"' - "+msg)}}if(this._bErrors){return}if(bUseDefaults){this._config={exclude:["./**/*-min.js","./**/*-min.css","./**/node_modules/**/*.*"],builtinJetRules:true,builtinCspRules:false,builtinJetWcRules:false,builtinJetWcOracleRules:false,builtinOjcMigrationRules:false,followLinks:true,severity:this._severity.ALL,format:"prose",ecmaVer:DEFAULTS.ECMAVER,options:{verbose:false,color:true}}}return bUseDefaults};Config.prototype._checkProperties=function(){return this._helper.checkPropNames()};Config.prototype._loadTsConfig=function(fp){return this._nd.jsonLoader.load(fp,this._nd,m=>{this._error(`Error loading tsconfig : ${m}.`);this._bErrors=true},false,this._utils)};function _convertMsgToRowCol(msg,data,utils){var x,n,rc;x=msg.indexOf("position");if(x<0){return msg}n=parseInt(msg.substr(x+8).trim());rc=utils.getRowColFromIndex(data,n);return msg.substr(0,x)+"row "+rc.row+", col "+rc.col};Config.prototype.processTokens=function(data){const TOKENS="\"tokens\"";var token,sub,start,end,json,toks,count,subst,rc,x,n;if(this._isDebug){this._debug("Performing config 'tokens' substitution...")}x=data.indexOf(TOKENS);if(x<0)return data;x+=TOKENS.length;n=this._expect(data,x,":",true);if(n<0){rc=this._utils.getRowColFromIndex(data,x);this._error("Config: expected ':' after property "+TOKENS+" on line "+rc.row+" position "+rc.col+".");this._bErrors=true;return}n=this._expect(data,n,"{");if(n<0){rc=this._utils.getRowColFromIndex(data,n);this._error("Config: expected '{' after property "+TOKENS+" on line "+rc.row+".");this._bErrors=true;return}start=n;end=data.indexOf("}",start);if(end<0){rc=this._utils.getRowColFromIndex(data,x);this._error("Config: "+TOKENS+" property syntax error (on/after line "+rc.row+").");this._bErrors=true;return}json=data.substring(start,end+1);try{toks=JSON.parse(json)}catch(e){rc=this._utils.getRowColFromIndex(data,x);this._error("Config: syntax error "+TOKENS+" property (on/after line "+rc.row+").");this._bErrors=true;return}subst=0;count=0;for(token in toks){if(token.charAt(0)!=="@"){this._error("Config: token '"+token+"' : must be prefixed with '@'");this._bErrors=true;return}sub=toks[token];token=token.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");token=new RegExp(token,"g");if(this._isVerbose||this._isDebug){n=data.match(token).length;subst+=n>1?--n:0}data=data.replace(token,sub);count++}if(count){try{start=data.indexOf(TOKENS);start=this._expect(data,start+TOKENS.length,":",true);start=this._expect(data,start,"{");end=data.indexOf("}",start+1);data=data.substring(0,start)+json+data.substring(end+1);if(this._isVerbose||this._isDebug){this._info("[Info]: "+subst+" config token substitution"+(subst!==1?"s":"")+" performed with "+count+" token"+(count!==1?"s":"")+".")}}catch(e){this._error("Config: \"tokens\" substitution failed - review \"tokens\" property value");this._bErrors=true}}return data};Config.prototype._expect=function(data,x,s,bump){var ret=-1;x=this._utils.eatWhitespace(data,x);if(x>=0&&data.substr(x,s.length)===s){ret=x+(bump?s.length:0)}return ret};Config.prototype.processIncludes=function(data,filepath,chain){var a,i,line,x,path,comma;var inserts,insert,incPath;var nd=this._nd;if(this._isDebug){this._debug("Checking for "+(chain?"sub ":"")+"@include. . .")}if((i=data.indexOf(AT_INCLUDE))<0||data.charAt(i-1)==="_"){if(this._isDebug){this._debug("No "+(chain?"sub ":"")+"@include found")}return data}inserts=[];a=data.split("\n");for(i=0;i<a.length;i++){line=a[i];x=line.indexOf(AT_INCLUDE);if(x<0){continue}path=_extractStringFromLine(line,x+AT_INCLUDE.length,this._utils);if(!path){this._error("Config - @include syntax error"+(chain?" in '"+filepath+"'":"!"));return null}incPath=nd.path.normalize(path);incPath=nd.path.resolve(this._dir,incPath);comma=_isTrailingComma(line,x+AT_INCLUDE.length,this._utils);try{if(this._isDebug){this._debug("Reading @include -> "+incPath)}insert=nd.fs.readFileSync(incPath,"utf8")}catch(e){this._error("Config @include - "+e);return null}if(!insert){this._error("Config - @include '"+incPath+"' not found!");return null}insert=this.processIncludes(insert,incPath,true);if(insert){inserts.push(i);inserts.push(insert+(comma?",":""))}else if(insert===null){return null}}if(inserts&&inserts.length){for(i=0;i<inserts.length;i++){a[inserts[i]]=inserts[++i]}}return a.join("\n")};function _extractStringFromLine(data,start,utils){var c,xEnd,wantQuote,antiQuote;start=utils.eatWhitespace(data,start);if(start<0){return null}c=data.charAt(start);wantQuote=c===QUOTE||c==="'"?c:null;if(wantQuote){antiQuote=c===QUOTE?"'":QUOTE;start++}for(xEnd=start;xEnd<data.length;xEnd++){c=data.charAt(xEnd);if(c===")"||wantQuote&&c===wantQuote){break}else if(c==="\n"||wantQuote&&c===antiQuote||!wantQuote&&(c===QUOTE||c==="'")){xEnd=-1;break}}if(xEnd<0||xEnd>=data.length||wantQuote&&data.charAt(xEnd)!==wantQuote){return null}data=data.substring(start,xEnd).trim();return data?data:null};function _isTrailingComma(s,x,utils){var n,ret=false;n=s.indexOf(")",x);if(n<0){return false}n=utils.eatWhitespace(s,n+1);if(n>=0){ret=s.charAt(n)===","}return ret};function _cloneConfig(o){return JSON.parse(JSON.stringify(o))};module.exports=Config;
|
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
|
-
const tmpFile=require("tmp");function FSU(nd,utils){this._nd=nd;this._utils=utils};FSU.prototype.toJAFPath=function(sourcePath){if(sourcePath){sourcePath=this._nd.path.normalize(sourcePath);if(this._utils.isWindows()){sourcePath=sourcePath.replace(/\\/g,"/")}}return sourcePath};FSU.prototype.toNativePath=function(sourcePath){if(sourcePath){sourcePath=this._nd.normalize(sourcePath);if(this._utils.isWindows()){sourcePath=sourcePath.replace(/\//g,"\\")}}return sourcePath};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.walkDirSync=function(dirPath,cb,forceFwdSlash){if(typeof cb!=="function"||!this.fileExistsSync(dirPath,true)){return}let path=this._nd.path;let fs=this._nd.fs;let _getFileType=this.getFileType.bind(this);function _walkDirSync(dirPath,cb,forceFwdSlash){var i,ftype,fpath,files,file,ret;if(files=fs.readdirSync(dirPath)){for(i=0;i<files.length;i++){file=files[i];fpath=path.join(dirPath,file);fpath=forceFwdSlash?fpath.replace(/\\/g,"/"):fpath;ftype=_getFileType(fpath);if(ftype==="f"||ftype==="d"||ftype==="l"){ret=cb(fpath,ftype);if(ret==="exit"){return false}else if(ret==="direxit"){break}if(ftype==="d"){if(!_walkDirSync(fpath,cb,forceFwdSlash)){return false}}}}}return true};_walkDirSync(dirPath,cb,forceFwdSlash)};FSU.prototype.makeAbsolutePath=function(filepath){if(!this._nd.path.isAbsolute(filepath)){filepath=this._nd.path.resolve(process.cwd(),filepath)}return filepath};module.exports=FSU;
|
|
6
|
+
const tmpFile=require("tmp");function FSU(nd,utils){this._nd=nd;this._utils=utils};FSU.prototype.toJAFPath=function(sourcePath){if(sourcePath){sourcePath=this._nd.path.normalize(sourcePath);if(this._utils.isWindows()){sourcePath=sourcePath.replace(/\\/g,"/")}}return sourcePath};FSU.prototype.toNativePath=function(sourcePath){if(sourcePath){sourcePath=this._nd.normalize(sourcePath);if(this._utils.isWindows()){sourcePath=sourcePath.replace(/\//g,"\\")}}return sourcePath};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.isFolderWritableSync=function(filepath){var ret=true;try{this._nd.fs.accessSync(filepath,this._nd.fs.constants.W_OK)}catch(e){ret=false}return ret};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.walkDirSync=function(dirPath,cb,forceFwdSlash){if(typeof cb!=="function"||!this.fileExistsSync(dirPath,true)){return}let path=this._nd.path;let fs=this._nd.fs;let _getFileType=this.getFileType.bind(this);function _walkDirSync(dirPath,cb,forceFwdSlash){var i,ftype,fpath,files,file,ret;if(files=fs.readdirSync(dirPath)){for(i=0;i<files.length;i++){file=files[i];fpath=path.join(dirPath,file);fpath=forceFwdSlash?fpath.replace(/\\/g,"/"):fpath;ftype=_getFileType(fpath);if(ftype==="f"||ftype==="d"||ftype==="l"){ret=cb(fpath,ftype);if(ret==="exit"){return false}else if(ret==="direxit"){break}if(ftype==="d"){if(!_walkDirSync(fpath,cb,forceFwdSlash)){return false}}}}}return true};_walkDirSync(dirPath,cb,forceFwdSlash)};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/HtmlUtils.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 COMMON_ATTRS={"accesskey":true,"class":true,"contenteditable":true,"contextmenu":true,"dir":true,"draggable":true,"dropzone":true,"hidden":true,"id":true,"lang":true,"role":true,"spellcheck":true,"style":true,"tabindex":true,"title":true,"translate":true};var COMMON_ELEMS={"a":true,"abbr":true,"address":true,"area":true,"article":true,"aside":true,"audio":true,"b":true,"base":true,"bdi":true,"bdo":true,"blockquote":true,"body":true,"br":true,"button":true,"canvas":true,"caption":true,"cite":true,"code":true,"col":true,"colgroup":true,"command":true,"datalist":true,"dd":true,"del":true,"details":true,"dfn":true,"div":true,"dl":true,"dt":true,"em":true,"embed":true,"fieldset":true,"figcaption":true,"figure":true,"footer":true,"form":true,"h1":true,"h2":true,"h3":true,"h4":true,"h5":true,"h6":true,"head":true,"header":true,"hgroup":true,"hr":true,"html":true,"i":true,"iframe":true,"img":true,"input":true,"ins":true,"kbd":true,"keygen":true,"label":true,"legend":true,"li":true,"link":true,"map":true,"main":true,"mark":true,"menu":true,"meta":true,"meter":true,"nav":true,"noscript":true,"object":true,"ol":true,"optgroup":true,"option":true,"output":true,"p":true,"param":true,"pre":true,"progress":true,"q":true,"rp":true,"rt":true,"ruby":true,"s":true,"samp":true,"script":true,"section":true,"select":true,"small":true,"source":true,"span":true,"strong":true,"style":true,"sub":true,"summary":true,"sup":true,"table":true,"tbody":true,"td":true,"textarea":true,"tfoot":true,"th":true,"thead":true,"time":true,"title":true,"tr":true,"track":true,"u":true,"ul":true,"var":true,"video":true,"wbr":true,"svg":true};var COMMON_EVENT_ATTRS={"onabort":true,"onauxclick":true,"onblur":true,"oncanplay":true,"oncanplaythrough":true,"onchange":true,"onclick":true,"oncontextmenu":true,"ondblclick":true,"ondblclickcapture":true,"ondrag":true,"ondragend":true,"ondragenter":true,"ondragleave":true,"ondragover":true,"ondragstart":true,"ondrop":true,"ondurationchange":true,"onemptied":true,"onended":true,"onerror":true,"onfocus":true,"onfocusin":true,"onfocusout":true,"onformchange":true,"onforminput":true,"oninput":true,"oninvalid":true,"onkeydown":true,"onkeypress":true,"onkeyup":true,"onload":true,"onloadeddata":true,"onloadedmetadata":true,"onloadstart":true,"onmousedown":true,"onmouseenter":true,"onmouseleave":true,"onmousemove":true,"onmouseout":true,"onmouseover":true,"onmouseup":true,"onmousewheel":true,"onpause":true,"onplay":true,"onplaying":true,"onprogress":true,"onratechange":true,"onreadystatechange":true,"onreset":true,"onscroll":true,"onseeked":true,"onseeking":true,"onselect":true,"onshow":true,"onstalled":true,"onsubmit":true,"onsuspend":true,"ontimeupdate":true,"onvolumechange":true,"onwaiting":true,"onwheel":true};const SVG_ELEMS={"animate":true,"animatemotion":true,"animatetransform":true,"circle":true,"clippath":true,"color-profile":true,"defs":true,"desc":true,"discard":true,"ellipse":true,"feblend":true,"fecolormatrix":true,"fecomponenttransfer":true,"fecomposite":true,"feconvolvematrix":true,"fediffuselighting":true,"fedisplacementmap":true,"fedistantlight":true,"fedropshadow":true,"feflood":true,"fefunca":true,"fefuncb":true,"fefuncg":true,"fefuncr":true,"fegaussianblur":true,"feimage":true,"femerge":true,"femergenode":true,"femorphology":true,"feoffset":true,"fepointlight":true,"fespecularlighting":true,"fespotLight":true,"fetile":true,"feturbulence":true,"filter":true,"foreignobject":true,"g":true,"hatch":true,"hatchpath":true,"image":true,"line":true,"lineargradient":true,"marker":true,"mask":true,"mesh":true,"meshgradient":true,"meshpatch":true,"meshrow":true,"metadata":true,"mpath":true,"path":true,"pattern":true,"polygon":true,"polyline":true,"radialgradient":true,"rect":true,"script":true,"set":true,"solidcolor":true,"stop":true,"style":true,"svg":true,"switch":true,"symbol":true,"text":true,"textpath":true,"title":true,"tspan":true,"unknown":true,"use":true,"view":true};const HTML5_OBS_TAGS={"applet":true,"acronym":true,"basefont":true,"bgsound":true,"big":true,"blink":true,"center":true,"dir":true,"font":true,"frame":true,"frameset":true,"noframes":true,"isindex":true,"keygen":true,"listing":true,"marquee":true,"menuitem":true,"multicol":true,"nextid":true,"nobr":true,"noembed":true,"plaintext":true,"rb":true,"rlc":true,"s":true,"spacer":true,"strike":true,"tt":true,"xmp":true};const HTML5_OBS_ATTRS={"a":["charset","coords","methods","name","rev","shape","urn"],"area":["nohref"],"body":["alink","background","bgcolor","bottommargin","leftmargin","link","marginheight","marginwidth","rightmargin","text","vlink"],"br":["clear"],"caption":["align"],"col":["align","char","charoff","valign","width"],"div":["align"],"dl":["compact"],"embed":["align","name","hspace","vspace"],"form":["accept"],"head":["profile"],"hr":["align","noshade","size","width"],"h1":["align"],"h2":["align"],"h3":["align"],"h4":["align"],"h5":["align"],"h6":["align"],"html":["version"],"iframe":["align","allowtransparency","frameborder","framespacing","hspace","longdesc","marginheight","marginwidth","scrolling","vspace"],"img":["align","border","hspace","longdesc","lowsrc","name","vspace"],"input":["align","border","hspace","ismap","usemap","vspace"],"legend":["align"],"li":["type"],"link":["charset","methods","rev","target","urn"],"menu":["compact","label","type"],"meta":["scheme"],"object":["align","archive","border","classid","code","codebase","codetype","declare","hspace","standby","typemustmatch","vspace"],"ol":["compact"],"option":["name"],"p":["align"],"param":["type","valuetype"],"pre":["width"],"script":["charset","event","for","language"],"style":["type"],"table":["align","background","bgcolor","border","bordercolor","cellpadding","cellspacing","datapagesize","frame","height","rules","summary","width"],"tbody":["align","background","char","charoff","valign"],"tfoot":["align","background","char","charoff","valign"],"thead":["align","background","char","charoff","valign"],"td":["abbr","align","axis","background","bgcolor","char","charoff","height","nowrap","scope","valign","width"],"th":["abbr","align","axis","background","bgcolor","char","charoff","height","nowrap","valign","width"],"tr":["align","background","bgcolor","char","charoff","height","valign"],"ul":["compact","type"]};const HTML5_OBS_ATTR_ALL_ELEM=["contextmenu","dropzone","onshow"];const SELF_CLOSING_ELEMS={"area":true,"base":true,"br":true,"embed":true,"hr":true,"iframe":true,"img":true,"input":true,"link":true,"meta":true,"param":true,"source":true,"track":true};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 OJ_NAMESPACE_PREFIXES=require("./ns");const ARIA_LIST=["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-dropeffect","aria-errormessage","aria-expanded","aria-flowto","aria-grabbed","aria-haspopup","aria-hidden","aria-invalid","aria-ketshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledecsription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext"];module.exports.isCommonAttr=function(attrName){var x;attrName=attrName.toLowerCase();attrName=attrName.charAt(0)===":"?attrName.substring(1):attrName;x=attrName.indexOf(".");if(x>=0){attrName=attrName.substring(0,x)};return COMMON_ATTRS[attrName]||attrName.startsWith("aria-")||attrName.startsWith("data-")&&attrName!=="data-oj-command"&&attrName!=="data-oj-context"};module.exports.isCommonEventAttr=function(attrName){attrName=attrName.toLowerCase();attrName=attrName.charAt(0)===":"?attrName.substring(1):attrName;if(attrName.startsWith("on-oj-")){return false}if(attrName.startsWith("on-")){attrName=attrName.substring(0,2)+attrName.substring(3)}return COMMON_EVENT_ATTRS[attrName]};module.exports.isCommonElem=function(elem){return COMMON_ELEMS[elem.toLowerCase()]};module.exports.isSvgElem=function(elem){return SVG_ELEMS[elem.toLowerCase()]};module.exports.isSvgPath=function(s){var c=s.trim().charAt(0);return SVG_PATH_COMMANDS.indexOf(c)>=0};module.exports.isSelfClosingTag=function(elem){return SELF_CLOSING_ELEMS[elem]};module.exports.isNamespacePrefix=function(prefix){return OJ_NAMESPACE_PREFIXES.has(prefix)};module.exports.isNamespaceTag=function(tag){var s=tag.replace(/[<>]/g,"");var x,ret=false;if(tag.startsWith("demo-")||tag.startsWith("my-")||tag.startsWith("ns-")){return true}while(true){x=s.lastIndexOf("-");if(x>=0){s=s.substring(0,x);if(s.lastIndexOf("-")<0&&s==="oj"){break}if(OJ_NAMESPACE_PREFIXES.has(s)){ret=true;break}}else{break}}return ret};module.exports.isHtml5ObsoleteElem=function(tag){return HTML5_OBS_TAGS[tag.toLowerCase()]};module.exports.isHtml5ObsoleteAttr=function(tagName,attrName){var depAttrs,ret=false;attrName=attrName.charAt(0)!==":"?attrName:attrName.substring(1);depAttrs=HTML5_OBS_ATTRS[tagName];if(!depAttrs){depAttrs=HTML5_OBS_ATTR_ALL_ELEM}if(depAttrs){if(depAttrs.includes(attrName)){ret=true}}return ret};module.exports.isAriaAttr=function(attrName){attrName=attrName.charAt(0)===":"?attrName.substring(1):attrName;return ARIA_LIST.includes(attrName.toLowerCase())};const EXPR_CHARS=new RegExp("[?\"'=+:/()[]{}]","g");module.exports.isEncodedLiteral=function(expr){if(expr.charAt(0)==="'"&&expr.charAt(expr.length-1)==="'"){return EXPR_CHARS.test(expr.substring(1,expr.length-1))}return false};module.exports.replaceEntities=function(s){const ENTITY_LT=/</g;const ENTITY_GT=/&/g;const ENTITY_QUOT=/"/g;const ENTITY_APOS=/'/g;const ENTITY_AMP=/&/g;const ENTITY_NBSP=/ /g;if(s.indexOf("&")>=0){s=s.replace(ENTITY_LT,"<");s=s.replace(ENTITY_GT,"&");s=s.replace(ENTITY_QUOT,"\"");s=s.replace(ENTITY_APOS,"'");s=s.replace(ENTITY_AMP,"&");s=s.replace(ENTITY_NBSP," ")}return s};
|
|
6
|
+
const COMMON_ATTRS={"accesskey":true,"class":true,"contenteditable":true,"contextmenu":true,"dir":true,"draggable":true,"dropzone":true,"hidden":true,"id":true,"lang":true,"role":true,"spellcheck":true,"style":true,"tabindex":true,"title":true,"translate":true};var COMMON_ELEMS={"a":true,"abbr":true,"address":true,"area":true,"article":true,"aside":true,"audio":true,"b":true,"base":true,"bdi":true,"bdo":true,"blockquote":true,"body":true,"br":true,"button":true,"canvas":true,"caption":true,"cite":true,"code":true,"col":true,"colgroup":true,"command":true,"datalist":true,"dd":true,"del":true,"details":true,"dfn":true,"div":true,"dl":true,"dt":true,"em":true,"embed":true,"fieldset":true,"figcaption":true,"figure":true,"footer":true,"form":true,"h1":true,"h2":true,"h3":true,"h4":true,"h5":true,"h6":true,"head":true,"header":true,"hgroup":true,"hr":true,"html":true,"i":true,"iframe":true,"img":true,"input":true,"ins":true,"kbd":true,"keygen":true,"label":true,"legend":true,"li":true,"link":true,"map":true,"main":true,"mark":true,"menu":true,"meta":true,"meter":true,"nav":true,"noscript":true,"object":true,"ol":true,"optgroup":true,"option":true,"output":true,"p":true,"param":true,"pre":true,"progress":true,"q":true,"rp":true,"rt":true,"ruby":true,"s":true,"samp":true,"script":true,"section":true,"select":true,"small":true,"source":true,"span":true,"strong":true,"style":true,"sub":true,"summary":true,"sup":true,"table":true,"tbody":true,"td":true,"textarea":true,"tfoot":true,"th":true,"thead":true,"time":true,"title":true,"tr":true,"track":true,"u":true,"ul":true,"var":true,"video":true,"wbr":true,"svg":true};var COMMON_EVENT_ATTRS={"onabort":true,"onauxclick":true,"onblur":true,"oncanplay":true,"oncanplaythrough":true,"onchange":true,"onclick":true,"oncontextmenu":true,"ondblclick":true,"ondblclickcapture":true,"ondrag":true,"ondragend":true,"ondragenter":true,"ondragleave":true,"ondragover":true,"ondragstart":true,"ondrop":true,"ondurationchange":true,"onemptied":true,"onended":true,"onerror":true,"onfocus":true,"onfocusin":true,"onfocusout":true,"onformchange":true,"onforminput":true,"oninput":true,"oninvalid":true,"onkeydown":true,"onkeypress":true,"onkeyup":true,"onload":true,"onloadeddata":true,"onloadedmetadata":true,"onloadstart":true,"onmousedown":true,"onmouseenter":true,"onmouseleave":true,"onmousemove":true,"onmouseout":true,"onmouseover":true,"onmouseup":true,"onmousewheel":true,"onpause":true,"onplay":true,"onplaying":true,"onprogress":true,"onratechange":true,"onreadystatechange":true,"onreset":true,"onscroll":true,"onseeked":true,"onseeking":true,"onselect":true,"onshow":true,"onstalled":true,"onsubmit":true,"onsuspend":true,"ontimeupdate":true,"onvolumechange":true,"onwaiting":true,"onwheel":true};const SVG_ELEMS={"animate":true,"animatemotion":true,"animatetransform":true,"circle":true,"clippath":true,"color-profile":true,"defs":true,"desc":true,"discard":true,"ellipse":true,"feblend":true,"fecolormatrix":true,"fecomponenttransfer":true,"fecomposite":true,"feconvolvematrix":true,"fediffuselighting":true,"fedisplacementmap":true,"fedistantlight":true,"fedropshadow":true,"feflood":true,"fefunca":true,"fefuncb":true,"fefuncg":true,"fefuncr":true,"fegaussianblur":true,"feimage":true,"femerge":true,"femergenode":true,"femorphology":true,"feoffset":true,"fepointlight":true,"fespecularlighting":true,"fespotLight":true,"fetile":true,"feturbulence":true,"filter":true,"foreignobject":true,"g":true,"hatch":true,"hatchpath":true,"image":true,"line":true,"lineargradient":true,"marker":true,"mask":true,"mesh":true,"meshgradient":true,"meshpatch":true,"meshrow":true,"metadata":true,"mpath":true,"path":true,"pattern":true,"polygon":true,"polyline":true,"radialgradient":true,"rect":true,"script":true,"set":true,"solidcolor":true,"stop":true,"style":true,"svg":true,"switch":true,"symbol":true,"text":true,"textpath":true,"title":true,"tspan":true,"unknown":true,"use":true,"view":true};const HTML5_OBS_TAGS={"applet":true,"acronym":true,"basefont":true,"bgsound":true,"big":true,"blink":true,"center":true,"dir":true,"font":true,"frame":true,"frameset":true,"noframes":true,"isindex":true,"keygen":true,"listing":true,"marquee":true,"menuitem":true,"multicol":true,"nextid":true,"nobr":true,"noembed":true,"plaintext":true,"rb":true,"rlc":true,"s":true,"spacer":true,"strike":true,"tt":true,"xmp":true};const HTML5_OBS_ATTRS={"a":["charset","coords","methods","name","rev","shape","urn"],"area":["nohref"],"body":["alink","background","bgcolor","bottommargin","leftmargin","link","marginheight","marginwidth","rightmargin","text","vlink"],"br":["clear"],"caption":["align"],"col":["align","char","charoff","valign","width"],"div":["align"],"dl":["compact"],"embed":["align","name","hspace","vspace"],"form":["accept"],"head":["profile"],"hr":["align","noshade","size","width"],"h1":["align"],"h2":["align"],"h3":["align"],"h4":["align"],"h5":["align"],"h6":["align"],"html":["version"],"iframe":["align","allowtransparency","frameborder","framespacing","hspace","longdesc","marginheight","marginwidth","scrolling","vspace"],"img":["align","border","hspace","longdesc","lowsrc","name","vspace"],"input":["align","border","hspace","ismap","usemap","vspace"],"legend":["align"],"li":["type"],"link":["charset","methods","rev","target","urn"],"menu":["compact","label","type"],"meta":["scheme"],"object":["align","archive","border","classid","code","codebase","codetype","declare","hspace","standby","typemustmatch","vspace"],"ol":["compact"],"option":["name"],"p":["align"],"param":["type","valuetype"],"pre":["width"],"script":["charset","event","for","language"],"style":["type"],"table":["align","background","bgcolor","border","bordercolor","cellpadding","cellspacing","datapagesize","frame","height","rules","summary","width"],"tbody":["align","background","char","charoff","valign"],"tfoot":["align","background","char","charoff","valign"],"thead":["align","background","char","charoff","valign"],"td":["abbr","align","axis","background","bgcolor","char","charoff","height","nowrap","scope","valign","width"],"th":["abbr","align","axis","background","bgcolor","char","charoff","height","nowrap","valign","width"],"tr":["align","background","bgcolor","char","charoff","height","valign"],"ul":["compact","type"]};const HTML5_OBS_ATTR_ALL_ELEM=["contextmenu","dropzone","onshow"];const SELF_CLOSING_ELEMS={"area":true,"base":true,"br":true,"embed":true,"hr":true,"iframe":true,"img":true,"input":true,"link":true,"meta":true,"param":true,"source":true,"track":true};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 OJ_NAMESPACE_PREFIXES=require("./ns");const ARIA_LIST=new Set(["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-dropeffect","aria-errormessage","aria-expanded","aria-flowto","aria-grabbed","aria-haspopup","aria-hidden","aria-invalid","aria-ketshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledecsription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext"]);module.exports.isCommonAttr=function(attrName){var x;attrName=attrName.toLowerCase();attrName=attrName.charAt(0)===":"?attrName.substring(1):attrName;x=attrName.indexOf(".");if(x>=0){attrName=attrName.substring(0,x)};return COMMON_ATTRS[attrName]||attrName.startsWith("aria-")||attrName.startsWith("data-")&&attrName!=="data-oj-command"&&attrName!=="data-oj-context"};module.exports.isCommonEventAttr=function(attrName){attrName=attrName.toLowerCase();attrName=attrName.charAt(0)===":"?attrName.substring(1):attrName;if(attrName.startsWith("on-oj-")){return false}if(attrName.startsWith("on-")){attrName=attrName.substring(0,2)+attrName.substring(3)}return COMMON_EVENT_ATTRS[attrName]};module.exports.isCommonElem=function(elem){return COMMON_ELEMS[elem.toLowerCase()]};module.exports.isSvgElem=function(elem){return SVG_ELEMS[elem.toLowerCase()]};module.exports.isSvgPath=function(s){var c=s.trim().charAt(0);return SVG_PATH_COMMANDS.indexOf(c)>=0};module.exports.isSelfClosingTag=function(elem){return SELF_CLOSING_ELEMS[elem]};module.exports.isNamespacePrefix=function(prefix){return OJ_NAMESPACE_PREFIXES.has(prefix)};module.exports.isNamespaceTag=function(tag){var s=tag.replace(/[<>]/g,"");var x,ret=false;if(tag.startsWith("demo-")||tag.startsWith("my-")||tag.startsWith("ns-")){return true}while(true){x=s.lastIndexOf("-");if(x>=0){s=s.substring(0,x);if(s.lastIndexOf("-")<0&&s==="oj"){break}if(OJ_NAMESPACE_PREFIXES.has(s)){ret=true;break}}else{break}}return ret};module.exports.isHtml5ObsoleteElem=function(tag){return HTML5_OBS_TAGS[tag.toLowerCase()]};module.exports.isHtml5ObsoleteAttr=function(tagName,attrName){var depAttrs,ret=false;attrName=attrName.charAt(0)!==":"?attrName:attrName.substring(1);depAttrs=HTML5_OBS_ATTRS[tagName];if(!depAttrs){depAttrs=HTML5_OBS_ATTR_ALL_ELEM}if(depAttrs){if(depAttrs.includes(attrName)){ret=true}}return ret};module.exports.isAriaAttr=function(attrName){attrName=attrName.charAt(0)===":"?attrName.substring(1):attrName;return ARIA_LIST.has(attrName.toLowerCase())};const EXPR_CHARS=new RegExp("[?\"'=+:/()[]{}]","g");module.exports.isEncodedLiteral=function(expr){if(expr.charAt(0)==="'"&&expr.charAt(expr.length-1)==="'"){return EXPR_CHARS.test(expr.substring(1,expr.length-1))}return false};module.exports.replaceEntities=function(s){const ENTITY_LT=/</g;const ENTITY_GT=/&/g;const ENTITY_QUOT=/"/g;const ENTITY_APOS=/'/g;const ENTITY_AMP=/&/g;const ENTITY_NBSP=/ /g;if(s.indexOf("&")>=0){s=s.replace(ENTITY_LT,"<");s=s.replace(ENTITY_GT,"&");s=s.replace(ENTITY_QUOT,"\"");s=s.replace(ENTITY_APOS,"'");s=s.replace(ENTITY_AMP,"&");s=s.replace(ENTITY_NBSP," ")}return s};
|
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,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.getJafReleaseCount()};JafLib.prototype.getJafReleaseCount=function(){return this._ageLib.getJafReleaseCount()};JafLib.prototype.getMajorReleaseCount=function(major){return this._ageLib.getMajorReleaseCount(major)};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),getJafReleaseCount:this.getJafReleaseCount.bind(this),getMajorReleaseCount:this.getMajorReleaseCount.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.getJafReleaseCount()};JafLib.prototype.getJafReleaseCount=function(){return this._ageLib.getJafReleaseCount()};JafLib.prototype.getMajorReleaseCount=function(major){return this._ageLib.getMajorReleaseCount(major)};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),getJafReleaseCount:this.getJafReleaseCount.bind(this),getMajorReleaseCount:this.getMajorReleaseCount.bind(this)}};JafLib.prototype.getPublic=function(){return{setFileset:this.setFileset.bind(this),getFileset:this.getFileset.bind(this),isCLI:this.isCLI.bind(this),isAPI:this.isAPI.bind(this),isAMD:this.isAMD.bind(this),getConfig:this.getConfig.bind(this)}};module.exports=JafLib;
|