@oracle/oraclejet-audit 11.1.3 → 12.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (364) hide show
  1. package/LICENSE.md +1 -1
  2. package/jaf-amd.js +6 -6
  3. package/jaf.js +2 -2
  4. package/jafapi.js +2 -2
  5. package/lib/AST.js +1 -1
  6. package/lib/AST_Ts.js +2 -2
  7. package/lib/AstJson.js +1 -1
  8. package/lib/AstMd.js +6 -0
  9. package/lib/AstNodeTypes.js +2 -2
  10. package/lib/Comments.js +1 -1
  11. package/lib/ComponentSvcs.js +1 -1
  12. package/lib/Components.js +2 -2
  13. package/lib/Config.js +2 -2
  14. package/lib/ConfigLib.js +2 -2
  15. package/lib/CssLib.js +1 -1
  16. package/lib/CssUtils.js +1 -1
  17. package/lib/DomUtils.js +2 -2
  18. package/lib/FileIndex.js +1 -1
  19. package/lib/FileSet.js +1 -1
  20. package/lib/FsUtils.js +2 -2
  21. package/lib/Histo.js +2 -2
  22. package/lib/HtmlTree.js +2 -2
  23. package/lib/HtmlUtils.js +1 -1
  24. package/lib/Issue.js +2 -2
  25. package/lib/JafEvents.js +1 -1
  26. package/lib/JafLib.js +2 -2
  27. package/lib/Json.js +2 -2
  28. package/lib/JsonLoader.js +2 -2
  29. package/lib/Md.js +6 -0
  30. package/lib/MetaLib.js +2 -2
  31. package/lib/NetUtils.js +1 -1
  32. package/lib/NodeTypes.js +1 -1
  33. package/lib/Parser.js +2 -2
  34. package/lib/RegTypes.js +2 -2
  35. package/lib/Registry.js +2 -2
  36. package/lib/Reporter.js +2 -2
  37. package/lib/RuleContext.js +1 -1
  38. package/lib/RulePack.js +1 -1
  39. package/lib/RuleSet.js +2 -2
  40. package/lib/Rules.js +2 -2
  41. package/lib/Scope.js +2 -2
  42. package/lib/SemVer.js +1 -1
  43. package/lib/Server.js +1 -1
  44. package/lib/SevLib.js +1 -1
  45. package/lib/Severity.js +1 -1
  46. package/lib/Stats.js +1 -1
  47. package/lib/Ts.js +2 -2
  48. package/lib/Utils.js +2 -2
  49. package/lib/Watch.js +1 -1
  50. package/lib/Writer.js +1 -1
  51. package/lib/ZipUtils.js +1 -1
  52. package/lib/api.js +2 -2
  53. package/lib/builtinpacks.js +6 -0
  54. package/lib/cliStats.js +2 -2
  55. package/lib/clone.js +2 -2
  56. package/lib/cmdline.js +2 -2
  57. package/lib/colors.js +2 -2
  58. package/lib/defaults.js +6 -0
  59. package/lib/deflist.js +6 -0
  60. package/lib/dislist.js +6 -0
  61. package/lib/exportRules.js +1 -1
  62. package/lib/extends.js +2 -2
  63. package/lib/filetypes.js +2 -2
  64. package/lib/grouplist.js +6 -0
  65. package/lib/groups.js +2 -2
  66. package/lib/help.js +2 -2
  67. package/lib/jetver.js +2 -2
  68. package/lib/macros.js +1 -1
  69. package/lib/manual.js +6 -0
  70. package/lib/metaLoader.js +1 -1
  71. package/lib/metahist.js +1 -1
  72. package/lib/msgidLoader.js +1 -1
  73. package/lib/ns.js +2 -2
  74. package/lib/nslist.js +1 -1
  75. package/lib/outFormat.js +1 -1
  76. package/lib/outfile.js +1 -1
  77. package/lib/ruleLoader.js +1 -1
  78. package/lib/scaffold.js +2 -2
  79. package/lib/scaffoldRule.js +2 -2
  80. package/lib/schema.js +2 -2
  81. package/lib/scopewalker.js +2 -2
  82. package/lib/spinner.js +2 -2
  83. package/lib/spinnernoop.js +1 -1
  84. package/lib/tabs.js +1 -1
  85. package/libext/expparser.js +1 -1
  86. package/meta/11.1.0/jetauditmeta.js +1 -1
  87. package/meta/12.0.0/jetauditmeta.js +9 -0
  88. package/meta/12.1.0/jetauditmeta.js +9 -0
  89. package/meta/metaverlist.json +1 -1
  90. package/package.json +72 -68
  91. package/rulepacks/csp/csp-html-script-unsafe-inline.js +1 -1
  92. package/rulepacks/csp/csp-html-style-unsafe-inline.js +1 -1
  93. package/rulepacks/csp/csp-html-unsafe-expr.js +1 -1
  94. package/rulepacks/csp/csp-js-script-unsafe-eval.js +1 -1
  95. package/rulepacks/csp/csp-js-style-unsafe-inline.js +1 -1
  96. package/rulepacks/csp/csp-ts-script-unsafe-eval.js +1 -1
  97. package/rulepacks/csp/csp-ts-style-unsafe-inline.js +1 -1
  98. package/rulepacks/csp/msgid.json +1 -1
  99. package/rulepacks/csp/rules.json +1 -1
  100. package/rulepacks/jetwc/jetwc-absolute-jetversion.js +2 -2
  101. package/rulepacks/jetwc/jetwc-aria-redefinition.js +2 -2
  102. package/rulepacks/jetwc/jetwc-bootstrap.js +2 -2
  103. package/rulepacks/jetwc/jetwc-compjson-bp-ar.js +2 -2
  104. package/rulepacks/jetwc/jetwc-compjson-bp-obj.js +2 -2
  105. package/rulepacks/jetwc/jetwc-component-dependencies.js +2 -2
  106. package/rulepacks/jetwc/jetwc-component-displayname.js +2 -2
  107. package/rulepacks/jetwc/jetwc-component-foldername.js +2 -2
  108. package/rulepacks/jetwc/jetwc-component-location.js +2 -2
  109. package/rulepacks/jetwc/jetwc-component-type.js +2 -2
  110. package/rulepacks/jetwc/jetwc-css-oj-complete.js +6 -0
  111. package/rulepacks/jetwc/jetwc-data-property-prefix.js +2 -2
  112. package/rulepacks/jetwc/jetwc-deprecated-lifecycle.js +2 -2
  113. package/rulepacks/jetwc/jetwc-disabled-property.js +2 -2
  114. package/rulepacks/jetwc/jetwc-displayname.js +2 -2
  115. package/rulepacks/jetwc/jetwc-dynamic-slot-context.js +2 -2
  116. package/rulepacks/jetwc/jetwc-dynamic-slots-naming.js +2 -2
  117. package/rulepacks/jetwc/jetwc-event-displayname.js +2 -2
  118. package/rulepacks/jetwc/jetwc-events.js +2 -2
  119. package/rulepacks/jetwc/jetwc-jet-version.js +2 -2
  120. package/rulepacks/jetwc/jetwc-loader-file.js +2 -2
  121. package/rulepacks/jetwc/jetwc-markdown-link.js +6 -0
  122. package/rulepacks/jetwc/jetwc-method-displayname.js +2 -2
  123. package/rulepacks/jetwc/jetwc-methods.js +2 -2
  124. package/rulepacks/jetwc/jetwc-namespace.js +2 -2
  125. package/rulepacks/jetwc/jetwc-nested-defaults.js +2 -2
  126. package/rulepacks/jetwc/jetwc-nls-languages.js +2 -2
  127. package/rulepacks/jetwc/jetwc-nls-root.js +2 -2
  128. package/rulepacks/jetwc/jetwc-oj-register.js +2 -2
  129. package/rulepacks/jetwc/jetwc-ojcss.js +2 -2
  130. package/rulepacks/jetwc/jetwc-pack-children.js +2 -2
  131. package/rulepacks/jetwc/jetwc-packable-components.js +2 -2
  132. package/rulepacks/jetwc/jetwc-prerelease-dependencies.js +2 -2
  133. package/rulepacks/jetwc/jetwc-prerelease-pattern.js +2 -2
  134. package/rulepacks/jetwc/jetwc-prerelease-version.js +2 -2
  135. package/rulepacks/jetwc/jetwc-property-changed.js +2 -2
  136. package/rulepacks/jetwc/jetwc-property-displayname.js +2 -2
  137. package/rulepacks/jetwc/jetwc-property-nesting.js +2 -2
  138. package/rulepacks/jetwc/jetwc-public-modules.js +2 -2
  139. package/rulepacks/jetwc/jetwc-register-css.js +2 -2
  140. package/rulepacks/jetwc/jetwc-register-with-promises.js +2 -2
  141. package/rulepacks/jetwc/jetwc-require-paths.js +2 -2
  142. package/rulepacks/jetwc/jetwc-required-subproperty.js +2 -2
  143. package/rulepacks/jetwc/jetwc-reserved-property.js +2 -2
  144. package/rulepacks/jetwc/jetwc-schema.js +2 -2
  145. package/rulepacks/jetwc/jetwc-semantic-version.js +2 -2
  146. package/rulepacks/jetwc/jetwc-slot-displayname.js +2 -2
  147. package/rulepacks/jetwc/jetwc-slots.js +2 -2
  148. package/rulepacks/jetwc/jetwc-standard-files.js +2 -2
  149. package/rulepacks/jetwc/jetwc-subproperty-writeback.js +2 -2
  150. package/rulepacks/jetwc/jetwc-template-slots.js +2 -2
  151. package/rulepacks/jetwc/jetwc-unused-events.js +2 -2
  152. package/rulepacks/jetwc/jetwc-unused-slots.js +2 -2
  153. package/rulepacks/jetwc/jetwc-vb-category.js +2 -2
  154. package/rulepacks/jetwc/jetwc-vb-icon.js +2 -2
  155. package/rulepacks/jetwc/jetwc-vcomponent-jetversion.js +6 -0
  156. package/rulepacks/jetwc/jetwc-vcomponent-loader.js +6 -0
  157. package/rulepacks/jetwc/jetwc-vcomponent-version.js +6 -0
  158. package/rulepacks/jetwc/jetwc-version-openrange.js +2 -2
  159. package/rulepacks/jetwc/jetwc-writeback-required.js +2 -2
  160. package/rulepacks/jetwc/msgid.json +2 -2
  161. package/rulepacks/jetwc/rules.json +2 -2
  162. package/rulepacks/jetwc-lib/jetwcutils-auditComponentCacheManager.js +6 -0
  163. package/rulepacks/jetwc-lib/jetwcutils-commonListenerImpls.js +6 -0
  164. package/rulepacks/jetwc-lib/jetwcutils-componentAuditUtils.js +6 -0
  165. package/rulepacks/jetwc-lib/jetwcutils-componentFinder.js +6 -0
  166. package/rulepacks/jetwc-lib/jetwcutils-preCompiler.js +6 -0
  167. package/rulepacks/jetwc-lib/jetwcutils-tsxUtils.js +6 -0
  168. package/rulepacks/jetwco/jetwco-bootstrap.js +2 -2
  169. package/rulepacks/jetwco/jetwco-cacc-auditConstraints.js +6 -0
  170. package/rulepacks/jetwco/jetwco-cacc-dependencies.js +6 -0
  171. package/rulepacks/jetwco/jetwco-cacc-dynamicSlots.js +6 -0
  172. package/rulepacks/jetwco/jetwco-cacc-eventBubbles.js +6 -0
  173. package/rulepacks/jetwco/jetwco-cacc-eventCancelable.js +6 -0
  174. package/rulepacks/jetwco/jetwco-cacc-eventPayload.js +6 -0
  175. package/rulepacks/jetwco/jetwco-cacc-events.js +6 -0
  176. package/rulepacks/jetwco/jetwco-cacc-helpers.js +6 -0
  177. package/rulepacks/jetwco/jetwco-cacc-jetVer.js +6 -0
  178. package/rulepacks/jetwco/jetwco-cacc-methodParamTypes.js +6 -0
  179. package/rulepacks/jetwco/jetwco-cacc-methodParams.js +6 -0
  180. package/rulepacks/jetwco/jetwco-cacc-methodReturnType.js +6 -0
  181. package/rulepacks/jetwco/jetwco-cacc-methods.js +6 -0
  182. package/rulepacks/jetwco/jetwco-cacc-packBundle.js +6 -0
  183. package/rulepacks/jetwco/jetwco-cacc-packBundleContent.js +6 -0
  184. package/rulepacks/jetwco/jetwco-cacc-packContent.js +6 -0
  185. package/rulepacks/jetwco/jetwco-cacc-properties.js +6 -0
  186. package/rulepacks/jetwco/jetwco-cacc-propertyDefault.js +6 -0
  187. package/rulepacks/jetwco/jetwco-cacc-propertyEnumeration.js +6 -0
  188. package/rulepacks/jetwco/jetwco-cacc-propertyReadOnly.js +6 -0
  189. package/rulepacks/jetwco/jetwco-cacc-propertyRequired.js +6 -0
  190. package/rulepacks/jetwco/jetwco-cacc-propertyType.js +6 -0
  191. package/rulepacks/jetwco/jetwco-cacc-propertyWriteback.js +6 -0
  192. package/rulepacks/jetwco/jetwco-cacc-publicModules.js +6 -0
  193. package/rulepacks/jetwco/jetwco-cacc-slotDataVariable.js +6 -0
  194. package/rulepacks/jetwco/jetwco-cacc-slotDataVariableType.js +6 -0
  195. package/rulepacks/jetwco/jetwco-cacc-slots.js +6 -0
  196. package/rulepacks/jetwco/jetwco-cacc-styleClasses.js +6 -0
  197. package/rulepacks/jetwco/jetwco-cacc-styleVariables.js +6 -0
  198. package/rulepacks/jetwco/jetwco-compjson-ns-reg.js +2 -2
  199. package/rulepacks/jetwco/jetwco-component-api-baseline-changes.js +2 -2
  200. package/rulepacks/jetwco/jetwco-component-api-changes.js +2 -2
  201. package/rulepacks/jetwco/jetwco-component-api-controlled-changes.js +6 -0
  202. package/rulepacks/jetwco/jetwco-component-cdn.js +2 -2
  203. package/rulepacks/jetwco/jetwco-description-standards.js +6 -0
  204. package/rulepacks/jetwco/jetwco-displayname-standards.js +6 -0
  205. package/rulepacks/jetwco/jetwco-exchange-version-check.js +2 -2
  206. package/rulepacks/jetwco/jetwco-license-info.js +2 -2
  207. package/rulepacks/jetwco/jetwco-prerelease-cdn.js +2 -2
  208. package/rulepacks/jetwco/jetwco-thirdparty-ba.js +2 -2
  209. package/rulepacks/jetwco/msgid.json +2 -2
  210. package/rulepacks/jetwco/rules.json +2 -2
  211. package/rulepacks/spoc/msgid.json +1 -1
  212. package/rulepacks/spoc/rules.json +1 -1
  213. package/rulepacks/spoc/spoc-dom-manip-inv-tag.js +1 -1
  214. package/rulepacks/spoc/spoc-dom-manip-tag-pos.js +1 -1
  215. package/rulepacks/spoc/spoc-dom-manip.js +1 -1
  216. package/rulepacks/wdt/msgid.json +6 -0
  217. package/rulepacks/wdt/rules.json +6 -0
  218. package/rulepacks/wdt/wd-driver-sleep.js +6 -0
  219. package/rulepacks/wdt/wd-xpath.js +6 -0
  220. package/rules/jaf/jaf-css-diagnose.js +1 -1
  221. package/rules/jaf/jaf-html-diagnose.js +1 -1
  222. package/rules/jaf/jaf-init-schema.js +1 -1
  223. package/rules/jaf/jaf-js-diagnose.js +1 -1
  224. package/rules/jaf/jaf-ts-diagnose.js +1 -1
  225. package/rules/jaf/jaf-ts-walk.js +6 -0
  226. package/rules/jaf/msgid.json +2 -2
  227. package/rules/jaf/rules.json +2 -2
  228. package/rules/jet/helpers/acc-aria-label.js +1 -1
  229. package/rules/jet/helpers/bp-checkPropType.js +1 -1
  230. package/rules/jet/helpers/cssHelper.js +1 -1
  231. package/rules/jet/helpers/extractStylesFromClass.js +1 -1
  232. package/rules/jet/helpers/has-slot-name.js +2 -2
  233. package/rules/jet/helpers/has-slot.js +1 -1
  234. package/rules/jet/helpers/json-prop-pos.js +1 -1
  235. package/rules/jet/helpers/json-propname-pos.js +1 -1
  236. package/rules/jet/helpers/style-selector.js +1 -1
  237. package/rules/jet/helpers/valid-attr.js +1 -1
  238. package/rules/jet/helpers/vartrack.js +1 -1
  239. package/rules/jet/jet-css-ojselector.js +1 -1
  240. package/rules/jet/msgid.json +2 -2
  241. package/rules/jet/oj-acc-aria-labelledby.js +1 -1
  242. package/rules/jet/oj-acc-aria-prop.js +2 -2
  243. package/rules/jet/oj-acc-avatar-aria-role.js +2 -2
  244. package/rules/jet/oj-acc-combobox-aria-label.js +2 -2
  245. package/rules/jet/oj-acc-film-strip-aria-label.js +2 -2
  246. package/rules/jet/oj-acc-input-aria-label.js +2 -2
  247. package/rules/jet/oj-acc-select-aria-label.js +2 -2
  248. package/rules/jet/oj-cca-compjson-bp-ar.js +1 -1
  249. package/rules/jet/oj-cca-compjson-bp-dsplyname.js +1 -1
  250. package/rules/jet/oj-cca-compjson-bp-jetver.js +1 -1
  251. package/rules/jet/oj-cca-compjson-bp-obj.js +1 -1
  252. package/rules/jet/oj-cca-compjson-ns-reg.js +1 -1
  253. package/rules/jet/oj-css-bp-border-color.js +1 -1
  254. package/rules/jet/oj-css-bp-dir-flow.js +1 -1
  255. package/rules/jet/oj-css-bp-float.js +1 -1
  256. package/rules/jet/oj-css-bp-textalign.js +1 -1
  257. package/rules/jet/oj-css-style-abs-units.js +2 -2
  258. package/rules/jet/oj-css-style-bp-color.js +1 -1
  259. package/rules/jet/oj-css-style-bp-display.js +1 -1
  260. package/rules/jet/oj-css-style-bp-font-family.js +1 -1
  261. package/rules/jet/oj-css-style-bp-font.js +1 -1
  262. package/rules/jet/oj-css-style-deprecated.js +1 -1
  263. package/rules/jet/oj-css-style-override.js +2 -2
  264. package/rules/jet/oj-css-var-override.js +1 -1
  265. package/rules/jet/oj-form-maxcols.js +2 -2
  266. package/rules/jet/oj-html-5-attr-obs.js +1 -1
  267. package/rules/jet/oj-html-5-tag-obs.js +1 -1
  268. package/rules/jet/oj-html-alta-deprecated.js +6 -0
  269. package/rules/jet/oj-html-attr-$unique.js +1 -1
  270. package/rules/jet/oj-html-attr-2def.js +1 -1
  271. package/rules/jet/oj-html-attr-json.js +1 -1
  272. package/rules/jet/oj-html-attr-prefix-expr.js +1 -1
  273. package/rules/jet/oj-html-attr-prefix-ro.js +1 -1
  274. package/rules/jet/oj-html-attr-req.js +1 -1
  275. package/rules/jet/oj-html-bindforeach-data.js +2 -2
  276. package/rules/jet/oj-html-bindif-test.js +2 -2
  277. package/rules/jet/oj-html-binding-attr.js +2 -2
  278. package/rules/jet/oj-html-cca-count.js +1 -1
  279. package/rules/jet/oj-html-cca-tagname.js +2 -2
  280. package/rules/jet/oj-html-cdn.js +1 -1
  281. package/rules/jet/oj-html-combo-converter.js +1 -1
  282. package/rules/jet/oj-html-cspexpr.js +1 -1
  283. package/rules/jet/oj-html-databind-all.js +1 -1
  284. package/rules/jet/oj-html-dlg-title.js +2 -2
  285. package/rules/jet/oj-html-file-pick-accept.js +2 -2
  286. package/rules/jet/oj-html-form-bindif.js +1 -1
  287. package/rules/jet/oj-html-form-layout-maxcols.js +2 -2
  288. package/rules/jet/oj-html-form-noflex.js +1 -1
  289. package/rules/jet/oj-html-input-isodate.js +2 -2
  290. package/rules/jet/oj-html-invalid-doctype.js +2 -2
  291. package/rules/jet/oj-html-jq-databind.js +2 -2
  292. package/rules/jet/oj-html-ko-comment.js +1 -1
  293. package/rules/jet/oj-html-ko-databind.js +2 -2
  294. package/rules/jet/oj-html-label-for-prefix.js +1 -1
  295. package/rules/jet/oj-html-missing-doctype.js +1 -1
  296. package/rules/jet/oj-html-msgs-cat-text.js +6 -0
  297. package/rules/jet/oj-html-no-style-tag.js +6 -0
  298. package/rules/jet/oj-html-notag-style.js +6 -0
  299. package/rules/jet/oj-html-oj-lib.js +1 -1
  300. package/rules/jet/oj-html-ojattr-520.js +1 -1
  301. package/rules/jet/oj-html-ojattr-deprecated.js +2 -2
  302. package/rules/jet/oj-html-ojattr-enum-deprecated.js +2 -2
  303. package/rules/jet/oj-html-ojattr-evt-syntax.js +2 -2
  304. package/rules/jet/oj-html-ojattr-value.js +1 -1
  305. package/rules/jet/oj-html-ojattr.js +2 -2
  306. package/rules/jet/oj-html-ojevent.js +2 -2
  307. package/rules/jet/oj-html-ojslot.js +2 -2
  308. package/rules/jet/oj-html-ojstyle.js +1 -1
  309. package/rules/jet/oj-html-ojtag-datacmd.js +2 -2
  310. package/rules/jet/oj-html-ojtag-datactx.js +1 -1
  311. package/rules/jet/oj-html-ojtag-deprecated.js +2 -2
  312. package/rules/jet/oj-html-ojtag-globattr-noprefix.js +2 -2
  313. package/rules/jet/oj-html-ojtag-id.js +1 -1
  314. package/rules/jet/oj-html-ojtag-nonglobattr-prefix.js +2 -2
  315. package/rules/jet/oj-html-ojtag-ns.js +1 -1
  316. package/rules/jet/oj-html-picker-attrs.js +2 -2
  317. package/rules/jet/oj-html-redwood-cssnovars.js +1 -1
  318. package/rules/jet/oj-html-redwood-cssvars.js +1 -1
  319. package/rules/jet/oj-html-self-close.js +1 -1
  320. package/rules/jet/oj-html-slot-item-minmax.js +1 -1
  321. package/rules/jet/oj-html-slot-name.js +2 -2
  322. package/rules/jet/oj-html-slot-pref-content.js +2 -2
  323. package/rules/jet/oj-html-style-abs-units.js +1 -1
  324. package/rules/jet/oj-html-style-bp-color.js +1 -1
  325. package/rules/jet/oj-html-style-bp-display.js +1 -1
  326. package/rules/jet/oj-html-style-bp-font-family.js +1 -1
  327. package/rules/jet/oj-html-style-bp-font.js +1 -1
  328. package/rules/jet/oj-html-style-deprecated.js +2 -2
  329. package/rules/jet/oj-html-style.js +1 -1
  330. package/rules/jet/oj-html-stylesel.js +1 -1
  331. package/rules/jet/oj-html-tag-attr-noprefix.js +2 -2
  332. package/rules/jet/oj-html-template-index.js +2 -2
  333. package/rules/jet/oj-html-unsup-theme.js +1 -1
  334. package/rules/jet/oj-html-wctag-$props.js +1 -1
  335. package/rules/jet/oj-html-wctag-arialabelledby.js +1 -1
  336. package/rules/jet/oj-html-wctag-for.js +1 -1
  337. package/rules/jet/oj-html-wctag-id.js +2 -2
  338. package/rules/jet/oj-html-wctag-nested.js +6 -0
  339. package/rules/jet/oj-html-wctag-packprivate.js +1 -1
  340. package/rules/jet/oj-js-comp-attr-deprecated.js +2 -2
  341. package/rules/jet/oj-js-comp-meth-deprecated.js +2 -2
  342. package/rules/jet/oj-js-no-ext-final.js +1 -1
  343. package/rules/jet/oj-js-noconsole.js +1 -1
  344. package/rules/jet/oj-js-ojcomp-deprecated.js +2 -2
  345. package/rules/jet/oj-js-ojcomp-exist.js +1 -1
  346. package/rules/jet/oj-js-ojcomp-new.js +1 -1
  347. package/rules/jet/oj-js-poly-promise.js +1 -1
  348. package/rules/jet/oj-js-var-undef.js +1 -1
  349. package/rules/jet/oj-json-syntax.js +1 -1
  350. package/rules/jet/oj-ts-comp-attr-deprecated.js +2 -2
  351. package/rules/jet/oj-ts-comp-meth-deprecated.js +2 -2
  352. package/rules/jet/oj-ts-no-ext-final.js +1 -1
  353. package/rules/jet/oj-ts-noconsole.js +1 -1
  354. package/rules/jet/oj-ts-ojcomp-deprecated.js +2 -2
  355. package/rules/jet/oj-ts-ojcomp-exist.js +1 -1
  356. package/rules/jet/oj-ts-ojcomp-new.js +1 -1
  357. package/rules/jet/oj-ts-poly-promise.js +1 -1
  358. package/rules/jet/rules.json +2 -2
  359. package/schema/component-schema.json +4 -1
  360. package/src/JafCore.js +2 -2
  361. package/types/index.d.ts +122 -82
  362. package/lib/imanual.js +0 -6
  363. package/lib/xmanual.js +0 -6
  364. package/rulepacks/jetwc-lib/component-audit-utils.js +0 -6
package/jaf.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #! /usr/bin/env node
2
2
  /*
3
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates.
3
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
4
4
  * Licensed under The Universal Permissive License (UPL), Version 1.0
5
5
  * as shown at https://oss.oracle.com/licenses/upl/
6
6
  */
7
- (function(){const ac=require("./src/JafCore");var nd={fs:require("fs"),path:require("path"),glob:require("glob"),process:process,os:require("os"),decomment:require("strip-json-comments"),decache:require("decache"),Config:require("./lib/Config"),metaLoader:require("./lib/metaLoader"),ruleLoader:require("./lib/ruleLoader"),msgidLoader:require("./lib/msgidLoader"),jsonLoader:require("./lib/JsonLoader"),Components:require("./lib/Components"),ComponentSvcs:require("./lib/ComponentSvcs"),schema:require("./lib/schema"),extends:require("./lib/extends"),tsparse:require("@typescript-eslint/typescript-estree"),scaffold:require("./lib/scaffold.js"),scaffoldRule:require("./lib/scaffoldRule.js"),fsUtils:require("./lib/FsUtils"),zipUtils:require("./lib/ZipUtils"),Watch:require("./lib/Watch"),colors:require("./lib/colors"),cmdLine:require("./lib/cmdline"),imanual:require("./lib/imanual"),xmanual:require("./lib/xmanual"),help:require("./lib/help"),jetver:require("./lib/jetver"),exportRules:require("./lib/exportRules"),nslist:require("./lib/nslist"),metahist:require("./lib/metahist"),cliStats:require("./lib/cliStats"),spinner:require("./lib/spinnernoop")};let rc=new ac(nd).start();if(rc!==99){process.exit(rc)}})();
7
+ (function(){const ac=require("./src/JafCore");var nd={fs:require("fs"),path:require("path"),glob:require("glob"),process:process,os:require("os"),decomment:require("strip-json-comments"),decache:require("decache"),Config:require("./lib/Config"),metaLoader:require("./lib/metaLoader"),ruleLoader:require("./lib/ruleLoader"),msgidLoader:require("./lib/msgidLoader"),jsonLoader:require("./lib/JsonLoader"),Components:require("./lib/Components"),ComponentSvcs:require("./lib/ComponentSvcs"),schema:require("./lib/schema"),builtinpacks:require("./lib/builtinpacks"),extends:require("./lib/extends"),tsparse:require("@typescript-eslint/typescript-estree"),scaffold:require("./lib/scaffold.js"),scaffoldRule:require("./lib/scaffoldRule.js"),fsUtils:require("./lib/FsUtils"),zipUtils:require("./lib/ZipUtils"),Watch:require("./lib/Watch"),colors:require("./lib/colors"),cmdLine:require("./lib/cmdline"),manual:require("./lib/manual"),help:require("./lib/help"),jetver:require("./lib/jetver"),defList:require("./lib/deflist"),exportRules:require("./lib/exportRules"),nslist:require("./lib/nslist"),grouplist:require("./lib/grouplist"),dislist:require("./lib/dislist"),metahist:require("./lib/metahist"),cliStats:require("./lib/cliStats"),spinner:require("./lib/spinnernoop")};let rc=new ac(nd).start();if(rc!==99){process.exit(rc)}})();
package/jafapi.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates.
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- var Jaf=function(){this._audit=require("./src/JafCore");this._api=require("./lib/api");this._nodeDeps={fs:require("fs"),path:require("path"),glob:require("glob"),process:process,os:require("os"),decomment:require("strip-json-comments"),decache:require("decache"),Config:require("./lib/Config"),metaLoader:require("./lib/metaLoader"),ruleLoader:require("./lib/ruleLoader"),msgidLoader:require("./lib/msgidLoader"),jsonLoader:require("./lib/JsonLoader"),Components:require("./lib/Components"),ComponentSvcs:require("./lib/ComponentSvcs"),schema:require("./lib/schema"),extends:require("./lib/extends"),tsparse:require("@typescript-eslint/typescript-estree"),scaffold:null,scaffoldRule:null,fsUtils:require("./lib/FsUtils"),zipUtils:require("./lib/ZipUtils"),Watch:null,colors:null,cmdLine:null,imanual:null,xmanual:null,help:null,jetver:require("./lib/jetver"),exportRules:require("./lib/exportRules"),nslist:null,metahist:null,cliStats:null,spinner:require("./lib/spinnernoop")};this._audit=new this._audit(this._nodeDeps,"api");this._api=new this._api(this._nodeDeps,this._audit);this._error=1};Jaf.prototype.initSync=function(config,cbIssue,cbMsg,cbSummary){this._error=this._api.startSync({config:config,cbIssue:cbIssue,cbMsg:cbMsg,cbSummary:cbSummary});return this._error};Jaf.prototype.init=function(config){var _self=this;return new Promise(function(resolve,reject){_self._api.start({config:config}).then(function(result){_self._error=result;resolve(result)}).catch(function(error){reject(error)})})};Jaf.prototype.auditSync=function(filespec){var i,rc=this._error;if(!this._error){if(this._audit._regListenerTypesSet){return rc}if(Array.isArray(filespec)&&filespec.length){for(i=0;i<filespec.length;i++){rc=this._api.auditSync(filespec[i])}}else{rc=this._api.auditSync(filespec)}}return rc};Jaf.prototype.audit=function(filespec){var _self;_self=this;return new Promise(function(resolve,reject){if(_self._error){reject(_self._error)}else{_self._api.audit(filespec).then(function(resultObj){resolve(resultObj)}).catch(function(error){reject(error)})}})};Jaf.prototype.on=function(evName,fn,extra){this._api.on(evName,fn,extra);return this};Jaf.prototype.removeAllListeners=function(evName){this._api.removeAllListeners(evName);return this};Jaf.prototype.removeListener=function(evName,fn){this._api.removeListener(evName,fn);return this};Jaf.prototype.getDescription=function(issue,short){return this._api.getDescription(issue,short)};Jaf.prototype.getActiveRulesetInfo=function(fmt){fmt=fmt!=="json"&&fmt!=="prose"&&fmt!=="sonar"?"json":fmt;return this._api.getActiveRulesetInfo(fmt)};Jaf.prototype.setCallbacks=function(fnIssue,fnMsg,fnSummary){this._audit.setApiCallbacks(fnIssue,fnMsg,fnSummary)};Jaf.prototype.enableMsgId=function(msgid,state){return this._api.enableMsgId(msgid,state)};Jaf.prototype.getConfig=function(){return this._api.getConfig()};Jaf.prototype.getSevLib=function(){return this._api.getSevLib()};Jaf.prototype.enableRule=function(ruleName,state){return this._api.enableRule(ruleName,state)};Jaf.prototype.setVsCodeExtHint=function(isVsCodeExt){isVsCodeExt=isVsCodeExt!==undefined?!!isVsCodeExt:true;return this._api.setVsCodeExtHint(isVsCodeExt)};module.exports=Jaf;
6
+ var Jaf=function(){this._audit=require("./src/JafCore");this._api=require("./lib/api");this._nodeDeps={fs:require("fs"),path:require("path"),glob:require("glob"),process:process,os:require("os"),decomment:require("strip-json-comments"),decache:require("decache"),Config:require("./lib/Config"),metaLoader:require("./lib/metaLoader"),ruleLoader:require("./lib/ruleLoader"),msgidLoader:require("./lib/msgidLoader"),jsonLoader:require("./lib/JsonLoader"),Components:require("./lib/Components"),ComponentSvcs:require("./lib/ComponentSvcs"),schema:require("./lib/schema"),builtinpacks:null,extends:require("./lib/extends"),tsparse:require("@typescript-eslint/typescript-estree"),scaffold:null,scaffoldRule:null,fsUtils:require("./lib/FsUtils"),zipUtils:require("./lib/ZipUtils"),Watch:null,colors:null,cmdLine:null,manual:null,help:null,jetver:require("./lib/jetver"),defList:null,exportRules:require("./lib/exportRules"),nslist:null,grouplist:null,dislist:null,metahist:null,cliStats:null,spinner:require("./lib/spinnernoop")};this._audit=new this._audit(this._nodeDeps,"api");this._api=new this._api(this._nodeDeps,this._audit);this._error=1};Jaf.prototype.initSync=function(config,cbIssue,cbMsg,cbSummary){this._error=this._api.startSync({config:config,cbIssue:cbIssue,cbMsg:cbMsg,cbSummary:cbSummary});return this._error};Jaf.prototype.init=function(config){var _self=this;return new Promise(function(resolve,reject){_self._api.start({config:config}).then(function(result){_self._error=result;resolve(result)}).catch(function(error){reject(error)})})};Jaf.prototype.auditSync=function(filespec){var i,rc=this._error;if(!this._error){if(this._audit._regListenerTypesSet){return rc}if(Array.isArray(filespec)&&filespec.length){for(i=0;i<filespec.length;i++){rc=this._api.auditSync(filespec[i])}}else{rc=this._api.auditSync(filespec)}}return rc};Jaf.prototype.audit=function(filespec){var _self;_self=this;return new Promise(function(resolve,reject){if(_self._error){reject(_self._error)}else{_self._api.audit(filespec).then(function(resultObj){resolve(resultObj)}).catch(function(error){reject(error)})}})};Jaf.prototype.on=function(evName,fn,extra){this._api.on(evName,fn,extra);return this};Jaf.prototype.removeAllListeners=function(evName){this._api.removeAllListeners(evName);return this};Jaf.prototype.removeListener=function(evName,fn){this._api.removeListener(evName,fn);return this};Jaf.prototype.getDescription=function(issue,short){return this._api.getDescription(issue,short)};Jaf.prototype.getActiveRulesetInfo=function(fmt){fmt=fmt!=="json"&&fmt!=="prose"&&fmt!=="sonar"?"json":fmt;return this._api.getActiveRulesetInfo(fmt)};Jaf.prototype.setCallbacks=function(fnIssue,fnMsg,fnSummary){this._audit.setApiCallbacks(fnIssue,fnMsg,fnSummary)};Jaf.prototype.enableMsgId=function(msgid,state){return this._api.enableMsgId(msgid,state)};Jaf.prototype.getConfig=function(){return this._api.getConfig()};Jaf.prototype.getSevLib=function(){return this._api.getSevLib()};Jaf.prototype.enableRule=function(ruleName,state){return this._api.enableRule(ruleName,state)};Jaf.prototype.getInfo=function(){return this._api.getInfo()};Jaf.prototype.setVsCodeExtHint=function(isVsCodeExt){isVsCodeExt=isVsCodeExt!==undefined?!!isVsCodeExt:true;return this._api.setVsCodeExtHint(isVsCodeExt)};module.exports=Jaf;
package/lib/AST.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates.
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
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
  */
package/lib/AST_Ts.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates.
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
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 NT=require("./AstNodeTypes");const Scope=require("./Scope");const COMMON_DOC_METHODS={"getElementsByClassName":true,"getElementsByTagName":true,"getElementsByTagNameNS":true,"getElementById":true,"getElementsByName":true,"querySelector":true,"querySelectorAll":true,"createElement":true,"createElementNS":true};var AST=function(data,fileType,nd,ecmaVer,comments,msgCtx,config){var opts={ecmaVersion:ecmaVer,comment:comments};if(fileType==="tsx"){opts.jsx=true}opts.loc=true;opts.range=true;opts.errorOnUnknownASTType=true;opts.project="D:/vsprojects/JetAuditDev/tsconfig/tsconfig.json";this._ast=nd.tsparse.parse(data,opts);this._data=data;this._scope=null;this._utils=null;this._program=null;this._isComments=comments;this._msgCtx=msgCtx;this._config=config;this._nd=nd};AST.prototype.walk=function(callback){try{this._walkAddParent(callback)}catch(e){console.log(`JAF internal TS WALK ERROR: ${e}`)}};AST.prototype.getAst=function(){return this._ast};AST.prototype.getRawComments=function(){return this._ast.comments};AST.prototype.getNodeFromIndex=function(index){return _getNodeFromIndex2(this._ast,index)};function _getNodeFromIndex2(node,index){var body,n,i,ret=null;if(!node){return null}if(index===node.range[0]){return node}if(index<node.range[0]||index>node.range[1]){return null}if(node.body){body=node.body;if(Array.isArray(body)){for(i=0;i<body.length;i++){n=body[i];if(index<n.range[0]){ret=n}else{ret=_getNodeFromIndex2(n,index)}if(ret){if(ret===-1){ret=null}break}}}else{ret=_getNodeFromIndex2(body,index);if(ret){if(ret===-1){ret=null}}}}else{if(node.type==="IfStatement"){ret=_getNodeFromIndex2(node.consequent,index)}else{ret=node}}return ret};AST.prototype.getUtils=function(){if(!this._utils){this._utils={getBlock:this.getBlock.bind(this),getBody:this.getBody.bind(this),getProgram:this.getProgram.bind(this),getContainingFunctionName:this.getContainingFunctionName.bind(this),isFuncArg:this.isFuncArg.bind(this),getScopes:this._createVarScopes.bind(this),getNodeTypes:_getNodeTypes,isCommonDocApi:this.isCommonDocApi,parseDefine:this.parseDefine.bind(this),parseImport:this.parseImport.bind(this)}}return this._utils};function _getNodeTypes(){return NT};AST.prototype.getBlock=function(node){var block;if(!node){if(!this._program){node=this._ast;if(node.type!==NT.PROGRAM){node=null}this._program=node}else{node=this._program}block=node}else{while(node){if(node.type){if(node.type===NT.BLOCK_STMT||node.type===NT.PROGRAM){block=node;break}}node=node.parent}}return block};AST.prototype.getBody=function(node){var block=this.getBlock(node);return block?block.body:block};AST.prototype.getFunctionBody=function(node){var block;if(!node){if(!this._program){node=this._ast;if(node.type!==NT.PROGRAM){node=null}this._program=node}else{node=this._program}block=node}else{while(node){if(node.type){if(node.type===NT.FUNC_DECLARATION||node.type===NT.PROGRAM){block=node;break}}node=node.parent}}return block};AST.prototype.getProgram=function(){return this._ast.type===NT.PROGRAM?this._ast:null};AST.prototype.getContainingFunctionName=function(node){var body=this.getFunctionBody(node);return body&&body.id?body.id.name:undefined};AST.prototype._createVarScopes=function(){if(!this._scope){this._scope=new Scope(this._msgCtx,this._config,this._nd);this._scopeStacks=this._scope.build(this._ast);this._accessor=this._scope.getAccessor()}return this._accessor};AST.prototype.getData=function(){return this._data};AST.prototype.isFuncArg=function(node,varName){var args,arg,n,j,ret=false;var n=node;while(n.type&&n.type!==NT.FUNC_DECLARATION){n=n.parent;if(!n||!n.type){n=null;break}}if(n){args=n.params;for(j=0;j<args.length;j++){arg=args[j];if(arg.type===NT.IDENTIFIER){if(arg.name===varName){ret=true;break}}}}return ret};AST.prototype.isCommonDocApi=function(method){return COMMON_DOC_METHODS[method]};AST.prototype.parseDefine=function(node,obj){var modules,names,len,i;if(!node.arguments||node.arguments.length<2){return null}modules=node.arguments[0].elements;names=node.arguments[1].params;obj=obj||null;if(modules&&names&&modules.length){len=Math.min(modules.length,names.length);obj=obj?obj:{};for(i=0;i<len;i++){obj[names[i].name]=modules[i].value}}return obj};AST.prototype.parseImport=function(node,obj){var source,specifiers,spec,name,i;obj=obj||{};source=node.source&&node.source.value;if(node.specifiers){specifiers=node.specifiers;for(var i=0;i<specifiers.length;i++){spec=specifiers[i];if((spec.type===NT.IMPORT_DEF_SPECIFIER||spec.type===NT.IMPORT_SPECIFIER)&&spec.local){name=spec.local.name;obj[name]=source}}}return obj};AST.prototype._walkAddParent=function(fn){var stack=[this._ast],i,j,key,len,node,child,subchild;for(i=0;i<stack.length;i+=1){node=stack[i];if(typeof node==="number"){continue}if(node.type==="Line"||node.type==="EmptyStatement"){continue}fn(node);for(key in node){if(key!=="parent"){child=node[key];if(child instanceof Array){for(j=0,len=child.length;j<len;j+=1){subchild=child[j];if(subchild){subchild.parent=node;stack.push(subchild)}}}else if(child!=void 0&&typeof child.type==="string"){child.parent=node;stack.push(child)}}}}};module.exports=AST;
6
+ const NT=require("./AstNodeTypes");const Scope=require("./Scope");const COMMON_DOC_METHODS={"getElementsByClassName":true,"getElementsByTagName":true,"getElementsByTagNameNS":true,"getElementById":true,"getElementsByName":true,"querySelector":true,"querySelectorAll":true,"createElement":true,"createElementNS":true};const LOC="loc";const RANGE="range";const PARENT="parent";var AST=function(data,file,fileType,nd,ecmaVer,comments,msgCtx,config){var opts={ecmaVersion:ecmaVer,comment:comments};if(fileType==="tsx"){opts.jsx=true}opts.loc=true;opts.range=true;opts.errorOnUnknownASTType=true;opts.project="D:/vsprojects/JetAuditDev/tsconfig/tsconfig.json";this._ast=nd.tsparse.parse(data,opts);this._data=data;this._file=file;this._scope=null;this._utils=null;this._program=null;this._isComments=comments;this._msgCtx=msgCtx;this._config=config;this._nd=nd};AST.prototype.walk=function(callback){try{this._walkAddParent(callback)}catch(e){console.log(`JAF internal TS/TSX WALK ERROR: ${e}`)}};AST.prototype.getAst=function(){return this._ast};AST.prototype.getFilePath=function(){return this._file};AST.prototype.getRawComments=function(){return this._ast.comments};AST.prototype.getNodeFromIndex=function(index){return _getNodeFromIndex2(this._ast,index)};function _getNodeFromIndex2(node,index){var body,n,i,ret=null;if(!node){return null}if(index===node.range[0]){return node}if(index<node.range[0]||index>node.range[1]){return null}if(node.body){body=node.body;if(Array.isArray(body)){for(i=0;i<body.length;i++){n=body[i];if(index<n.range[0]){ret=n}else{ret=_getNodeFromIndex2(n,index)}if(ret){if(ret===-1){ret=null}break}}}else{ret=_getNodeFromIndex2(body,index);if(ret){if(ret===-1){ret=null}}}}else{if(node.type==="IfStatement"){ret=_getNodeFromIndex2(node.consequent,index)}else{ret=node}}return ret};AST.prototype.getUtils=function(){if(!this._utils){this._utils={getBlock:this.getBlock.bind(this),getBody:this.getBody.bind(this),getProgram:this.getProgram.bind(this),getContainingFunctionName:this.getContainingFunctionName.bind(this),isFuncArg:this.isFuncArg.bind(this),getScopes:this._createVarScopes.bind(this),getNodeTypes:_getNodeTypes,isCommonDocApi:this.isCommonDocApi,parseDefine:this.parseDefine.bind(this),parseImport:this.parseImport.bind(this)}}return this._utils};function _getNodeTypes(){return NT};AST.prototype.getBlock=function(node){var block;if(!node){if(!this._program){node=this._ast;if(node.type!==NT.PROGRAM){node=null}this._program=node}else{node=this._program}block=node}else{while(node){if(node.type){if(node.type===NT.BLOCK_STMT||node.type===NT.PROGRAM){block=node;break}}node=node.parent}}return block};AST.prototype.getBody=function(node){var block=this.getBlock(node);return block?block.body:block};AST.prototype.getFunctionBody=function(node){var block;if(!node){if(!this._program){node=this._ast;if(node.type!==NT.PROGRAM){node=null}this._program=node}else{node=this._program}block=node}else{while(node){if(node.type){if(node.type===NT.FUNC_DECLARATION||node.type===NT.PROGRAM){block=node;break}}node=node.parent}}return block};AST.prototype.getProgram=function(){return this._ast.type===NT.PROGRAM?this._ast:null};AST.prototype.getContainingFunctionName=function(node){var body=this.getFunctionBody(node);return body&&body.id?body.id.name:undefined};AST.prototype._createVarScopes=function(){if(!this._scope){this._scope=new Scope(this._msgCtx,this._config,this._file,this._nd);this._scopeStacks=this._scope.build(this._ast);this._accessor=this._scope.getAccessor()}return this._accessor};AST.prototype.getData=function(){return this._data};AST.prototype.isFuncArg=function(node,varName){var args,arg,n,j,ret=false;var n=node;while(n.type&&n.type!==NT.FUNC_DECLARATION){n=n.parent;if(!n||!n.type){n=null;break}}if(n){args=n.params;for(j=0;j<args.length;j++){arg=args[j];if(arg.type===NT.IDENTIFIER){if(arg.name===varName){ret=true;break}}}}return ret};AST.prototype.isCommonDocApi=function(method){return COMMON_DOC_METHODS[method]};AST.prototype.parseDefine=function(node,obj){var modules,names,len,i;if(!node.arguments||node.arguments.length<2){return null}modules=node.arguments[0].elements;names=node.arguments[1].params;obj=obj||null;if(modules&&names&&modules.length){len=Math.min(modules.length,names.length);obj=obj?obj:{};for(i=0;i<len;i++){obj[names[i].name]=modules[i].value}}return obj};AST.prototype.parseImport=function(node,obj){var source,specifiers,spec,name,i;obj=obj||{};source=node.source&&node.source.value;if(node.specifiers){specifiers=node.specifiers;for(var i=0;i<specifiers.length;i++){spec=specifiers[i];if((spec.type===NT.IMPORT_DEF_SPECIFIER||spec.type===NT.IMPORT_SPECIFIER)&&spec.local){name=spec.local.name;obj[name]=source}}}return obj};AST.prototype._walkAddParent=function(fn){var stack=[this._ast],i,j,key,len,node,child,subchild;for(i=0;i<stack.length;i+=1){node=stack[i];if(node.type==="Line"||node.type==="EmptyStatement"){continue}fn(node);for(key in node){if(key!==PARENT){if(key===RANGE||key===LOC){continue}child=node[key];if(child instanceof Array){for(j=0,len=child.length;j<len;j+=1){subchild=child[j];if(subchild){subchild.parent=node;stack.push(subchild)}}}else if(child!=void 0&&typeof child.type==="string"){child.parent=node;stack.push(child)}}}}};module.exports=AST;
package/lib/AstJson.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates.
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
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
  */
package/lib/AstMd.js ADDED
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
3
+ * Licensed under The Universal Permissive License (UPL), Version 1.0
4
+ * as shown at https://oss.oracle.com/licenses/upl/
5
+ */
6
+ var parser=require("markdown-it");const PARA_OPEN="paragraph_open";const PARA_CLOSE="paragraph_close";const HEADING_OPEN="heading_open";const HEADING_CLOSE="heading_close";const LINK_OPEN="link_open";const IMAGE="image";const INLINE="inline";const FENCE="fence";const TEXT="text";const UL_OPEN="bullet_list_open";const UL_CLOSE="bullet_list_close";const OL_OPEN="ordered_list_open";const OL_CLOSE="ordered_list_close";const CODE="code";const HTTP="http://";const RE_BRACKET=/\[([^)]+)\].*:/g;const RE_DEL_BRACKET_COLON=/\[|\]|:/g;const RE_REFLINK=/\[[^[]*\]\s*\[([^[]*)\]/;function AstMd(appCtx){this._parser=new parser;this._parser.set({linkify:true});this._appCtx=appCtx;this._utils=appCtx.utils;this._state={};this._links=[];this._paras=[];this._images=[];this._code=[];this._lists=[];this._refLinks=undefined;this._lineMap=new Map};AstMd.prototype.parse=function(data){var state=this._state;state.para=state.heading=state.list=false;state.level=0;state.listType=undefined;this._curListItem=null;this._listsStack=[];this._listItemStack=[];this._stateStack=[];this._mapStack=[];this._links.length=this._paras.length=this._images.length=this._code.length=this._lists.length=0;this._refLinks={};this._ast=this._parser.parse(data,{});this._data=data;this._loadLineMap();return this._ast};AstMd.prototype.createHandler=function(){this._createHandlerContent();return{getLinks:this._getLinks.bind(this),getParas:this._getParas.bind(this),getImages:this._getImages.bind(this),getCode:this._getCode.bind(this),getLists:this._getLists.bind(this),getRefLinks:this._getRefLinks.bind(this),test:this._testParas.bind(this),getLine:this._getLine.bind(this),getLineDisp:this._getLineDisp.bind(this),getLineMap:this._getLineMap.bind(this)}};AstMd.prototype._createHandlerContent=function(){this._createRefs();this._walkChildren(this._ast,this._state)};AstMd.prototype._walkChildren=function(ast,state){var i,o,txt,link,refLink,obj,pos,pos2,start;for(i=0;i<ast.length;i++){o=ast[i];if(o.type===PARA_OPEN&&!state.list){state.para=true;this._map=this._setPos(o.map)}else if(o.type===PARA_CLOSE&&!state.list){state.para=false}else if(o.type===HEADING_OPEN&&!state.list){state.heading=true;this._map=this._setPos(o.map);state.level=_getLevel(o.tag)}else if(o.type===HEADING_CLOSE&&!state.list){state.heading=false;state.level=0}else if(o.type===UL_OPEN||o.type===OL_OPEN){if(this._curListItem){this._listItemStack.push(this._curListItem);this._stateStack.push(state);this._listsStack.push(this._lists);this._lists=this._curListItem.items[this._curListItem.items.length-1].children=[];state={};this._mapStack.push(this._map);this._map=this._setPos(o.map)}state.list=true;state.listType=o.tag;this._map=this._setPos(o.map);pos=this._lineMap.get(o.map[0]+1);pos2=null;if(o.map[0]+1<o.map[1]){pos2=this._lineMap.get(o.map[1])}this._curListItem={ordered:state.listType==="ol",items:[],pos:[{line:o.map[0]+1,start:pos.start,end:pos.end}]};if(pos2){this._curListItem.pos.push({line:o.map[1],start:pos2.start,end:pos2.end})}}else if(o.type===UL_CLOSE||o.type===OL_CLOSE){state.list=false;state.listType=undefined;this._lists.push(this._curListItem);this._curListItem=null;if(this._listItemStack.length){this._curListItem=this._listItemStack.pop();this._lists=this._listsStack.pop();state=this._stateStack.pop();this._map=this._mapStack.pop()}}else if(o.type===INLINE){if(state.list){this._curListItem.items.push({item:o.children[0].content})}else if(state.para||state.heading){pos=this._lineMap.get(o.map[0]+1);pos2=null;if(o.map[0]+1<o.map[1]){pos2=this._lineMap.get(o.map[1])}obj={level:state.level,text:o.content,pos:[{line:o.map[0]+1,start:pos.start,end:pos.end}]};if(pos2){obj.pos.push({line:o.map[1],start:pos2.start,end:pos2.end})}this._paras.push(obj)}else if(o.content.charAt(0)==="!"){var jj=42}}else if(o.type===LINK_OPEN){let bContinue=true;txt=_peekContent(ast,i,TEXT);link=o.attrs[0][1];if(this._map){pos=this._getColsExtent(txt?txt:link)}if(o.markup==="linkify"){let t=ast[i+1].content;if(t.toLowerCase().endsWith(".md")&&!t.startsWith("http")){bContinue=false}}if(bContinue){if(refLink=this._isRefLink(pos.line)){pos=this._getRefLinkPos(pos.line,refLink);obj={text:txt||null,inline:false,refKey:refLink,pos:pos}}else{start=this._getLineDisp(pos.line,pos.col);obj={inline:true,link:link,text:txt||null,pos:{line:pos.line,col:pos.col,start:start,end:start+=link.length-1}}}this._links.push(obj)}}else if(o.type===IMAGE){link=o.attrs[0][1];pos=this._getColsExtent(link);start=this._getLineDisp(pos.line,pos.col);obj={alt:o.content,pos:{line:pos.line,col:pos.col,start:start,end:start+=link.length-1}};if(this._refLinks[link]){obj.inline=false,obj.refKey=link}else{obj.inline=true,obj.link=link}this._images.push(obj)}else if(o.type===FENCE&&o.tag===CODE){pos=this._lineMap.get(o.map[0]+1);pos2=null;if(o.map[0]+1<o.map[1]){pos2=this._lineMap.get(o.map[1])}obj={code:o.content,pos:[{line:o.map[0]+1,start:pos.start,end:pos.end}]};if(pos2){obj.pos.push({line:o.map[1],start:pos2.start,end:pos2.end})}this._code.push(obj)}if(o.children){this._walkChildren(o.children,state)}}};AstMd.prototype._getLinks=function(){return this._links};AstMd.prototype._getParas=function(){return this._paras};AstMd.prototype._getImages=function(){return this._images};AstMd.prototype._getCode=function(){return this._code};AstMd.prototype._getLists=function(){return this._lists};AstMd.prototype._getRefLinks=function(){return this._refLinks};AstMd.prototype._getLineMap=function(){return this._lineMap};AstMd.prototype._testParas=function(regexp,firstMatch){var ret=null;var paras=this._getParas();try{for(let i=0;i<paras.length;i++){regexp.lastIndex=0;if(regexp.test(paras[i].text)){if(!ret){ret=[]}ret.push(paras[i]);if(firstMatch){break}}}}catch(e){}return ret?ret:null};AstMd.prototype._getColsExtent=function(txt){var lineNum,line,txt2,x=-1;for(lineNum=this._map[0];lineNum<=this._map[1];lineNum++){line=this._getLine(lineNum);if(txt.startsWith(HTTP)){txt2=txt.substr(HTTP.length)}if((x=line.indexOf(txt))<0){if(txt2){x=line.indexOf(txt2)}}if(x>=0){return{line:lineNum,col:x+1}}}return null};AstMd.prototype._getLineDisp=function(lineNum,col){var ret=-1;if(lineNum<=this._lineMap.size){ret=this._lineMap.get(lineNum).start;if(typeof col==="number"){ret+=col-1}}return ret};AstMd.prototype._getLine=function(lineNum){var start,end,line,pos;;if(lineNum<=this._lineMap.size){pos=this._lineMap.get(lineNum);start=pos.start;end=pos.end;line=this._data.substring(start,end+1)}return line};AstMd.prototype._isRefLink=function(line){var line=this._getLine(line);var match=line.match(RE_REFLINK);return match?match[1]:null};AstMd.prototype._getRefLinkPos=function(lineNum,refLink){var line=this._getLine(lineNum);var x=line.indexOf(refLink);var pos=this._lineMap.get(lineNum);var start=pos.start+x;return{line:lineNum,col:x+1,start:start,end:start+refLink.length-1}};AstMd.prototype._setPos=function(ar){return[ar[0]+1,ar[1]]};AstMd.prototype._loadLineMap=function(){let data,map,line=1,lastDisp,i;this._lineMap.clear();data=this._data;map=this._lineMap;if(data.length){lastDisp=0;for(i=0;i<data.length;i++){if(data.charAt(i)==="\n"){map.set(line++,{start:lastDisp,end:i});lastDisp=i+1;if(lastDisp===data.length){return map}}}map.set(line,{start:lastDisp,end:i-1})}return map};AstMd.prototype._createRefs=function(){var line,col,match,ref,start,i,j,x;var link,title,obj;var lineCount=this._lineMap.size;for(i=1;i<=lineCount;i++){line=this._getLine(i);if((x=this._utils.eatWhitespace(line,0))<0){continue}if(line.charAt(x)==="["){if(match=line.match(RE_BRACKET)){match=match[0];j=match.indexOf(":");match=match.substring(0,j+1);ref=match.replace(RE_DEL_BRACKET_COLON,"").trim();x+=match.length;link=line.substr(x).trim();title=undefined;if(link.charAt(0)==="<"){j=link.indexOf(">",1);if(j>=0){title=link.substring(j+1).trim();title=title.replace(/[\'\\(\)"']*/g,"");link=link.substring(1,j)}}else{if((j=this._utils.getIndexToWhitespace(link))>=0){title=link.substring(j+1).trim();title=title.replace(/[\"\'"]/g,"");link=link.substring(0,j)}}col=x+1;for(j=x;j<line.length;j++){if(this._utils.isWhitespace(line.charAt(j))){col++}else{break}}start=this._getLineDisp(i,col);obj={link:link,pos:{line:i,col:col,start:start,end:start+link.length-1}};if(title){obj.title=title}this._refLinks[ref]=obj}}}};function _peekContent(ast,i,type){var o,ret;if(ast[i].markup!=="linkify"){o=ast[i+1];if(o.type===type){ret=o.content}}return ret?ret:""};function _getLevel(level){var val=0;if(level.charAt(0)==="h"){val=level.charCodeAt(1)-48}return val};module.exports=AstMd;
@@ -1,6 +1,6 @@
1
1
  /*
2
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates.
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
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
- module.exports.ARRAY_EXPR="ArrayExpression";module.exports.ARROW_FUNC_EXPR="ArrowFunctionExpression";module.exports.ASSIGN_PATTERN="AssignmentPattern";module.exports.ASSIGN_EXPR="AssignmentExpression";module.exports.ASSIGNMENT_EXPR="AssignmentExpression";module.exports.AWAIT_EXPR="AwaitExpression";module.exports.BINARY_EXPR="BinaryExpression";module.exports.BLOCK_STMT="BlockStatement";module.exports.BREAK_STMT="BreakStatement";module.exports.CALL_EXPR="CallExpression";module.exports.CATCH_CLAUSE="CatchClause";module.exports.CLASS_BODY="ClassBody";module.exports.CLASS_DECLARATION="ClassDeclaration";module.exports.CLASS_EXPR="ClassExpression";module.exports.CONDITIONAL_EXPR="ConditionalExpression";module.exports.CONTINUE_STMT="ContinueStatement";module.exports.DO_WHILE_STMT="DoWhileStatement";module.exports.DEBUG_STMT="DebuggerStatement";module.exports.EMPTY_STMT="EmptyStatement";module.exports.EX_REST_PROP="ExperimentalRestProperty";module.exports.EX_SPREAD_STMT="ExperimentalSpreadProperty";module.exports.EXPR_STMT="ExpressionStatement";module.exports.FOR_STMT="ForStatement";module.exports.FOR_IN_STMT="ForInStatement";module.exports.FOR_OF_STMT="ForOfStatement";module.exports.FUNC_DECLARATION="FunctionDeclaration";module.exports.FUNC_EXPR="FunctionExpression";module.exports.IDENTIFIER="Identifier";module.exports.IF_STMT="IfStatement";module.exports.LOGIC_EXPR="LogicalExpression";module.exports.LABELED_STMT="LabeledStatement";module.exports.LITERAL="Literal";module.exports.MEMBER_EXPR="MemberExpression";module.exports.META_PROP="MetaProperty";module.exports.METH_DEF="MethodDefinition";module.exports.NEW_EXPR="NewExpression";module.exports.OBJ_EXPR="ObjectExpression";module.exports.OBJ_PATTERN="ObjectPattern";module.exports.PROGRAM="Program";module.exports.PROPERTY="Property";module.exports.REST_ELEM="RestElement";module.exports.RETURN_STMT="ReturnStatement";module.exports.SEQUENCE_EXPR="SequenceExpression";module.exports.SPREAD_ELEM="SpreadElement";module.exports.SUPER="Super";module.exports.SWITCH_CASE="SwitchCase";module.exports.SWITCH_STMT="SwitchStatement";module.exports.TAGGED_TEMPLATE_EXPR="TaggedTemplateExpression";module.exports.TEMPLATE_ELEM="TemplateElement";module.exports.TEMPLATE_LIT="TemplateLiteral";module.exports.THIS_EXPR="ThisExpression";module.exports.THROW_EXPR="ThrowExpression";module.exports.TRY_STMT="TryStatement";module.exports.UNARY_EXPR="UnaryExpression";module.exports.UPDATE_EXPR="UpdateExpression";module.exports.VAR_DECLARATION="VariableDeclaration";module.exports.VAR_DECLARATOR="VariableDeclarator";module.exports.WHILE_STMT="WhileStatement";module.exports.WITH_STMT="WithStatementt";module.exports.YIELD_EXPR="YieldExpression";module.exports.JSX_ID="JSXIdentifier";module.exports.JSX_NS_NAME="JSXNamespacedName";module.exports.JSX_EMPTY_EXPR="JSXEmptyExpression";module.exports.JSX_EXPR_CONTAINER="JSXExpressionContainer";module.exports.JSX_ELEM="JSXElement";module.exports.JSX_CLOSING_ELEM="JSXClosingElement";module.exports.JSX_OPENING_ELEM="JSXOpeningElement";module.exports.JSX_ATTRIB="JSXAttribute";module.exports.JSX_SPREAD_ATTRIB="JSXSpreadAttribute";module.exports.JSX_TEXT="JSXText";module.exports.EXPORT_DEFAULT_DECL="ExportDefaultDeclaration";module.exports.EXPORT_NAMED_DECL="ExportNamedDeclaration";module.exports.EXPORT_ALL_DECL="ExportAllDeclaration";module.exports.EXPORT_SPECIFIER="ExportSpecifier";module.exports.IMPORT_DECL="Importdeclaration";module.exports.IMPORT_EQUALS_DECL="TSImportEqualsDeclaration";module.exports.IMPORT_SPECIFIER="ImportSpecifier";module.exports.IMPORT_DEF_SPECIFIER="ImportDefaultSpecifier";module.exports.IMPORT_NS_SPECIFIER="ImportNamespaceSpecifier";module.exports.EXTERN_MOD_REF="TSExternalModuleReference";
6
+ module.exports.ARRAY_EXPR="ArrayExpression";module.exports.ARROW_FUNC_EXPR="ArrowFunctionExpression";module.exports.ASSIGN_PATTERN="AssignmentPattern";module.exports.ASSIGN_EXPR="AssignmentExpression";module.exports.ASSIGNMENT_EXPR="AssignmentExpression";module.exports.AWAIT_EXPR="AwaitExpression";module.exports.BINARY_EXPR="BinaryExpression";module.exports.BLOCK_STMT="BlockStatement";module.exports.BREAK_STMT="BreakStatement";module.exports.CALL_EXPR="CallExpression";module.exports.CATCH_CLAUSE="CatchClause";module.exports.CLASS_BODY="ClassBody";module.exports.CLASS_DECLARATION="ClassDeclaration";module.exports.CLASS_EXPR="ClassExpression";module.exports.CLASS_PROP="ClassProperty";module.exports.CONDITIONAL_EXPR="ConditionalExpression";module.exports.CONTINUE_STMT="ContinueStatement";module.exports.DO_WHILE_STMT="DoWhileStatement";module.exports.DEBUG_STMT="DebuggerStatement";module.exports.EMPTY_STMT="EmptyStatement";module.exports.EX_REST_PROP="ExperimentalRestProperty";module.exports.EX_SPREAD_STMT="ExperimentalSpreadProperty";module.exports.EXPR_STMT="ExpressionStatement";module.exports.FOR_STMT="ForStatement";module.exports.FOR_IN_STMT="ForInStatement";module.exports.FOR_OF_STMT="ForOfStatement";module.exports.FUNC_DECLARATION="FunctionDeclaration";module.exports.FUNC_EXPR="FunctionExpression";module.exports.IDENTIFIER="Identifier";module.exports.IF_STMT="IfStatement";module.exports.LOGIC_EXPR="LogicalExpression";module.exports.LABELED_STMT="LabeledStatement";module.exports.LITERAL="Literal";module.exports.MEMBER_EXPR="MemberExpression";module.exports.META_PROP="MetaProperty";module.exports.METH_DEF="MethodDefinition";module.exports.NEW_EXPR="NewExpression";module.exports.OBJ_EXPR="ObjectExpression";module.exports.OBJ_PATTERN="ObjectPattern";module.exports.PROGRAM="Program";module.exports.PROPERTY="Property";module.exports.REST_ELEM="RestElement";module.exports.RETURN_STMT="ReturnStatement";module.exports.SEQUENCE_EXPR="SequenceExpression";module.exports.SPREAD_ELEM="SpreadElement";module.exports.SUPER="Super";module.exports.SWITCH_CASE="SwitchCase";module.exports.SWITCH_STMT="SwitchStatement";module.exports.TAGGED_TEMPLATE_EXPR="TaggedTemplateExpression";module.exports.TEMPLATE_ELEM="TemplateElement";module.exports.TEMPLATE_LIT="TemplateLiteral";module.exports.THIS_EXPR="ThisExpression";module.exports.THROW_EXPR="ThrowExpression";module.exports.TRY_STMT="TryStatement";module.exports.UNARY_EXPR="UnaryExpression";module.exports.UPDATE_EXPR="UpdateExpression";module.exports.VAR_DECLARATION="VariableDeclaration";module.exports.VAR_DECLARATOR="VariableDeclarator";module.exports.WHILE_STMT="WhileStatement";module.exports.WITH_STMT="WithStatement";module.exports.YIELD_EXPR="YieldExpression";module.exports.JSX_ID="JSXIdentifier";module.exports.JSX_NS_NAME="JSXNamespacedName";module.exports.JSX_EMPTY_EXPR="JSXEmptyExpression";module.exports.JSX_EXPR_CONTAINER="JSXExpressionContainer";module.exports.JSX_ELEM="JSXElement";module.exports.JSX_CLOSING_ELEM="JSXClosingElement";module.exports.JSX_OPENING_ELEM="JSXOpeningElement";module.exports.JSX_ATTRIB="JSXAttribute";module.exports.JSX_SPREAD_ATTRIB="JSXSpreadAttribute";module.exports.JSX_TEXT="JSXText";module.exports.EXPORT_DEFAULT_DECL="ExportDefaultDeclaration";module.exports.EXPORT_NAMED_DECL="ExportNamedDeclaration";module.exports.EXPORT_ALL_DECL="ExportAllDeclaration";module.exports.EXPORT_ASSIGNMENT="TSExportAssignment";module.exports.EXPORT_SPECIFIER="ExportSpecifier";module.exports.IMPORT_DECL="ImportDeclaration";module.exports.IMPORT_EQUALS_DECL="TSImportEqualsDeclaration";module.exports.IMPORT_SPECIFIER="ImportSpecifier";module.exports.IMPORT_DEF_SPECIFIER="ImportDefaultSpecifier";module.exports.IMPORT_NS_SPECIFIER="ImportNamespaceSpecifier";module.exports.ANY_KEYWORD="TSAnyKeyword";module.exports.ARRAY_TYPE="TSArrayType";module.exports.AS_EXPR="TSAsExpression";module.exports.BOOLEAN_KEYWORD="TSBooleanKeyword";module.exports.EXTERN_MOD_REF="TSExternalModuleReference";module.exports.ENUM_TS_DECL="TSEnumDeclaration";module.exports.FUNCTION_TYPE="TSFunctionType";module.exports.INTERFACE_BODY="TSInterfaceBody";module.exports.INTERFACE_DECL="TSInterfaceDeclaration";module.exports.INTERSECTION_TYPE="TSIntersectionType";module.exports.LITERAL_TYPE="TSLiteralType";module.exports.NUMBER_KEYWORD="TSNumberKeyword";module.exports.OBJECT_KEYWORD="TSObjectKeyword";module.exports.OPTIONAL_TYPE="TSOptionalType";module.exports.PROPERTY_SIGNATURE="TSPropertySignature";module.exports.STRING_KEYWORD="TSStringKeyword";module.exports.TUPLE_TYPE="TSTupleType";module.exports.TYPE_ALIAS_DECL="TSTypeAliasDeclaration";module.exports.TYPE_LITERAL="TSTypeLiteral";module.exports.TYPE_REF="TSTypeReference";module.exports.UNION_TYPE="TSUnionType";
package/lib/Comments.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates.
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
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
  */
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates.
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
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
  */
package/lib/Components.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates.
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
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 PROP_SLOTS="slots";const PROP_PROPS="props";const PROP_EVENTS="events";const PROP_STYLECLASSES="styleClasses";const PROP_IMPLEMENTS="implements";const PROP_FOLDER="folder";const PROP_VERSION="version";const PROP_UNSUP_THEME="unsupTheme";const PROP_STATUS="status";const PROP_SUBCOMPONENT_TYPE="subcomponentType";const PROP_TYPE="type";const PROP_PACK="pack";const DEPRECATED="deprecated";const PROPERTY_VALUE="propertyValue";const PACK_PRIVATE="packPrivate";const DYNAMIC_FORM_ELEM="DynamicFormElement";const DYNAMIC_TABLE_ELEM="DynamicTableElement";const REGXPR=/string|number|object|array|boolean|[\|.<>]/gi;function Components(nd,runMode,compSvcs,urlBase,urls,filePaths,jetCore,msgCtx,runOpts,utils){this._nd=nd;this._tagLookup={};this._styleLookup={};this._implements={};this._path=null;this._reqAttrs=null;this._utils=utils;this._compSvcs=compSvcs;this._isAMD=runMode==="amd";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._isDebug=msgCtx.isDebug;this._isVerbose=msgCtx.isVerbose;this._count=0;this._isOk=true;this._runOpts=runOpts;this._init(urlBase,urls,filePaths,jetCore)};Components.prototype.isTag=function(tagName){return!!this._tagLookup[tagName]};Components.prototype.isTagAttr=function(tagName,attrName){return this.isTagProp(tagName,attrName)};Components.prototype.isTagDeprecated=function(tag){var tag,stats,stat,ret=null,i;if(tag=this._tagLookup[_removeChevrons(tag)]){if(stats=tag.status){for(i=0;i<stats.length;i++){stat=stats[i];if(stat.type===DEPRECATED){ret={since:stat.since,description:stat.description};break}}}}return ret};Components.prototype.isTagAttrDeprecated=function(tagName,attrName){var prop,stats,stat,i;prop=this.getTagProp(tagName,attrName);if(prop&&prop.status){stats=prop.status;for(i=0;i<stats.length;i++){stat=stats[i];if(stat.type===DEPRECATED&&!stat.value){return{since:stat.since,description:stat.description}}}}return null};Components.prototype.isTagAttrTranslatable=function(tag,attr){var prop=this.getTagProp(tag,attr);return prop&&prop.translatable};Components.prototype.isTagAttrReadOnly=function(tag,attr){var prop=this.getTagProp(tag,attr);return prop&&prop.readonly};Components.prototype.isTagProp=function(tagName,propName){return!!this.getTagProp(tagName,propName)};Components.prototype.getTagProp=function(tagName,propName){var tag,props;tag=this._tagLookup[_removeChevrons(tagName)];props=tag?tag[PROP_PROPS]:null;if(props){propName=_deCamelCaseProp(propName)}return props?props[propName]:false};Components.prototype.getTagPropType=function(tagName,propName){var prop,ret;if(prop=this.getTagProp(tagName,propName)){ret=prop?prop.type:undefined}return ret};Components.prototype.getTagMetadata=function(tag){return this._tagLookup[_removeChevrons(tag)]};Components.prototype.isTagEvent=function(tagName,eventName){var propName,o,b;o=this._tagLookup[tagName];if(o){if(eventName.startsWith("on-")){b=o.events&&o.events[eventName];if(b)return b;if(o.implements&&(o.implements.includes(DYNAMIC_FORM_ELEM)||o.implements.includes(DYNAMIC_TABLE_ELEM))){return true}if(eventName.endsWith("-changed")){if(o.props){propName=eventName.replace("-changed","").substring(3);return!!o.props[propName]}}}}return false};Components.prototype.isTagStyle=function(tag,style){if(this._tagLookup[tag]){let tags,styles,sc;if(tags=Object.keys(this._tagLookup)){for(let i=0;i<tags.length;i++){if(styles=this._tagLookup[tags[i]].styleClasses){if(sc=styles[style]){return true}}}}}return false};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._tagLookup[tagName];return!!(o&&o.slots&&o.slots[slotName])};Components.prototype.getPreferredSlotContent=function(tag,slotName){var o,slot,prefContent=null,content,comps=null;if(this._utils.hasAnyProps(this._implements)){if(o=this._tagLookup[tag]){if(o.slots){if(slot=o.slots[slotName]){if(prefContent=slot.preferredContent){prefContent.forEach(impl=>{if(content=this._implements[impl]){if(!comps){comps=[]}comps.push(...content)}})}}}}}return{interfaces:prefContent,components:comps}};Components.prototype.getTagSlotMetadata=function(tag,slot){var o,ret;if(o=this._tagLookup[tag]){if(o.slots){if(slot=o.slots[slot]){ret=slot}}}return ret};Components.prototype.hasTagAttrValues=function(tagName,attrName){var tag,props,prop,propName,ret=false;tag=this._tagLookup[tagName];if(tag){props=tag[PROP_PROPS];if(props){propName=_deCamelCaseProp(attrName);prop=props[propName];if(prop){ret=!!prop.enums}}}return ret};Components.prototype.isTagAttrValue=function(tagName,attrName,value){var tag,props,prop,propName,ret=false;tag=this._tagLookup[tagName];if(tag){props=tag[PROP_PROPS];if(props){propName=_deCamelCaseProp(attrName);prop=props[propName];if(prop&&prop.enums){ret=prop.enums.indexOf(value)>=0}}}return ret};Components.prototype.isTagAttrEnumDeprecated=function(tag,attr,val){var tag,props,prop,propName,stats,stat,i,ret=false;tag=this._tagLookup[tag];if(tag){props=tag[PROP_PROPS];if(props){propName=_deCamelCaseProp(attr);prop=props[propName];if(prop&&prop.status){stats=prop.status;for(i=0;i<stats.length;i++){stat=stats[i];if(stat.type===DEPRECATED&&stat.target==="propertyValue"){if(stat.value&&stat.value.includes(val)){ret={since:stat.since,description:stat.description}}break}}}}}return ret};Components.prototype.isTagSupportedInTheme=function(tag,theme){var o,unsup,ret=true;o=this._tagLookup[tag];if(o){unsup=o[PROP_UNSUP_THEME];if(unsup){ret=!unsup.includes(theme)}}return ret};Components.prototype.isAttrSupportedInTheme=function(tag,attr,theme){var o,props,prop,propName,unsup,ret=true;o=this._tagLookup[tag];if(o){props=o[PROP_PROPS];if(props){propName=_deCamelCaseProp(attr);prop=props[propName];if(prop){unsup=prop[PROP_UNSUP_THEME];if(unsup){ret=!unsup.includes(theme)}}}}return ret};Components.prototype.isTagPackPrivate=function(tag){var o,ret;tag=_removeChevrons(tag);if(o=this._tagLookup[tag]){ret=o[PROP_SUBCOMPONENT_TYPE]===PACK_PRIVATE}return ret};Components.prototype.getRequiredAttrs=function(tagName){var tag,props,attr,attrName,obj,ret=null;tagName=_removeChevrons(tagName);if(this._reqAttrs){let r=this._reqAttrs[tagName];if(r){return typeof r==="boolean"?null:r}}tag=this._tagLookup[tagName];if(tag&&tag.props){if(!this._reqAttrs){this._reqAttrs={}}if(!this._reqAttrs[tagName]){this._reqAttrs[tagName]=true}props=tag.props;for(attrName in props){attr=props[attrName];if(attr.required){if(!obj){obj=[]}obj.push(_deCamelCaseProp(attrName))}}}if(obj&&obj.length){this._reqAttrs[tagName]=obj;ret=obj}return ret};Components.prototype.getNames=function(){var name,a=[];for(name in this._tagLookup){a.push({name:name,version:this._tagLookup[name].version})}return a};Components.prototype.getCount=function(){return this._count};Components.prototype.isOk=function(){return this._isOk};Components.prototype._init=function(base,urls,filePaths,jetCore){if(this._isAMD){return}if(base){base=base.trim();if(base.charAt(base.length-1)!=="/"){base=base+"/"}}else{base=""}this._processFilePaths(filePaths);this._processUrls(base,urls);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,true)}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)){obj=this._readComponentJson(fpath);if(obj){if(obj.type&&obj.type==="pack"){continue}this.processComponentJson(obj,this._nd.path.dirname(fpath),true)}continue}this._recurse(fpath)}}if(this._isDebug){this._debug("-".repeat(70))}};Components.prototype._recurse=function(fpath){var dirs,inFile,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){inFile=this._nd.path.join(fpath,COMPONENT_JSON);if(this._isDebug){this._debug(" processing "+inFile+"...")}obj=this._readComponentJson(inFile);if(obj){if(!obj.type||obj.type==="composite"){this.processComponentJson(obj,fpath,true)}}else{return}}var curPath=this._nd.path.join(fpath,inFile);if(this._nd.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,false)){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,true)}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.processComponentJson=function(obj,fromLocation,wantDecache){var comp,props,events,event,compName;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,wantDecache)}if(!this._compSvcs.validateComponentJson(obj,fromLocation)){if(wantDecache){this._nd.decache(obj)}this._isOk=false;return false}}compName=obj.pack?obj.pack+"-"+obj.name:obj.name;if(this._tagLookup[compName]){this._warn(`Ignoring duplicate component '${compName}' at '${fromLocation}'`);return}this._tagLookup[compName]=comp={};comp[PROP_FOLDER]=fromLocation;comp[PROP_VERSION]=obj.version;if(obj.slots){comp[PROP_SLOTS]=obj.slots}if(obj.properties){comp[PROP_PROPS]=props={};this._extractProps(props,null,obj.properties,obj.name)}if(obj.events){comp[PROP_EVENTS]=events={};for(event in obj.events){event=_deCamelCaseEvent(event);events[event]=true}}if(obj.implements){comp[PROP_IMPLEMENTS]=obj.implements;this._processImplements(compName,obj.implements)}if(obj.extension&&obj.extension.theme&&obj.extension.theme.unsupportedThemes){comp[PROP_UNSUP_THEME]=obj.extension.theme.unsupportedThemes}if(obj.subcomponentType){comp[PROP_SUBCOMPONENT_TYPE]=obj.subcomponentType}if(obj.type){comp[PROP_TYPE]=obj.type}if(obj.pack){comp[PROP_PACK]=obj.pack}if(obj.status){comp[PROP_STATUS]=obj.status}if(obj.styleClasses){comp[PROP_STYLECLASSES]=this._extractStyles(obj.styleClasses)}if(wantDecache){this._nd.decache(obj)}this._count++;return true};Components.prototype._extractProps=function(propObj,propSoFar,properties,name,rdonly){var prop,newProp,thisProp,soFar,obj,stats,stat,dep,i;for(prop in properties){newProp=_deCamelCaseProp(prop);soFar=(propSoFar?propSoFar+".":"")+newProp;propObj[soFar]=obj={};thisProp=properties[prop];if(thisProp.enumValues){if(Array.isArray(thisProp.enumValues)){obj.enums=thisProp.enumValues}else{this._error("Web component'"+name+"' property '"+soFar+"' has invalid 'enumValues' in component.json")}}if(thisProp.status){stats=thisProp.status;for(i=0;i<stats.length;i++){stat=stats[i];if(stat.type===DEPRECATED){if(stat.since||stat.description){dep={};if(stat.value&&stat.target===PROPERTY_VALUE){dep.value=stat.value}dep.type=DEPRECATED;dep.target=PROPERTY_VALUE;if(stat.since){dep.since=stat.since}if(stat.description){dep.description=stat.description}if(!obj.status){obj.status=[]}obj.status.push(dep)}}}}if(thisProp.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.translatable){obj.translatable=true}if(typeof thisProp.readonly==="boolean"){obj.readonly=thisProp.readOnly}else{if(rdonly){obj.readonly=true}}if(thisProp.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._processImplements=function(compName,impls){var i,impl;if(Array.isArray(impls)){for(i=0;i<impls.length;i++){impl=impls[i];if(this._implements[impl]){this._implements[impl].push(compName)}else{this._implements[impl]=[compName]}}}};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._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)};function _deCamelCaseProp(str){return str.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase()};function _deCamelCaseEvent(str){return"on-"+_deCamelCaseProp(str)};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 PROP_SLOTS="slots";const PROP_PROPS="props";const PROP_EVENTS="events";const PROP_STYLECLASSES="styleClasses";const PROP_IMPLEMENTS="implements";const PROP_FOLDER="folder";const PROP_VERSION="version";const PROP_UNSUP_THEME="unsupTheme";const PROP_STATUS="status";const PROP_SUBCOMPONENT_TYPE="subcomponentType";const PROP_TYPE="type";const PROP_PACK="pack";const DEPRECATED="deprecated";const PROPERTY_VALUE="propertyValue";const PROPERTY_TYPE="propertyType";const PACK_PRIVATE="packPrivate";const DYNAMIC_FORM_ELEM="DynamicFormElement";const DYNAMIC_TABLE_ELEM="DynamicTableElement";const VB_FRAGMENT_ELEM="VbFragmentElement";const REGXPR=/string|number|object|array|boolean|[\|.<>]/gi;function Components(nd,runMode,compSvcs,urlBase,urls,filePaths,metaLib,jetCore,msgCtx,runOpts,utils){this._nd=nd;this._tagLookup={};this._styleLookup={};this._path=null;this._reqAttrs=null;this._metaLib=metaLib;this._utils=utils;this._compSvcs=compSvcs;this._isAMD=runMode==="amd";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._isDebug=msgCtx.isDebug;this._isVerbose=msgCtx.isVerbose;this._count=0;this._isOk=true;this._runOpts=runOpts;this._init(urlBase,urls,filePaths,jetCore)};Components.prototype.isTag=function(tagName){return!!this._tagLookup[tagName]};Components.prototype.isTagAttr=function(tagName,attrName){return this.isTagProp(tagName,attrName)};Components.prototype.isTagDeprecated=function(tag){var tag,stats,status,ret=null;if(tag=this._tagLookup[_removeChevrons(tag)]){if(stats=tag.status){for(status of stats){if(!status.hasOwnProperty("target")){ret=status;break}}}}return ret};Components.prototype.isTagAttrDeprecated=function(tagName,attrName){var prop,status,stats,o,ret=null;prop=this.getTagProp(tagName,attrName);if(prop&&(stats=prop.status)){ret=[];for(status of stats){if(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.isTagAttrTranslatable=function(tag,attr){var prop=this.getTagProp(tag,attr);return prop&&prop.translatable};Components.prototype.isTagAttrReadOnly=function(tag,attr){var prop=this.getTagProp(tag,attr);return prop&&prop.readonly};Components.prototype.isTagProp=function(tagName,propName){return!!this.getTagProp(tagName,propName)};Components.prototype.getTagProp=function(tagName,propName){var tag,props;tag=this._tagLookup[_removeChevrons(tagName)];props=tag?tag[PROP_PROPS]:null;if(props){propName=propName.charAt(0)===":"?propName.substring(1):propName;propName=_deCamelCaseProp(propName)}return props?props[propName]:false};Components.prototype.getTagPropType=function(tagName,propName){var prop,ret;if(prop=this.getTagProp(tagName,propName)){ret=prop?prop.type:undefined}return ret};Components.prototype.getTagMetadata=function(tag){return this._tagLookup[_removeChevrons(tag)]};Components.prototype.isTagEvent=function(tagName,eventName){var propName,o,b;o=this._tagLookup[tagName];if(o){if(eventName.startsWith("on-")){b=o.events&&o.events[eventName];if(b)return b;if(o.implements&&(o.implements.includes(DYNAMIC_FORM_ELEM)||o.implements.includes(DYNAMIC_TABLE_ELEM)||o.implements.includes(VB_FRAGMENT_ELEM))){return true}if(eventName.endsWith("-changed")){if(o.props){propName=eventName.replace("-changed","").substring(3);return!!o.props[propName]}}}}return false};Components.prototype.isTagStyle=function(tag,style){if(this._tagLookup[tag]){let tags,styles,sc;if(tags=Object.keys(this._tagLookup)){for(let i=0;i<tags.length;i++){if(styles=this._tagLookup[tags[i]].styleClasses){if(sc=styles[style]){return true}}}}}return false};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._tagLookup[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._tagLookup[tag]){if(o.slots){if(slot=o.slots[slotName]){if(prefContent=slot.preferredContent){prefContent.forEach(impl=>{if(content=impls[impl]){if(!comps){comps=[]}comps.push(...content)}})}}}}}return prefContent||comps?{interfaces:prefContent,components:comps}:null};Components.prototype.getTagSlotMetadata=function(tag,slot){var o,ret;if(o=this._tagLookup[tag]){if(o.slots){if(slot=o.slots[slot]){ret=slot}}}return ret};Components.prototype.hasTagAttrValues=function(tagName,attrName){var prop,ret=false;if(prop=this.getTagProp(tagName,attrName)){ret=!!prop.enumValues}return ret};Components.prototype.isTagAttrValue=function(tagName,attrName,value){var prop,ret;if(prop=this.getTagProp(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.getTagProp(tag,attr)){if(prop.status){stats=prop.status;for(status of stats){if(status.type===DEPRECATED&&status.target==="propertyValue"){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;o=this._tagLookup[tag];if(o){unsup=o[PROP_UNSUP_THEME];if(unsup){ret=!unsup.includes(theme)}}return ret};Components.prototype.isAttrSupportedInTheme=function(tag,attr,theme){var prop,unsup,ret=true;if(prop=this.getTagProp(tag,attr)){if(unsup=prop[PROP_UNSUP_THEME]){ret=!unsup.includes(theme)}}return ret};Components.prototype.isTagPackPrivate=function(tag){var o,ret;tag=_removeChevrons(tag);if(o=this._tagLookup[tag]){ret=o[PROP_SUBCOMPONENT_TYPE]===PACK_PRIVATE}return ret};Components.prototype.getRequiredAttrs=function(tagName){var tag,props,attr,attrName,obj,ret=null;tagName=_removeChevrons(tagName);if(this._reqAttrs){let r=this._reqAttrs[tagName];if(r){return typeof r==="boolean"?null:r}}tag=this._tagLookup[tagName];if(tag&&tag.props){if(!this._reqAttrs){this._reqAttrs={}}if(!this._reqAttrs[tagName]){this._reqAttrs[tagName]=true}props=tag.props;for(attrName in props){attr=props[attrName];if(attr.required){if(!obj){obj=[]}obj.push(_deCamelCaseProp(attrName))}}}if(obj&&obj.length){this._reqAttrs[tagName]=obj;ret=obj}return ret};Components.prototype.getNames=function(){var name,a=[];for(name in this._tagLookup){a.push({name:name,version:this._tagLookup[name].version})}return a};Components.prototype.getCount=function(){return this._count};Components.prototype.isOk=function(){return this._isOk};Components.prototype._init=function(base,urls,filePaths,jetCore){if(this._isAMD){return}if(base){base=base.trim();if(base.charAt(base.length-1)!=="/"){base=base+"/"}}else{base=""}this._processFilePaths(filePaths);this._processUrls(base,urls);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,true)}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)){obj=this._readComponentJson(fpath);if(obj){if(obj.type&&obj.type==="pack"){continue}this.processComponentJson(obj,this._nd.path.dirname(fpath),true)}continue}this._recurse(fpath)}}if(this._isDebug){this._debug("-".repeat(70))}};Components.prototype._recurse=function(fpath){var dirs,inFile,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){inFile=this._nd.path.join(fpath,COMPONENT_JSON);if(this._isDebug){this._debug(" processing "+inFile+"...")}obj=this._readComponentJson(inFile);if(obj){if(!obj.type||obj.type==="composite"){this.processComponentJson(obj,fpath,true)}}else{return}}var curPath=this._nd.path.join(fpath,inFile);if(this._nd.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,false)){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,true)}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.processComponentJson=function(obj,fromLocation){var comp,props,events,event,compName;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(!this._compSvcs.validateComponentJson(obj,fromLocation)){this._isOk=false;return false}}compName=obj.pack?obj.pack+"-"+obj.name:obj.name;if(this._tagLookup[compName]){this._warn(`Ignoring duplicate component '${compName}' at '${fromLocation}'`);return true}this._tagLookup[compName]=comp={};comp[PROP_FOLDER]=fromLocation;comp[PROP_VERSION]=obj.version;if(obj.slots){comp[PROP_SLOTS]=obj.slots}if(obj.properties){comp[PROP_PROPS]=props={};this._extractProps(props,null,obj.properties,obj.name)}if(obj.events){comp[PROP_EVENTS]=events={};for(event in obj.events){event=_deCamelCaseEvent(event);events[event]=true}}if(obj.implements){comp[PROP_IMPLEMENTS]=obj.implements;this._metaLib.processImplements(compName,obj.implements)}if(obj.extension&&obj.extension.theme&&obj.extension.theme.unsupportedThemes){comp[PROP_UNSUP_THEME]=obj.extension.theme.unsupportedThemes}if(obj.subcomponentType){comp[PROP_SUBCOMPONENT_TYPE]=obj.subcomponentType}if(obj.type){comp[PROP_TYPE]=obj.type}if(obj.pack){comp[PROP_PACK]=obj.pack}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,newProp,thisProp,soFar,obj;for(prop in properties){newProp=_deCamelCaseProp(prop);soFar=(propSoFar?propSoFar+".":"")+newProp;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("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._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)};function _deCamelCaseProp(str){return str.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase()};function _deCamelCaseEvent(str){return"on-"+_deCamelCaseProp(str)};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
@@ -1,6 +1,6 @@
1
1
  /*
2
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates.
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- var nodeDeps;const Helper=require("./ConfigLib");const MACROS=require("../lib/macros");var JET_VERSIONS;var DEFAULT_JETVER;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){this._path=iniPath;this._dir=null;this._config=null;this._tsconfig=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._severity=severity;this._helper=new Helper(this,nd,severity,utils,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();DEFAULT_JETVER=nd.jetver.getDefault();this._cliGroups=cliGroups;this._cliSev=cliSev;nodeDeps=nd;if(iniPath){this._init(base,iniPath)}};Config.prototype.getConfig=function(){var tmp=JSON.parse(JSON.stringify(this._config));if(tmp._sev){delete tmp._sev}return tmp};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.getComponentOptions=function(){return this._config.componentOptions};Config.prototype.getTsConfig=function(){return this._config.tsconfig};Config.prototype.getTsConfigObj=function(){return this._tsconfig};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.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.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){var i,s,val,val2,bUseDefaults=false;if(typeof iniPath==="string"){this._dir=nodeDeps.path.dirname(iniPath);bUseDefaults=this._loadConfig(iniPath);if(this._bErrors){return}}else{this._config=iniPath;this._dir=nodeDeps.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._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=nodeDeps.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._config)){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(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=false;this._config.builtinJetWcRules=false;this._config.builtinJetWcOracleRules=false}}this._config.jetPagesOnly=!!this._config.jetPagesOnly;if(!this._config.files){this._config.files=[]}if(!this._config.options){this._config.options={}}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();val2=val.split(".");for(i=0;i<val2.length;i++){s=parseInt(val2[i]);if(s===NaN){this._error(`Config entry 'jetVer' --> '${val}' is not a valid version string`);this._bErrors=true;return}val2[i]=""+s}val=val2.join(".");if(val2.length!==3||val2[2]==="0"){s=val2.length===3;val2=nodeDeps.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=DEFAULT_JETVER}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.processTsConfig()){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=nodeDeps.path.resolve(nodeDeps.process.cwd(),this._config.tempDir)}}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()}};Config.prototype.validateRetCode=function(val,cb){return this._helper.validateRetCode(val,cb)};Config.prototype._cleanConfigPaths=function(){var src,i,ftype,dir;if(!this._config.extends){this._info("[Info]: Using config base '"+this._config.base+"'","I")}src=this._config.files;if(src){for(i=0;i<src.length;i++){if(!src[i].startsWith("http")){if(!nodeDeps.path.isAbsolute(src[i])){src[i]=nodeDeps.path.normalize(src[i]);src[i]=nodeDeps.path.resolve(this._config.base,src[i])}}}}src=this._config.exclude;if(src){for(i=0;i<src.length;i++){if(!nodeDeps.path.isAbsolute(src[i])){src[i]=nodeDeps.path.normalize(src[i]);src[i]=nodeDeps.path.resolve(this._config.base,src[i])}}}src=this._config.components;if(src){for(i=0;i<src.length;i++){if(!nodeDeps.path.isAbsolute(src[i])){dir=nodeDeps.path.normalize(src[i]);dir=nodeDeps.path.resolve(this._config.base,dir);this._config.components[i]=dir}}}src=this._config.outPath;if(src&&src!=="$noout"){if(!nodeDeps.path.isAbsolute(src)){src=nodeDeps.path.normalize(src);src=nodeDeps.path.resolve(this._config.base,src);this._config.outPath=src}}src=this._config.rulePacks;if(src){for(i=0;i<src.length;i++){if(!nodeDeps.path.isAbsolute(src[i].path)){dir=nodeDeps.path.normalize(src[i].path);src[i].path=nodeDeps.path.resolve(this._config.base,dir)}if(src[i].path.endsWith(".zip")){continue}ftype=nodeDeps.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}}}src=this._config.tsconfig;if(src&&typeof src==="string"){if(!nodeDeps.path.isAbsolute(src)){dir=nodeDeps.path.normalize(src);dir=nodeDeps.path.resolve(this._config.base,dir)}else{dir=src}if(dir.endsWith(TSCONFIG)){dir=nodeDeps.path.dirname(dir)}src=this._loadTsConfig(nodeDeps.path.join(dir,TSCONFIG));if(src){this._config.tsconfig=dir;this._tsconfig=src}else{this._bErrors=true;return}}if(this._bErrors){return};};Config.prototype._cleanBase=function(){var p,ft;p=this._config.base;p=nodeDeps.path.normalize(p);p=nodeDeps.path.resolve(this._dir,p);ft=nodeDeps.fsUtils.getFileType(p);if(ft!=="d"){this._error(`Config file 'base' is not a directory - '${p}'`);this._bErrors=true;return false}p=nodeDeps.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;try{stats=nodeDeps.fs.statSync(iniPath);if(!stats.isFile()){this._warn("\n[Warn]: Config file '"+iniPath+"' not found. Using defaults.\n");bUseDefaults=true}else{data=nodeDeps.fs.readFileSync(iniPath,"utf8");data=nodeDeps.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(nodeDeps.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,followLinks:true,severity:this._severity.ALL,format:"prose",ecmaVer:this._helper.getDefaultEcmaVer(),options:{verbose:false,color:true}}}return bUseDefaults};Config.prototype._checkProperties=function(){return this._helper.checkPropNames()};Config.prototype._loadTsConfig=function(fp){return nodeDeps.jsonLoader.load(fp,nodeDeps,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;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=nodeDeps.path.normalize(path);incPath=nodeDeps.path.resolve(this._dir,incPath);comma=_isTrailingComma(line,x+AT_INCLUDE.length,this._utils);try{if(this._isDebug){this._debug("Reading @include -> "+incPath)}insert=nodeDeps.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
+ var nodeDeps;const Helper=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,cbDebug,jetVer){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._severity=severity;this._helper=new Helper(this,nd,severity,utils,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;nodeDeps=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.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.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.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.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=nodeDeps.path.dirname(iniPath);bUseDefaults=this._loadConfig(iniPath);if(this._bErrors){return}}else{this._config=iniPath;this._dir=nodeDeps.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;cbDebug(this._isVerbose,this._isDebug);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=nodeDeps.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._config)){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._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();val2=val.split(".");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=nodeDeps.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.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=nodeDeps.path.resolve(nodeDeps.process.cwd(),this._config.tempDir)}}if(!this._helper.processTypeScript()){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;if(!this._config.extends){this._info("[Info]: Using config base '"+this._config.base+"'","I")}src=this._config.files;if(src){for(i=0;i<src.length;i++){if(!src[i].startsWith("http")){if(!nodeDeps.path.isAbsolute(src[i])){src[i]=nodeDeps.path.normalize(src[i]);src[i]=nodeDeps.path.resolve(this._config.base,src[i])}}}}src=this._config.exclude;if(src){for(i=0;i<src.length;i++){if(!nodeDeps.path.isAbsolute(src[i])){src[i]=nodeDeps.path.normalize(src[i]);src[i]=nodeDeps.path.resolve(this._config.base,src[i])}}}src=this._config.components;if(src){for(i=0;i<src.length;i++){if(!nodeDeps.path.isAbsolute(src[i])){dir=nodeDeps.path.normalize(src[i]);dir=nodeDeps.path.resolve(this._config.base,dir);this._config.components[i]=dir}}}src=this._config.outPath;if(src&&src!=="$noout"){if(!nodeDeps.path.isAbsolute(src)){src=nodeDeps.path.normalize(src);src=nodeDeps.path.resolve(this._config.base,src);this._config.outPath=src}}src=this._config.rulePacks;if(src){for(i=0;i<src.length;i++){if(!nodeDeps.path.isAbsolute(src[i].path)){dir=nodeDeps.path.normalize(src[i].path);src[i].path=nodeDeps.path.resolve(this._config.base,dir)}if(src[i].path.endsWith(".zip")){continue}ftype=nodeDeps.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(!nodeDeps.path.isAbsolute(src)){dir=nodeDeps.path.normalize(src);dir=nodeDeps.path.resolve(this._config.base,dir)}else{dir=src}if(!dir.endsWith(TSCONFIG)){dir=nodeDeps.path.join(dir,TSCONFIG)}this._config.typescript.tsconfig=dir}if(this._bErrors){return};};Config.prototype._cleanBase=function(){var p,ft;p=this._config.base;p=nodeDeps.path.normalize(p);p=nodeDeps.path.resolve(this._dir,p);ft=nodeDeps.fsUtils.getFileType(p);if(ft!=="d"){this._error(`Config file 'base' is not a directory - '${p}'`);this._bErrors=true;return false}p=nodeDeps.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;try{stats=nodeDeps.fs.statSync(iniPath);if(!stats.isFile()){this._warn("\n[Warn]: Config file '"+iniPath+"' not found. Using defaults.\n");bUseDefaults=true}else{data=nodeDeps.fs.readFileSync(iniPath,"utf8");data=nodeDeps.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(nodeDeps.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 nodeDeps.jsonLoader.load(fp,nodeDeps,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;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=nodeDeps.path.normalize(path);incPath=nodeDeps.path.resolve(this._dir,incPath);comma=_isTrailingComma(line,x+AT_INCLUDE.length,this._utils);try{if(this._isDebug){this._debug("Reading @include -> "+incPath)}insert=nodeDeps.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/ConfigLib.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates.
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const GROUPS=require("./groups");const COMPOSITES="jet-composites";const TYPE_STRING="string";const TYPE_BOOLEAN="boolean";const AUTO="auto";const ERRORS="errors";const UNDEF="undefined";const NUMBER="number";const TOP_PROPS=["rulePacks","ruleMods","builtinJetRules","builtinCspRules","builtinSpocRules","builtinJetWcRules","builtinJetWcOracleRules","severity","groups","defGroups","ruleNames","base","files","exclude","tsconfig","jetPagesOnly","format","proseFormat","lineFormat","outPath","tabs","messages","addFileList","title","jetVer","components","componentUrls","componentOptions","stylesets","ecmaVer","ruleDescriptions","rulesFired","userDefs","options","comments","extends","extendOptions","nameSpaces","followLinks","tempDir","tokens","common","$JetCore","sevMap","theme","ojet","appendFileList"];const NOT_AMD=["addFileList","base","components","componentOptions","componentUrls","extends","extendOptions","files","exclude","followLinks","outPath","rulePacks","tempDir","tokens","tsconfig"];const OPTIONS_PROPS=["debug","verbose","color","msgid","ruleName","retCode","rc","ojetUpdate","$unittest","xex"];const THEMES=["redwood","stable","alta","none"];const DEF_THEME="Alta";const DEF_ECMAVER=11;const DEF_COMMENTS=false;const DEF_RULE_DESCRIPT="none";const DEF_GROUPS=["all"];const DEF_RETCODE="auto";const ECMA_VER=[5,6,7,8,9,10,11];const ECMA_YEAR=[-1,2015,2016,2017,2018,2019,2020];function CfgLib(oConfig,nodeDeps,sevLib,utils,msgCtx,modeCtx){this._oConfig=oConfig;this._config=null;this._dir=null;this._sevLib=sevLib;this._utils=utils;this._nd=nodeDeps;this._msgCtx=msgCtx;this._modeCtx=modeCtx;this._isVerbose=msgCtx.isVerbose;this._isCLI=modeCtx.isCLI||modeCtx.isOJETCLI;this._error=msgCtx.error;this._warn=msgCtx.warn;this._info=msgCtx.info};CfgLib.prototype.processWebComponents=function(){var dir,o,t,i;var config=this._config;if(config.componentUrlBase){if(!typeof config.componentUrlBase===TYPE_STRING){this._error("Config entry 'componentUrlBase' must be a string!");return false}}if(config.componentUrls){if(typeof config.componentUrls===TYPE_STRING){config.componentUrls=[config.componentUrls]}else if(!Array.isArray(config.componentUrls)){this._error("Config entry 'componentUrls' must be a string or an aray of strings!");return false}for(i=0;i<this._config.componentUrls.length;i++){config.componentUrls[i]=config.componentUrls[i].trim();if(config.componentUrls[i].length===0){config.componentUrls.splice(i,1);i--}}}if(!config.components){if(this._isCLI&&!this._isOJET&&this._experimentalSet){dir=this._findCompositesDir(config.base);if(dir){config.components=[];config.components.push(this._nd.path.join(dir,COMPOSITES))}}}if(config.components){if(typeof config.components===TYPE_STRING){config.components=[config.components]}else if(!Array.isArray(config.components)){this._error("Config entry 'components' must be a string or an array of strings!");return false}for(i=0;i<config.components.length;i++){config.components[i]=config.components[i].trim();if(config.components[i].length===0){config.components.splice(i,1);i--}}}if(config.components&&config.components.length||config.componentUrls&&config.componentUrls.length){o=config.componentOptions;if(o){if(!this._utils.isObject(o)){this._error("Config 'components' sub-property 'componentOptions' must be an Object!");return false}t=typeof o.applySchema;if(t==="undefined"){o.applySchema=true}else if(t!=="boolean"){this._error("Config 'components' sub-property 'componentOptions' must be an Object!");return false}}}return true};CfgLib.prototype.processTsConfig=function(){let ret=true;if(this._config.tsconfig){if(typeof this._config.tsconfig!=="string"){this._error("Config entry 'tsconfig must be a directory string!");ret=false}}return ret};CfgLib.prototype.processRulePacks=function(){var packs,pack,i;var config=this._config;if(config.rulePacks){packs=this._config.rulePacks;if(!Array.isArray(packs)){this._error("Config entry 'rulePacks' is not an array!");return false}for(i=0;i<packs.length;i++){pack=packs[i];if(typeof pack!==TYPE_BOOLEAN){pack.enabled=true}if(!pack.path){this._error(`Config entry 'rulePacks' (entry ${i+1}) does not have a 'path' entry!`);return false}else{pack.path=pack.path.trim()}if(pack.status&&!Array.isArray(pack)){this._error(`Config entry 'rulePacks' (entry ${i+1}) 'status' property is not an array!`);return false}}}else{config.rulePacks=[]}return true};CfgLib.prototype.processRuleMods=function(){var mods,mod,val;var config=this._config;const MSG="Config 'ruleMods' sub-property '${mod}' is not an array of rule names or group names!";var b;if(config.ruleMods){mods=config.ruleMods;for(mod in mods){val=mods[mod];if(mod==="enabled"){this._error("'ruleMods' : invalid sub-property 'enabled' - did you mean 'enable'?");b=true}else if(mod==="disabled"){this._error("'ruleMods' : invalid sub-property 'disabled' - did you mean 'disable'?");b=true}if(b){return!b}if(mod==="enable"||mod==="disable"){if(!Array.isArray(val)){this._error(this._utils.format(MSG,{mod:mod}));b=true}if(!this._utils.isArrayContentsType(val,"string")){this._error(this._utils.format(MSG,{mod:mod}));b=true}}else if(!this._utils.isObject(val)){this._error(`Config 'ruleMods' sub-property '${mod}' is not an object!`);b=true}}if(!b&&mods.enable&&mods.disable){let self=this;mods.enable.forEach(function(r){if(mods.disable.includes(r)){self._error(`Config 'ruleMods': 'enable' & 'disable' conflicting entry '${r}'!`);b=true}})}}return!b};CfgLib.prototype.processFormat=function(){var config=this._config;if(config.format){if(config.format!=="json"&&config.format!=="prose"&&config.format!=="line"){this._error(`Config entry 'format' '${config.format}' not valid. Must be 'json', 'prose' or 'line'!`);return false}}return true};CfgLib.prototype.processProseFormat=function(){var config=this._config;if(config.proseFormat){if(typeof config.proseFormat==="string"){if(config.format!=="prose"){this._warn("Config entry 'proseFormat' ignored - not applicable if 'format is not 'prose'!")}}else{this._error(`Config entry 'proseFormat' '${config.proseFormat}' is not valid!`);return false}}return true};CfgLib.prototype.processLineFormat=function(){var config=this._config;if(config.lineFormat){if(typeof config.lineFormat==="string"){if(config.format!=="line"){this._warn("Config entry 'lineFormat' ignored - not applicable if 'format is not 'line'!")}}else{this._error(`Config entry 'lineFormat' '${config.lineFormat}' is not valid!`);return false}}return true};CfgLib.prototype.processRuleDescriptions=function(){var val,valType;var config=this._config;if(config.ruleDescriptions){val=config.ruleDescriptions;valType=typeof val;if(valType!=="string"||val!="all"&&val!=="short"&&val!=="long"&&val!=="none"){this._error(`Config entry 'ruleDescriptions' '${val}' is not valid!`);return false}}else{config.ruleDescriptions=DEF_RULE_DESCRIPT}return true};CfgLib.prototype.processRulesFired=function(){var config=this._config;if(config.rulesFired){if(!this._modeCtx.isAPI&&!this._modeCtx.isAMD&&(!config.format||config.format!=="json")){this._error(`Config entry 'rulesFired' - API/AMD mode required, or 'format' property set to 'json' for CLI mode!`);return false}}return true};CfgLib.prototype.processSevMap=function(){var config=this._config;var set,sev,msgs,inv,mapped,val,b,error;if(!config.sevMap){return true}set=config.sevMap.sevSet;if(set){b=error=false;for(val in set){if(!this._sevLib.isValidConfigSeverity(val)){this._error(`Config entry 'sevMap' sub-property 'sevSet' value '${val}' is not 'major/minor/blocker/critical/info'!`);error=true;continue}if(val==="all"){this._error("Config entry 'sevMap' sub-property 'sevSet' - pseudo severity 'all' cannot be remapped!");error=true;continue}if(typeof set[val]!=="string"){this._error(`Config entry 'sevMap' sub-property 'sevSet' value '${val}' is not a string!`);error=true;continue}b=true}if(error){return false}if(b){inv={};for(sev in set){mapped=set[sev];if(inv[mapped]){if(!Array.isArray(inv[mapped])){inv[mapped]=[inv[mapped]]}inv[mapped].push(sev)}else{inv[mapped]=sev}}this._sevLib.setSevMap(config.sevMap,inv)}else{config.sevMap.sevSet=null}}msgs=config.sevMap.sevMsg;if(msgs){if(!this._utils.isObject(msgs)){this._error("Config entry 'sevMap' sub-property 'sevMsg' is not an object!");return false}b=error=false;for(val in msgs){sev=msgs[val];if(typeof sev!=="string"){this._error(`Config entry 'sevMap' sub-property 'sevMsg' : '${val}' is not a string!`);error=true;continue}if(!this._sevLib.isSev(sev)){this._error(`Config entry 'sevMap' sub-property 'sevMsg' : '${sev}' is ${UNDEF}!`);error=true;continue}b=true}if(error){return false}if(b){this._sevLib.setSevMsg(msgs)}else{config.sevMap.sevMsg=null}}else{b=true;for(val in config.sevMap){if(val!=="sevSet"&&val!=="sevMsg"){this._error(`Config entry 'sevMap' unknown sub-property '${val}'!`);b=false}}if(!b){return false}}return true};CfgLib.prototype.processSeverity=function(cliSev){var config=this._config;var val,se,i;if(cliSev){config.severity=cliSev}if(config.severity){val=config.severity;if(typeof val==="string"){se=this._sevLib.getSevExpr(val);if(!this._sevLib.isValidConfigSeverity(val)){if(se.op&&se.sev==="all"){this._error(`Config entry 'severity' ('${val}') : 'all' cannot be used with a severity expression !`)}else if(cliSev){this._error(`command line --severity '${val}' is not 'major/minor/blocker/critical/info', 'all', or a remapped severity!`)}else{this._error(`Config entry 'severity' ('${val}') is not 'major/minor/blocker/critical/info', 'all', or a remapped severity!`)}return false}this._sevLib.setSevExpr(se)}else if(Array.isArray(val)&&this._utils.isArrayContentsType(val,"string")){for(i=0;i<val.length;i++){if(!this._sevLib.isValidConfigSeverity(val[i])){this._error(`Config entry 'severity' ('${val[i]}') is not 'major/minor/blocker/critical/info', 'all', or a remapped severity!`);return false}}}else{this._error("Config entry 'severity' is invalid!");return false}}else{config.severity=this._sevLib.ALL;this._sevLib.setSevExpr(this._sevLib.getSevExpr(this._sevLib.ALL))}return true};CfgLib.prototype.processGroups=function(cliGroups){var group,i;var config=this._config;if(cliGroups){config.groups=cliGroups}if(!config.groups){config.groups=DEF_GROUPS;return true}if(!Array.isArray(config.groups)){config.groups=[config.groups]}if(config.groups.length===0){config.groups.push("all")}else{for(i=0;i<config.groups.length;i++){group=config.groups[i];if(!GROUPS.isGroup(group)){if(group.startsWith("jet-")||group.startsWith("htm")){this._error(`Config 'groups' entry '${group}' is not defined!`);return false}}}}return true};CfgLib.prototype.processDefGroups=function(){var config=this._config;if(config.defGroups){if(!this._utils.isObject(config.defGroups)){this._error("Config entry 'defGroups' is not an object!");return false}}else{config.defGroups=null}return true};CfgLib.prototype.processRuleNames=function(){var config=this._config;if(config.ruleNames){if(!Array.isArray(config.ruleNames)){this._error("Config entry 'ruleNames' is not an array!");return false}}return true};CfgLib.prototype.processTheme=function(){var t,config=this._config;t=config.theme;if(t){t=t.toLowerCase();if(typeof t==="string"){if(!THEMES.includes(t)){this._error(`Invalid config theme '${t}' : must be 'Redwood' or 'Alta' (or 'none')`);return false}}else{this._error("Config entry 'theme' is not a string!");return false}config.theme=t.charAt(0).toUpperCase()+t.substring(1)}else{config.theme=DEF_THEME;if(this._isVerbose){this._info(`[Info]: Default theme '${DEF_THEME}' applied`)}}return true};CfgLib.prototype.processComments=function(){var t,config=this._config;t=typeof config.comments;if(t===UNDEF){config.comments=DEF_COMMENTS}else if(t!=="boolean"){this._error("Invalid 'comments' property - expected a boolean");return false}return true};CfgLib.prototype.processEcmaVer=function(){var val,config=this._config;if(config.ecmaVer){val=config.ecmaVer;if(typeof val==="string"){val=parseInt(val);if(isNaN(val)){val=0}}if(typeof val===NUMBER){if(!(ECMA_VER.includes(val)||ECMA_YEAR.includes(val))){this._error(`Config 'ecmaVer: ${config.ecmaVer}' is not in the version range 5-10 or the year range 2015-2019!`);return false}}if(val>=2015){val=ECMA_YEAR.indexOf(val);config.ecmaVer=ECMA_VER[val]}else{config.ecmaVer=val}}else{config.ecmaVer=DEF_ECMAVER}return true};CfgLib.prototype.processMessages=function(){var val,config=this._config;if(config.messages){val=config.messages;if(!this._utils.isObject(val)){this._error("Config entry 'messages' is not an object!");return false}if(val.accept&&val.reject){this._error("Config entry 'messages' - 'accept' and 'reject' are mutually exclusive!");return false}if(val.accept){if(!Array.isArray(val.accept)){this._error("Config entry 'messages.accept' is not an array!");return false}else if(!this._utils.isArrayContentsType(val.accept,"string")){this._error("Config entry 'messages.accept' property array does not contain all strings");return false}}if(val.reject){if(!Array.isArray(val.reject)){this._error("Config entry 'messages.reject' is not an array!");return false}else if(!this._utils.isArrayContentsType(val.reject,"string")){this._error("Config entry 'messages.reject' property array does not contain all strings");return false}}}return true};CfgLib.prototype.processAddFileList=function(){var config=this._config;if(config.appendFileList){this._appendFileList=true;this._warn("Configuration property 'appendFileList' : change to 'addFileList'")}else if(config.addFileList){this._addFileList=true}return true};CfgLib.prototype.processNameSpaces=function(){var config,nsp,ns,e;config=this._config;if(!config.nameSpaces){return true}if(!Array.isArray(config.nameSpaces)){config.nameSpaces=[config.nameSpaces]}nsp=config.nameSpaces;for(let i=0;i<nsp.length;i++){ns=nsp[i];if(!ns||typeof ns!=="string"){this._error(`Config 'nameSpaces' entry "${ns}" at index ${i} is not a valid namespace`);e=true}else if(ns.startsWith("oj-")||ns.startsWith("ns-")){this._error(`Config 'nameSpaces' entry '${ns}' must not use reserved JET prefix ${ns.substring(0,3)}`);e=true}}return e?false:true};CfgLib.prototype.processOptions=function(){var prop,opts,config=this._config,isCLI=this._modeCtx.isCLI||this._modeCtx.isOJETCLI;if(config.options){opts=config.options;for(prop in opts){if(!OPTIONS_PROPS.includes(prop)){this._error(`Config - unknown 'options' sub-property '${prop}'!`);return false}else if((prop==="retCode"||prop==="rc")&&!isCLI){this._error(`"Config - 'options' property '${prop}' is valid in CLI mode only!`);return false}}}return true};CfgLib.prototype.processExtends=function(oCfg){if(!this._config.options.xex){this._error("Config 'extends' inheritance has 'early adopter' status - use experimental option 'xex': true.");return false}if(this._config.extendOptions){if(!this._utils.isObject(this._config.extendOptions)){this._error("Config 'extendOptions' is not an object.");return false}}var extLib=new this._nd.extends(this,this._oConfig,oCfg,this._path,this._nd,this._msgCtx,this._utils);var cfg=extLib.extend();return cfg};CfgLib.prototype.processTitle=function(){var t,config=this._config;if(config.title){t=this._utils.getType(config.title);if(t!=="string"&&t!=="array"){this._error(`Config entry 'title has incorrect type ('${t}')`);return false}}return true};CfgLib.prototype.processRetCode=function(){var rc,prop,ret,config=this._config;if(config.options){prop=typeof config.options.retCode!==UNDEF?"retCode":typeof config.options.rc!==UNDEF?"rc":null;if(prop){rc=config.options[prop];ret=this.validateRetCode(rc,sev=>{this._error(`Config entry 'options.${prop}' : unknown severity '${sev}'`)});if(ret||typeof ret==="number"){config.options[prop]=ret}else{config.options[prop]=AUTO;return false}}}if(!prop){if(!config.options){config.options={}}config.options.retCode=DEF_RETCODE}return true};CfgLib.prototype.validateFileList=function(aFiles){var i,j,f,msg,ret=true;;for(i=0;i<aFiles.length;i++){f=aFiles[i];if(typeof f==="string"){continue}if(!this._utils.isObject(f)){msg=" property entry "+(i+1)+" is not a string or an object";break}if(f.files){if(!(Array.isArray(f.files)&&this._utils.isArrayContentsType(f.files,"string"))){msg=" property entry "+(i+1)+" does not contain a 'files' property array, or not all elements are strings";break}}else{msg=" property entry "+(i+1)+", does not contain a 'files' property";break}if(!f.base){msg=" property entry "+(i+1)+" does not contain a 'base' property";break}for(j=0;j<f.files.length;j++){f.files[j]=this._nd.path.join(f.base,f.files[j])}}if(!msg){for(i=0;i<aFiles.length;i++){f=aFiles[i];if(this._utils.isObject(f)){aFiles.splice(i,1,...f.files)}}}if(msg){this._error(msg);ret=false}return ret};CfgLib.prototype.validateRetCode=function(val,cb){var t,i,b;t=typeof val;if(t==="number"||t==="string"&&val===DEF_RETCODE||val===ERRORS){return val}if(t==="string"){if(!this._sevLib.isSev(val)){cb(val);return false}else{return this._sevLib.unmap(val)}}if(Array.isArray(val)){b=true;for(i=0;i<val.length;i++){if(!this._sevLib.isSev(val[i])){cb(val[i]);b=false}else{val[i]=this._sevLib.unmap(val[i])}}if(b){for(i=0;i<val.length;i++){if(Array.isArray(val[i])){let ar=[];for(i=0;i<val.length;i++){ar=ar.concat(val[i])}val=ar;break}}return val}}return false};CfgLib.prototype.setMessages=function(msgid,state){var accept,reject,msgs,target,changed=false,i;var config=this._config;msgs=config.messages;state=!!state;if(!msgs){if(!state){config.messages={reject:[msgid]};changed=true}}else{reject=msgs.reject;accept=msgs.accept;target=accept||reject;i=target?target.indexOf(msgid):-1;if(state){if(!accept&&!reject){msgs.accept=accept=[]}if(reject){if(i>=0){reject.splice(i,1);changed=true;if(reject.length===0){delete msgs.reject}}}else if(accept){if(i<0){accept.push(msgid);changed=true}}}else{if(!accept&&!reject){msgs.reject=reject=[]}if(reject){if(i<0){reject.push(msgid);changed=true}}else if(accept){if(i>=0){accept.splice(i,1);if(accept.length===0){delete msgs.accept}changed=true}}}}return changed};CfgLib.prototype.getAddFileList=function(){return!!(this._addFileList||this._appendFileList)};CfgLib.prototype.checkPropNames=function(cfg,path){var prop,ret=true,config=cfg?cfg:this._config;for(prop in config){if(!TOP_PROPS.includes(prop)){if(prop.charAt(0)==="_"){delete config[prop];continue}this._error(`Config - unknown property '${prop}' ${path?path:""}!`);ret=false}else if(this._modeCtx.isAMD&&NOT_AMD.includes(prop)){this._error(`Config - property '${prop}' inapplicable in AMD mode!`);ret=false}}return ret};CfgLib.prototype.getDefaultEcmaVer=function(){return DEF_ECMAVER};CfgLib.prototype.setConfig=function(cfg,cfgPath,dir){this._config=cfg;this._path=cfgPath;this._dir=dir};CfgLib.prototype._findCompositesDir=function(base){return this._nd.fsUtils.findFile(base,COMPOSITES)};module.exports=CfgLib;
6
+ const GROUPS=require("./groups");const DEFAULTS=require("./defaults");const SemVer=require("semver");const COMPOSITES="jet-composites";const TYPE_STRING="string";const TYPE_BOOLEAN="boolean";const AUTO="auto";const ERRORS="errors";const UNDEF="undefined";const NUMBER="number";const TOP_PROPS=["rulePacks","ruleMods","builtinJetRules","builtinCspRules","builtinSpocRules","builtinJetWcRules","builtinJetWcOracleRules","builtinOjcMigrationRules","builtinWebDriverTestRules","severity","groups","defGroups","ruleNames","base","files","exclude","typescript","jetPagesOnly","format","proseFormat","lineFormat","outPath","tabs","messages","addFileList","title","jetVer","components","componentUrls","componentOptions","stylesets","ecmaVer","ruleDescriptions","rulesFired","userDefs","options","comments","extends","extendOptions","nameSpaces","followLinks","tempDir","tokens","common","$JetCore","sevMap","theme","ojet","appendFileList"];const NOT_AMD=["addFileList","base","builtinJetWcRules","builtinJetWcOracleRules","builtinOjcMigrationRules","builtinWebDriverTestRules","components","componentOptions","componentUrls","extends","extendOptions","files","exclude","followLinks","outPath","rulePacks","tempDir","tokens","typescript"];const OPTIONS_PROPS=["debug","verbose","color","msgid","ruleName","retCode","rc","ojetUpdate","$unittest"];const THEMES=["redwood","alta","none"];const DEF_COMMENTS=false;const DEF_RULE_DESCRIPT="none";const DEF_GROUPS=["all"];const DEF_RETCODE="auto";const ECMA_VER=[5,6,7,8,9,10,11];const ECMA_YEAR=[-1,2015,2016,2017,2018,2019,2020];function CfgLib(oConfig,nodeDeps,sevLib,utils,msgCtx,modeCtx){this._oConfig=oConfig;this._config=null;this._dir=null;this._sevLib=sevLib;this._utils=utils;this._nd=nodeDeps;this._msgCtx=msgCtx;this._modeCtx=modeCtx;this._isVerbose=msgCtx.isVerbose;this._isCLI=modeCtx.isCLI||modeCtx.isOJETCLI;this._error=msgCtx.error;this._warn=msgCtx.warn;this._info=msgCtx.info};CfgLib.prototype.setDebugStatus=function(verbose,debug){this._isVerbose=this._msgCtx.isVerbose=verbose};CfgLib.prototype.processWebComponents=function(){var dir,o,t,i;var config=this._config;if(config.componentUrlBase){if(!typeof config.componentUrlBase===TYPE_STRING){this._error("Config entry 'componentUrlBase' must be a string!");return false}}if(config.componentUrls){if(typeof config.componentUrls===TYPE_STRING){config.componentUrls=[config.componentUrls]}else if(!Array.isArray(config.componentUrls)){this._error("Config entry 'componentUrls' must be a string or an aray of strings!");return false}for(i=0;i<this._config.componentUrls.length;i++){config.componentUrls[i]=config.componentUrls[i].trim();if(config.componentUrls[i].length===0){config.componentUrls.splice(i,1);i--}}}if(!config.components){if(this._isCLI&&!this._isOJET&&this._experimentalSet){dir=this._findCompositesDir(config.base);if(dir){config.components=[];config.components.push(this._nd.path.join(dir,COMPOSITES))}}}if(config.components){if(typeof config.components===TYPE_STRING){config.components=[config.components]}else if(!Array.isArray(config.components)){this._error("Config entry 'components' must be a string or an array of strings!");return false}for(i=0;i<config.components.length;i++){config.components[i]=config.components[i].trim();if(config.components[i].length===0){config.components.splice(i,1);i--}}}if(config.components&&config.components.length||config.componentUrls&&config.componentUrls.length){o=config.componentOptions;if(o){if(!this._utils.isObject(o)){this._error("Config 'components' sub-property 'componentOptions' must be an Object!");return false}t=typeof o.applySchema;if(t==="undefined"){o.applySchema=true}else if(t!=="boolean"){this._error("Config 'components' sub-property 'componentOptions' must be an Object!");return false}}}return true};CfgLib.prototype.processTypeScript=function(){var ts,ret=true;if(this._config.hasOwnProperty("typescript")){ts=this._config.typescript;if(!this._utils.isObject(ts)){this._error("Config 'typescript' property is not an object!");ret=false}if(ts.hasOwnProperty("compile")){if(typeof ts.compile!=="boolean"){this._error("Config 'typescript' sub-property 'compile' is not a boolean!");ret=false}}if(ts.hasOwnProperty("tsconfig")){if(typeof ts.tsconfig!=="string"){this._error("Config 'typescript' sub-property 'tsconfig' must be a directory string!");ret=false}}}return ret};CfgLib.prototype.processRulePacks=function(){var packs,pack,i;var config=this._config;if(config.rulePacks){packs=this._config.rulePacks;if(!Array.isArray(packs)){this._error("Config entry 'rulePacks' is not an array!");return false}for(i=0;i<packs.length;i++){pack=packs[i];if(typeof pack!==TYPE_BOOLEAN){pack.enabled=true}if(!pack.path){this._error(`Config entry 'rulePacks' (entry ${i+1}) does not have a 'path' entry!`);return false}else{pack.path=pack.path.trim()}if(pack.status&&!Array.isArray(pack)){this._error(`Config entry 'rulePacks' (entry ${i+1}) 'status' property is not an array!`);return false}}}else{config.rulePacks=[]}return true};CfgLib.prototype.processRuleMods=function(){var mods,mod,val;var config=this._config;const MSG="Config 'ruleMods' sub-property '${mod}' is not an array of rule names or group names!";var b;if(config.ruleMods){mods=config.ruleMods;for(mod in mods){val=mods[mod];if(mod==="enabled"){this._error("'ruleMods' : invalid sub-property 'enabled' - did you mean 'enable'?");b=true}else if(mod==="disabled"){this._error("'ruleMods' : invalid sub-property 'disabled' - did you mean 'disable'?");b=true}if(b){return!b}if(mod==="enable"||mod==="disable"){if(!Array.isArray(val)){this._error(this._utils.format(MSG,{mod:mod}));b=true}if(!this._utils.isArrayContentsType(val,"string")){this._error(this._utils.format(MSG,{mod:mod}));b=true}}else if(!this._utils.isObject(val)){this._error(`Config 'ruleMods' sub-property '${mod}' is not an object!`);b=true}}if(!b&&mods.enable&&mods.disable){let self=this;mods.enable.forEach(function(r){if(mods.disable.includes(r)){self._error(`Config 'ruleMods': 'enable' & 'disable' conflicting entry '${r}'!`);b=true}})}}return!b};CfgLib.prototype.processFormat=function(){var config=this._config;if(config.format){if(config.format!=="json"&&config.format!=="prose"&&config.format!=="line"){this._error(`Config entry 'format' '${config.format}' not valid. Must be 'json', 'prose' or 'line'!`);return false}}return true};CfgLib.prototype.processProseFormat=function(){var config=this._config;if(config.proseFormat){if(typeof config.proseFormat==="string"){if(config.format!=="prose"){this._warn("Config entry 'proseFormat' ignored - not applicable if 'format is not 'prose'!")}}else{this._error(`Config entry 'proseFormat' '${config.proseFormat}' is not valid!`);return false}}return true};CfgLib.prototype.processLineFormat=function(){var config=this._config;if(config.lineFormat){if(typeof config.lineFormat==="string"){if(config.format!=="line"){this._warn("Config entry 'lineFormat' ignored - not applicable if 'format is not 'line'!")}}else{this._error(`Config entry 'lineFormat' '${config.lineFormat}' is not valid!`);return false}}return true};CfgLib.prototype.processRuleDescriptions=function(){var val,valType;var config=this._config;if(config.ruleDescriptions){val=config.ruleDescriptions;valType=typeof val;if(valType!=="string"||val!="all"&&val!=="short"&&val!=="long"&&val!=="none"){this._error(`Config entry 'ruleDescriptions' '${val}' is not valid!`);return false}}else{config.ruleDescriptions=DEF_RULE_DESCRIPT}return true};CfgLib.prototype.processRulesFired=function(){var config=this._config;if(config.rulesFired){if(!this._modeCtx.isAPI&&!this._modeCtx.isAMD&&(!config.format||config.format!=="json")){this._error(`Config entry 'rulesFired' - API/AMD mode required, or 'format' property set to 'json' for CLI mode!`);return false}}return true};CfgLib.prototype.processSevMap=function(){var config=this._config;var set,sev,msgs,inv,mapped,val,b,error;if(!config.sevMap){return true}set=config.sevMap.sevSet;if(set){b=error=false;for(val in set){if(!this._sevLib.isValidConfigSeverity(val)){this._error(`Config entry 'sevMap' sub-property 'sevSet' value '${val}' is not 'major/minor/blocker/critical/info'!`);error=true;continue}if(val==="all"){this._error("Config entry 'sevMap' sub-property 'sevSet' - pseudo severity 'all' cannot be remapped!");error=true;continue}if(typeof set[val]!=="string"){this._error(`Config entry 'sevMap' sub-property 'sevSet' value '${val}' is not a string!`);error=true;continue}b=true}if(error){return false}if(b){inv={};for(sev in set){mapped=set[sev];if(inv[mapped]){if(!Array.isArray(inv[mapped])){inv[mapped]=[inv[mapped]]}inv[mapped].push(sev)}else{inv[mapped]=sev}}this._sevLib.setSevMap(config.sevMap,inv)}else{config.sevMap.sevSet=null}}msgs=config.sevMap.sevMsg;if(msgs){if(!this._utils.isObject(msgs)){this._error("Config entry 'sevMap' sub-property 'sevMsg' is not an object!");return false}b=error=false;for(val in msgs){sev=msgs[val];if(typeof sev!=="string"){this._error(`Config entry 'sevMap' sub-property 'sevMsg' : '${val}' is not a string!`);error=true;continue}if(!this._sevLib.isSev(sev)){this._error(`Config entry 'sevMap' sub-property 'sevMsg' : '${sev}' is ${UNDEF}!`);error=true;continue}b=true}if(error){return false}if(b){this._sevLib.setSevMsg(msgs)}else{config.sevMap.sevMsg=null}}else{b=true;for(val in config.sevMap){if(val!=="sevSet"&&val!=="sevMsg"){this._error(`Config entry 'sevMap' unknown sub-property '${val}'!`);b=false}}if(!b){return false}}return true};CfgLib.prototype.processSeverity=function(cliSev){var config=this._config;var val,se,i;if(cliSev){config.severity=cliSev}if(config.severity){val=config.severity;if(typeof val==="string"){se=this._sevLib.getSevExpr(val);if(!this._sevLib.isValidConfigSeverity(val)){if(se.op&&se.sev==="all"){this._error(`Config entry 'severity' ('${val}') : 'all' cannot be used with a severity expression !`)}else if(cliSev){this._error(`command line --severity '${val}' is not 'major/minor/blocker/critical/info', 'all', or a remapped severity!`)}else{this._error(`Config entry 'severity' ('${val}') is not 'major/minor/blocker/critical/info', 'all', or a remapped severity!`)}return false}this._sevLib.setSevExpr(se)}else if(Array.isArray(val)&&this._utils.isArrayContentsType(val,"string")){for(i=0;i<val.length;i++){if(!this._sevLib.isValidConfigSeverity(val[i])){this._error(`Config entry 'severity' ('${val[i]}') is not 'major/minor/blocker/critical/info', 'all', or a remapped severity!`);return false}}}else{this._error("Config entry 'severity' is invalid!");return false}}else{config.severity=this._sevLib.ALL;this._sevLib.setSevExpr(this._sevLib.getSevExpr(this._sevLib.ALL))}return true};CfgLib.prototype.processGroups=function(cliGroups){var group,i;var config=this._config;if(cliGroups){config.groups=cliGroups}if(!config.groups){config.groups=DEF_GROUPS;return true}if(!Array.isArray(config.groups)){config.groups=[config.groups]}if(config.groups.length===0){config.groups.push("all")}else{for(i=0;i<config.groups.length;i++){group=config.groups[i];if(!GROUPS.isGroup(group)){if(group.startsWith("jet-")||group.startsWith("htm")){this._error(`Config 'groups' entry '${group}' is not defined!`);return false}}}}return true};CfgLib.prototype.processDefGroups=function(){var config=this._config;if(config.defGroups){if(!this._utils.isObject(config.defGroups)){this._error("Config entry 'defGroups' is not an object!");return false}}else{config.defGroups=null}return true};CfgLib.prototype.processRuleNames=function(){var config=this._config;if(config.ruleNames){if(!Array.isArray(config.ruleNames)){this._error("Config entry 'ruleNames' is not an array!");return false}}return true};CfgLib.prototype.processTheme=function(){var t,config=this._config;t=config.theme;if(t){t=t.toLowerCase();if(typeof t==="string"){if(!THEMES.includes(t)){this._error(`Invalid config theme '${t}' : must be 'Redwood' or 'Alta' (or 'none')`);return false}}else{this._error("Config entry 'theme' is not a string!");return false}config.theme=t.charAt(0).toUpperCase()+t.substring(1)}else{config.theme=SemVer.gte(config.jetVer,"12.0.0")?"Redwood":DEFAULTS.THEME;if(this._isVerbose){this._info(`[Info]: Default theme '${config.theme}' applied for jetVer ${config.jetVer}`)}}return true};CfgLib.prototype.processComments=function(){var t,config=this._config;t=typeof config.comments;if(t===UNDEF){config.comments=DEF_COMMENTS}else if(t!=="boolean"){this._error("Invalid 'comments' property - expected a boolean");return false}return true};CfgLib.prototype.processEcmaVer=function(){var val,config=this._config;if(config.ecmaVer){val=config.ecmaVer;if(typeof val==="string"){val=parseInt(val);if(isNaN(val)){val=0}}if(typeof val===NUMBER){if(!(ECMA_VER.includes(val)||ECMA_YEAR.includes(val))){this._error(`Config 'ecmaVer: ${config.ecmaVer}' is not in the version range 5-10 or the year range 2015-2019!`);return false}}if(val>=2015){val=ECMA_YEAR.indexOf(val);config.ecmaVer=ECMA_VER[val]}else{config.ecmaVer=val}}else{config.ecmaVer=DEFAULTS.ECMAVER}return true};CfgLib.prototype.processMessages=function(){var val,config=this._config;if(config.messages){val=config.messages;if(!this._utils.isObject(val)){this._error("Config entry 'messages' is not an object!");return false}if(val.accept&&val.reject){this._error("Config entry 'messages' - 'accept' and 'reject' are mutually exclusive!");return false}if(val.accept){if(!Array.isArray(val.accept)){this._error("Config entry 'messages.accept' is not an array!");return false}else if(!this._utils.isArrayContentsType(val.accept,"string")){this._error("Config entry 'messages.accept' property array does not contain all strings");return false}}if(val.reject){if(!Array.isArray(val.reject)){this._error("Config entry 'messages.reject' is not an array!");return false}else if(!this._utils.isArrayContentsType(val.reject,"string")){this._error("Config entry 'messages.reject' property array does not contain all strings");return false}}}return true};CfgLib.prototype.processAddFileList=function(){var config=this._config;if(config.appendFileList){this._appendFileList=true;this._warn("Configuration property 'appendFileList' : change to 'addFileList'")}else if(config.addFileList){this._addFileList=true}return true};CfgLib.prototype.processNameSpaces=function(){var config,nsp,ns,e;config=this._config;if(!config.nameSpaces){return true}if(!Array.isArray(config.nameSpaces)){config.nameSpaces=[config.nameSpaces]}nsp=config.nameSpaces;for(let i=0;i<nsp.length;i++){ns=nsp[i];if(!ns||typeof ns!=="string"){this._error(`Config 'nameSpaces' entry "${ns}" at index ${i} is not a valid namespace`);e=true}else if(ns.startsWith("oj-")||ns.startsWith("ns-")){this._error(`Config 'nameSpaces' entry '${ns}' must not use reserved JET prefix ${ns.substring(0,3)}`);e=true}}return e?false:true};CfgLib.prototype.processOptions=function(){var prop,opts,config=this._config,isCLI=this._modeCtx.isCLI||this._modeCtx.isOJETCLI;if(config.options){opts=config.options;for(prop in opts){if(!OPTIONS_PROPS.includes(prop)){this._error(`Config - unknown 'options' sub-property '${prop}'`);return false}else if((prop==="retCode"||prop==="rc")&&!isCLI){this._error(`Config - 'options' property '${prop}' is valid in CLI mode only`);return false}}}return true};CfgLib.prototype.processExtends=function(oCfg){if(this._config.extendOptions){if(!this._utils.isObject(this._config.extendOptions)){this._error("Config 'extendOptions' is not an object.");return false}}var extLib=new this._nd.extends(this,this._oConfig,oCfg,this._path,this._nd,this._msgCtx,this._utils);var cfg=extLib.extend();return cfg};CfgLib.prototype.processTitle=function(){var t,config=this._config;if(config.title){t=this._utils.getType(config.title);if(t!=="string"&&t!=="array"){this._error(`Config entry 'title has incorrect type ('${t}')`);return false}}return true};CfgLib.prototype.processRetCode=function(){var rc,prop,ret,config=this._config;if(config.options){prop=typeof config.options.retCode!==UNDEF?"retCode":typeof config.options.rc!==UNDEF?"rc":null;if(prop){rc=config.options[prop];ret=this.validateRetCode(rc,sev=>{this._error(`Config entry 'options.${prop}' : unknown severity '${sev}'`)});if(ret||typeof ret==="number"){config.options[prop]=ret}else{config.options[prop]=AUTO;return false}}}if(!prop){if(!config.options){config.options={}}config.options.retCode=DEF_RETCODE}return true};CfgLib.prototype.validateFileList=function(aFiles){var i,j,f,msg,ret=true;;for(i=0;i<aFiles.length;i++){f=aFiles[i];if(typeof f==="string"){continue}if(!this._utils.isObject(f)){msg=" property entry "+(i+1)+" is not a string or an object";break}if(f.files){if(!(Array.isArray(f.files)&&this._utils.isArrayContentsType(f.files,"string"))){msg=" property entry "+(i+1)+" does not contain a 'files' property array, or not all elements are strings";break}}else{msg=" property entry "+(i+1)+", does not contain a 'files' property";break}if(!f.base){msg=" property entry "+(i+1)+" does not contain a 'base' property";break}for(j=0;j<f.files.length;j++){f.files[j]=this._nd.path.join(f.base,f.files[j])}}if(!msg){for(i=0;i<aFiles.length;i++){f=aFiles[i];if(this._utils.isObject(f)){aFiles.splice(i,1,...f.files)}}}if(msg){this._error(msg);ret=false}return ret};CfgLib.prototype.validateRetCode=function(val,cb){var t,i,b;t=typeof val;if(t==="number"||t==="string"&&val===DEF_RETCODE||val===ERRORS){return val}if(t==="string"){if(!this._sevLib.isSev(val)){cb(val);return false}else{return this._sevLib.unmap(val)}}if(Array.isArray(val)){b=true;for(i=0;i<val.length;i++){if(!this._sevLib.isSev(val[i])){cb(val[i]);b=false}else{val[i]=this._sevLib.unmap(val[i])}}if(b){for(i=0;i<val.length;i++){if(Array.isArray(val[i])){let ar=[];for(i=0;i<val.length;i++){ar=ar.concat(val[i])}val=ar;break}}return val}}return false};CfgLib.prototype.setMessages=function(msgid,state){var accept,reject,msgs,target,changed=false,i;var config=this._config;msgs=config.messages;state=!!state;if(!msgs){if(!state){config.messages={reject:[msgid]};changed=true}}else{reject=msgs.reject;accept=msgs.accept;target=accept||reject;i=target?target.indexOf(msgid):-1;if(state){if(!accept&&!reject){msgs.accept=accept=[]}if(reject){if(i>=0){reject.splice(i,1);changed=true;if(reject.length===0){delete msgs.reject}}}else if(accept){if(i<0){accept.push(msgid);changed=true}}}else{if(!accept&&!reject){msgs.reject=reject=[]}if(reject){if(i<0){reject.push(msgid);changed=true}}else if(accept){if(i>=0){accept.splice(i,1);if(accept.length===0){delete msgs.accept}changed=true}}}}return changed};CfgLib.prototype.getAddFileList=function(){return!!(this._addFileList||this._appendFileList)};CfgLib.prototype.checkPropNames=function(cfg,path){var prop,ret=true,config=cfg?cfg:this._config;for(prop in config){if(!TOP_PROPS.includes(prop)){if(prop.charAt(0)==="_"){delete config[prop];continue}this._error(`Config - unknown property '${prop}' ${path?path:""}!`);ret=false}else if(this._modeCtx.isAMD&&NOT_AMD.includes(prop)){this._error(`Config - property '${prop}' is not available in AMD mode!`);ret=false}}return ret};CfgLib.prototype.setConfig=function(cfg,cfgPath,dir){this._config=cfg;this._path=cfgPath;this._dir=dir};CfgLib.prototype._findCompositesDir=function(base){return this._nd.fsUtils.findFile(base,COMPOSITES)};module.exports=CfgLib;
package/lib/CssLib.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates.
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
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
  */
package/lib/CssUtils.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates.
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
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
  */
package/lib/DomUtils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates.
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const jsonParser=require('really-relaxed-json').createParser();const HtmlUtils=require('./HtmlUtils');const NodeType=require('./NodeTypes');const OJCOMPONENT='ojComponent';const COMPONENT='component';const SVG_PATH_COMMANDS=['M','m','L','I','H','h','V','v','C','c','S','s','Q','q','T','t','A','a','Z','z'];const DOT='.';const ON_DASH='on-';function DomUtils(nodeDeps,appContext,oTabs){this._tree=null;this._nodeDeps=nodeDeps;this._appContext=appContext;this._tabs=oTabs;this._utils=appContext.utils};DomUtils.prototype.getFirst=function(){return this._tree.length?this._tree[0]:null};DomUtils.prototype.getLast=function(){var node;node=this._tree.length?this._tree[this._tree.length-1]:null;while(node&&node.children&&node.children.length){node=node.children[node.children.length-1]}return node};DomUtils.prototype.getFirstElem=function(){var node=this.getFirst();while(node){if(node.type===NodeType.TAG){break};node=node.next}return node};DomUtils.prototype.getChildren=function(node){return node.children};DomUtils.prototype.getParent=function(node){return node.parent};DomUtils.prototype.getSiblings=function(node){var parent=this.getParent(node);if(parent){return this.getChildren(parent)}else{return this._tree}};DomUtils.prototype.getNext=function(node){return node.next||null};DomUtils.prototype.getAttribs=function(node){return node.attribs||null};DomUtils.prototype.getAttribValue=function(node,name){return node.attribs?node.attribs[name]:undefined};DomUtils.prototype.getAttribRawValue=function(ruleCtx,name){var val,pos;if(ruleCtx.tagNode.attribs){if(typeof(val=ruleCtx.tagNode.attribs[name])==='string'){pos=this.getAttrPosition(ruleCtx.data,ruleCtx.tagNode,name);return _getAttrRawValue(ruleCtx.data,pos.start,name,val,ruleCtx.utils.utils)}}};DomUtils.prototype.hasAttrib=function(node,name){return!!node.attribs&&hasOwnProperty.call(node.attribs,name)};DomUtils.prototype.hasChildren=function(node){return!!node.children};DomUtils.prototype.hasNext=function(node){return!!node.next};DomUtils.prototype.getName=function(node){return node.name};DomUtils.prototype.getType=function(node){return node.type};DomUtils.prototype.getElemsByName=function(name){var a=[],i,names;if(!this._tree){return a}names=typeof name==='string'?[name]:name;for(i=0;i<names.length;i++){names[i]=names[i].toLowerCase()}for(i=0;i<this._tree.length;i++){_getElemsByName2(this._tree[i],a,names)}return a};function _getElemsByName2(node,a,names){var children,i;if((node.type===NodeType.TAG||node.type===NodeType.SCRIPT)&&names.indexOf(node.name.toLowerCase())>=0){a.push(node)}if(node.children){children=node.children;for(i=0;i<children.length;i++){_getElemsByName2(children[i],a,names)}}};DomUtils.prototype.getElemById=function(id,labelId){var node,i;if(!this._tree){return null}for(i=0;i<this._tree.length;i++){node=this._tree[i];if(node.type===NodeType.TAG||_isHtmlScript(node)){node=this._getElemById2(node,id,labelId);if(node){return node}}}return null};DomUtils.prototype._getElemById2=function(node,id,labelId){var curNode,attrib,attr,attribLower,i;if((node.type===NodeType.TAG||_isHtmlScript(node))&&node.attribs){for(attrib in node.attribs){attribLower=attrib.toLowerCase();if(attribLower==='id'||labelId&&attribLower==='label-id'){if(node.attribs[attrib]===id){return node}}else if(attrib==='data-bind'){attr=this.extractAttribsFromDataBind(node.attribs[attrib]);if(attr&&attr['id']===id){return node}}}}if(node.children){for(i=0;i<node.children.length;i++){curNode=this._getElemById2(node.children[i],id,labelId);if(curNode){return curNode}}}return null};DomUtils.prototype.getElems=function(){var a=[],i;if(!this._tree){return a}for(i=0;i<this._tree.length;i++){_getElems2(this._tree[i],a)}return a};function _getElems2(node,a){var children,i;if(node.type===NodeType.TAG||node.type===NodeType.SCRIPT){a.push(node)}if(node.children){children=node.children;for(i=0;i<children.length;i++){_getElems2(children[i],a)}}};DomUtils.prototype.getComponentElems=function(){var a=[],i;if(!this._tree){return a}for(i=0;i<this._tree.length;i++){this._getComponentElems2(this._tree[i],a)}return a};DomUtils.prototype._getComponentElems2=function(node,a){var children,i;if(node.type===NodeType.TAG&&this._appContext.metaLib.isCCATag(node.name)){a.push(node)}if(node.children){children=node.children;for(i=0;i<children.length;i++){this._getComponentElems2(children[i],a)}}};DomUtils.prototype.isCommonAttr=function(attrName){attrName=attrName.toLowerCase();attrName=attrName.charAt(0)===':'?attrName.substr(1):attrName;return HtmlUtils.isCommonAttr(attrName)};DomUtils.prototype.isCommonEventAttr=function(attrName){attrName=attrName.toLowerCase();attrName=attrName.charAt(0)===':'?attrName.substr(1):attrName;if(attrName.startsWith('on-oj-')){return false}if(attrName.startsWith('on-')){attrName=attrName.substring(0,2)+attrName.substring(3)}return HtmlUtils.isCommonEventAttr(attrName)};DomUtils.prototype.isCommonElem=function(elem){return HtmlUtils.isCommonElem(elem)};DomUtils.prototype.isSvgElem=function(elem){return HtmlUtils.isSvgElem(elem)};DomUtils.prototype.isHtml5ObsoleteElem=function(tag){return HtmlUtils.isHtml5ObsoleteElem(tag)};DomUtils.prototype.isHtml5ObsoleteAttr=function(tagName,attrName){return HtmlUtils.isHtml5ObsoleteAttr(tagName,attrName)};DomUtils.prototype.isSelfClosingTag=function(tag){return HtmlUtils.isSelfClosingTag(tag)};DomUtils.prototype.isNamespaceTag=function(tagName){if(this._appContext.metaLib.isJetTag(tagName)){return true}return HtmlUtils.isNamespaceTag(tagName)};DomUtils.prototype.isNamespacePrefix=function(tagPrefix){return!!HtmlUtils.isNamespacePrefix(tagPrefix)};DomUtils.prototype.isChildOfElem=function(elemName,node){return!!this.isChildOfElemNode(elemName,node)};DomUtils.prototype.isChildOfElemNode=function(elemName,node){var ret=null;while(node.parent){if(node.parent.name===elemName){ret=node.parent;break}node=node.parent}return ret};DomUtils.prototype.getDataBindComponent=function(context){var node,val,attrVal,ret=null;node=context.tagNode;if(this.getAttribs(node)){attrVal=this.getAttribValue(node,'data-bind');if(attrVal){val=this.extractComponentFromDataBind(attrVal);if(val){ret='oj.'+val}}}return ret};DomUtils.prototype.getDataBindAttr=function(context){return this.getDataBindAttrsFromNode(context,context.node)};DomUtils.prototype.getDataBindAttrs=function(context){return this.getDataBindAttrsFromNode(context,context.node)};DomUtils.prototype.getDataBindAttrsFromNode=function(context,node){var attrVal,ret=null;if(this.getAttribs(node)){attrVal=this.getAttribValue(node,'data-bind');if(attrVal){ret=this.extractAttribsFromDataBind(attrVal)}}return ret};DomUtils.prototype.extractComponentFromDataBind=function(attrValue){var dataBind,componentName,x;x=attrValue.indexOf(OJCOMPONENT);if(x<0){return}componentName=null;if(attrValue.length>OJCOMPONENT.length){dataBind=attrValue.substring(x+OJCOMPONENT.length);x=dataBind.indexOf(COMPONENT);if(x>=0){dataBind=dataBind.substring(x+COMPONENT.length).trim();if(dataBind.charAt(0)===':'){x=dataBind.indexOf('oj');if(x>=0){dataBind=dataBind.substring(x);componentName=_extractComponentName(dataBind,this._utils)}}}}return componentName};function _extractComponentName(s,utils){var componentName,i,c;for(i=0;i<s.length;i++){c=s.charAt(i);if(c==='\''||c==='"'||utils.isWhitespace(c)){componentName=s.substring(0,i);break}}return componentName};DomUtils.prototype.extractAttribsFromDataBind=function(attrValue){var s,a,nextAttr,val,i,j,x,ret=null;if(attrValue.indexOf(':')<0){return ret}a=attrValue.split('attr');if(a.length<2){return ret}for(i=0;i<a.length;i++){a[i]=s=a[i].trim();if(s.charAt(0)===':'){s=s.substr(1).trim();if(s.charAt(0)==='{'){try{ret=jsonParser.stringToJson(s);ret=JSON.parse(ret)}catch(e){s=s.substring(1).trim();a=s.split(':');for(j=0;j<a.length;j++){if(nextAttr){if(!ret){ret={}}ret[nextAttr]=val=a[j].replace(/['\"]/g,'').trim();x=val.lastIndexOf('}');if(x>=0){ret[nextAttr]=val.substring(0,x).trim();break}nextAttr=null}if(j+1===a.length){break}a[j]=s=a[j].trim();s=s.replace(/['\"]/g,'').trim();if(s.length===0)continue;if(!ret){ret={}}ret[s]=val=a[++j].trim();x=val.indexOf(',');if(x>=0){ret[s]=val.substring(0,x).replace(/['\"]/g,'').trim();nextAttr=val.substring(x+1).trim();nextAttr=nextAttr.replace(/['\"]/g,'').trim();val=val.substring(0,x).replace(/['\"]/g,'').trim()}else{ret[s]=val.replace(/['\"]/g,'').trim()}x=val.lastIndexOf('}');if(x>=0){ret[s]=val.substring(0,x).trim();break}}}}break}}return ret};DomUtils.prototype.getAttrPosition=function(data,node,attrName){var startIndex=this.getAttrIndex(data,node,attrName);var endIndex=startIndex+attrName.length-1;var rowCol=this._utils.getRowColFromIndex(data,startIndex,'html');rowCol.start=startIndex;rowCol.end=endIndex;return rowCol};DomUtils.prototype.getAttrIndex=function(data,node,attrName){var attribs,index,temp,c,i,isQuote=attrName==='"'||attrName==='\'';attribs=node.attribs;if(!attribs){this._appContext.assert('no attrs in tag '+node.name+'(expected attr \''+attrName+')');return node.startIndex}if(!attribs.hasOwnProperty(attrName)&&!attribs.hasOwnProperty(':'+attrName)){this._appContext.assert('expected attr \''+attrName+'\' in tag '+node.name);return node.startIndex}index=data.indexOf(attrName,node.startIndex);while(true){index=data.indexOf(attrName,index);if(index>=0){temp=data.substring(index+attrName.length,index+100);i=this._utils.eatWhitespace(temp);if(i<0){return node.startIndex}c=temp.charAt(i);if(c==='='||c==='>'||!isQuote&&this._utils.isWhitespace(temp.charAt(0))){return index}index+=i+1;continue}this._appContext.assert('expected attr \''+attrName+'\' in tag '+node.name);return node.startIndex}};DomUtils.prototype.isNonFragmentJetPage=function(context){return this.hasBody(context)&&this.isJetPage(context)};DomUtils.prototype.hasBody=function(context){var i,siblings,ret=false;siblings=this.getSiblings(context.node);for(i=0;i<siblings.length;i++){if(this._hasBody2(siblings[i])){ret=true;break}}return ret};DomUtils.prototype._hasBody2=function(node){var i,children,ret=false;if(node.type===NodeType.TAG&&node.name.toLowerCase()==='body'){return true}if(node.children){children=node.children;for(i=0;i<children.length;i++){if(this._hasBody2(children[i])){ret=true;break}}}return ret};DomUtils.prototype.isJetPage=function(context){var i,siblings,ret=false;siblings=this.getSiblings(context.node);for(i=0;i<siblings.length;i++){if(this._isJetPage2(siblings[i])){ret=true;break}}return ret};DomUtils.prototype._isJetPage2=function(node){var i,children,ret=false;if(node.type===NodeType.TAG&&node.name.toLowerCase().startsWith('oj-')){return true}if(node.children){children=node.children;for(i=0;i<children.length;i++){if(this._isJetPage2(children[i])){ret=true;break}}}return ret};DomUtils.prototype.isValidJson=function(value,data){var data,ret;if(value.charAt(0)!=='{'){return true}try{data=JSON.parse(this._nodeDeps.decomment(value));ret=!!data}catch(e){if(typeof data==='string'&&e.toString().startsWith('SyntaxError')){var obj=_convertMsgToRowCol(e.message,data,this._utils);ret.msg=obj.msg;ret.line=obj.row;ret.col=obj.col;ret.position=obj.position}else{ret=e.message}}return ret};DomUtils.prototype.isAttrExprConstant=function(expr){return HtmlUtils.isAttrExprConstant(expr)};DomUtils.prototype.isSvgPath=function(s){var c=s.trim().charAt(0);return SVG_PATH_COMMANDS.indexOf(c)>=0};DomUtils.prototype.camelCase=function(str){var parts,i;function _camelCase(str){return str.replace(/(?:^\w|[A-Z]|\b\w)/g,function(word,index){return index==0?word.toLowerCase():word.toUpperCase()}).replace(/-|\s+/g,'')};parts=str.split(DOT);for(i=0;i<parts.length;i++){parts[i]=_camelCase(parts[i])}return parts.join(DOT)};DomUtils.prototype.kebabCase=function(str){return str.replace(/([a-zA-Z])(?=[A-Z])/g,'$1-').toLowerCase()};DomUtils.prototype.kekabCaseEvent=function(str){return ON_DASH+this.kebabCase(str)};function _isHtmlScript(node){var attribs=node.attribs;return node.type&&node.type===NodeType.SCRIPT&&attribs&&attribs.type&&attribs.type.indexOf('html')>=0};function _convertMsgToRowCol(msg,data,utils){var x,n,obj;x=msg.indexOf('position');if(x<0){return null}n=parseInt(msg.substr(x+8).trim());obj=utils.getRowColFromIndex(data,n);obj.msg=msg.substr(0,x)+'line '+obj.row+', col '+obj.col+' (position '+n+')';obj.position=n;return obj};function _getAttrRawValue(data,index,attrName,attrValue,utils){var ret=null,delim,i;i=index+attrName.length;if(data.charAt(i)==='='){i=utils.eatWhitespace(data,i+1);delim=data.substr(i,1);delim=delim==='\''||delim==='"'?delim:'"';ret=delim+attrValue+data.charAt(i+attrValue.length+1)}else{ret=attrValue}return ret};DomUtils.prototype.setDom=function(oDom){this._tree=oDom};module.exports=DomUtils;
6
+ const jsonParser=require('really-relaxed-json').createParser();const HtmlUtils=require('./HtmlUtils');const NodeType=require('./NodeTypes');const OJCOMPONENT='ojComponent';const COMPONENT='component';const SVG_PATH_COMMANDS=['M','m','L','I','H','h','V','v','C','c','S','s','Q','q','T','t','A','a','Z','z'];const DOT='.';const ON_DASH='on-';function DomUtils(nodeDeps,appContext,oTabs,fileIndex){this._tree=null;this._nodeDeps=nodeDeps;this._appContext=appContext;this._tabs=oTabs;this._utils=appContext.utils;this._fileIndex=fileIndex};DomUtils.prototype.getFirst=function(){return this._tree.length?this._tree[0]:null};DomUtils.prototype.getLast=function(){var node;node=this._tree.length?this._tree[this._tree.length-1]:null;while(node&&node.children&&node.children.length){node=node.children[node.children.length-1]}return node};DomUtils.prototype.getFirstElem=function(){var node=this.getFirst();while(node){if(node.type===NodeType.TAG){break};node=node.next}return node};DomUtils.prototype.getChildren=function(node){return node.children};DomUtils.prototype.getParent=function(node){return node.parent};DomUtils.prototype.getSiblings=function(node){var parent;if(parent=this.getParent(node)){return this.getChildren(parent)}else{return this._tree}};DomUtils.prototype.getNext=function(node){return node.next||null};DomUtils.prototype.getAttribs=function(node){return node.attribs||null};DomUtils.prototype.getAttribValue=function(node,name){return node.attribs?node.attribs[name]:undefined};DomUtils.prototype.getAttribRawValue=function(ruleCtx,name){var val,pos;if(ruleCtx.tagNode.attribs){if(typeof(val=ruleCtx.tagNode.attribs[name])==='string'){pos=this.getAttrPosition(ruleCtx.data,ruleCtx.tagNode,name);return _getAttrRawValue(ruleCtx.data,pos.start,name,val,ruleCtx.utils.utils)}}};DomUtils.prototype.hasAttrib=function(node,name){return!!node.attribs&&hasOwnProperty.call(node.attribs,name)};DomUtils.prototype.hasChildren=function(node){return!!node.children};DomUtils.prototype.hasNext=function(node){return!!node.next};DomUtils.prototype.getName=function(node){return node.name};DomUtils.prototype.getType=function(node){return node.type};DomUtils.prototype.getElemsByName=function(name){var a=[],i,names;if(!this._tree){return a}names=typeof name==='string'?[name]:name;for(i=0;i<names.length;i++){names[i]=names[i].toLowerCase()}for(i=0;i<this._tree.length;i++){_getElemsByName2(this._tree[i],a,names)}return a};function _getElemsByName2(node,a,names){var children,i;if((node.type===NodeType.TAG||node.type===NodeType.SCRIPT)&&names.indexOf(node.name.toLowerCase())>=0){a.push(node)}if(node.children){children=node.children;for(i=0;i<children.length;i++){_getElemsByName2(children[i],a,names)}}};DomUtils.prototype.getElemById=function(id,labelId){var node,i;if(!this._tree){return null}for(i=0;i<this._tree.length;i++){node=this._tree[i];if(node.type===NodeType.TAG||_isHtmlScript(node)){node=this._getElemById2(node,id,labelId);if(node){return node}}}return null};DomUtils.prototype._getElemById2=function(node,id,labelId){var curNode,attrib,attr,attribLower,i;if((node.type===NodeType.TAG||_isHtmlScript(node))&&node.attribs){for(attrib in node.attribs){attribLower=attrib.toLowerCase();if(attribLower==='id'||labelId&&attribLower==='label-id'){if(node.attribs[attrib]===id){return node}}else if(attrib==='data-bind'){attr=this.extractAttribsFromDataBind(node.attribs[attrib]);if(attr&&attr['id']===id){return node}}}}if(node.children){for(i=0;i<node.children.length;i++){curNode=this._getElemById2(node.children[i],id,labelId);if(curNode){return curNode}}}return null};DomUtils.prototype.getElems=function(){var a=[],i;if(!this._tree){return a}for(i=0;i<this._tree.length;i++){_getElems2(this._tree[i],a)}return a};function _getElems2(node,a){var children,i;if(node.type===NodeType.TAG||node.type===NodeType.SCRIPT){a.push(node)}if(node.children){children=node.children;for(i=0;i<children.length;i++){_getElems2(children[i],a)}}};DomUtils.prototype.getScripts=function(){var head,ch,a=[];if(head=this.getHead()){if(ch=head.children){ch.forEach(elem=>{if(elem.type===NodeType.TAG&&elem.name==='script'){a.push(elem)}})}}return a};DomUtils.prototype.getLinks=function(){var head,ch,a=[];if(head=this.getHead()){if(ch=head.children){ch.forEach(elem=>{if(elem.type===NodeType.TAG&&elem.name==='link'){a.push(elem)}})}}return a};DomUtils.prototype.getHead=function(){var elem,ch,i;if(!this._tree){return null}for(i=0;i<this._tree.length;i++){elem=this._tree[i];if(elem.type===NodeType.TAG&&elem.name==='html'){if(ch=elem.children){for(i=0;i<ch.length;i++){elem=ch[i];if(elem.type===NodeType.TAG&&elem.name==='head'){return elem}}}break}}return null};DomUtils.prototype.getBody=function(){var elem,ch,i;if(!this._tree){return null}for(i=0;i<this._tree.length;i++){elem=this._tree[i];if(elem.type===NodeType.TAG&&elem.name==='html'){if(ch=elem.children){for(i=0;i<ch.length;i++){elem=ch[i];if(elem.type===NodeType.TAG&&elem.name==='body'){return elem}}}break}}return null};DomUtils.prototype.getComponentElems=function(){var a=[],i;if(!this._tree){return a}for(i=0;i<this._tree.length;i++){this._getComponentElems2(this._tree[i],a)}return a};DomUtils.prototype._getComponentElems2=function(node,a){var children,i;if(node.type===NodeType.TAG&&this._appContext.metaLib.isWCTag(node.name)){a.push(node)}if(node.children){children=node.children;for(i=0;i<children.length;i++){this._getComponentElems2(children[i],a)}}};DomUtils.prototype.isCommonAttr=function(attrName){attrName=attrName.toLowerCase();attrName=attrName.charAt(0)===':'?attrName.substr(1):attrName;return HtmlUtils.isCommonAttr(attrName)};DomUtils.prototype.isCommonEventAttr=function(attrName){attrName=attrName.toLowerCase();attrName=attrName.charAt(0)===':'?attrName.substr(1):attrName;if(attrName.startsWith('on-oj-')){return false}if(attrName.startsWith('on-')){attrName=attrName.substring(0,2)+attrName.substring(3)}return HtmlUtils.isCommonEventAttr(attrName)};DomUtils.prototype.isCommonElem=function(elem){return HtmlUtils.isCommonElem(elem)};DomUtils.prototype.isSvgElem=function(elem){return HtmlUtils.isSvgElem(elem)};DomUtils.prototype.isHtml5ObsoleteElem=function(tag){return HtmlUtils.isHtml5ObsoleteElem(tag)};DomUtils.prototype.isHtml5ObsoleteAttr=function(tagName,attrName){return HtmlUtils.isHtml5ObsoleteAttr(tagName,attrName)};DomUtils.prototype.isSelfClosingTag=function(tag){return HtmlUtils.isSelfClosingTag(tag)};DomUtils.prototype.isNamespaceTag=function(tagName){if(this._appContext.metaLib.isJetTag(tagName)){return true}return HtmlUtils.isNamespaceTag(tagName)};DomUtils.prototype.isNamespacePrefix=function(tagPrefix){return!!HtmlUtils.isNamespacePrefix(tagPrefix)};DomUtils.prototype.isChildOfElem=function(elemName,node){return!!this.isChildOfElemNode(elemName,node)};DomUtils.prototype.isChildOfElemNode=function(elemName,node){var ret=null;while(node.parent){if(node.parent.name===elemName){ret=node.parent;break}node=node.parent}return ret};DomUtils.prototype.getDataBindComponent=function(context){var node,val,attrVal,ret=null;node=context.tagNode;if(this.getAttribs(node)){attrVal=this.getAttribValue(node,'data-bind');if(attrVal){val=this.extractComponentFromDataBind(attrVal);if(val){ret='oj.'+val}}}return ret};DomUtils.prototype.getDataBindAttr=function(context){return this.getDataBindAttrsFromNode(context,context.node)};DomUtils.prototype.getDataBindAttrs=function(context){return this.getDataBindAttrsFromNode(context,context.node)};DomUtils.prototype.getDataBindAttrsFromNode=function(context,node){var attrVal,ret=null;if(this.getAttribs(node)){attrVal=this.getAttribValue(node,'data-bind');if(attrVal){ret=this.extractAttribsFromDataBind(attrVal)}}return ret};DomUtils.prototype.extractComponentFromDataBind=function(attrValue){var dataBind,componentName,x;x=attrValue.indexOf(OJCOMPONENT);if(x<0){return}componentName=null;if(attrValue.length>OJCOMPONENT.length){dataBind=attrValue.substring(x+OJCOMPONENT.length);x=dataBind.indexOf(COMPONENT);if(x>=0){dataBind=dataBind.substring(x+COMPONENT.length).trim();if(dataBind.charAt(0)===':'){x=dataBind.indexOf('oj');if(x>=0){dataBind=dataBind.substring(x);componentName=_extractComponentName(dataBind,this._utils)}}}}return componentName};function _extractComponentName(s,utils){var componentName,i,c;for(i=0;i<s.length;i++){c=s.charAt(i);if(c==='\''||c==='"'||utils.isWhitespace(c)){componentName=s.substring(0,i);break}}return componentName};DomUtils.prototype.extractAttribsFromDataBind=function(attrValue){var s,a,nextAttr,val,i,j,x,ret=null;if(attrValue.indexOf(':')<0){return ret}a=attrValue.split('attr');if(a.length<2){return ret}for(i=0;i<a.length;i++){a[i]=s=a[i].trim();if(s.charAt(0)===':'){s=s.substr(1).trim();if(s.charAt(0)==='{'){try{ret=jsonParser.stringToJson(s);ret=JSON.parse(ret)}catch(e){s=s.substring(1).trim();a=s.split(':');for(j=0;j<a.length;j++){if(nextAttr){if(!ret){ret={}}ret[nextAttr]=val=a[j].replace(/['\"]/g,'').trim();x=val.lastIndexOf('}');if(x>=0){ret[nextAttr]=val.substring(0,x).trim();break}nextAttr=null}if(j+1===a.length){break}a[j]=s=a[j].trim();s=s.replace(/['\"]/g,'').trim();if(s.length===0)continue;if(!ret){ret={}}ret[s]=val=a[++j].trim();x=val.indexOf(',');if(x>=0){ret[s]=val.substring(0,x).replace(/['\"]/g,'').trim();nextAttr=val.substring(x+1).trim();nextAttr=nextAttr.replace(/['\"]/g,'').trim();val=val.substring(0,x).replace(/['\"]/g,'').trim()}else{ret[s]=val.replace(/['\"]/g,'').trim()}x=val.lastIndexOf('}');if(x>=0){ret[s]=val.substring(0,x).trim();break}}}}break}}return ret};DomUtils.prototype.getAttribPosition=function(data,node,attrName){var startIndex=this.getAttrIndex(data,node,attrName);var endIndex=startIndex+attrName.length-1;var pos=this._utils.getRowColFromIndex(data,startIndex,'html');pos.start=startIndex;pos.end=endIndex;return pos};DomUtils.prototype.getAttrPosition=function(data,node,attrName){return this.getAttribPosition(data,node,attrName)};DomUtils.prototype.getAttribValuePosition=function(data,node,attrName){var attrPos,pos,endPos,ws,ret,good;var isDouble,isSingle,isUnquoted;attrPos=this.getAttrPosition(data,node,attrName);if(!attrPos||attrPos.start===node.startIndex){return}if((pos=this._utils.eatWhitespace(data,attrPos.end+1))>=0){if(data.charAt(pos++)==='='){if((endPos=this._utils.eatWhitespace(data,pos))>=0){isDouble=data.charAt(endPos)==='"';isSingle=data.charAt(endPos)==='\'';isUnquoted=!(isSingle||isDouble);if(isDouble){if((endPos=data.indexOf('"',pos+1))>=0){good=true}}else if(isSingle){if((endPos=data.indexOf('\'',pos+1))>=0){good=true}}else if(isUnquoted){ws=this._utils.getIndexToWhitespace(data,pos);endPos=data.indexOf('>',pos);if(ws>=0&&endPos>=0){endPos=(endPos<ws?endPos:ws)-1;good=true}}if(good){attrPos=this.getLineCol(data,pos);ret={row:attrPos.row,col:attrPos.col,start:pos,end:endPos}}}}}return ret};DomUtils.prototype.getAttrValuePosition=function(data,node,attrName){return this.getAttribValuePosition(data,node,attrName)};DomUtils.prototype.getLineCol=function(data,index){return this._fileIndex.getRowCol(data,{start:index},'html')};DomUtils.prototype.getAttribIndex=function(data,node,attrName){var attribs,index,temp,c,i,isQuote=attrName==='"'||attrName==='\'';attribs=node.attribs;if(!attribs){this._appContext.assert('no attrs in tag '+node.name+'(expected attr \''+attrName+')');return node.startIndex}if(!attribs.hasOwnProperty(attrName)&&!attribs.hasOwnProperty(':'+attrName)){this._appContext.assert('expected attr \''+attrName+'\' in tag '+node.name);return node.startIndex}index=data.indexOf(attrName,node.startIndex);while(true){index=data.indexOf(attrName,index);if(index>=0){temp=data.substring(index+attrName.length,index+100);i=this._utils.eatWhitespace(temp);if(i<0){return node.startIndex}c=temp.charAt(i);if(c==='='||c==='>'||!isQuote&&this._utils.isWhitespace(temp.charAt(0))){return index}index+=i+1;continue}this._appContext.assert('expected attr \''+attrName+'\' in tag '+node.name);return node.startIndex}};DomUtils.prototype.getAttrIndex=function(data,node,attrName){return this.getAttribIndex(data,node,attrName)};DomUtils.prototype.isNonFragmentJetPage=function(context){return this.hasBody(context)&&this.isJetPage(context)};DomUtils.prototype.hasBody=function(context){var i,siblings,ret=false;siblings=this.getSiblings(context.node);for(i=0;i<siblings.length;i++){if(this._hasBody2(siblings[i])){ret=true;break}}return ret};DomUtils.prototype._hasBody2=function(node){var i,children,ret=false;if(node.type===NodeType.TAG&&node.name.toLowerCase()==='body'){return true}if(node.children){children=node.children;for(i=0;i<children.length;i++){if(this._hasBody2(children[i])){ret=true;break}}}return ret};DomUtils.prototype.isJetPage=function(context){var i,siblings,ret=false;siblings=this.getSiblings(context.node);for(i=0;i<siblings.length;i++){if(this._isJetPage2(siblings[i])){ret=true;break}}return ret};DomUtils.prototype._isJetPage2=function(node){var i,children,ret=false;if(node.type===NodeType.TAG&&node.name.toLowerCase().startsWith('oj-')){return true}if(node.children){children=node.children;for(i=0;i<children.length;i++){if(this._isJetPage2(children[i])){ret=true;break}}}return ret};DomUtils.prototype.isValidJson=function(value,data){var data,ret;if(value.charAt(0)!=='{'){return true}try{data=JSON.parse(this._nodeDeps.decomment(value));ret=!!data}catch(e){if(typeof data==='string'&&e.toString().startsWith('SyntaxError')){var obj=_convertMsgToRowCol(e.message,data,this._utils);ret.msg=obj.msg;ret.line=obj.row;ret.col=obj.col;ret.position=obj.position}else{ret=e.message}}return ret};DomUtils.prototype.isAttrExprConstant=function(expr){return HtmlUtils.isAttrExprConstant(expr)};const RE_EXPRESSION=/^(?:\[{2})(.*)(?:\]{2})$|^(?:\{{2})(.*)(?:\}{2})$/;DomUtils.prototype.isExpression=function(s){var ret=false;if(s){ret=RE_EXPRESSION.test(s.trim())}return ret};DomUtils.prototype.getExpression=function(s){var ret=null;if(this.isExpression(s)){ret=s.substring(2,s.length-2).trim()}return ret};DomUtils.prototype.isSvgPath=function(s){var c=s.trim().charAt(0);return SVG_PATH_COMMANDS.indexOf(c)>=0};DomUtils.prototype.camelCase=function(str){var parts,i;function _camelCase(str){return str.replace(/(?:^\w|[A-Z]|\b\w)/g,function(word,index){return index==0?word.toLowerCase():word.toUpperCase()}).replace(/-|\s+/g,'')};parts=str.split(DOT);for(i=0;i<parts.length;i++){parts[i]=_camelCase(parts[i])}return parts.join(DOT)};DomUtils.prototype.kebabCase=function(str){return str.replace(/([a-zA-Z])(?=[A-Z])/g,'$1-').toLowerCase()};DomUtils.prototype.kekabCaseEvent=function(str){return ON_DASH+this.kebabCase(str)};function _isHtmlScript(node){var attribs=node.attribs;return node.type&&node.type===NodeType.SCRIPT&&attribs&&attribs.type&&attribs.type.indexOf('html')>=0};function _convertMsgToRowCol(msg,data,utils){var x,n,obj;x=msg.indexOf('position');if(x<0){return null}n=parseInt(msg.substr(x+8).trim());obj=utils.getRowColFromIndex(data,n);obj.msg=msg.substr(0,x)+'line '+obj.row+', col '+obj.col+' (position '+n+')';obj.position=n;return obj};function _getAttrRawValue(data,index,attrName,attrValue,utils){var ret=null,delim,i;i=index+attrName.length;if(data.charAt(i)==='='){i=utils.eatWhitespace(data,i+1);delim=data.substr(i,1);delim=delim==='\''||delim==='"'?delim:'"';ret=delim+attrValue+data.charAt(i+attrValue.length+1)}else{ret=attrValue}return ret};DomUtils.prototype.setDom=function(oDom){this._tree=oDom};module.exports=DomUtils;