@oracle/oraclejet-audit 11.0.0 → 12.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/jaf-amd.js +6 -6
- package/jaf.js +2 -2
- package/jafapi.js +2 -2
- package/lib/AST.js +1 -1
- package/lib/AST_Ts.js +2 -2
- package/lib/AstJson.js +2 -2
- package/lib/AstMd.js +6 -0
- package/lib/AstNodeTypes.js +2 -2
- package/lib/Comments.js +1 -1
- package/lib/ComponentSvcs.js +1 -1
- package/lib/Components.js +2 -2
- package/lib/Config.js +2 -2
- package/lib/ConfigLib.js +2 -2
- package/lib/CssLib.js +1 -1
- package/lib/CssUtils.js +1 -1
- package/lib/DomUtils.js +2 -2
- package/lib/FileIndex.js +1 -1
- package/lib/FileSet.js +1 -1
- package/lib/FsUtils.js +2 -2
- package/lib/Histo.js +2 -2
- package/lib/HtmlTree.js +2 -2
- package/lib/HtmlUtils.js +1 -1
- package/lib/Issue.js +2 -2
- package/lib/JafEvents.js +1 -1
- package/lib/JafLib.js +2 -2
- package/lib/Json.js +2 -2
- package/lib/JsonLoader.js +2 -2
- package/lib/Md.js +6 -0
- package/lib/MetaLib.js +2 -2
- package/lib/NetUtils.js +1 -1
- package/lib/NodeTypes.js +1 -1
- package/lib/Parser.js +2 -2
- package/lib/RegTypes.js +2 -2
- package/lib/Registry.js +2 -2
- package/lib/Reporter.js +2 -2
- package/lib/RuleContext.js +1 -1
- package/lib/RulePack.js +1 -1
- package/lib/RuleSet.js +2 -2
- package/lib/Rules.js +2 -2
- package/lib/Scope.js +2 -2
- package/lib/SemVer.js +1 -1
- package/lib/Server.js +1 -1
- package/lib/SevLib.js +1 -1
- package/lib/Severity.js +1 -1
- package/lib/Stats.js +1 -1
- package/lib/Ts.js +2 -2
- package/lib/Utils.js +2 -2
- package/lib/Watch.js +1 -1
- package/lib/Writer.js +1 -1
- package/lib/ZipUtils.js +1 -1
- package/lib/api.js +2 -2
- package/lib/builtinpacks.js +6 -0
- package/lib/cliStats.js +2 -2
- package/lib/clone.js +2 -2
- package/lib/cmdline.js +2 -2
- package/lib/colors.js +2 -2
- package/lib/defaults.js +6 -0
- package/lib/deflist.js +6 -0
- package/lib/dislist.js +6 -0
- package/lib/exportRules.js +1 -1
- package/lib/extends.js +2 -2
- package/lib/filetypes.js +2 -2
- package/lib/grouplist.js +6 -0
- package/lib/groups.js +2 -2
- package/lib/help.js +2 -2
- package/lib/jetver.js +2 -2
- package/lib/macros.js +1 -1
- package/lib/manual.js +6 -0
- package/lib/metaLoader.js +1 -1
- package/lib/metahist.js +1 -1
- package/lib/msgidLoader.js +1 -1
- package/lib/ns.js +2 -2
- package/lib/nslist.js +1 -1
- package/lib/outFormat.js +1 -1
- package/lib/outfile.js +1 -1
- package/lib/ruleLoader.js +1 -1
- package/lib/scaffold.js +2 -2
- package/lib/scaffoldRule.js +2 -2
- package/lib/schema.js +2 -2
- package/lib/scopewalker.js +2 -2
- package/lib/spinner.js +2 -2
- package/lib/spinnernoop.js +1 -1
- package/lib/tabs.js +1 -1
- package/libext/expparser.js +1 -1
- package/meta/11.1.0/jetauditmeta.js +9 -0
- package/meta/12.0.0/jetauditmeta.js +9 -0
- package/meta/metaverlist.json +1 -1
- package/package.json +72 -68
- package/rulepacks/csp/csp-html-script-unsafe-inline.js +1 -1
- package/rulepacks/csp/csp-html-style-unsafe-inline.js +1 -1
- package/rulepacks/csp/csp-html-unsafe-expr.js +1 -1
- package/rulepacks/csp/csp-js-script-unsafe-eval.js +1 -1
- package/rulepacks/csp/csp-js-style-unsafe-inline.js +1 -1
- package/rulepacks/csp/csp-ts-script-unsafe-eval.js +1 -1
- package/rulepacks/csp/csp-ts-style-unsafe-inline.js +1 -1
- package/rulepacks/csp/msgid.json +1 -1
- package/rulepacks/csp/rules.json +1 -1
- package/rulepacks/jetwc/jetwc-absolute-jetversion.js +2 -2
- package/rulepacks/jetwc/jetwc-aria-redefinition.js +2 -2
- package/rulepacks/jetwc/jetwc-bootstrap.js +2 -2
- package/rulepacks/jetwc/jetwc-compjson-bp-ar.js +2 -2
- package/rulepacks/jetwc/jetwc-compjson-bp-obj.js +2 -2
- package/rulepacks/jetwc/jetwc-component-dependencies.js +2 -2
- package/rulepacks/jetwc/jetwc-component-displayname.js +2 -2
- package/rulepacks/jetwc/jetwc-component-foldername.js +2 -2
- package/rulepacks/jetwc/jetwc-component-location.js +2 -2
- package/rulepacks/jetwc/jetwc-component-type.js +2 -2
- package/rulepacks/jetwc/jetwc-css-oj-complete.js +6 -0
- package/rulepacks/jetwc/jetwc-data-property-prefix.js +2 -2
- package/rulepacks/jetwc/jetwc-deprecated-lifecycle.js +2 -2
- package/rulepacks/jetwc/jetwc-disabled-property.js +2 -2
- package/rulepacks/jetwc/jetwc-displayname.js +2 -2
- package/rulepacks/jetwc/jetwc-dynamic-slot-context.js +2 -2
- package/rulepacks/jetwc/jetwc-dynamic-slots-naming.js +2 -2
- package/rulepacks/jetwc/jetwc-event-displayname.js +2 -2
- package/rulepacks/jetwc/jetwc-events.js +2 -2
- package/rulepacks/jetwc/jetwc-jet-version.js +2 -2
- package/rulepacks/jetwc/jetwc-loader-file.js +2 -2
- package/rulepacks/jetwc/jetwc-markdown-link.js +6 -0
- package/rulepacks/jetwc/jetwc-method-displayname.js +2 -2
- package/rulepacks/jetwc/jetwc-methods.js +2 -2
- package/rulepacks/jetwc/jetwc-namespace.js +2 -2
- package/rulepacks/jetwc/jetwc-nested-defaults.js +2 -2
- package/rulepacks/jetwc/jetwc-nls-languages.js +2 -2
- package/rulepacks/jetwc/jetwc-nls-root.js +2 -2
- package/rulepacks/jetwc/jetwc-oj-register.js +2 -2
- package/rulepacks/jetwc/jetwc-ojcss.js +2 -2
- package/rulepacks/jetwc/jetwc-pack-children.js +2 -2
- package/rulepacks/jetwc/jetwc-packable-components.js +2 -2
- package/rulepacks/jetwc/jetwc-prerelease-dependencies.js +2 -2
- package/rulepacks/jetwc/jetwc-prerelease-pattern.js +2 -2
- package/rulepacks/jetwc/jetwc-prerelease-version.js +2 -2
- package/rulepacks/jetwc/jetwc-property-changed.js +2 -2
- package/rulepacks/jetwc/jetwc-property-displayname.js +2 -2
- package/rulepacks/jetwc/jetwc-property-nesting.js +2 -2
- package/rulepacks/jetwc/jetwc-public-modules.js +2 -2
- package/rulepacks/jetwc/jetwc-register-css.js +2 -2
- package/rulepacks/jetwc/jetwc-register-with-promises.js +2 -2
- package/rulepacks/jetwc/jetwc-require-paths.js +2 -2
- package/rulepacks/jetwc/jetwc-required-subproperty.js +2 -2
- package/rulepacks/jetwc/jetwc-reserved-property.js +2 -2
- package/rulepacks/jetwc/jetwc-schema.js +2 -2
- package/rulepacks/jetwc/jetwc-semantic-version.js +2 -2
- package/rulepacks/jetwc/jetwc-slot-displayname.js +2 -2
- package/rulepacks/jetwc/jetwc-slots.js +2 -2
- package/rulepacks/jetwc/jetwc-standard-files.js +2 -2
- package/rulepacks/jetwc/jetwc-subproperty-writeback.js +2 -2
- package/rulepacks/jetwc/jetwc-template-slots.js +2 -2
- package/rulepacks/jetwc/jetwc-unused-events.js +2 -2
- package/rulepacks/jetwc/jetwc-unused-slots.js +2 -2
- package/rulepacks/jetwc/jetwc-vb-category.js +2 -2
- package/rulepacks/jetwc/jetwc-vb-icon.js +2 -2
- package/rulepacks/jetwc/jetwc-vcomponent-jetversion.js +6 -0
- package/rulepacks/jetwc/jetwc-vcomponent-loader.js +6 -0
- package/rulepacks/jetwc/jetwc-vcomponent-version.js +6 -0
- package/rulepacks/jetwc/jetwc-version-openrange.js +2 -2
- package/rulepacks/jetwc/jetwc-writeback-required.js +2 -2
- package/rulepacks/jetwc/msgid.json +2 -2
- package/rulepacks/jetwc/rules.json +2 -2
- package/rulepacks/jetwc-lib/jetwcutils-auditComponentCacheManager.js +6 -0
- package/rulepacks/jetwc-lib/jetwcutils-commonListenerImpls.js +6 -0
- package/rulepacks/jetwc-lib/jetwcutils-componentAuditUtils.js +6 -0
- package/rulepacks/jetwc-lib/jetwcutils-componentFinder.js +6 -0
- package/rulepacks/jetwc-lib/jetwcutils-preCompiler.js +6 -0
- package/rulepacks/jetwc-lib/jetwcutils-tsxUtils.js +6 -0
- package/rulepacks/jetwco/jetwco-bootstrap.js +2 -2
- package/rulepacks/jetwco/jetwco-cacc-auditConstraints.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-dependencies.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-dynamicSlots.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-eventBubbles.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-eventCancelable.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-eventPayload.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-events.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-helpers.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-jetVer.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-methodParamTypes.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-methodParams.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-methodReturnType.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-methods.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-packBundle.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-packBundleContent.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-packContent.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-properties.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-propertyDefault.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-propertyEnumeration.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-propertyReadOnly.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-propertyRequired.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-propertyType.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-propertyWriteback.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-publicModules.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-slotDataVariable.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-slotDataVariableType.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-slots.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-styleClasses.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-styleVariables.js +6 -0
- package/rulepacks/jetwco/jetwco-compjson-ns-reg.js +2 -2
- package/rulepacks/jetwco/jetwco-component-api-baseline-changes.js +2 -2
- package/rulepacks/jetwco/jetwco-component-api-changes.js +2 -2
- package/rulepacks/jetwco/jetwco-component-api-controlled-changes.js +6 -0
- package/rulepacks/jetwco/jetwco-component-cdn.js +2 -2
- package/rulepacks/jetwco/jetwco-description-standards.js +6 -0
- package/rulepacks/jetwco/jetwco-displayname-standards.js +6 -0
- package/rulepacks/jetwco/jetwco-exchange-version-check.js +2 -2
- package/rulepacks/jetwco/jetwco-license-info.js +2 -2
- package/rulepacks/jetwco/jetwco-prerelease-cdn.js +2 -2
- package/rulepacks/jetwco/jetwco-thirdparty-ba.js +2 -2
- package/rulepacks/jetwco/msgid.json +2 -2
- package/rulepacks/jetwco/rules.json +2 -2
- package/rulepacks/spoc/msgid.json +1 -1
- package/rulepacks/spoc/rules.json +1 -1
- package/rulepacks/spoc/spoc-dom-manip-inv-tag.js +1 -1
- package/rulepacks/spoc/spoc-dom-manip-tag-pos.js +1 -1
- package/rulepacks/spoc/spoc-dom-manip.js +1 -1
- package/rulepacks/wdt/msgid.json +6 -0
- package/rulepacks/wdt/rules.json +6 -0
- package/rulepacks/wdt/wd-driver-sleep.js +6 -0
- package/rulepacks/wdt/wd-xpath.js +6 -0
- package/rules/jaf/jaf-css-diagnose.js +1 -1
- package/rules/jaf/jaf-html-diagnose.js +1 -1
- package/rules/jaf/jaf-init-schema.js +1 -1
- package/rules/jaf/jaf-js-diagnose.js +1 -1
- package/rules/jaf/jaf-ts-diagnose.js +1 -1
- package/rules/jaf/jaf-ts-walk.js +6 -0
- package/rules/jaf/msgid.json +2 -2
- package/rules/jaf/rules.json +2 -2
- package/rules/jet/helpers/acc-aria-label.js +1 -1
- package/rules/jet/helpers/bp-checkPropType.js +1 -1
- package/rules/jet/helpers/cssHelper.js +1 -1
- package/rules/jet/helpers/extractStylesFromClass.js +1 -1
- package/rules/jet/helpers/has-slot-name.js +2 -2
- package/rules/jet/helpers/has-slot.js +1 -1
- package/rules/jet/helpers/json-prop-pos.js +1 -1
- package/rules/jet/helpers/json-propname-pos.js +1 -1
- package/rules/jet/helpers/style-selector.js +1 -1
- package/rules/jet/helpers/valid-attr.js +1 -1
- package/rules/jet/helpers/vartrack.js +1 -1
- package/rules/jet/jet-css-ojselector.js +1 -1
- package/rules/jet/msgid.json +2 -2
- package/rules/jet/oj-acc-aria-labelledby.js +1 -1
- package/rules/jet/oj-acc-aria-prop.js +2 -2
- package/rules/jet/oj-acc-avatar-aria-role.js +2 -2
- package/rules/jet/oj-acc-combobox-aria-label.js +2 -2
- package/rules/jet/oj-acc-film-strip-aria-label.js +2 -2
- package/rules/jet/oj-acc-input-aria-label.js +2 -2
- package/rules/jet/oj-acc-select-aria-label.js +2 -2
- package/rules/jet/oj-cca-compjson-bp-ar.js +1 -1
- package/rules/jet/oj-cca-compjson-bp-dsplyname.js +1 -1
- package/rules/jet/oj-cca-compjson-bp-jetver.js +1 -1
- package/rules/jet/oj-cca-compjson-bp-obj.js +1 -1
- package/rules/jet/oj-cca-compjson-ns-reg.js +1 -1
- package/rules/jet/oj-css-bp-border-color.js +1 -1
- package/rules/jet/oj-css-bp-dir-flow.js +1 -1
- package/rules/jet/oj-css-bp-float.js +1 -1
- package/rules/jet/oj-css-bp-textalign.js +1 -1
- package/rules/jet/oj-css-style-abs-units.js +2 -2
- package/rules/jet/oj-css-style-bp-color.js +1 -1
- package/rules/jet/oj-css-style-bp-display.js +1 -1
- package/rules/jet/oj-css-style-bp-font-family.js +1 -1
- package/rules/jet/oj-css-style-bp-font.js +1 -1
- package/rules/jet/oj-css-style-deprecated.js +1 -1
- package/rules/jet/oj-css-style-override.js +2 -2
- package/rules/jet/oj-css-var-override.js +1 -1
- package/rules/jet/oj-form-maxcols.js +2 -2
- package/rules/jet/oj-html-5-attr-obs.js +1 -1
- package/rules/jet/oj-html-5-tag-obs.js +1 -1
- package/rules/jet/oj-html-alta-deprecated.js +6 -0
- package/rules/jet/oj-html-attr-$unique.js +1 -1
- package/rules/jet/oj-html-attr-2def.js +1 -1
- package/rules/jet/oj-html-attr-json.js +1 -1
- package/rules/jet/oj-html-attr-prefix-expr.js +1 -1
- package/rules/jet/oj-html-attr-prefix-ro.js +1 -1
- package/rules/jet/oj-html-attr-req.js +1 -1
- package/rules/jet/oj-html-bindforeach-data.js +2 -2
- package/rules/jet/oj-html-bindif-test.js +2 -2
- package/rules/jet/oj-html-binding-attr.js +2 -2
- package/rules/jet/oj-html-cca-count.js +1 -1
- package/rules/jet/oj-html-cca-tagname.js +2 -2
- package/rules/jet/oj-html-cdn.js +1 -1
- package/rules/jet/oj-html-combo-converter.js +1 -1
- package/rules/jet/oj-html-cspexpr.js +1 -1
- package/rules/jet/oj-html-databind-all.js +1 -1
- package/rules/jet/oj-html-dlg-title.js +2 -2
- package/rules/jet/oj-html-file-pick-accept.js +2 -2
- package/rules/jet/oj-html-form-bindif.js +1 -1
- package/rules/jet/oj-html-form-layout-maxcols.js +2 -2
- package/rules/jet/oj-html-form-noflex.js +1 -1
- package/rules/jet/oj-html-input-isodate.js +2 -2
- package/rules/jet/oj-html-invalid-doctype.js +2 -2
- package/rules/jet/oj-html-jq-databind.js +2 -2
- package/rules/jet/oj-html-ko-comment.js +1 -1
- package/rules/jet/oj-html-ko-databind.js +2 -2
- package/rules/jet/oj-html-label-for-prefix.js +1 -1
- package/rules/jet/oj-html-missing-doctype.js +1 -1
- package/rules/jet/oj-html-msgs-cat-text.js +6 -0
- package/rules/jet/oj-html-no-style-tag.js +6 -0
- package/rules/jet/oj-html-notag-style.js +6 -0
- package/rules/jet/oj-html-oj-lib.js +1 -1
- package/rules/jet/oj-html-ojattr-520.js +1 -1
- package/rules/jet/oj-html-ojattr-deprecated.js +2 -2
- package/rules/jet/oj-html-ojattr-enum-deprecated.js +2 -2
- package/rules/jet/oj-html-ojattr-evt-syntax.js +2 -2
- package/rules/jet/oj-html-ojattr-value.js +1 -1
- package/rules/jet/oj-html-ojattr.js +2 -2
- package/rules/jet/oj-html-ojevent.js +2 -2
- package/rules/jet/oj-html-ojslot.js +2 -2
- package/rules/jet/oj-html-ojstyle.js +1 -1
- package/rules/jet/oj-html-ojtag-datacmd.js +2 -2
- package/rules/jet/oj-html-ojtag-datactx.js +1 -1
- package/rules/jet/oj-html-ojtag-deprecated.js +2 -2
- package/rules/jet/oj-html-ojtag-globattr-noprefix.js +2 -2
- package/rules/jet/oj-html-ojtag-id.js +1 -1
- package/rules/jet/oj-html-ojtag-nonglobattr-prefix.js +2 -2
- package/rules/jet/oj-html-ojtag-ns.js +1 -1
- package/rules/jet/oj-html-picker-attrs.js +2 -2
- package/rules/jet/oj-html-redwood-cssnovars.js +1 -1
- package/rules/jet/oj-html-redwood-cssvars.js +1 -1
- package/rules/jet/oj-html-self-close.js +1 -1
- package/rules/jet/oj-html-slot-item-minmax.js +1 -1
- package/rules/jet/oj-html-slot-name.js +2 -2
- package/rules/jet/oj-html-slot-pref-content.js +2 -2
- package/rules/jet/oj-html-style-abs-units.js +1 -1
- package/rules/jet/oj-html-style-bp-color.js +1 -1
- package/rules/jet/oj-html-style-bp-display.js +1 -1
- package/rules/jet/oj-html-style-bp-font-family.js +1 -1
- package/rules/jet/oj-html-style-bp-font.js +1 -1
- package/rules/jet/oj-html-style-deprecated.js +2 -2
- package/rules/jet/oj-html-style.js +1 -1
- package/rules/jet/oj-html-stylesel.js +1 -1
- package/rules/jet/oj-html-tag-attr-noprefix.js +2 -2
- package/rules/jet/oj-html-template-index.js +2 -2
- package/rules/jet/oj-html-unsup-theme.js +1 -1
- package/rules/jet/oj-html-wctag-$props.js +1 -1
- package/rules/jet/oj-html-wctag-arialabelledby.js +1 -1
- package/rules/jet/oj-html-wctag-for.js +1 -1
- package/rules/jet/oj-html-wctag-id.js +2 -2
- package/rules/jet/oj-html-wctag-nested.js +6 -0
- package/rules/jet/oj-html-wctag-packprivate.js +1 -1
- package/rules/jet/oj-js-comp-attr-deprecated.js +2 -2
- package/rules/jet/oj-js-comp-meth-deprecated.js +2 -2
- package/rules/jet/oj-js-no-ext-final.js +1 -1
- package/rules/jet/oj-js-noconsole.js +1 -1
- package/rules/jet/oj-js-ojcomp-deprecated.js +2 -2
- package/rules/jet/oj-js-ojcomp-exist.js +1 -1
- package/rules/jet/oj-js-ojcomp-new.js +1 -1
- package/rules/jet/oj-js-poly-promise.js +1 -1
- package/rules/jet/oj-js-var-undef.js +1 -1
- package/rules/jet/oj-json-syntax.js +1 -1
- package/rules/jet/oj-ts-comp-attr-deprecated.js +2 -2
- package/rules/jet/oj-ts-comp-meth-deprecated.js +2 -2
- package/rules/jet/oj-ts-no-ext-final.js +1 -1
- package/rules/jet/oj-ts-noconsole.js +1 -1
- package/rules/jet/oj-ts-ojcomp-deprecated.js +2 -2
- package/rules/jet/oj-ts-ojcomp-exist.js +1 -1
- package/rules/jet/oj-ts-ojcomp-new.js +1 -1
- package/rules/jet/oj-ts-poly-promise.js +1 -1
- package/rules/jet/rules.json +2 -2
- package/schema/component-schema.json +14 -1
- package/src/JafCore.js +2 -2
- package/types/index.d.ts +122 -82
- package/lib/imanual.js +0 -6
- package/lib/xmanual.js +0 -6
- package/rulepacks/jetwc-lib/component-audit-utils.js +0 -6
package/lib/DomUtils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
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;
|
package/lib/FileIndex.js
CHANGED
package/lib/FileSet.js
CHANGED
package/lib/FsUtils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
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,Utils;const tmpFile=require('tmp');function getFileType(path){var stats,ret;try{stats=nodeDeps.fs.statSync(path);if(stats.isFile()){ret='f'}else if(stats.isDirectory()){ret='d'}}catch(e){ret=e}return ret};function getFileTypeWithMsg(path){var ret;ret=getFileType(path);if(ret!=='f'&&ret!=='d'){if(ret.message.startsWith('ENOENT:')){console.log('\n** File "'+path+'" not found')}else{console('\n** File "'+path+'" error.\n'+' '+ret.message+'.\n')}ret='?'}return ret};function getFileExt(path){var s;try{if(!isSymLink(path)){s=nodeDeps.path.extname(path)}else{let p=nodeDeps.fs.readlinkSync(path);if(p){s=nodeDeps.path.extname(p)}}if(s&&s.charAt(0)==='.'){s=s.substring(1)}return s}catch(e){}return''};function isSymLink(path){var stats;try{stats=nodeDeps.fs.lstatSync(path);return stats.isSymbolicLink()}catch(e){}return false};function fileExists(filepath,dir){var stats,ret=false;try{stats=nodeDeps.fs.lstatSync(filepath);ret=dir?stats.isDirectory():stats.isFile()}catch(e){}return ret};function pathExistsSync(filepath){try{return nodeDeps.fs.existsSync(filepath)}catch(e){}return false};function readDir(path){var ret=[];try{_readDir(path,ret)}catch(e){ret=null}return ret};function _readDir(dir,ar){var files,file,filePath,stat,arDir,i;files=nodeDeps.fs.readdirSync(dir);for(i=0;i<files.length;i++){file=files[i];if(file[0]==='.'){continue}filePath=nodeDeps.path.join(dir,file);stat=nodeDeps.fs.statSync(filePath);if(stat.isFile()){ar.push({name:file,isFile:true})}else if(stat.isDirectory()){arDir=[];ar.push({name:file,isFile:false,files:arDir});_readDir(filePath,arDir)}}};function createFolder(dirPath,orig){var rc;dirPath=nodeDeps.path.resolve(dirPath);if(!orig){orig=dirPath}try{if(!nodeDeps.fs.statSync(dirPath).isDirectory()){return new Error(dirPath+' exists but is not a directory')}}catch(err){if(err.code==='ENOENT'){var np=nodeDeps.path.dirname(dirPath);if(np===dirPath){return new Error(orig+' cannot be created')}rc=createFolder(np,orig);if(typeof rc!=='boolean'){return rc}nodeDeps.fs.mkdirSync(dirPath);if(dirPath===orig){return true}}else{return err}}return true};function deleteFolder(filepath,deleteTarget){if(nodeDeps.fs.existsSync(filepath)){nodeDeps.fs.readdirSync(filepath).forEach(function(file){var curPath=nodeDeps.path.join(filepath,file);if(nodeDeps.fs.lstatSync(curPath).isDirectory()){deleteFolder(curPath,true)}else{nodeDeps.fs.unlinkSync(curPath)}});if(deleteTarget){nodeDeps.fs.rmdirSync(filepath)}}};function getUniqueFileName(template){
|
|
6
|
+
var nodeDeps,Utils;const tmpFile=require('tmp');function getFileType(path){var stats,ret;try{stats=nodeDeps.fs.statSync(path);if(stats.isFile()){ret='f'}else if(stats.isDirectory()){ret='d'}}catch(e){ret=e}return ret};function getFileTypeWithMsg(path){var ret;ret=getFileType(path);if(ret!=='f'&&ret!=='d'){if(ret.message.startsWith('ENOENT:')){console.log('\n** File "'+path+'" not found')}else{console('\n** File "'+path+'" error.\n'+' '+ret.message+'.\n')}ret='?'}return ret};function getFileExt(path){var s;try{if(!isSymLink(path)){s=nodeDeps.path.extname(path)}else{let p=nodeDeps.fs.readlinkSync(path);if(p){s=nodeDeps.path.extname(p)}}if(s&&s.charAt(0)==='.'){s=s.substring(1)}return s}catch(e){}return''};function isSymLink(path){var stats;try{stats=nodeDeps.fs.lstatSync(path);return stats.isSymbolicLink()}catch(e){}return false};function fileExists(filepath,dir){var stats,ret=false;try{stats=nodeDeps.fs.lstatSync(filepath);ret=dir?stats.isDirectory():stats.isFile()}catch(e){}return ret};function pathExistsSync(filepath){try{return nodeDeps.fs.existsSync(filepath)}catch(e){}return false};function readDir(path){var ret=[];try{_readDir(path,ret)}catch(e){ret=null}return ret};function _readDir(dir,ar){var files,file,filePath,stat,arDir,i;files=nodeDeps.fs.readdirSync(dir);for(i=0;i<files.length;i++){file=files[i];if(file[0]==='.'){continue}filePath=nodeDeps.path.join(dir,file);stat=nodeDeps.fs.statSync(filePath);if(stat.isFile()){ar.push({name:file,isFile:true})}else if(stat.isDirectory()){arDir=[];ar.push({name:file,isFile:false,files:arDir});_readDir(filePath,arDir)}}};function createFolder(dirPath,orig){var rc;dirPath=nodeDeps.path.resolve(dirPath);if(!orig){orig=dirPath}try{if(!nodeDeps.fs.statSync(dirPath).isDirectory()){return new Error(dirPath+' exists but is not a directory')}}catch(err){if(err.code==='ENOENT'){var np=nodeDeps.path.dirname(dirPath);if(np===dirPath){return new Error(orig+' cannot be created')}rc=createFolder(np,orig);if(typeof rc!=='boolean'){return rc}nodeDeps.fs.mkdirSync(dirPath);if(dirPath===orig){return true}}else{return err}}return true};function deleteFolder(filepath,deleteTarget){if(nodeDeps.fs.existsSync(filepath)){nodeDeps.fs.readdirSync(filepath).forEach(function(file){var curPath=nodeDeps.path.join(filepath,file);if(nodeDeps.fs.lstatSync(curPath).isDirectory()){deleteFolder(curPath,true)}else{nodeDeps.fs.unlinkSync(curPath)}});if(deleteTarget){nodeDeps.fs.rmdirSync(filepath)}}};function getUniqueFileName(template,targetFolder){const opts={template:template};if(targetFolder){opts.dir=targetFolder}return tmpFile.tmpNameSync(opts)};function findFile(dir,name,fncb){var ret;try{ret=_findFile(dir,name,fncb)}catch(e){}return ret};function _findFile(dir,name,fncb){var files,file,filePath,stat,ret,i;files=nodeDeps.fs.readdirSync(dir);for(i=0;i<files.length;i++){file=files[i];if(!fncb||fncb(dir,file)){if(file===name){return dir}}if(file[0]==='.'){continue}filePath=nodeDeps.path.join(dir,file);stat=nodeDeps.fs.statSync(filePath);if(stat.isDirectory()){ret=_findFile(filePath,name,fncb);if(ret){return ret}}}return null};function readFileSync(filePath,error){return _readFileSync(filePath,false,error)};function readFileBufSync(filePath,error){return _readFileSync(filePath,true,error)};function _readFileSync(filePath,wantBuffer,error){var haveFn,doThrow,noThrow,t;t=typeof error;doThrow=t==='boolean'&&error;noThrow=t==='boolean'&&!error;haveFn=t==='function';try{return wantBuffer?nodeDeps.fs.readFileSync(filePath):nodeDeps.fs.readFileSync(filePath,'utf8')}catch(e){function _prepErr(){var s=e.message;if(s.startsWith('ENOENT')){s=`ENOENT: file not found - '${filePath}'`}return s}if(haveFn){error(_prepErr())}else if(doThrow){throw new Error(e)}else if(noThrow){return _prepErr()}}return null};function readJsonSync(filepath,comments,error){var e,haveFn,doThrow,noThrow,t;t=typeof error;doThrow=t==='boolean'&&error;noThrow=t==='boolean'&&!error;haveFn=t==='function';var _fn=function(err){err='SYNTAX: '+err;e=err;if(haveFn){error(err)}};filepath=makeAbsolutePath(filepath);var o=nodeDeps.jsonLoader.load(filepath,nodeDeps,_fn,comments,Utils);if(e){if(doThrow){throw new Error(e)}else if(noThrow){return e}return null}if(o){return o}let msg='NOFILE: '+filepath;if(doThrow){throw new Error(msg)}if(noThrow){return msg}if(haveFn){error(msg)}return null};function writeJsonSync(obj,filepath,opts,error){var repl,ind,err;var doThrow,noThrow,haveFn,t;t=typeof error;doThrow=t==='boolean'&&error;noThrow=t==='boolean'&&!error;haveFn=t==='function';if(opts){repl=opts.replacer?opts.replacer:null;ind=opts.spaces}filepath=makeAbsolutePath(filepath);try{let s=JSON.stringify(obj,repl,ind);nodeDeps.fs.writeFileSync(filepath,s);return true}catch(e){if(doThrow){throw e}err=e}if(err){if(haveFn){error(err.message);return false}if(noThrow){return err.message}}return false};function makeAbsolutePath(filepath){if(!nodeDeps.path.isAbsolute(filepath)){filepath=nodeDeps.path.resolve(process.cwd(),filepath)}return filepath};function setNodeDeps(nd,utils){nodeDeps=nd;Utils=utils};module.exports.fileExistsSync=fileExists;module.exports.fileExists=fileExists;module.exports.pathExistsSync=pathExistsSync;module.exports.getFileTypeSync=getFileType;module.exports.getFileType=getFileType;module.exports.getFileTypeWithMsgSync=getFileTypeWithMsg;module.exports.getFileTypeWithMsg=getFileTypeWithMsg;module.exports.getFileExtSync=getFileExt;module.exports.getFileExt=getFileExt;module.exports.isSymLinkSync=isSymLink;module.exports.isSymLink=isSymLink;module.exports.createFolderSync=createFolder;module.exports.createFolder=createFolder;module.exports.deleteFolderSync=deleteFolder;module.exports.deleteFolder=deleteFolder;module.exports.readDirSync=readDir;module.exports.readDir=readDir;module.exports.readFileSync=readFileSync;module.exports.readFileBufSync=readFileBufSync;module.exports.readJsonSync=readJsonSync;module.exports.writeJsonSync=writeJsonSync;module.exports.makeAbsolutePath=makeAbsolutePath;module.exports.findFileSync=findFile;module.exports.findFile=findFile;module.exports.getUniqueFileNameSync=getUniqueFileName;module.exports.getUniqueFileName=getUniqueFileName;module.exports.setNodeDeps=setNodeDeps;
|
package/lib/Histo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
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 FULL_BLOCK="\u2588";const HALF_ELEM="\u2588";const FOURTH_ELEM="\u258C";function Histo(oStats,width,
|
|
6
|
+
const FULL_BLOCK="\u2588";const HALF_ELEM="\u2588";const FOURTH_ELEM="\u258C";function Histo(oStats,width,oColors){this._maxWidth=width;this._Colors=oColors;this._colorMode=oColors.isColor();this._count=0;let sev,nums=[];for(sev in oStats){nums.push(oStats[sev])};this._total=_sum(nums);this._maxBar=this._barLengths(nums);this._factor=this._maxBar>1?this._maxWidth/this._maxBar:1;this._clrCounts=_barColors(nums.length)};Histo.prototype.bar=function(n){var ret,val=n/this._total*this._maxWidth;var colors=this._Colors;if(val>0.5&&val<1){ret=HALF_ELEM.repeat(this._factor)}else if(val===0){ret=""}else if(val<0.5){ret=FOURTH_ELEM.repeat(this._factor)}else{ret=FULL_BLOCK.repeat(val*this._factor)}if(this._colorMode){ret=++this._count<=this._clrCounts[0]?colors.RED(ret):this._count<=this._clrCounts[1]?colors.BRIGHTBLUE(ret):colors.GREEN(ret)}return ret};Histo.prototype._barLengths=function(nums){var i,max=0,n;for(i=0;i<nums.length;i++){n=nums[i]/this._total*this._maxWidth;if(n>max){max=n}}this._factor=max>1?this._maxWidth/max:1;return max};function _sum(nums){var t=0;nums.forEach(n=>{if(!isNaN(n)){t+=n}});return t};function _barColors(n){var a=[];if(n===5){a.push(2);a.push(4)}else if(n===4){a.push(2);a.push(3);a.push(4)}else if(n===3){a.push(1);a.push(2);a.push(3)}else if(n<=2){a.push(1);a.push(2)}else if(n===1){a.push(1)}return a}module.exports=Histo;
|
package/lib/HtmlTree.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
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 NodeType=require("./NodeTypes");const BAD_TAGS=["=","'","\"",",",".","/","\\",";",":","&","%","$","#","@","*"];var HtmlTree=function(nodeDeps,appContext,HtmlParser,domUtils){this._HtmlParser=HtmlParser;this._Dom=null;this._elemStack=[];this._DomUtils=domUtils;this._tabs=null;this._nodeDeps=nodeDeps;this._appContext=appContext;this._error=appContext.error;this._assert=appContext.assert;this._utils=this._appContext.utils};HtmlTree.prototype.walk=function(cb){var dom=this._Dom;var i;if(dom){for(i=0;i<dom.length;i++){this._walk2(dom[i],cb)}}cb.onEnd()};HtmlTree.prototype._walk2=function(node,cb){var tagName,attr,nt,nodePushed,inJsScript,i;nt=node.type;if(this.isScriptTypescript(node)){return}if(nt===NodeType.TAG||nt===NodeType.STYLE||nt===NodeType.SCRIPT){if(BAD_TAGS.includes(node.name.charAt(0))){return}this._elemStack.push(node);nodePushed=true;tagName=node.name;cb.onOpenTagname(node,tagName);inJsScript=this.isScriptExecutable(node);if(
|
|
6
|
+
const NodeType=require("./NodeTypes");const BAD_TAGS=["=","'","\"",",",".","/","\\",";",":","&","%","$","#","@","*"];var HtmlTree=function(nodeDeps,appContext,HtmlParser,domUtils){this._HtmlParser=HtmlParser;this._Dom=null;this._elemStack=[];this._DomUtils=domUtils;this._tabs=null;this._nodeDeps=nodeDeps;this._appContext=appContext;this._error=appContext.error;this._assert=appContext.assert;this._utils=this._appContext.utils};HtmlTree.prototype.walk=function(cb){var dom=this._Dom;var i;if(dom){for(i=0;i<dom.length;i++){this._walk2(dom[i],cb)}}cb.onEnd()};HtmlTree.prototype._walk2=function(node,cb){var tagName,attr,nt,nodePushed,inJsScript,i;nt=node.type;if(this.isScriptTypescript(node)){return}if(nt===NodeType.TAG||nt===NodeType.STYLE||nt===NodeType.SCRIPT){if(BAD_TAGS.includes(node.name.charAt(0))){return}this._elemStack.push(node);nodePushed=true;tagName=node.name;cb.onOpenTagname(node,tagName);inJsScript=this.isScriptExecutable(node);if(node.attribs){for(attr in node.attribs){cb.onAttribute(node,attr,node.attribs[attr])}}}else if(nt===NodeType.TEXT){cb.onText(node,node.data)}else if(nt===NodeType.COMMENT){cb.onComment(node,node.data)}else if(nt===NodeType.DIRECTIVE){if(node.data.charAt(0)==="?"){cb.onProcessingInstruction(node,node.data)}else{cb.onDirective(node,node.data)}}if(!inJsScript&&tagName!=="pre"&&nt!==NodeType.TEXT){if(node.children){for(i=0;i<node.children.length;i++){this._walk2(node.children[i],cb)}}}if(nodePushed){this._elemStack.pop()}};HtmlTree.prototype.getElemStack=function(){return this._elemStack};HtmlTree.prototype.dumpElemStack=function(){var i,s="",indent=" ";for(i=0;i<this._elemStack.length;i++){s+=i>0?"\n"+indent.repeat(i):"";s+=this._elemStack[i].name}return s};HtmlTree.prototype.getFirstTagNode=function(){var dom=this._Dom;var i,node,ret=null;if(dom){for(i=0;i<dom.length;i++){node=this._getFirstTagNode2(dom[i]);if(node){return node}}}return ret};HtmlTree.prototype._getFirstTagNode2=function(node){var nt,i;nt=node.type;if(nt===NodeType.TAG||nt===NodeType.STYLE||nt===NodeType.SCRIPT){return node}if(node.children){for(i=0;i<node.children.length;i++){node=this._getFirstTagNode2(node.children[i]);if(node){return node}}}return null};HtmlTree.prototype.getTopNode=function(){return this._Dom&&this._Dom.length>0?this._Dom[0]:null};HtmlTree.prototype.parse=function(pageText){var _self=this;this._Dom=null;this._data=pageText;var DomHandler=new this._HtmlParser.DomHandler(function(error,dom){if(error){_self._error("Parse Html tree error : "+error);return}else{_self._Dom=dom;_self._DomUtils.setDom(dom)}},{xmlMode:true,withStartIndices:true,withEndIndices:true,recognizeSelfClosing:true});var treeParser=new this._HtmlParser.Parser(DomHandler,{xmlMode:true,withStartIndices:true,withEndIndices:true,lowerCaseTags:false,lowerCaseAttributeNames:false,recognizeSelfClosing:true});treeParser.write(pageText);treeParser.end();this._applyParserFix1();this._applyParserFix2()};HtmlTree.prototype._applyParserFix1=function(){if(!this._Dom||this._Dom.length<2){return}if(this._Dom[0].type===NodeType.TEXT&&this._Dom[1].type===NodeType.DIRECTIVE){this._Dom[1].startIndex=this._Dom[0].endIndex}};HtmlTree.prototype._applyParserFix2=function(){var node;if(!this._Dom||this._Dom.length<1){return}node=this._Dom[0];if(node.type===NodeType.DIRECTIVE&&node.endIndex===null){node.endIndex=node.data.length}};HtmlTree.prototype.isScriptExecutable=function(scriptNode){var attribs=scriptNode.attribs;return scriptNode.type&&scriptNode.type===NodeType.SCRIPT&&(!attribs||!attribs.type||attribs.type.indexOf("html")<0&&attribs.type.indexOf("typescript")<0)};HtmlTree.prototype.isScriptJSLink=function(scriptNode){var ret=null;var attribs=scriptNode.attribs;if(attribs.src){ret=attribs.src.toLowerCase().endsWith("js")?attribs.src:null}return ret};HtmlTree.prototype.isScriptTypescript=function(scriptNode){var attribs=scriptNode.attribs;return scriptNode.type&&scriptNode.type===NodeType.SCRIPT&&attribs&&attribs.type&&attribs.type.indexOf("typescript")>=0};module.exports=HtmlTree;
|
package/lib/HtmlUtils.js
CHANGED
package/lib/Issue.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
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 Issue=function(msg,id){this.msg=msg;if(id){this.setId(id)}};Issue.prototype.setMsg=function(msg){this.msg=msg;return this};Issue.prototype.setId=function(id){this.msgId=id||"0000";return this};Issue.prototype.setMsgKey=function(key){this.msgKey=key;return this};Issue.prototype.setPosition=function(arg,col,startIndex,endIndex){var line;if(arg&&typeof arg==="object"){
|
|
6
|
+
var Issue=function(msg,id){this.msg=msg;if(id){this.setId(id)}};Issue.prototype.setMsg=function(msg){this.msg=msg;return this};Issue.prototype.setId=function(id){this.msgId=id||"0000";return this};Issue.prototype.setMsgKey=function(key){this.msgKey=key;return this};Issue.prototype.setPosition=function(arg,col,startIndex,endIndex){var line;if(arg&&typeof arg==="object"){if(arg.hasOwnProperty("startIndex")){startIndex=arg.startIndex}else if(arg.hasOwnProperty("start")){startIndex=arg.start}if(arg.hasOwnProperty("endIndex")){endIndex=arg.endIndex}else if(arg.hasOwnProperty("end")){endIndex=arg.end}if(arg.hasOwnProperty("line")){line=arg.line}else if(arg.hasOwnProperty("row")){line=arg.row}col=arg.col}else{line=arg}if(line!==null&&col!==null){this.index={line:line,col:col}}if(startIndex!==undefined){if(!this.index){this.index={}}this.index.start=startIndex;this.index.end=endIndex}return this};Issue.prototype.setSeverity=function(severity){if(severity){this.severity=severity}return this};Issue.prototype.setReportedFilePath=function(fp){this.filepath=fp};module.exports=Issue;
|
package/lib/JafEvents.js
CHANGED
package/lib/JafLib.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
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 CLI_MODE="cli";const API_MODE="api";const AMD_MODE="amd";function JafLib(nd,jfs,mctx,runMode,jafver,jv,cfg){this._rdy=-1;this.setup(nd,jfs,mctx,runMode,jafver,jv,cfg)};JafLib.prototype.getFileset=function(ruleCtx){if(this._nd&&ruleCtx.phase&&ruleCtx.phase==="startaudit"){return this._jfs.getFiles()}};JafLib.prototype.setFileset=function(ruleCtx,files,exclude){var rc=false;if(this._nd&&ruleCtx.phase&&ruleCtx.phase==="startaudit"){if(files&&!Array.isArray(files)||exclude&&!Array.isArray(exclude)){this._mCtx.error("Rule '"+ruleCtx.ruleName+"' attempt to call JafLib.setfiles() with non-array");this._jfs.setFiles(null,null);return false}this._jfs.setFiles(files,exclude);rc=true}return rc};JafLib.prototype.getRunMode=function(){return this._runMode};JafLib.prototype.getConfig=function(){return this._cfg};JafLib.prototype.
|
|
6
|
+
const CLI_MODE="cli";const API_MODE="api";const AMD_MODE="amd";function JafLib(nd,jfs,mctx,runMode,jafver,jv,cfg){this._rdy=-1;this.setup(nd,jfs,mctx,runMode,jafver,jv,cfg)};JafLib.prototype.getFileset=function(ruleCtx){if(this._nd&&ruleCtx.phase&&ruleCtx.phase==="startaudit"){return this._jfs.getFiles()}};JafLib.prototype.setFileset=function(ruleCtx,files,exclude){var rc=false;if(this._nd&&ruleCtx.phase&&ruleCtx.phase==="startaudit"){if(files&&!Array.isArray(files)||exclude&&!Array.isArray(exclude)){this._mCtx.error("Rule '"+ruleCtx.ruleName+"' attempt to call JafLib.setfiles() with non-array");this._jfs.setFiles(null,null);return false}this._jfs.setFiles(files,exclude);rc=true}return rc};JafLib.prototype.getRunMode=function(){return this._runMode};JafLib.prototype.getConfig=function(){return this._cfg};JafLib.prototype.getTsConfigObj=function(){return this._cfg.getTsConfigObj()};JafLib.prototype.isCLI=function(){return this._runMode===CLI_MODE};JafLib.prototype.isAPI=function(){return this._runMode===API_MODE};JafLib.prototype.isAMD=function(){return this._runMode===AMD_MODE};JafLib.prototype.getJetVer=function(){return this._jetver};JafLib.prototype.getJafVer=function(){return this._jafver};JafLib.prototype.setup=function(nd,jfs,mctx,runMode,jafver,jv,cfg){if(this._rdy===-1){this._nd=nd;this._jfs=jfs;this._mCtx=mctx;this._runMode=runMode;this._jafver=jafver;this._jetver=jv;this._cfg=cfg}};JafLib.prototype.disable=function(){this._rdy=-2};JafLib.prototype.getJafLib=function(){return{getConfig:this.getConfig.bind(this),getTsConfigObj:this.getTsConfigObj.bind(this),getRunMode:this.getRunMode.bind(this),isCLI:this.isCLI.bind(this),isAPI:this.isAPI.bind(this),isAMD:this.isAMD.bind(this),getJetVer:this.getJetVer.bind(this),getJafVer:this.getJafVer.bind(this)}};JafLib.prototype.getPublic=function(){return{setFileset:this.setFileset.bind(this),getFileset:this.getFileset.bind(this)}};module.exports=JafLib;
|
package/lib/Json.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
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 AstJson=require("../lib/AstJson");const FILETYPE=require("./filetypes");class Json{constructor(parser,nd,rules,fileIndex,appCtx,msgCtx){this._parser=parser;this._rules=rules;this._Issue=appCtx.Issue;this._reporter=appCtx.reporter;this._fileIndex=fileIndex;this._utils=appCtx.utils;this._msgCtx=msgCtx;this._nd=nd;this._Ast=null;this._AstJson=new AstJson(msgCtx)}parse(data,file){var suppData,rc;suppData=this._checkSyntax(data,false);rc=this._parser.fireHookFileRules(suppData.ast,suppData,false);if(typeof rc==="undefined"||typeof rc==="boolean"&&rc){this._rules.fireRules({type:FILETYPE.JSON,obj:suppData,tagNode:null,rawData:this._rawData,data:this._data,suppData:suppData
|
|
6
|
+
const AstJson=require("../lib/AstJson");const FILETYPE=require("./filetypes");class Json{constructor(parser,nd,rules,fileIndex,appCtx,msgCtx){this._parser=parser;this._rules=rules;this._Issue=appCtx.Issue;this._reporter=appCtx.reporter;this._fileIndex=fileIndex;this._utils=appCtx.utils;this._msgCtx=msgCtx;this._nd=nd;this._Ast=null;this._AstJson=new AstJson(msgCtx)}parse(data,file){var suppData,rc;suppData=this._checkSyntax(data,false);rc=this._parser.fireHookFileRules(suppData.ast,suppData,false);if(typeof rc==="undefined"||typeof rc==="boolean"&&rc){this._rules.fireRules({type:FILETYPE.JSON,obj:suppData,tagNode:null,rawData:this._rawData,data:this._data,suppData:suppData},null,file,FILETYPE.JSON,suppData,false)}this._parser.fireHookFileRules(null,null)}parseOnly(data){return this._checkSyntax(data,false)}getAst(){return this._Ast}clear(){}_checkSyntax(data,hasComments){var suppData=this._isValidJson(data,hasComments);if(typeof suppData.msg==="string"){suppData.ast=null;this._parser.startIndex=this._parser.endIndex=suppData.position}else{suppData.ast=this._AstJson.parse(data);this._startIndex=this._endIndex=0}return suppData}_isValidJson(data,isComments){var obj=this._utils.parseJson(data,isComments);if(obj.msg){obj.msg=obj.msg+` at line ${obj.line}, col ${obj.col} (position ${obj.startIndex})`;obj.position=obj.startIndex}return obj}}module.exports=Json;
|
package/lib/JsonLoader.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
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
|
-
function load(inFile,nd,fnError,allowComments,utils){var obj=null,json;try{if(nd.fs.existsSync(inFile)){
|
|
6
|
+
function load(inFile,nd,fnError,allowComments,utils){var obj=null,json;try{if(nd.fs.existsSync(inFile)){json=nd.fs.readFileSync(inFile,'utf8');if(allowComments){json=nd.decomment(json)}obj=JSON.parse(nd.decomment(json))}else{if(fnError){fnError(`file not found "${inFile}"`)}}}catch(e){if(fnError){let msg=_convertJsonPosToRowCol(e.message,nd.fs.readFileSync(inFile,'utf8'),utils);fnError(msg?msg:e.message)}}return obj};function _convertJsonPosToRowCol(msg,data,utils){var x,n,rc;x=msg.indexOf('position');if(x<0){return null}n=parseInt(msg.substr(x+8).trim());rc=utils.getRowColFromIndex(data,n);return msg.substr(0,x)+'row '+rc.row+', col '+rc.col};module.exports.load=load;
|
package/lib/Md.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
const AstMd=require("../lib/AstMd");const FILETYPE=require("./filetypes");class Md{constructor(parser,nd,rules,fileIndex,appCtx,msgCtx){this._parser=parser;this._rules=rules;this._Issue=appCtx.Issue;this._reporter=appCtx.reporter;this._utils=appCtx.utils;this._msgCtx=msgCtx;this._nd=nd;this._Ast=null;this._AstMd=new AstMd(appCtx)}parse(data,file){var suppData,rc;this._Ast=this._AstMd.parse(data,{});suppData={ast:this._Ast,utils:this._AstMd.createHandler()};rc=this._parser.fireHookFileRules(suppData.ast,suppData,false);if(typeof rc==="undefined"||typeof rc==="boolean"&&rc){this._fireMdEvents(suppData,file)}this._parser.fireHookFileRules(null,null)}getAst(){return this._Ast}clear(){this._Ast=null}_fireMdEvents(suppData,file){var data,prop,obj,val,utils=suppData.utils;data=utils.getLinks();data.forEach(link=>{this._fireEvent("md-link",link,suppData,file)});data=utils.getRefLinks();obj={};for(prop in data){val=data[prop];obj.refKey=prop;obj.link=val.link;obj.pos=val.pos;this._fireEvent("md-ref",obj,suppData,file)}data=utils.getParas();data.forEach(para=>{this._fireEvent("md-para",para,suppData,file)});data=utils.getImages();data.forEach(img=>{this._fireEvent("md-image",img,suppData,file)});data=utils.getLists();data.forEach(list=>{this._fireEvent("md-list",list,suppData,file)});data=utils.getCode();data.forEach(code=>{this._fireEvent("md-code",code,suppData,file)})}_fireEvent(type,arg1,suppData,file){this._rules.fireRules({type:type,obj:suppData,tagNode:null,rawData:this._rawData,data:this._data,suppData:suppData},arg1,file,FILETYPE.MD,suppData,false)}}module.exports=Md;
|
package/lib/MetaLib.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
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 Namespaces=require("./ns");const HtmlUtils=require("./HtmlUtils");const SemVer=require("semver");var nodeDeps;const NO_SUGGESTION_AVAIL="No suggestion available.";const OJPREFIX="oj-";const OJEVENTPREFIX="on-oj-";const OJS="ojs/oj";const EVENT_PREFIX="on-";const DOT=".";const DATA_OJ_CMD="data-oj-command";const PROP_SLOTS="slots";const PROP_PROPS="props";const PROP_EVENTS="events";const PROP_IMPLEMENTS="implements";const PROP_FOLDER="folder";const PROP_VERSION="version";const PROP_UNSUP_THEME="unsupTheme";const PROP_SUBCOMPONENT_TYPE="subcomponentType";const PACK_PRIVATE="packPrivate";function MetaLib(nd,runMode,msgContext,utils){this._json=null;this._delHist=null;this._renHist=null;this._reqAttrs=null;this._nonClasses=null;this._components=null;this._compSvcs=null;this._stylesets=null;this._runMode=runMode;this._utils=utils;this._domUtils=null;if(nd.jetver){this._jetVersions=nd.jetver.getVersions();this._jetDefVersion=nd.jetver.getDefault()}this._jetVer=null;this._theme=null;this._deprecatedMethods=null;this._deprecatedMembers=null;this._deletedMethods=null;this._deletedMembers=null;this._error=msgContext.error;this._debug=msgContext.debug;this._info=msgContext.info;this._msg=msgContext.msg;nodeDeps=nd};MetaLib.prototype.isNSRegistered=function(prefix){return Namespaces.has(prefix)};MetaLib.prototype.isNamespacePrefix=function(tagName){return HtmlUtils.isNamespaceTag(tagName)};MetaLib.prototype.isJetTag=function(tagName){return!!this._getComponentNameFromTag(_removeChevrons(tagName))};MetaLib.prototype.isComponentTag=function(tagName){return this._components&&this._components.isTag(_removeChevrons(tagName))};MetaLib.prototype.isWCTag=function(tagName){return this.isJetTag(tagName)||this.isComponentTag(tagName)};MetaLib.prototype.isCCATag=function(tagName){return this.isWCTag(tagName)};MetaLib.prototype.isTagDeprecated=function(tagName){var clazz,ret;if(clazz=this._getComponentNameFromTag(_removeChevrons(tagName))){ret=this.isClassDeprecated(clazz)}else{ret=this._components.isTagDeprecated(tagName)}return ret};MetaLib.prototype.isTagAttrDeprecated=function(tagName,attrName){var member,ret=null;member=this._getTagAttrMemberObj(tagName,attrName);if(member){ret=this._isSubStateDeprecated(member)}else{ret=this._components.isTagAttrDeprecated(tagName,attrName)}if(ret){if(typeof ret==="string"){ret=HtmlUtils.replaceEntities(ret)}else{if(ret.description){ret.description=HtmlUtils.replaceEntities(ret.description)}}}return ret};MetaLib.prototype.isTagEventDeprecated=function(tag,attr){var x1,x2;if((x1=attr.indexOf("-"))<0){return false}attr=attr.substring(x1+1);if((x2=attr.lastIndexOf("-"))>=0){attr=attr.substring(0,x2)}return this.isTagAttrDeprecated(tag,attr)};MetaLib.prototype.isTagAttr=function(tagName,attrName){var o,ret=false;attrName=attrName.charAt(0)===":"?attrName.substr(1):attrName;if(this.isCCATag(tagName)){o=this._getComponentFromTag(tagName);if(o){ret=this.isJetTagAttr(o,attrName)}else{ret=this._components&&this._components.isTagAttr(tagName,attrName)}}return ret};MetaLib.prototype.isJetTagAttr=function(tagObj,attrName){attrName=attrName.charAt(0)===":"?attrName.substr(1):attrName;var ret=!!(tagObj.htmlattributes&&tagObj.htmlattributes[attrName]);if(!ret&&attrName===DATA_OJ_CMD){ret=!!tagObj.member[DATA_OJ_CMD]}return ret};MetaLib.prototype._getTagAttrMemberObj=function(tagName,attrName){var obj,attrib,member,x;obj=this._getComponentFromTag(_removeChevrons(tagName));attrName=attrName.charAt(0)===":"?attrName.substr(1):attrName;if(!obj||!obj.htmlattributes||!obj.htmlattributes[attrName]){return null}member=null;attrib=obj.htmlattributes[attrName];if(attrib){x=attrib.indexOf(DOT);if(x>=0){if(obj.member){member=this._findSubMember(obj,obj.member,attrib,attrib)}}else{member=obj.member[attrib];if(member){return member}}}return member};MetaLib.prototype._findSubMember=function(obj,mem,attrName,subMemberPart){var member,ts,sm,rest,x,ret=null;x=subMemberPart.indexOf(DOT);if(x>=0){sm=subMemberPart.substring(0,x);rest=subMemberPart.substring(x+1)}else{sm=subMemberPart;rest=null}for(member in mem){member=mem[member];if(member.name!==sm){continue}if(!rest){ret=member;break}if(member.submember){ret=this._findSubMember(obj,member.submember,attrName,rest);if(ret){break}}else if(member.tstype){ts=this._getTsTypeObject(member);if(ts){ret=this._findSubMember(obj,ts.member,attrName,rest);if(ret){break}}}if(ret){break}}return ret};MetaLib.prototype._getTsTypeObject=function(mem){var ts,o,s,x;ts=mem.tstype;if(ts&&ts.target==="Type"&&typeof ts.value==="string"){s=ts.value;s=s.replace("=","");x=s.indexOf("|");if(x>=0){s=s.substring(0,x).trimRight()}if(s.charAt(s.length-1)===">"){x=s.lastIndexOf("<");if(s>=0){s=s.substring(0,x)}}o=this._json[s];if(!o){o=this._json[mem.memberof];if(o.typedef){s=ts.value;x=s.lastIndexOf(DOT);if(x>=0){s=s.substring(x+1);o=o.typedef[s]}}}}return o?o:null};MetaLib.prototype._getSubMemberPart=function(fullAttr,soFar){var s,x;s=fullAttr.replace(soFar,"");if(s.length){if(s.charAt(0)==="."){x=s.indexOf(DOT,1);if(x>=0){s=soFar+s.substring(0,x)}else{s=soFar+s}}}else{s=soFar}return s};MetaLib.prototype._handleAttrObject=function(member){var link,types,i,x;types=member.tstype;if(types){for(i=0;i<types.length;i++){if(types[i].target==="Type"){link=types[i].value;link=link.replace("=","");x=link.indexOf("<K");if(x>=0){link=link.substring(0,x)}break}}}return link};MetaLib.prototype.hasTagAttrValues=function(tagName,attrName){var member,ojv,ret=false;member=this._getTagAttrMemberObj(tagName,attrName);if(member){ojv=this._getOjValues(member);return!!ojv}else if(this._components.isTag(tagName)){ret=this._components.hasTagAttrValues(tagName,attrName)}return ret};MetaLib.prototype.isTagAttrValue=function(tagName,attrName,attrValue){var member,ojv,values,curValue,valType,i,ret=false;member=this._getTagAttrMemberObj(tagName,attrName);if(member){ojv=this._getOjValues(member);if(ojv){values=ojv.name;for(i=0;i<values.length;i++){if(ojv.type){valType=ojv.type[i];curValue=_convertValue(valType,attrValue);ret=curValue===values[i]}else{ret=attrValue===values[i]}if(ret){break}}}else{ret=true}}else{if(this._components.isTag(tagName)){ret=this._components.isTagAttrValue(tagName,attrName,attrValue)}}return ret};MetaLib.prototype.isTagAttrEnumValueDeprecated=function(tagName,attrName,enumValue){var member,ojv,values,deps,dep,i,j,ret=null;member=this._getTagAttrMemberObj(tagName,attrName);if(!member){return this._isCompTagAttrEnumDepr(tagName,attrName,enumValue)}if(member.ojdeprecated){ojv=this._getOjValues(member);if(ojv){values=ojv.name;for(i=0;i<values.length;i++){if(values[i]===enumValue){deps=member.ojdeprecated;for(j=0;j<deps.length;j++){dep=deps[j];if(dep.target==="propertyValue"&&dep.for===enumValue){ret={since:dep.since,description:dep.description};break}}}if(ret){break}}}}return ret};MetaLib.prototype._isCompTagAttrEnumDepr=function(tagName,attrName,enumValue){return this._components?this._components.isTagAttrEnumDeprecated(tagName,attrName,enumValue):null};MetaLib.prototype.hasTagSlot=function(tagName){return this._getSlots(tagName)?true:false};MetaLib.prototype.hasDynamicTagSlot=function(tagName){};MetaLib.prototype.isTagSlotValue=function(tagName,slotName){var tag,slot;tag=_removeChevrons(tagName);if(this.isJetTag(tagName)){slot=this._getSlotByName(this._getComponentFromTag(tag),slotName)}else if(this._components){if(!HtmlUtils.isCommonElem(tag)){slot=this._components.hasTagSlotName(tag,slotName)}}return!!slot};MetaLib.prototype.isTagDynamicSlotValue=function(tagName,slotName){};MetaLib.prototype.getPreferredSlotContent=function(tag,slot){var ret;tag=_removeChevrons(tag);if(this.isJetTag(tag)){ret=this._getJetPreferredSlotContent(tag,slot)}else if(this._components){ret=this._components.getPreferredSlotContent(tag,slot)}return ret};MetaLib.prototype._getJetPreferredSlotContent=function(tag,slot){};MetaLib.prototype.getTagSlotMetadata=function(tag,slot){var ret;tag=_removeChevrons(tag);if(this.isJetTag(tag)){ret=this._getJetTagSlotMetadata(tag,slot)}else if(this._components){ret=this._components.getTagSlotMetadata(tag,slot)}return ret};MetaLib.prototype._getJetTagSlotMetadata=function(tag,slot){};MetaLib.prototype.isTagSupportedInTheme=function(tag){var o,a,ret=true;o=this._getComponentFromTag(tag);if(o){if(o.header){a=o.header.ojunsupportedthemes;ret=!(a&&a.includes(this._theme))}}else{ret=this._components&&this._components.isTagSupportedInTheme(tag,this._theme)}return ret};MetaLib.prototype.isAttrSupportedInTheme=function(tag,attr){var o,a,ret=true;o=this._getTagAttrMemberObj(tag,attr);if(o){a=o.ojunsupportedthemes;ret=!(a&&a.includes(this._theme))}else{ret=this._components.isAttrSupportedInTheme(tag,attr,this._theme)}return ret};MetaLib.prototype.hasTagCompPropSubprop=function(tagName,propName){var obj,ret=false;if(this.isCCATag(tagName)){obj=this._getComponentFromTag(tagName);if(obj&&obj.member){ret=obj.member[propName];ret=ret&&ret.submember}else if(this._components){ret=this._components.getTagProp(tagName,propName);ret=ret&&ret.properties}}return ret};MetaLib.prototype.isTagCompProp=function(tagName,propName){var obj,ret=false;if(this.isCCATag(tagName)){obj=this._getComponentFromTag(tagName);if(obj&&obj.member){ret=obj.member[propName]}else if(this._components){ret=this._components.isTagProp(tagName,propName)}}return ret};MetaLib.prototype.getTagAttrType=function(tag,attr){var member=this._getTagAttrMemberObj(tag,attr);return member?member.type:this._components.getTagPropType(tag,attr)};MetaLib.prototype.getTagPropType=function(tagName,propName){var ret;if(this._components){ret=this._components.getTagPropType(tagName,propName)}return ret};MetaLib.prototype.getTagAttrMetadata=function(tag,attr){var obj,member,req;var member=this._getTagAttrMemberObj(tag,attr);if(member){obj={type:member.type};if(member.deprecated||member.ojdeprecated){obj.deprecated=true}if(member.ojtranslatable){obj.translatable=true}if(req=this.getRequiredAttrs(tag)){for(let i=0;i<req.length;i++){if(req[i]===attr){obj.required=true;break}}}obj.type=member.type}else if(this._components){obj=this._components.getTagProp(tag,attr)}return obj};MetaLib.prototype.getTagMetadata=function(tag){var obj,comp,hdr,events,props,event,ret;obj=this._getComponentFromTag(_removeChevrons(tag));if(obj){if(hdr=obj.hdr){comp={};comp.name=hdr.customelement;if(hdr.slot){comp[PROP_SLOTS]=obj.slots}}if(obj.properties){comp[PROP_PROPS]=props={};this._extractProps(props,null,obj.properties,obj.name)}if(obj.events){comp[PROP_EVENTS]=events={};for(event in obj.events){}}if(obj.implements){comp[PROP_IMPLEMENTS]=obj.implements}if(obj.extension&&obj.extension.theme&&obj.extension.theme.unsupportedThemes){comp[PROP_UNSUP_THEME]=obj.extension.theme.unsupportedThemes}if(hdr&&hdr.ojsubcomponenttype){comp[PROP_SUBCOMPONENT_TYPE]=hdr.subcomponenttype}}else if(this._components){ret=this._components.getTagMetadata(tag)}return ret};MetaLib.prototype.isTagStyleDeprecated=function(tagName,styleName){var o,ret;o=this.isWCStyleDeprecated(styleName);if(o){tagName=_removeChevrons(tagName);if(this._json.ojStyles.containers[o.index]===tagName){ret=o.dep.description}}return ret};MetaLib.prototype.isTagStyle=function(tagName,styleName){var obj,ret=false,compName,containers,indices,index,i;tagName=_removeChevrons(tagName);obj=this._getComponentFromTag(tagName);if(obj){compName=this._getComponentNameFromTag(tagName);containers=this._json.ojStyles.containers;indices=_getStyleIndices(this._json.ojStyles,styleName);if(indices){for(i=0;i<indices.length;i++){index=indices[i];if(index>=0){if(containers[index]===compName){ret=true;break}}}}}return!!ret};MetaLib.prototype.isStyle=function(style){return this.isGenStyle(style)||this.isClassStyle(style)||this.isStylesetStyle(style)};MetaLib.prototype.isGenStyle=function(style){var x=this._json.genericStyles[style];return x||x===0?true:false};MetaLib.prototype.isJetStyle=function(style){return this._json.genericStyles[style]?"g":this._json.ojStyles[style]?"j":undefined};MetaLib.prototype.isCustomStyle=function(style){return this._components&&this._components.isStyle(style)};MetaLib.prototype.getStyleOrigin=function(style){var ret;if(this._json.genericStyles[style]){ret="g"}if(this._json.ojStyles[style]){ret=ret?"b":"j"}if(!ret&&this._components){if(this._components.isStyle(style)){ret="c"}}return ret};MetaLib.prototype.isClassStyle=function(style){var x=this._json.ojStyles[style];return x||x===0?true:false};MetaLib.prototype.isStylesetStyle=function(style){return this._stylesets?!!this._stylesets[style]:false};MetaLib.prototype.getStyleSelector=function(style,jet){var o,i,ret;if(typeof jet==="boolean"){o=jet?this._json.ojStyles[style]:this._json.genericStyles[style]}else{o=this._json.ojStyles[style];if(!o&&o!==0){o=this._json.genericStyles[style]}if(!o&&this._components){o=this._components.getStyleMetadata(style)}}if(this._utils.isObject(o)){if(o.styleselector){ret=o.styleselector}else if(o.meta){ret=o.meta.styleSelector}}else if(Array.isArray(o)){for(i=0;i<o.length;i++){if(this._utils.isObject(o[i])&&o[i].styleselector){if(!ret){ret=[]}ret.push(o[i].styleselector)}}if(ret&&ret.length===1){ret=ret[0]}}return ret?ret:null};MetaLib.prototype.isJetStylePrefix=function(s){var x;if(!s.startsWith(OJPREFIX)||!this._json.jetCssPrefixes.classes){return false}x=s.indexOf("-",3);if(x>=0){s=s.substring(0,x)}return this._json.jetCssPrefixes.classes.includes(s)};MetaLib.prototype.hasJetStylePrefixes=function(){return this._json.jetCssPrefixes&&this._json.jetCssPrefixes.classes};MetaLib.prototype.getClassesFromStyle=function(styleName,scope){var indices,oStyles,ret;scope=scope||"oj";if(scope==="oj"||scope==="both"){oStyles=this._json.ojStyles;if(oStyles){indices=_getStyleIndices(oStyles,styleName);if(indices){return _toContainers(oStyles,indices)}}}if(scope==="gen"||scope==="both"){oStyles=this._json.genericStyles;if(oStyles){indices=_getStyleIndices(oStyles,styleName);if(indices){ret=_toContainers(oStyles,indices)}}}return ret?ret:null};MetaLib.prototype.getJetTagFromStyle=function(styleName){var indices,oStyles,clazz;oStyles=this._json.ojStyles;if(oStyles){indices=_getStyleIndices(oStyles,styleName)}if(indices){if(indices.length>1||indices.length===0){clazz=null}else{clazz=this.isGenStyle(styleName)?null:_toContainers(oStyles,indices)}}return clazz?this.getTagFromClass(clazz):null};MetaLib.prototype.getJetTagsFromStyle=function(styleName){var indices,oStyles;oStyles=this._json.ojStyles;if(oStyles){indices=_getStyleIndices(oStyles,styleName);if(indices){return _toContainers(oStyles,indices,this._json)}}return null};MetaLib.prototype.getClassFromTag=function(tagName){return this._getComponentNameFromTag(_removeChevrons(tagName))};MetaLib.prototype.getClassFromModule=function(module){var clazz=this._json.moduleLookup[module];return clazz?clazz:null};MetaLib.prototype.getTagFromClass=function(className){if(className==="oj.ojTree"){return"oj-tree"}var ret=this._json[className];return ret&&ret.header?ret.header.customelement:null};MetaLib.prototype.isClass=function(className){var b=this._json[className];if(!b){className=this._classChange[className];if(className){b=this._json[className]}}return!!b};MetaLib.prototype.isClassFinal=function(className){var clazz=this._json[className];if(!clazz){className=this._classChange[className];if(className){clazz=this._json[className]}}return clazz&&clazz.header&&clazz.header.readonly};MetaLib.prototype.isClassMethod=function(className,methName){var clazz=this._json[className];return!!(clazz&&clazz.function&&clazz.function[methName])};MetaLib.prototype.isClassMethodStatic=function(className,methName){var meth,ret=null;var clazz=this._json[className];if(clazz&&clazz.function){meth=clazz.function[methName];ret=meth&&meth.scope&&meth.scope=="static"}return ret};MetaLib.prototype.getClassMethodScope=function(className,methName){var meth,ret=null;var clazz=this._json[className];if(clazz&&clazz.function){meth=clazz.function[methName];ret=meth.scope}return ret};MetaLib.prototype.isClassMember=function(className,memName){var clazz=this._json[className];return!!(clazz&&clazz.member&&clazz.member[memName])};MetaLib.prototype.isClassMemberStatic=function(className,memName){var mem,ret=null;var clazz=this._json[className];if(clazz&&clazz.member){mem=clazz.member[memName];ret=mem&&mem.scope&&mem.scope=="static"}return ret};MetaLib.prototype.getRequiredAttrs=function(tagName){let obj,clazz,i,ret=null;tagName=_removeChevrons(tagName);obj=this._getComponentFromTag(tagName);if(obj){clazz=this._getComponentNameFromTag(tagName)}ret=obj?this._reqAttrs[clazz]:this._components.getRequiredAttrs(tagName);if(obj&&ret&&ret.length){for(i=0;i<ret.length;i++){ret[i]=this._domUtils.kebabCase(ret[i])}}return ret};MetaLib.prototype.getTagsFromStyle=function(styleName){var classNames,tag,i,ret;ret=null;classNames=this.getClassesFromStyle(styleName);if(classNames){for(i=0;i<classNames.length;i++){tag=this.getTagFromClass(classNames[i]);if(tag){if(!ret){ret=[]}ret.push(tag)}}}return ret?ret:null};MetaLib.prototype.isStyleDeprecated=function(name){var s,o,t,i;s=this._json.genericStyles[name];if(!s&&s!==0&&this._json.ojStyles){s=this._json.ojStyles[name];if(!s&&s!==0&&this._stylesets){s=this._stylesets[name];return this._utils.isObject(s)?s:null}}if(s){t=typeof s;if(Array.isArray(s)){for(i=0;i<s.length;i++){o=s[0];if(typeof o==="object"){break}}}else if(t==="object"){o=s}else{o=null}}return o?o.dep:null};MetaLib.prototype.isWCStyleDeprecated=function(name){var s,o,t,i;s=this._json.ojStyles[name];if(s){t=typeof s;if(Array.isArray(s)){for(i=0;i<s.length;i++){o=s[i];if(typeof o==="object"){break}o=null}}else if(t==="object"){o=s}}return o?o:null};MetaLib.prototype.isBindingTag=function(tagName){var obj=this._getComponentFromTag(_removeChevrons(tagName));return obj&&obj.header?!!obj.header.ojbindingelement:false};MetaLib.prototype.isComponent=function(className){var obj=this._json[className];if(!obj){if(!className.startsWith("oj.")){obj=this._json["oj."+className]}}return!!obj};MetaLib.prototype.isClass=function(className){return!!this._json[className]};MetaLib.prototype.isJetComponentClass=function(className){return this.isClass(className)};MetaLib.prototype.isComponentDeprecated=function(className){return this.isClassDeprecated(className)};MetaLib.prototype.isClassDeleted=function(className){var classes,cn,version=null;if(this._delHist){classes=this._delHist.classes;if(classes){cn=this._classChange[className];if(cn){className=cn}version=classes[className]}}return version};MetaLib.prototype.isClassRenamed=function(className){return this._renHist?this._renHist[className]:null};MetaLib.prototype.isClassDeprecated=function(className){var obj,ret=null;if(className==="oj.ojTree"){if(SemVer.gte(this._jetVer,"5.2.0")){return null}else{return"Use ojTreeView instead"}}obj=this._json[className];if(!obj){className=this._classChange[className];obj=className?this._json[className]:undefined}if(!obj){return false}if(obj&&obj.header){ret=this._isSubStateDeprecated(obj.header)}else{ret=this._isSubStateDeprecated(obj)}return ret};MetaLib.prototype.isClassMemberDeprecated=function(className,memName){var obj,member,ret=null;obj=this._json[className];memName=memName.charAt(0)===":"?memName.substr(1):memName;if(obj&&obj.member){for(member in obj.member){member=obj.member[member];if(memName===member.name){ret=this._isSubStateDeprecated(member);break}}}return ret};MetaLib.prototype.isClassMethodDeleted=function(className,methodName){var a,cn,i,ret=null;a=this._deletedMethods[methodName];if(a){cn=this._classChange[className];if(cn){className=cn}for(i=0;i<a.length;i++){if(a[i]===className){ret=a[i+1];break}i++}}return ret};MetaLib.prototype.isClassMethodDeprecated=function(className,methodName){var obj,method,ret=null;obj=this._json[className];if(!obj){className=this._classChange[className];obj=className?this._json[className]:undefined}if(obj&&obj.function){for(method in obj.function){if(method===methodName){method=obj.function[method];ret=this._isSubStateDeprecated(method);break}}}return ret};MetaLib.prototype.isClassMemberDeleted=function(className,memberName){var a,i,cname,ret=null;a=this._deletedMembers[memberName];if(a){cname=this._classChange[className];for(i=0;i<a.length;i++){if(a[i]===className||a[i]===cname){ret=a[i+1];break}i++}}return ret};MetaLib.prototype.isClassMemberDeprecated=function(className,memName){var obj,member,obj,ret=null;obj=this._json[className];if(!obj){className=this._classChange[className];obj=className?this._json[className]:undefined}memName=memName.charAt(0)===":"?memName.substr(1):memName;if(obj&&obj.member){for(member in obj.member){if(member===memName){member=obj.member[memName];ret=this._isSubStateDeprecated(member);break}}}return ret};MetaLib.prototype.isClassAttrDeprecated=function(className,attrName){var obj,member,ret=null;obj=this._json[className];attrName=attrName.charAt(0)===":"?attrName.substr(1):attrName;if(obj&&obj.member){for(member in obj.member){member=obj.member[member];if(attrName===member.name){ret=this._isSubStateDeprecated(member);break}}}return ret};MetaLib.prototype.isComponentDeleted=function(className){return this.isClassDeleted(className)};MetaLib.prototype.isComponentAttrDeprecated=function(className,attrName){return this.isClassAttrDeprecated(className,attrName)};MetaLib.prototype.isComponentMethodDeprecated=function(className,methodName){return this.isClassMethodDeprecated(className,methodName)};MetaLib.prototype.isComponentMemberDeprecated=function(className,memberName){return this.isClassMemberDeprecated(className,memberName)};MetaLib.prototype.isComponentMethodDeleted=function(className,methodName){return this.isClassMethodDeleted(className,methodName)};MetaLib.prototype.isComponentMemberDeleted=function(className,memberName){return this.isClassMemberDeleted(className,memberName)};MetaLib.prototype.isTagPackPrivate=function(tag){var o,ret;tag=_removeChevrons(tag);if(this.isJetTag(tag)){if(o=this._getComponentFromTag(tag)){ret=o.header&&o.header.ojsubcomponenttype===PACK_PRIVATE}}else if(this._components){ret=this._components.isTagPackPrivate(tag)}return ret};MetaLib.prototype.isTagAttrTranslatable=function(tag,attr){var member=this._getTagAttrMemberObj(tag,attr);return member?this._isSubStateTranslatable(member):this._components.isTagAttrTranslatable(tag,attr)};MetaLib.prototype.isTagAttrReadOnly=function(tag,attr){var o,ret=false;tag=_removeChevrons(tag);if(o=this._getTagAttrMemberObj(tag,attr)){ret=o&&o.readonly}else if(this._components){ret=this._components.isTagAttrReadOnly(tag,attr)}return ret};MetaLib.prototype.hasTagDataOjCommand=function(tagName){var obj,ret=false,compName,containers,indexes,i;tagName=_removeChevrons(tagName);obj=this._getComponentFromTag(tagName);if(obj){compName=this._getComponentNameFromTag(tagName);indexes=this._json.dataOjCommand;if(indexes){containers=this._json.ojStyles.containers;for(i=0;i<indexes.length;i++){if(containers[indexes[i]]===compName){ret=true;break}}}}return ret};MetaLib.prototype.isTagEvent=function(tagName,eventName){var obj,ret=false;eventName=eventName.charAt(0)===":"?eventName.substr(1):eventName;if(!eventName.startsWith(EVENT_PREFIX)){return}if(this.isCCATag(tagName)){if(this._getComponentNameFromTag(tagName)){obj=this._getComponentFromTag(_removeChevrons(tagName));if(obj&&obj.htmlevents){ret=!!obj.htmlevents[eventName]}}else{ret=this._components&&this._components.isTagEvent(tagName,eventName)}if(!ret){ret=HtmlUtils.isCommonEventAttr(eventName)}}return ret};MetaLib.prototype.applySchema=function(obj){return this._compSvcs.validateComponentJsonWithSchema(obj)};MetaLib.prototype.walkElemStackForOJTag=function(ctx,excludeBindIf){var i,name,ret=null;var stack=ctx.elemStack;if(stack&&stack.length){for(i=stack.length-1;i>=0;i--){name=stack[i].name;if(name.toLowerCase().startsWith(OJPREFIX)){if(!name.startsWith("oj-bind-")||!excludeBindIf){ret=name;break}}}}return ret};MetaLib.prototype.walkDomStackForOJTag=function(ctx,excludeBindIf){return this.walkElemStackForOJTag(ctx,excludeBindIf)};MetaLib.prototype.getPublicInterface=function(){return{isJetTag:this.isJetTag.bind(this),isWCTag:this.isWCTag.bind(this),isComponentTag:this.isComponentTag.bind(this),isTagDeprecated:this.isTagDeprecated.bind(this),isTagSupportedInTheme:this.isTagSupportedInTheme.bind(this),isAttrSupportedInTheme:this.isAttrSupportedInTheme.bind(this),isTagAttrDeprecated:this.isTagAttrDeprecated.bind(this),isTagAttrTranslatable:this.isTagAttrTranslatable.bind(this),isTagAttrReadOnly:this.isTagAttrReadOnly.bind(this),isTagEventDeprecated:this.isTagEventDeprecated.bind(this),isTagAttrEnumValueDeprecated:this.isTagAttrEnumValueDeprecated.bind(this),isTagAttr:this.isTagAttr.bind(this),isJetTagAttr:this.isJetTagAttr.bind(this),hasTagAttrValues:this.hasTagAttrValues.bind(this),isTagAttrValue:this.isTagAttrValue.bind(this),getTagAttrType:this.getTagAttrType.bind(this),getTagAttrMetadata:this.getTagAttrMetadata.bind(this),getTagMetadata:this.getTagMetadata.bind(this),isTagCompProp:this.isTagCompProp.bind(this),hasTagCompPropSubprop:this.hasTagCompPropSubprop.bind(this),getTagPropType:this.getTagPropType.bind(this),hasTagSlot:this.hasTagSlot.bind(this),isTagSlotValue:this.isTagSlotValue.bind(this),getPreferredSlotContent:this.getPreferredSlotContent.bind(this),getTagSlotMetadata:this.getTagSlotMetadata.bind(this),hasTagDataOjCommand:this.hasTagDataOjCommand.bind(this),isBindingTag:this.isBindingTag.bind(this),isTagPackPrivate:this.isTagPackPrivate.bind(this),isClass:this.isClass.bind(this),isClassRenamed:this.isClassRenamed.bind(this),isClassDeleted:this.isClassDeleted.bind(this),isClassDeprecated:this.isClassDeprecated.bind(this),isClassMethodDeleted:this.isClassMethodDeleted.bind(this),isClassMemberDeleted:this.isClassMemberDeleted.bind(this),isClassMethodDeprecated:this.isClassMethodDeprecated.bind(this),isClassMemberDeprecated:this.isClassMemberDeprecated.bind(this),isClassAttrDeprecated:this.isClassAttrDeprecated.bind(this),isClassFinal:this.isClassFinal.bind(this),isClassMethod:this.isClassMethod.bind(this),isClassMethodStatic:this.isClassMethodStatic.bind(this),isClassMember:this.isClassMember.bind(this),isClassMemberStatic:this.isClassMemberStatic.bind(this),getClassMethodScope:this.getClassMethodScope.bind(this),getStyleOrigin:this.getStyleOrigin.bind(this),isJetStyle:this.isJetStyle.bind(this),isCustomStyle:this.isCustomStyle.bind(this),isTagStyle:this.isTagStyle.bind(this),isStyle:this.isStyle.bind(this),isGenStyle:this.isGenStyle.bind(this),isClassStyle:this.isClassStyle.bind(this),isStylesetStyle:this.isStylesetStyle.bind(this),isStyleDeprecated:this.isStyleDeprecated.bind(this),getStyleSelector:this.getStyleSelector.bind(this),getNonSSStyleElems:this.getNonSSStyleElems.bind(this),isJetStylePrefix:this.isJetStylePrefix.bind(this),hasJetStylePrefixes:this.hasJetStylePrefixes.bind(this),isTagEvent:this.isTagEvent.bind(this),getTagsFromStyle:this.getTagsFromStyle.bind(this),getJetTagFromStyle:this.getJetTagFromStyle.bind(this),getJetTagsFromStyle:this.getJetTagsFromStyle.bind(this),getClassesFromStyle:this.getClassesFromStyle.bind(this),getClassFromTag:this.getClassFromTag.bind(this),getClassFromModule:this.getClassFromModule.bind(this),getTagFromClass:this.getTagFromClass.bind(this),getDeprecatedMethodList:this.getDeprecatedMethodList.bind(this),getDeprecatedMemberList:this.getDeprecatedMemberList.bind(this),getDeletedMethodList:this.getDeletedMethodList.bind(this),getDeletedMemberList:this.getDeletedMemberList.bind(this),getRequiredAttrs:this.getRequiredAttrs.bind(this),isComponent:this.isComponent.bind(this),isNSRegistered:this.isNSRegistered.bind(this),isNamespacePrefix:this.isNamespacePrefix.bind(this),getRenamedClassList:this.getRenamedClassList.bind(this),getDeletedClassList:this.getDeletedClassList.bind(this),getMetaVers:this.getMetaVers.bind(this),walkElemStackForOJTag:this.walkelemStackForOJTag,walkDomStackForOJTag:this.walkDomStackForOJTag,isIgnoreAttr:this.isIgnoreAttr.bind(this),applySchema:this.applySchema.bind(this),getRevisionInfo:this.getRevisionInfo.bind(this),isCCATag:this.isCCATag.bind(this),isComponentDeprecated:this.isComponentDeprecated.bind(this),isComponentDeleted:this.isComponentDeleted.bind(this),isComponentMethodDeprecated:this.isComponentMethodDeprecated.bind(this),isComponentMethodDeleted:this.isComponentMethodDeleted.bind(this),isComponentMemberDeprecated:this.isComponentMemberDeprecated.bind(this),isComponentMemberDeleted:this.isComponentMemberDeleted.bind(this),isComponentAttrDeprecated:this.isComponentAttrDeprecated.bind(this)}};MetaLib.prototype.loadMeta=function(metaFile){var metaObj,ret=false;if(!this._json){try{metaObj=nodeDeps.metaLoader.loadMeta(metaFile,nodeDeps);if(metaObj){this._json=metaObj.meta;this._delHist=metaObj.delMeta;this._renHist=metaObj.renMeta;this._reqAttrs=metaObj.reqattr;this._jetVer=this._json.meta.jetversion;this._createNonClassList(this._json.meta);this._createModuleLookup();this._createClassNameChanges();this._fixup_jet_42315();ret=true}else{this._error("Metadata '"+metaFile+"' not found!")}}catch(e){this._error("["+e.name+"]: Metadata load ("+metaFile+") - "+e.message)}}return ret};MetaLib.prototype.getRenamedClassList=function(){return this._renHist};MetaLib.prototype.getDeletedClassList=function(){return this._delHist};const OJV_CHARS=/[<>]/;MetaLib.prototype._getOjValues=function(mem){var ts,ret;if(!mem){return false}if(mem.ojvalues){if(mem.ojvalues.name&&Array.isArray(mem.ojvalues.name)&&mem.ojvalues.name.length){return mem.ojvalues}return}if(mem.tstype&&mem.tstype.m_ojvalues){return mem.tstype.m_ojvalues}ts=this._getTsTypeObject(mem);if(ts&&ts.ojvalues&&ts.ojvalues.name){if(Array.isArray(ts.ojvalues.name)&&ts.ojvalues.name.length){ret=ts.ojvalues}}return ret};MetaLib.prototype._createNonClassList=function(mp){this._nonClasses=mp.nonClasses?mp.nonClasses:["genericStyles","ojStyles"];this._nonClasses.push("moduleLookup");this._nonClasses.push("newGenericStyles");this._nonClasses.push("newOjStyles");if(!this._nonClasses.includes("custElementClassLookup"))this._nonClasses.push("custElementClassLookup");if(!this._nonClasses.includes("meta"))this._nonClasses.push("meta");if(!this._nonClasses.includes("ResponsivePrefixes"))this._nonClasses.push("ResponsivePrefixes")};MetaLib.prototype.setAmdMeta=function(obj){this._json=obj.jetMeta.meta;this._delHist=obj.jetMeta.delMeta;this._reqAttrs=obj.jetMeta.reqattr;this._jetVer=this._json.meta.jetversion;this._createNonClassList(this._json.meta);this._createModuleLookup();return true};MetaLib.prototype.setTheme=function(theme){this._theme=theme};MetaLib.prototype._createModuleLookup=function(){var comps,compName,lookup,hdr;comps=this._json;this._json.moduleLookup=lookup={};for(compName in comps){if(!this._nonClasses.includes(compName)&&!compName.startsWith("oj.__")){hdr=comps[compName].header;if(hdr){if(hdr.memberof==="oj"){lookup[OJS+hdr.name.toLowerCase()]=compName}else{lookup[OJS+hdr.name.toLowerCase()]=compName}}}}};MetaLib.prototype._createClassNameChanges=function(){var comps,compName,o,hdr;comps=this._json;this._classChange=o={};for(compName in comps){if(!this._nonClasses.includes(compName)){hdr=comps[compName].header;if(hdr&&compName!==hdr.name){o[hdr.name]=compName}}}};MetaLib.prototype._fixup_jet_42315=function(){var o;if(SemVer.gte(this._jetVer,"8.0.0")){if(o=this._json.Color||this._json["oj.Color"]||this._json["oj.ojColor"]){if(!o.header){o.header={}}o.header.readonly=true}}};MetaLib.prototype.getMetaVers=function(){return{versions:this._jetVersions,runver:this._jetVer}};MetaLib.prototype.setComponentsLib=function(compSvcs,comps){this._compSvcs=compSvcs;if(comps){this._components=comps}};MetaLib.prototype.setStylesets=function(ss){if(!ss){return}var o,obj,e,i;if(!this._stylesets){this._stylesets=obj={}}else{obj=this._stylesheets}for(i=0;i<ss.length;i++){o=ss[i];if(typeof o==="string"){obj[o]=true}else if(o.deprecated){obj[o.deprecated]=e={};if(o.since){e.since=o.since}if(o.note){e.description=o.note}else if(o.description){e.description=o.description}}}};MetaLib.prototype.setDomUtils=function(du){this._domUtils=du};MetaLib.prototype.getRevisionInfo=function(){var metaSect=this._json.meta;var revision="";return{revision:revision,tag:metaSect.jetrevision,jetVersion:metaSect.jetversion,date:metaSect.date,time:metaSect.time}};MetaLib.prototype._isSubStateDeprecated=function(obj){var depr,prop,i,len,ret=null;if(!obj){return false}if(obj.deprecated){depr=obj.deprecated;if(depr){ret=typeof depr==="boolean"?NO_SUGGESTION_AVAIL:depr}}else{if(obj.ojdeprecated&&obj.ojdeprecated.length){depr=obj.ojdeprecated;len=depr.length;for(i=0;i<len;i++){prop=depr[i];if(!prop.target){if(prop.description){ret=prop.description;break}else if(prop.since){ret=NO_SUGGESTION_AVAIL;break}}}}}return ret};MetaLib.prototype._isSubStateTranslatable=function(obj){return obj&&obj.ojtranslatable};MetaLib.prototype._getComponentNameFromTag=function(tagName){tagName=tagName.toLowerCase();return this._json.custElementClassLookup[tagName]?this._json.custElementClassLookup[tagName]:null};MetaLib.prototype.isIgnoreAttr=function(tagName,attrName){var ret=false;attrName=attrName.toLowerCase();attrName=attrName.charAt(0)===":"?attrName.substr(1):attrName;if(HtmlUtils.isCommonElem(attrName)||attrName.startsWith("aria-")){return true}if(tagName==="oj-avatar"){if(attrName==="src"||attrName==="initials")ret=true}else if(tagName==="oj-option"){if(attrName==="value")ret=true}return ret};MetaLib.prototype.getDeprecatedMethodList=function(){if(this._deprecatedMethods){return this._deprecatedMethods}var json=this._json;var name,methName,methObj,o,a;var ret={};for(name in json){o=json[name];if(o&&o.function){for(methName in o.function){methObj=o.function[methName];if(methObj.ojdeprecated){if(ret[methName]){a=ret[methName]}else{ret[methName]=a=[]}a.push(name)}}}}return this._deprecatedMethods=ret};MetaLib.prototype.getDeprecatedMemberList=function(){if(this._deprecatedMembers){return this._deprecatedMembers}var json=this._json;var name,memName,memObj,o,a;var ret={};for(name in json){o=json[name];if(o&&o.member){for(memName in o.member){memObj=o.member[memName];if(memObj.ojdeprecated){if(ret[memName]){a=ret[memName]}else{ret[memName]=a=[]}a.push(name)}}}}return this._deprecatedMembers=ret};MetaLib.prototype.getDeletedMethodList=function(){if(this._deletedMethods){return this._deletedMethods}var json=this._delHist;var name,methName,ver,o,a;var ret={};if(json){for(name in json){o=json[name];if(o&&o.methods){for(methName in o.methods){ver=o.methods[methName];if(ret[methName]){a=ret[methName]}else{ret[methName]=a=[]}a.push(name);a.push(ver)}}}}return this._deletedMethods=ret};MetaLib.prototype.getDeletedMemberList=function(){if(this._deletedMembers){return this._deletedMembers}var json=this._delHist;var name,memName,ver,o,a;var ret={};if(json){for(name in json){o=json[name];if(o&&o.members){for(memName in o.members){ver=o.members[memName];if(ret[memName]){a=ret[memName]}else{ret[memName]=a=[]}a.push(name);a.push(ver)}}}}return this._deletedMembers=ret};MetaLib.prototype._getSlots=function(tagName){var obj=this._getComponentFromTag(_removeChevrons(tagName));return this._getSlots2(obj)};MetaLib.prototype._getSlots2=function(base){var bases,base,i,ret=null;while(base){ret=base&&base.slot?base.slot:null;if(ret){break}bases=base.header&&base.header.augments?base.header.augments:null;if(!bases){break}for(i=0;i<bases.length;i++){base=this._json[bases[i]];ret=this._getSlots2(base);if(ret){base=null;break}}}return ret?ret:null};MetaLib.prototype._getSlotByName=function(base,slotName){var ret=null;while(base){ret=base&&base.slot?base.slot:null;if(ret){ret=base.slot[slotName];if(ret){break}}break}return ret?ret:null};MetaLib.prototype._getComponentFromTag=function(tagName){var o=this._getComponentNameFromTag(tagName);if(o){o=this._json[o]}return o?o:null};function _getStyleIndices(scope,styleName){var a,n,ret,i;a=scope[styleName];if(a||a===0){if(!ret){ret=[]}if(Array.isArray(a)){for(i=0;i<a.length;i++){n=a[i];if(typeof n==="object"){n=a[i].index}ret.push(n)}}else{if(typeof a==="object"){n=a.index}else{n=a}ret.push(n)}}return ret&&ret.length?ret:null};MetaLib.prototype.getNonSSStyleElems=function(styleName,scope){var a,n,ret,i;scope=scope?this._json.ojStyles:this._json.genericStyles;a=scope[styleName];if(a||a===0){if(!ret){ret=[]}if(Array.isArray(a)){for(i=0;i<a.length;i++){n=a[i];if(typeof n==="object"&&!n.styleselector){n=a[i].index}ret.push(n)}}else{if(typeof a==="object"&&!a.styleselector){n=a.index}else{n=a}ret.push(n)}}return ret&&ret.length?_toContainers(scope,ret,this._json):null};function _toContainers(scope,indices,json){var cont,ret,clazz,elem,n,i;cont=scope.containers;for(i=0;i<indices.length;i++){n=indices[i];if(n>=0){if(!ret){ret=[]}if(!json){ret[i]=cont[n]}else{clazz=cont[n];elem=json[clazz];if(elem&&elem.header){elem=elem.header.customelement;if(elem){ret[i]=elem}}}}}return ret&&ret.length?ret:null};function _convertValue(valType,value){var retValue=value;if(valType==="string"){retValue=value}else if(valType==="number"){retValue=Number(value)}else if(valType==="boolean"){retValue=value.toLowerCase()==="true"}return retValue};function _removeChevrons(tagName){if(tagName){let len=tagName.length-1;let start=tagName.charAt(0)==="<"?1:0;let end=tagName.charAt(len)===">"?len:++len;tagName=tagName.substring(start,end)}return tagName};module.exports=MetaLib;
|
|
6
|
+
"use strict";const Namespaces=require("./ns");const HtmlUtils=require("./HtmlUtils");const SemVer=require("semver");var nodeDeps;const NO_SUGGESTION_AVAIL="No suggestion available.";const OJPREFIX="oj-";const OJEVENTPREFIX="on-oj-";const OJS="ojs/oj";const EVENT_PREFIX="on-";const DOT=".";const DATA_OJ_CMD="data-oj-command";const PROP_SLOTS="slots";const PROP_PROPS="props";const PROP_EVENTS="events";const PROP_IMPLEMENTS="implements";const PROP_FOLDER="folder";const PROP_VERSION="version";const PROP_UNSUP_THEME="unsupTheme";const PROP_SUBCOMPONENT_TYPE="subcomponentType";const PACK_PRIVATE="packPrivate";const DEPRECATED="deprecated";function MetaLib(nd,runMode,msgCtx,utils){this._json=null;this._delHist=null;this._renHist=null;this._reqAttrs=null;this._nonClasses=null;this._implements=null;this._hasJetWCIFCs=false;this._components=null;this._compSvcs=null;this._stylesets=null;this._runMode=runMode;this._utils=utils;this._domUtils=null;if(nd.jetver){this._jetVersions=nd.jetver.getVersions()}this._jetVer=null;this._theme=null;this._deprecatedMethods=null;this._deprecatedMembers=null;this._deletedMethods=null;this._deletedMembers=null;this._error=msgCtx.error;this._debug=msgCtx.debug;this._info=msgCtx.info;this._msg=msgCtx.msg;this._console=msgCtx.console;this._isDebug=msgCtx.isdebug;this._isVerbose=msgCtx.isVerbose;nodeDeps=nd};MetaLib.prototype.isNSRegistered=function(prefix){return Namespaces.has(prefix)};MetaLib.prototype.isNamespacePrefix=function(tagName){return HtmlUtils.isNamespaceTag(tagName)};MetaLib.prototype.isJetTag=function(tagName){return!!this._getComponentNameFromTag(_removeChevrons(tagName))};MetaLib.prototype.isComponentTag=function(tagName){return this._components&&this._components.isTag(_removeChevrons(tagName))};MetaLib.prototype.isWCTag=function(tagName){return this.isJetTag(tagName)||this.isComponentTag(tagName)};MetaLib.prototype.isCCATag=function(tagName){return this.isWCTag(tagName)};MetaLib.prototype.isTagDeprecated=function(tagName){var clazz,ret;if(clazz=this._getComponentNameFromTag(_removeChevrons(tagName))){ret=this.isClassDeprecated(clazz)}else{ret=this._components.isTagDeprecated(tagName)}return ret};MetaLib.prototype.isTagAttrDeprecated=function(tagName,attrName){var member,ret=null;member=this._getTagAttrMemberObj(tagName,attrName);ret=member?this._isSubStateDeprecated(member,true):this._components.isTagAttrDeprecated(tagName,attrName);if(ret){ret.forEach(status=>{if(status.description){status.description=HtmlUtils.replaceEntities(status.description)}})}return ret};MetaLib.prototype.isTagEventDeprecated=function(tag,attr){var x1,x2;if((x1=attr.indexOf("-"))<0){return false}attr=attr.substring(x1+1);if((x2=attr.lastIndexOf("-"))>=0){attr=attr.substring(0,x2)}return this.isTagAttrDeprecated(tag,attr)};MetaLib.prototype.isTagAttr=function(tagName,attrName){var o,ret=false;attrName=attrName.charAt(0)===":"?attrName.substr(1):attrName;if(this.isCCATag(tagName)){o=this._getComponentFromTag(tagName);if(o){ret=this.isJetTagAttr(o,attrName)}else{ret=this._components&&this._components.isTagAttr(tagName,attrName)}}return ret};MetaLib.prototype.isJetTagAttr=function(tagObj,attrName){attrName=attrName.charAt(0)===":"?attrName.substr(1):attrName;var ret=!!(tagObj.htmlattributes&&tagObj.htmlattributes[attrName]);if(!ret&&attrName===DATA_OJ_CMD&&tagObj.member){ret=!!tagObj.member[DATA_OJ_CMD]}return ret};MetaLib.prototype._getTagAttrMemberObj=function(tagName,attrName){var obj,attrib,member,x;obj=this._getComponentFromTag(_removeChevrons(tagName));attrName=attrName.charAt(0)===":"?attrName.substring(1):attrName;if(!obj||!obj.htmlattributes||!obj.htmlattributes[attrName]){return null}member=null;attrib=obj.htmlattributes[attrName];if(attrib){x=attrib.indexOf(DOT);if(x>=0){if(obj.member){member=this._findSubMember(obj,obj.member,attrib,attrib)}}else{member=obj.member[attrib];if(member){return member}}}return member};MetaLib.prototype._findSubMember=function(obj,mem,attrName,subMemberPart){var member,ts,sm,rest,x,ret=null;x=subMemberPart.indexOf(DOT);if(x>=0){sm=subMemberPart.substring(0,x);rest=subMemberPart.substring(x+1)}else{sm=subMemberPart;rest=null}for(member in mem){member=mem[member];if(member.name===attrName&&!rest){ret=member;break}if(member.name!==sm){continue}if(!rest){ret=member;break}if(member.submember){ret=this._findSubMember(obj,member.submember,attrName,rest);if(ret){break}}else if(member.tstype){ts=this._getTsTypeObject(member);if(ts){ret=this._findSubMember(obj,ts.member,attrName,rest);if(ret){break}}}if(ret){break}}return ret};MetaLib.prototype._getTsTypeObject=function(mem){var ts,o,s,x;ts=mem.tstype;if(ts&&ts.target==="Type"&&typeof ts.value==="string"){s=ts.value;s=s.replace("=","");x=s.indexOf("|");if(x>=0){s=s.substring(0,x).trimRight()}if(s.charAt(s.length-1)===">"){x=s.lastIndexOf("<");if(s>=0){s=s.substring(0,x)}}o=this._json[s];if(!o){o=this._json[mem.memberof];if(o.typedef){s=ts.value;x=s.lastIndexOf(DOT);if(x>=0){s=s.substring(x+1);o=o.typedef[s]}}}}return o?o:null};MetaLib.prototype._getSubMemberPart=function(fullAttr,soFar){var s,x;s=fullAttr.replace(soFar,"");if(s.length){if(s.charAt(0)==="."){x=s.indexOf(DOT,1);if(x>=0){s=soFar+s.substring(0,x)}else{s=soFar+s}}}else{s=soFar}return s};MetaLib.prototype._handleAttrObject=function(member){var link,types,i,x;types=member.tstype;if(types){for(i=0;i<types.length;i++){if(types[i].target==="Type"){link=types[i].value;link=link.replace("=","");x=link.indexOf("<K");if(x>=0){link=link.substring(0,x)}break}}}return link};MetaLib.prototype.hasTagAttrValues=function(tagName,attrName){var member,ojv,ret=false;member=this._getTagAttrMemberObj(tagName,attrName);if(member){ojv=this._getOjValues(member);return!!ojv}else if(this._components.isTag(tagName)){ret=this._components.hasTagAttrValues(tagName,attrName)}return ret};MetaLib.prototype.isTagAttrValue=function(tagName,attrName,attrValue){var member,ojv,values,curValue,valType,i,ret=false;member=this._getTagAttrMemberObj(tagName,attrName);if(member){ojv=this._getOjValues(member);if(ojv){values=ojv.name;for(i=0;i<values.length;i++){if(ojv.type){valType=ojv.type[i];curValue=_convertValue(valType,attrValue);ret=curValue===values[i]}else{ret=attrValue===values[i]}if(ret){break}}}else{ret=true}}else{if(this._components.isTag(tagName)){ret=this._components.isTagAttrValue(tagName,attrName,attrValue)}}return ret};MetaLib.prototype.isTagAttrEnumValueDeprecated=function(tagName,attrName,enumValue){var member,ojv,values,deps,dep,i,j,ret=null;member=this._getTagAttrMemberObj(tagName,attrName);if(!member){return this._isCompTagAttrEnumDepr(tagName,attrName,enumValue)}if(!member.ojdeprecated){return null}if(ojv=this._getOjValues(member)){values=ojv.name;for(i=0;i<values.length;i++){if(values[i]===enumValue){deps=member.ojdeprecated;for(j=0;j<deps.length;j++){dep=deps[j];if(dep.target==="propertyValue"&&dep.for===enumValue){ret={type:DEPRECATED,since:dep.since,description:dep.description};break}}}if(ret){break}}}return ret};MetaLib.prototype._isCompTagAttrEnumDepr=function(tagName,attrName,enumValue){return this._components?this._components.isTagAttrEnumDeprecated(tagName,attrName,enumValue):null};MetaLib.prototype.hasTagSlot=function(tagName){return this._getSlots(tagName)?true:false};MetaLib.prototype.hasDynamicTagSlot=function(tagName){};MetaLib.prototype.isTagSlotName=function(tagName,slotName){var tag,slot;tag=_removeChevrons(tagName);if(this.isJetTag(tagName)){slot=this._getSlotByName(this._getComponentFromTag(tag),slotName)}else if(this._components){if(!HtmlUtils.isCommonElem(tag)){slot=this._components.hasTagSlotName(tag,slotName)}}return!!slot};MetaLib.prototype.isTagSlotValue=function(tagName,slotName){return this.isTagSlotName(tagName,slotName)};MetaLib.prototype.isTagDynamicSlotValue=function(tagName,slotName){};MetaLib.prototype.getPreferredSlotContent=function(tag,slot){var ret;tag=_removeChevrons(tag);if(this.isJetTag(tag)){ret=this.getJetPreferredSlotContent(tag,slot)}else if(this._components&&this._implements){ret=this._components.getPreferredSlotContent(tag,slot,this._implements)}return ret};MetaLib.prototype.getJetPreferredSlotContent=function(tag,slot){var clazz,slot,prefContent,content,comps;if(!this._implements){return null}if(clazz=this._getComponentFromTag(tag)){if(clazz.slot){if(slot=clazz.slot[slot]){if(prefContent=slot.ojpreferredcontent){prefContent.forEach(impl=>{if(content=this._implements[impl]){if(!comps){comps=[]}comps.push(...content)}})}}}else{{let defMem;if(clazz.member&&(defMem=clazz.member["Default"])&&defMem.ojchild){if(prefContent=defMem.ojpreferredcontent){prefContent.forEach(impl=>{if(content=this._implements[impl]){if(!comps){comps=[]}comps.push(...content)}})}}}}}return prefContent||comps?{interfaces:prefContent,components:comps}:null};MetaLib.prototype.getTagSlotMetadata=function(tag,slot){var ret;tag=_removeChevrons(tag);if(this.isJetTag(tag)){ret=this._getJetTagSlotMetadata(tag,slot)}else if(this._components){ret=this._components.getTagSlotMetadata(tag,slot)}return ret};MetaLib.prototype._getJetTagSlotMetadata=function(tag,slot){};MetaLib.prototype.isTagSupportedInTheme=function(tag){var o,a,ret=true;o=this._getComponentFromTag(tag);if(o){if(o.header){a=o.header.ojunsupportedthemes;ret=!(a&&a.includes(this._theme))}}else{ret=this._components&&this._components.isTagSupportedInTheme(tag,this._theme)}return ret};MetaLib.prototype.isAttrSupportedInTheme=function(tag,attr){var o,a,ret=true;o=this._getTagAttrMemberObj(tag,attr);if(o){a=o.ojunsupportedthemes;ret=!(a&&a.includes(this._theme))}else{ret=this._components.isAttrSupportedInTheme(tag,attr,this._theme)}return ret};MetaLib.prototype.hasTagCompPropSubprop=function(tagName,propName){var obj,ret=false;if(this.isCCATag(tagName)){obj=this._getComponentFromTag(tagName);if(obj&&obj.member){ret=obj.member[propName];ret=ret&&ret.submember}else if(this._components){ret=this._components.getTagProp(tagName,propName);ret=ret&&ret.properties}}return ret};MetaLib.prototype.isTagCompProp=function(tagName,propName){var obj,ret=false;if(this.isCCATag(tagName)){obj=this._getComponentFromTag(tagName);if(obj&&obj.member){ret=obj.member[propName]}else if(this._components){ret=this._components.isTagProp(tagName,propName)}}return ret};MetaLib.prototype.getTagAttrType=function(tag,attr){var member=this._getTagAttrMemberObj(tag,attr);return member?member.type:this._components.getTagPropType(tag,attr)};MetaLib.prototype.getTagPropType=function(tagName,propName){var ret;if(this._components){ret=this._components.getTagPropType(tagName,propName)}return ret};MetaLib.prototype.getTagAttrMetadata=function(tag,attr){var obj,member,req;var member=this._getTagAttrMemberObj(tag,attr);if(!member){if(this._components){obj=this._components.getTagProp(tag,attr)}}else{obj={type:member.type};if(member.deprecated||member.ojdeprecated){obj.deprecated=true}if(member.ojtranslatable){obj.translatable=true}if(req=this.getRequiredAttrs(tag)){for(let i=0;i<req.length;i++){if(req[i]===attr){obj.required=true;break}}}obj.type=member.type}return obj};MetaLib.prototype.getTagMetadata=function(tag){var obj,comp,hdr,events,props,event,ret;obj=this._getComponentFromTag(_removeChevrons(tag));if(obj){if(hdr=obj.hdr){comp={};comp.name=hdr.customelement;if(hdr.slot){comp[PROP_SLOTS]=obj.slots}}if(obj.properties){comp[PROP_PROPS]=props={};this._extractProps(props,null,obj.properties,obj.name)}if(obj.events){comp[PROP_EVENTS]=events={};for(event in obj.events){}}if(obj.implements){comp[PROP_IMPLEMENTS]=obj.implements}if(obj.extension&&obj.extension.theme&&obj.extension.theme.unsupportedThemes){comp[PROP_UNSUP_THEME]=obj.extension.theme.unsupportedThemes}if(hdr&&hdr.ojsubcomponenttype){comp[PROP_SUBCOMPONENT_TYPE]=hdr.subcomponenttype}}else if(this._components){ret=this._components.getTagMetadata(tag)}return ret};MetaLib.prototype.isTagStyleDeprecated=function(tagName,styleName){var o,ret;o=this.isWCStyleDeprecated(styleName);if(o){tagName=_removeChevrons(tagName);if(this._json.ojStyles.containers[o.index]===tagName){ret=o.dep.description}}return ret};MetaLib.prototype.isTagStyle=function(tagName,styleName){var obj,ret=false,compName,containers,indices,index,i;tagName=_removeChevrons(tagName);obj=this._getComponentFromTag(tagName);if(obj){compName=this._getComponentNameFromTag(tagName);containers=this._json.ojStyles.containers;indices=_getStyleIndices(this._json.ojStyles,styleName);if(indices){for(i=0;i<indices.length;i++){index=indices[i];if(index>=0){if(containers[index]===compName){ret=true;break}}}}}return!!ret};MetaLib.prototype.isStyle=function(style){return this.isGenStyle(style)||this.isClassStyle(style)||this.isStylesetStyle(style)};MetaLib.prototype.isGenStyle=function(style){var x=this._json.genericStyles[style];return x||x===0?true:false};MetaLib.prototype.isJetStyle=function(style){return this._json.genericStyles[style]?"g":this._json.ojStyles[style]?"j":undefined};MetaLib.prototype.isCustomStyle=function(style){return this._components&&this._components.isStyle(style)};MetaLib.prototype.getStyleOrigin=function(style){var ret;if(this._json.genericStyles[style]){ret="g"}if(this._json.ojStyles[style]){ret=ret?"b":"j"}if(!ret&&this._components){if(this._components.isStyle(style)){ret="c"}}return ret};MetaLib.prototype.isClassStyle=function(style){var x=this._json.ojStyles[style];return x||x===0?true:false};MetaLib.prototype.isStylesetStyle=function(style){return this._stylesets?!!this._stylesets[style]:false};MetaLib.prototype.getStyleSelector=function(style,jet){var o,i,ret;if(typeof jet==="boolean"){o=jet?this._json.ojStyles[style]:this._json.genericStyles[style]}else{o=this._json.ojStyles[style];if(!o&&o!==0){o=this._json.genericStyles[style]}if(!o&&this._components){o=this._components.getStyleMetadata(style)}}if(this._utils.isObject(o)){if(o.styleselector){ret=o.styleselector}else if(o.meta){ret=o.meta.styleSelector}}else if(Array.isArray(o)){for(i=0;i<o.length;i++){if(this._utils.isObject(o[i])&&o[i].styleselector){if(!ret){ret=[]}ret.push(o[i].styleselector)}}if(ret&&ret.length===1){ret=ret[0]}}return ret?ret:null};MetaLib.prototype.isJetStylePrefix=function(s){var x;if(!s.startsWith(OJPREFIX)||!this._json.jetCssPrefixes.classes){return false}x=s.indexOf("-",3);if(x>=0){s=s.substring(0,x)}return this._json.jetCssPrefixes.classes.includes(s)};MetaLib.prototype.hasJetStylePrefixes=function(){return this._json.jetCssPrefixes&&this._json.jetCssPrefixes.classes};MetaLib.prototype.getClassesFromStyle=function(styleName,scope){var indices,oStyles,ret;scope=scope||"oj";if(scope==="oj"||scope==="both"){oStyles=this._json.ojStyles;if(oStyles){indices=_getStyleIndices(oStyles,styleName);if(indices){return _toContainers(oStyles,indices)}}}if(scope==="gen"||scope==="both"){oStyles=this._json.genericStyles;if(oStyles){indices=_getStyleIndices(oStyles,styleName);if(indices){ret=_toContainers(oStyles,indices)}}}return ret?ret:null};MetaLib.prototype.getJetTagFromStyle=function(styleName){var indices,oStyles,clazz;oStyles=this._json.ojStyles;if(oStyles){indices=_getStyleIndices(oStyles,styleName)}if(indices){if(indices.length>1||indices.length===0){clazz=null}else{clazz=this.isGenStyle(styleName)?null:_toContainers(oStyles,indices)}}return clazz?this.getTagFromClass(clazz):null};MetaLib.prototype.getJetTagsFromStyle=function(styleName){var indices,oStyles;oStyles=this._json.ojStyles;if(oStyles){indices=_getStyleIndices(oStyles,styleName);if(indices){return _toContainers(oStyles,indices,this._json)}}return null};MetaLib.prototype.getClassFromTag=function(tagName){return this._getComponentNameFromTag(_removeChevrons(tagName))};MetaLib.prototype.getClassFromModule=function(module){var clazz=this._json.moduleLookup[module];return clazz?clazz:null};MetaLib.prototype.getTagFromClass=function(className){if(className==="oj.ojTree"){return"oj-tree"}let ret=this._json[className];return ret&&ret.header?ret.header.customelement:null};MetaLib.prototype.isClass=function(className){var b=this._json[className];if(!b){if(className=this._classChange[className]){b=this._json[className]}}return!!b};MetaLib.prototype.isClassFinal=function(className){var clazz=this._json[className];if(!clazz){if(className=this._classChange[className]){clazz=this._json[className]}}return clazz&&clazz.header&&clazz.header.readonly};MetaLib.prototype.isClassMethod=function(className,methName){var clazz=this._json[className];return!!(clazz&&clazz.function&&clazz.function[methName])};MetaLib.prototype.isClassMethodStatic=function(className,methName){var meth,ret=null;var clazz=this._json[className];if(clazz&&clazz.function){meth=clazz.function[methName];ret=meth&&meth.scope&&meth.scope=="static"}return ret};MetaLib.prototype.getClassMethodScope=function(className,methName){var meth,ret=null;var clazz=this._json[className];if(clazz&&clazz.function){meth=clazz.function[methName];ret=meth.scope}return ret};MetaLib.prototype.isClassMember=function(className,memName){var clazz=this._json[className];return!!(clazz&&clazz.member&&clazz.member[memName])};MetaLib.prototype.isClassMemberStatic=function(className,memName){var mem,ret=null;var clazz=this._json[className];if(clazz&&clazz.member){mem=clazz.member[memName];ret=mem&&mem.scope&&mem.scope=="static"}return ret};MetaLib.prototype.getRequiredAttrs=function(tagName){let obj,clazz,i,ret=null;tagName=_removeChevrons(tagName);obj=this._getComponentFromTag(tagName);if(obj){clazz=this._getComponentNameFromTag(tagName)}ret=obj?this._reqAttrs[clazz]:this._components.getRequiredAttrs(tagName);if(obj&&ret&&ret.length){for(i=0;i<ret.length;i++){ret[i]=this._domUtils.kebabCase(ret[i])}}return ret};MetaLib.prototype.getTagsFromStyle=function(styleName){var classNames,tag,i,ret;ret=null;classNames=this.getClassesFromStyle(styleName);if(classNames){for(i=0;i<classNames.length;i++){tag=this.getTagFromClass(classNames[i]);if(tag){if(!ret){ret=[]}ret.push(tag)}}}return ret?ret:null};MetaLib.prototype.isStyleDeprecated=function(name){var s,o,t,i;s=this._json.genericStyles[name];if(!s&&s!==0&&this._json.ojStyles){s=this._json.ojStyles[name];if(!s&&s!==0&&this._stylesets){s=this._stylesets[name];return this._utils.isObject(s)?s:null}}if(s){t=typeof s;if(Array.isArray(s)){for(i=0;i<s.length;i++){o=s[0];if(typeof o==="object"){break}}}else if(t==="object"){o=s}else{o=null}}return o?o.dep:null};MetaLib.prototype.isStyleDeprecatedEx=function(style){var a=null,ss,t,i;function _pushSS(o){if(o.dep){if(!a){a=[]}a.push(o)}};function _stashSS(s){t=typeof s;if(Array.isArray(s)){for(i=0;i<s.length;i++){_pushSS(s[i])}}else if(t==="object"){_pushSS(s)}};if(ss=this._json.genericStyles[style]){_stashSS(ss)}if(ss=this._json.ojStyles[style]){_stashSS(ss)}else if(ss!==0&&this._stylesets){ss=this._stylesets[style];return this._utils.isObject(ss)?ss:null}return a};MetaLib.prototype.isWCStyleDeprecated=function(name){var s,o,t,i;s=this._json.ojStyles[name];if(s){t=typeof s;if(Array.isArray(s)){for(i=0;i<s.length;i++){o=s[i];if(typeof o==="object"){break}o=null}}else if(t==="object"){o=s}}return o?o:null};MetaLib.prototype.isBindingTag=function(tagName){var obj=this._getComponentFromTag(_removeChevrons(tagName));return obj&&obj.header?!!obj.header.ojbindingelement:false};MetaLib.prototype.isComponent=function(className){var obj=this._json[className];if(!obj){if(!className.startsWith("oj.")){obj=this._json["oj."+className]}}return!!obj};MetaLib.prototype.isClass=function(className){return!!this._json[className]};MetaLib.prototype.isJetComponentClass=function(className){return this.isClass(className)};MetaLib.prototype.isComponentDeprecated=function(className){return this.isClassDeprecated(className)};MetaLib.prototype.isClassDeleted=function(className){var classes,cn,version=null;if(this._delHist){if(classes=this._delHist.classes){cn=this._classChange[className];if(cn){className=cn}version=classes[className]}}return version};MetaLib.prototype.isClassRenamed=function(className){return this._renHist?this._renHist[className]:null};MetaLib.prototype.isClassDeprecated=function(className){var obj,ret=null;if(className==="oj.ojTree"){if(SemVer.gte(this._jetVer,"5.2.0")){return null}else{return{type:DEPRECATED,description:"Use ojTreeView instead"}}}if(!(obj=this._json[className])){className=this._classChange[className];obj=className?this._json[className]:undefined}if(!obj){return false}if(obj.header){ret=this._isClassDeprecated(obj.header)}if(!ret){ret=this._isClassDeprecated(obj)}return ret};MetaLib.prototype._isClassDeprecated=function(obj){var depr,status,ret=null;if(obj){if(obj.ojdeprecated&&obj.ojdeprecated.length){depr=obj.ojdeprecated;for(status of depr){ret=status;break}}else if(depr=obj.deprecated){ret={type:DEPRECATED,description:typeof depr==="boolean"?NO_SUGGESTION_AVAIL:depr}}}return ret};MetaLib.prototype.isClassMethodDeleted=function(className,methodName){var a,cn,i,ret=null;a=this._deletedMethods[methodName];if(a){cn=this._classChange[className];if(cn){className=cn}for(i=0;i<a.length;i++){if(a[i]===className){ret=a[i+1];break}i++}}return ret};MetaLib.prototype.isClassMethodDeprecated=function(className,methodName){var obj,method,ret=null;obj=this._json[className];if(!obj){className=this._classChange[className];obj=className?this._json[className]:undefined}if(obj&&obj.function){for(method in obj.function){if(method===methodName){method=obj.function[method];ret=this._isSubStateDeprecated(method);break}}}return ret};MetaLib.prototype.isClassMemberDeleted=function(className,memberName){var a,i,cname,ret=null;a=this._deletedMembers[memberName];if(a){cname=this._classChange[className];for(i=0;i<a.length;i++){if(a[i]===className||a[i]===cname){ret=a[i+1];break}i++}}return ret};MetaLib.prototype.isClassMemberDeprecated=function(className,memName){var obj,member,obj,ret=null;obj=this._json[className];if(!obj){className=this._classChange[className];obj=className?this._json[className]:undefined}if(obj&&obj.member){memName=memName.charAt(0)===":"?memName.substr(1):memName;for(member in obj.member){if(member===memName){member=obj.member[memName];ret=this._isSubStateDeprecated(member,true);break}}}return ret};MetaLib.prototype.isClassAttrDeprecated=function(className,attrName){var obj,member,ret=null;obj=this._json[className];attrName=attrName.charAt(0)===":"?attrName.substr(1):attrName;if(obj&&obj.member){for(member in obj.member){member=obj.member[member];if(attrName===member.name){ret=this._isSubStateDeprecated(member,true);break}}}return ret};MetaLib.prototype.isComponentDeleted=function(className){return this.isClassDeleted(className)};MetaLib.prototype.isComponentAttrDeprecated=function(className,attrName){return this.isClassAttrDeprecated(className,attrName)};MetaLib.prototype.isComponentMethodDeprecated=function(className,methodName){return this.isClassMethodDeprecated(className,methodName)};MetaLib.prototype.isComponentMemberDeprecated=function(className,memberName){return this.isClassMemberDeprecated(className,memberName)};MetaLib.prototype.isComponentMethodDeleted=function(className,methodName){return this.isClassMethodDeleted(className,methodName)};MetaLib.prototype.isComponentMemberDeleted=function(className,memberName){return this.isClassMemberDeleted(className,memberName)};MetaLib.prototype.isTagPackPrivate=function(tag){var o,ret;tag=_removeChevrons(tag);if(this.isJetTag(tag)){if(o=this._getComponentFromTag(tag)){ret=o.header&&o.header.ojsubcomponenttype===PACK_PRIVATE}}else if(this._components){ret=this._components.isTagPackPrivate(tag)}return ret};MetaLib.prototype.isTagAttrTranslatable=function(tag,attr){var member=this._getTagAttrMemberObj(tag,attr);return member?this._isSubStateTranslatable(member):this._components.isTagAttrTranslatable(tag,attr)};MetaLib.prototype.isTagAttrReadOnly=function(tag,attr){var o,ret=false;tag=_removeChevrons(tag);if(o=this._getTagAttrMemberObj(tag,attr)){ret=o&&o.readonly}else if(this._components){ret=this._components.isTagAttrReadOnly(tag,attr)}return ret};MetaLib.prototype.hasTagDataOjCommand=function(tagName){var obj,ret=false,compName,containers,indexes,i;tagName=_removeChevrons(tagName);obj=this._getComponentFromTag(tagName);if(obj){compName=this._getComponentNameFromTag(tagName);indexes=this._json.dataOjCommand;if(indexes){containers=this._json.ojStyles.containers;for(i=0;i<indexes.length;i++){if(containers[indexes[i]]===compName){ret=true;break}}}}return ret};MetaLib.prototype.isTagEvent=function(tagName,eventName){var obj,attr,x,ret=false;eventName=eventName.charAt(0)===":"?eventName.substr(1):eventName;if(!eventName.startsWith(EVENT_PREFIX)){return ret}if(this.isWCTag(tagName)){if(this._getComponentNameFromTag(tagName)){obj=this._getComponentFromTag(_removeChevrons(tagName));if(obj&&obj.htmlevents){ret=!!obj.htmlevents[eventName]}if(!ret){if((x=eventName.lastIndexOf("-changed"))>=0){attr=eventName.substring(3,x);attr=this._domUtils.camelCase(attr);ret=!!obj.member[attr]}}}else{ret=this._components&&this._components.isTagEvent(tagName,eventName)}if(!ret){ret=HtmlUtils.isCommonEventAttr(eventName)}}return ret};MetaLib.prototype.applySchema=function(obj){return this._compSvcs.validateComponentJsonWithSchema(obj)};MetaLib.prototype.walkElemStackForOJTag=function(ctx,excludeBindIf){var i,name,ret=null;var stack=ctx.elemStack;if(stack&&stack.length){for(i=stack.length-1;i>=0;i--){name=stack[i].name;if(name.toLowerCase().startsWith(OJPREFIX)){if(!name.startsWith("oj-bind-")||!excludeBindIf){ret=name;break}}}}return ret};MetaLib.prototype.walkDomStackForOJTag=function(ctx,excludeBindIf){return this.walkElemStackForOJTag(ctx,excludeBindIf)};MetaLib.prototype.getPublicInterface=function(){return{isJetTag:this.isJetTag.bind(this),isWCTag:this.isWCTag.bind(this),isComponentTag:this.isComponentTag.bind(this),isTagDeprecated:this.isTagDeprecated.bind(this),isTagSupportedInTheme:this.isTagSupportedInTheme.bind(this),isAttrSupportedInTheme:this.isAttrSupportedInTheme.bind(this),isTagAttrDeprecated:this.isTagAttrDeprecated.bind(this),isTagAttrTranslatable:this.isTagAttrTranslatable.bind(this),isTagAttrReadOnly:this.isTagAttrReadOnly.bind(this),isTagEventDeprecated:this.isTagEventDeprecated.bind(this),isTagAttrEnumValueDeprecated:this.isTagAttrEnumValueDeprecated.bind(this),isTagAttr:this.isTagAttr.bind(this),isJetTagAttr:this.isJetTagAttr.bind(this),hasTagAttrValues:this.hasTagAttrValues.bind(this),isTagAttrValue:this.isTagAttrValue.bind(this),getTagAttrType:this.getTagAttrType.bind(this),getTagAttrMetadata:this.getTagAttrMetadata.bind(this),getTagMetadata:this.getTagMetadata.bind(this),isTagCompProp:this.isTagCompProp.bind(this),hasTagCompPropSubprop:this.hasTagCompPropSubprop.bind(this),getTagPropType:this.getTagPropType.bind(this),hasTagSlot:this.hasTagSlot.bind(this),isTagSlotName:this.isTagSlotName.bind(this),isTagSlotValue:this.isTagSlotValue.bind(this),getPreferredSlotContent:this.getPreferredSlotContent.bind(this),getTagSlotMetadata:this.getTagSlotMetadata.bind(this),hasTagDataOjCommand:this.hasTagDataOjCommand.bind(this),isBindingTag:this.isBindingTag.bind(this),isTagPackPrivate:this.isTagPackPrivate.bind(this),isClass:this.isClass.bind(this),isClassRenamed:this.isClassRenamed.bind(this),isClassDeleted:this.isClassDeleted.bind(this),isClassDeprecated:this.isClassDeprecated.bind(this),isClassMethodDeleted:this.isClassMethodDeleted.bind(this),isClassMemberDeleted:this.isClassMemberDeleted.bind(this),isClassMethodDeprecated:this.isClassMethodDeprecated.bind(this),isClassMemberDeprecated:this.isClassMemberDeprecated.bind(this),isClassAttrDeprecated:this.isClassAttrDeprecated.bind(this),isClassFinal:this.isClassFinal.bind(this),isClassMethod:this.isClassMethod.bind(this),isClassMethodStatic:this.isClassMethodStatic.bind(this),isClassMember:this.isClassMember.bind(this),isClassMemberStatic:this.isClassMemberStatic.bind(this),getClassMethodScope:this.getClassMethodScope.bind(this),getStyleOrigin:this.getStyleOrigin.bind(this),isJetStyle:this.isJetStyle.bind(this),isCustomStyle:this.isCustomStyle.bind(this),isTagStyle:this.isTagStyle.bind(this),isStyle:this.isStyle.bind(this),isGenStyle:this.isGenStyle.bind(this),isClassStyle:this.isClassStyle.bind(this),isStylesetStyle:this.isStylesetStyle.bind(this),isStyleDeprecated:this.isStyleDeprecated.bind(this),isStyleDeprecatedEx:this.isStyleDeprecatedEx.bind(this),getStyleSelector:this.getStyleSelector.bind(this),getNonSSStyleElems:this.getNonSSStyleElems.bind(this),isJetStylePrefix:this.isJetStylePrefix.bind(this),hasJetStylePrefixes:this.hasJetStylePrefixes.bind(this),isTagEvent:this.isTagEvent.bind(this),getTagsFromStyle:this.getTagsFromStyle.bind(this),getJetTagFromStyle:this.getJetTagFromStyle.bind(this),getJetTagsFromStyle:this.getJetTagsFromStyle.bind(this),getClassesFromStyle:this.getClassesFromStyle.bind(this),getClassFromTag:this.getClassFromTag.bind(this),getClassFromModule:this.getClassFromModule.bind(this),getTagFromClass:this.getTagFromClass.bind(this),getDeprecatedMethodList:this.getDeprecatedMethodList.bind(this),getDeprecatedMemberList:this.getDeprecatedMemberList.bind(this),getDeletedMethodList:this.getDeletedMethodList.bind(this),getDeletedMemberList:this.getDeletedMemberList.bind(this),getRequiredAttrs:this.getRequiredAttrs.bind(this),isComponent:this.isComponent.bind(this),isNSRegistered:this.isNSRegistered.bind(this),isNamespacePrefix:this.isNamespacePrefix.bind(this),getRenamedClassList:this.getRenamedClassList.bind(this),getDeletedClassList:this.getDeletedClassList.bind(this),processImplements:this.processImplements.bind(this),getWCInterfaces:this.getWCInterfaces.bind(this),hasWCInterfaces:this.hasWCInterfaces.bind(this),hasJetWCInterfaces:this.hasJetWCInterfaces.bind(this),getMetaVers:this.getMetaVers.bind(this),walkElemStackForOJTag:this.walkelemStackForOJTag,walkDomStackForOJTag:this.walkDomStackForOJTag,isIgnoreAttr:this.isIgnoreAttr.bind(this),applySchema:this.applySchema.bind(this),getRevisionInfo:this.getRevisionInfo.bind(this)}};MetaLib.prototype.loadMeta=function(metaFile){var metaObj,ret=false;if(!this._json){try{if(metaObj=nodeDeps.metaLoader.loadMeta(metaFile,nodeDeps)){this._json=metaObj.meta;this._delHist=metaObj.delMeta;this._renHist=metaObj.renMeta;this._reqAttrs=metaObj.reqattr;this._jetVer=this._json.meta.jetversion;this._createNonClassList(this._json.meta);this._createModuleLookup();this._createClassNameChanges();this._fixup_jet_42315();this._createImplements();ret=true}else{this._error(`Metadata '${metaFile}' not found!`)}}catch(e){this._error(`[${e.name}]: Metadata load (${metaFile}) - ${e.message}`)}}return ret};MetaLib.prototype.getRenamedClassList=function(){return this._renHist};MetaLib.prototype.getDeletedClassList=function(){return this._delHist};MetaLib.prototype.processImplements=function(tag,impls){if(Array.isArray(impls)&&this._implements){impls.forEach(impl=>{if(this._implements[impl]){this._implements[impl].push(tag)}else{this._implements[impl]=[tag]}})}};const OJV_CHARS=/[<>]/;MetaLib.prototype._getOjValues=function(mem){var ts,ret;if(!mem){return false}if(mem.ojvalues){if(mem.ojvalues.name&&Array.isArray(mem.ojvalues.name)&&mem.ojvalues.name.length){return mem.ojvalues}return}if(mem.tstype&&mem.tstype.m_ojvalues){return mem.tstype.m_ojvalues}ts=this._getTsTypeObject(mem);if(ts&&ts.ojvalues&&ts.ojvalues.name){if(Array.isArray(ts.ojvalues.name)&&ts.ojvalues.name.length){ret=ts.ojvalues}}return ret};MetaLib.prototype.getWCInterfaces=function(){return this._implements};MetaLib.prototype.hasJetWCInterfaces=function(){return this._hasJetWCIFCs};MetaLib.prototype.hasWCInterfaces=function(){return!!this._implements};MetaLib.prototype._createNonClassList=function(mp){this._nonClasses=mp.nonClasses?mp.nonClasses:["genericStyles","ojStyles"];this._nonClasses.push("moduleLookup");this._nonClasses.push("newGenericStyles");this._nonClasses.push("newOjStyles");if(!this._nonClasses.includes("custElementClassLookup"))this._nonClasses.push("custElementClassLookup");if(!this._nonClasses.includes("meta"))this._nonClasses.push("meta");if(!this._nonClasses.includes("ResponsivePrefixes"))this._nonClasses.push("ResponsivePrefixes")};MetaLib.prototype.setAmdMeta=function(obj){this._json=obj.jetMeta.meta;this._delHist=obj.jetMeta.delMeta;this._reqAttrs=obj.jetMeta.reqattr;this._jetVer=this._json.meta.jetversion;this._createNonClassList(this._json.meta);this._createModuleLookup();return true};MetaLib.prototype.setTheme=function(theme){this._theme=theme};MetaLib.prototype._createModuleLookup=function(){var comps,compName,lookup,hdr;if(this._json.moduleLookup){return}this._json.moduleLookup=lookup={};comps=this._json;for(compName in comps){if(!this._nonClasses.includes(compName)&&!compName.startsWith("oj.__")){hdr=comps[compName].header;if(hdr){lookup[OJS+hdr.name.toLowerCase()]=compName}}}};MetaLib.prototype._createClassNameChanges=function(){var comps,compName,o,hdr;if(this._classChange=this._json.meta.isClassNameChanges){return}this._classChange=o={};comps=this._json;for(compName in comps){if(!this._nonClasses.includes(compName)){hdr=comps[compName].header;if(hdr&&compName!==hdr.name){o[hdr.name]=compName}}}this._json.meta.isClassNameChanges=true};MetaLib.prototype._fixup_jet_42315=function(){var o;if(SemVer.gte(this._jetVer,"8.0.0")){if(o=this._json.Color||this._json["oj.Color"]||this._json["oj.ojColor"]){if(!o.header){o.header={}}o.header.readonly=true}}};MetaLib.prototype._createImplements=function(){var clazzes,clazz,tag,impls,impl,o={},a,hdr;if(this._implements=this._json.meta.interfaces){return}clazzes=this._json;for(clazz in clazzes){if(this._nonClasses.includes(clazz)){continue}if(hdr=clazzes[clazz].header){if(hdr.domInterface&&hdr.customelement){impls=hdr.domInterface;impls=Array.isArray(impls)?impls:[impls];for(impl of impls){if(o[impl]){a=o[impl]}else{o[impl]=a=[]}this._hasJetWCIFCs=true;tag=this.getTagFromClass(clazz);if(tag&&!a.includes(tag)){a.push(tag)}}}}}this._implements=this._hasJetWCIFCs?o:null};MetaLib.prototype.getMetaVers=function(){return{versions:this._jetVersions,runver:this._jetVer}};MetaLib.prototype.setComponentsLib=function(compSvcs,comps){if(compSvcs){this._compSvcs=compSvcs}if(comps){this._components=comps}};MetaLib.prototype.setStylesets=function(ss){if(!ss){return}var o,obj,e,i;if(!this._stylesets){this._stylesets=obj={}}else{obj=this._stylesheets}for(i=0;i<ss.length;i++){o=ss[i];if(typeof o==="string"){obj[o]=true}else if(o.deprecated){obj[o.deprecated]=e={};if(o.since){e.since=o.since}if(o.note){e.description=o.note}else if(o.description){e.description=o.description}}}};MetaLib.prototype.setDomUtils=function(du){this._domUtils=du};MetaLib.prototype.getRevisionInfo=function(){var metaSect=this._json.meta;var revision="";return{revision:revision,tag:metaSect.jetrevision,jetVersion:metaSect.jetversion,date:metaSect.date,time:metaSect.time}};MetaLib.prototype._isSubStateDeprecated=function(obj,isMember){var depr,retStatus=null,o;if(!obj){return false}if(obj.ojdeprecated&&obj.ojdeprecated.length){retStatus=[];depr=obj.ojdeprecated;depr.forEach(status=>{o={type:DEPRECATED};if(status.hasOwnProperty("target")){o.target=status.target;if(isMember&&status.target==="memberType"){o.target="propertyType"}}if(status.hasOwnProperty("description")){o.description=status.description}if(status.hasOwnProperty("since")){o.since=status.since}if(status.hasOwnProperty("for")){o.value=[status.for]}else if(status.hasOwnProperty("value")){o.value=status.value}retStatus.push(o)});retStatus=retStatus.length?retStatus:null}else if(depr=obj.deprecated){retStatus=typeof depr==="boolean"?NO_SUGGESTION_AVAIL:depr;retStatus=[{type:DEPRECATED,description:retStatus}]}return retStatus};MetaLib.prototype._isSubStateTranslatable=function(obj){return obj&&obj.ojtranslatable};MetaLib.prototype._getComponentNameFromTag=function(tagName){tagName=tagName.toLowerCase();return this._json.custElementClassLookup[tagName]?this._json.custElementClassLookup[tagName]:null};MetaLib.prototype.isIgnoreAttr=function(tagName,attrName){var ret=false;attrName=attrName.toLowerCase();attrName=attrName.charAt(0)===":"?attrName.substr(1):attrName;if(HtmlUtils.isCommonElem(attrName)||attrName.startsWith("aria-")){return true}if(tagName==="oj-avatar"){if(attrName==="src"||attrName==="initials")ret=true}else if(tagName==="oj-option"){if(attrName==="value")ret=true}return ret};MetaLib.prototype.getDeprecatedMethodList=function(){if(this._deprecatedMethods){return this._deprecatedMethods}var json=this._json;var name,methName,methObj,o,a;var ret={};for(name in json){o=json[name];if(o&&o.function){for(methName in o.function){methObj=o.function[methName];if(methObj.ojdeprecated){if(ret[methName]){a=ret[methName]}else{ret[methName]=a=[]}a.push(name)}}}}return this._deprecatedMethods=ret};MetaLib.prototype.getDeprecatedMemberList=function(){if(this._deprecatedMembers){return this._deprecatedMembers}var json=this._json;var name,memName,memObj,o,a;var ret={};for(name in json){o=json[name];if(o&&o.member){for(memName in o.member){memObj=o.member[memName];if(memObj.ojdeprecated){if(ret[memName]){a=ret[memName]}else{ret[memName]=a=[]}a.push(name)}}}}return this._deprecatedMembers=ret};MetaLib.prototype.getDeletedMethodList=function(){if(this._deletedMethods){return this._deletedMethods}var json=this._delHist;var name,methName,ver,o,a;var ret={};if(json){for(name in json){o=json[name];if(o&&o.methods){for(methName in o.methods){ver=o.methods[methName];if(ret[methName]){a=ret[methName]}else{ret[methName]=a=[]}a.push(name);a.push(ver)}}}}return this._deletedMethods=ret};MetaLib.prototype.getDeletedMemberList=function(){if(this._deletedMembers){return this._deletedMembers}var json=this._delHist;var name,memName,ver,o,a;var ret={};if(json){for(name in json){o=json[name];if(o&&o.members){for(memName in o.members){ver=o.members[memName];if(ret[memName]){a=ret[memName]}else{ret[memName]=a=[]}a.push(name);a.push(ver)}}}}return this._deletedMembers=ret};MetaLib.prototype._getSlots=function(tagName){var obj=this._getComponentFromTag(_removeChevrons(tagName));return this._getSlots2(obj)};MetaLib.prototype._getSlots2=function(base){var bases,base,i,ret=null;while(base){ret=base&&base.slot?base.slot:null;if(ret){break}bases=base.header&&base.header.augments?base.header.augments:null;if(!bases){break}for(i=0;i<bases.length;i++){base=this._json[bases[i]];ret=this._getSlots2(base);if(ret){base=null;break}}}return ret?ret:null};MetaLib.prototype._getSlotByName=function(base,slotName){var ret=null;while(base){ret=base&&base.slot?base.slot:null;if(ret){ret=base.slot[slotName];if(ret){break}}break}return ret?ret:null};MetaLib.prototype._getComponentFromTag=function(tagName){var o=this._getComponentNameFromTag(tagName);if(o){o=this._json[o]}return o?o:null};function _getStyleIndices(scope,styleName){var a,n,ret,i;a=scope[styleName];if(a||a===0){if(!ret){ret=[]}if(Array.isArray(a)){for(i=0;i<a.length;i++){n=a[i];if(typeof n==="object"){n=a[i].index}ret.push(n)}}else{if(typeof a==="object"){n=a.index}else{n=a}ret.push(n)}}return ret&&ret.length?ret:null};MetaLib.prototype.getNonSSStyleElems=function(styleName,scope){var a,n,ret,i;scope=scope?this._json.ojStyles:this._json.genericStyles;a=scope[styleName];if(a||a===0){if(!ret){ret=[]}if(Array.isArray(a)){for(i=0;i<a.length;i++){n=a[i];if(typeof n==="object"&&!n.styleselector){n=a[i].index}ret.push(n)}}else{if(typeof a==="object"&&!a.styleselector){n=a.index}else{n=a}ret.push(n)}}return ret&&ret.length?_toContainers(scope,ret,this._json):null};MetaLib.prototype.displayImpls=function(){var impls,impl;this._console("[info] :--------- JET Interfaces Implemented ---------","I");if(!(impls=this._implements)){this._console(" None!","I")}else{for(impl in impls){this._console(`${impl} : <- <${impls[impl].join(",")}>`,"I")}}this._console("[info]: -------- End Declared Web Components ---------\n","I")};function _toContainers(scope,indices,json){var cont,ret,clazz,elem,n,i;cont=scope.containers;for(i=0;i<indices.length;i++){n=indices[i];if(n>=0){if(!ret){ret=[]}if(!json){ret[i]=cont[n]}else{clazz=cont[n];elem=json[clazz];if(elem&&elem.header){elem=elem.header.customelement;if(elem){ret[i]=elem}}}}}return ret&&ret.length?ret:null};function _convertValue(valType,value){var retValue=value;if(valType==="string"){retValue=value}else if(valType==="number"){retValue=Number(value)}else if(valType==="boolean"){retValue=value.toLowerCase()==="true"}return retValue};function _removeChevrons(tagName){if(tagName){let len=tagName.length-1;let start=tagName.charAt(0)==="<"?1:0;let end=tagName.charAt(len)===">"?len:++len;tagName=tagName.substring(start,end)}return tagName};module.exports=MetaLib;
|
package/lib/NetUtils.js
CHANGED
package/lib/NodeTypes.js
CHANGED
package/lib/Parser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
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 FILETYPE=require("./filetypes");const Json=require("./Json.js");const Ts=require("./Ts.js");function Parser(core,nodeDeps,rules,fileIndex,DomUtils,appCtx,msgCtx,constants){this.cssUtils=null;this.curFile=null;this.curFileType=null;this._fireHookFileRules=appCtx.fireHookFileRules;this.startCssPosition=0;this.startJsPosition=0;this.startIndex=0;this.endIndex=0;this.parseErrors=0;this._setConstants(constants);this._appCtx=appCtx;this._msgCtx=msgCtx;this._Json=new Json(this,nodeDeps,rules,fileIndex,appCtx,msgCtx);this._Ts=new Ts(this,nodeDeps,rules,fileIndex,appCtx,msgCtx)};Parser.prototype.clear=function(){this.startIndex=0;this.endIndex=0;this.startCssPosition={row:1,col:1,index:0};this._Json.clear();this._Ts.clear()};Parser.prototype.getAst=function(){var o;switch(this.curFileType){case FILETYPE.TS:o=this._Ts;break;case FILETYPE.JS:o=this._Js;break;case FILETYPE.JSON:o=this._Json;break;}return o?o.getAst():null};Parser.prototype.getAstUtils=function(){return FILETYPE.isFileTypeTsOrTsx(this.curFileType)?this._Ts.getAstUtils():this.curFileType==="js"?this.Js.getAstUtils():null};Parser.prototype.fireHookFileRules=function(node,obj,inScriptJs){return this._fireHookFileRules(node,obj,inScriptJs)};Parser.prototype.getParseErrors=function(){return this.parseErrors};Parser.prototype.parse=function(text,curFile,curFileType,arg1){var ret;switch(curFileType){case FILETYPE.TS:case FILETYPE.TSX:ret=this._parseTs(text,curFile,curFileType,arg1);break;case FILETYPE.JSON:ret=this._parseJson(text,curFile,curFileType);break;}return ret};Parser.prototype.parseOnly=function(text,curFile,curFileType){var ret;switch(curFileType){case FILETYPE.JSON:ret=this._parseJsonOnly(text,curFile,curFileType);break;default:this._msgCtx.assert("Unhandled Parser.parseOnly unexpected invocation");}return ret};Parser.prototype._parseHtml=function(text,curFile,curFileType,rawData,suppData){};Parser.prototype.getHtmlTopNode=function(){return this._Html.getTopNode()};Parser.prototype.getCurTagNode=function(){return this._Html.getCurTagNode()};Parser.prototype._parseCss=function(text){return this._Css.parse(text)};Parser.prototype._parseJs=function(text,curFile,curFileType,inner){if(typeof curFile!=="string"){var jj=42}if(curFile){this.curFile=curFile}if(curFileType){this.curFileType=curFileType}return this._Js.parse(text,inner)};Parser.prototype.getJsAst=function(){return this._Js.getJsAst()};Parser.prototype.getInScriptJs=function(){return this._Html.getInScriptJs()};Parser.prototype._parseTs=function(text,curFile,curFileType
|
|
6
|
+
const FILETYPE=require("./filetypes");const Json=require("./Json.js");const Ts=require("./Ts.js");const Md=require("./Md.js");function Parser(core,nodeDeps,rules,fileIndex,DomUtils,appCtx,msgCtx,constants){this.cssUtils=null;this.curFile=null;this.curFileType=null;this._fireHookFileRules=appCtx.fireHookFileRules;this.startCssPosition=0;this.startJsPosition=0;this.startIndex=0;this.endIndex=0;this.parseErrors=0;this._setConstants(constants);this._appCtx=appCtx;this._msgCtx=msgCtx;this._Json=new Json(this,nodeDeps,rules,fileIndex,appCtx,msgCtx);this._Ts=new Ts(this,nodeDeps,rules,fileIndex,appCtx,msgCtx);this._Md=new Md(this,nodeDeps,rules,fileIndex,appCtx,msgCtx)};Parser.prototype.clear=function(){this.startIndex=0;this.endIndex=0;this.startCssPosition={row:1,col:1,index:0};this._Json.clear();this._Ts.clear();this._Md.clear()};Parser.prototype.getAst=function(){var o;switch(this.curFileType){case FILETYPE.TS:o=this._Ts;break;case FILETYPE.JS:o=this._Js;break;case FILETYPE.JSON:o=this._Json;break;case FILETYPE.MD:o=this._Md;break;}return o?o.getAst():null};Parser.prototype.getAstUtils=function(){return FILETYPE.isFileTypeTsOrTsx(this.curFileType)?this._Ts.getAstUtils():this.curFileType==="js"?this.Js.getAstUtils():null};Parser.prototype.fireHookFileRules=function(node,obj,inScriptJs){return this._fireHookFileRules(node,obj,inScriptJs)};Parser.prototype.getParseErrors=function(){return this.parseErrors};Parser.prototype.parse=function(text,curFile,curFileType,arg1){var ret;switch(curFileType){case FILETYPE.TS:case FILETYPE.TSX:ret=this._parseTs(text,curFile,curFileType,arg1);break;case FILETYPE.JSON:ret=this._parseJson(text,curFile,curFileType);break;case FILETYPE.MD:ret=this._parseMd(text,curFile,curFileType);break;}return ret};Parser.prototype.parseOnly=function(text,curFile,curFileType){var ret;switch(curFileType){case FILETYPE.JSON:ret=this._parseJsonOnly(text,curFile,curFileType);break;default:this._msgCtx.assert("Unhandled Parser.parseOnly unexpected invocation");}return ret};Parser.prototype._parseHtml=function(text,curFile,curFileType,rawData,suppData){};Parser.prototype.getHtmlTopNode=function(){return this._Html.getTopNode()};Parser.prototype.getCurTagNode=function(){return this._Html.getCurTagNode()};Parser.prototype._parseCss=function(text){return this._Css.parse(text)};Parser.prototype._parseJs=function(text,curFile,curFileType,inner){if(typeof curFile!=="string"){var jj=42}if(curFile){this.curFile=curFile}if(curFileType){this.curFileType=curFileType}return this._Js.parse(text,inner)};Parser.prototype.getJsAst=function(){return this._Js.getJsAst()};Parser.prototype.getInScriptJs=function(){return this._Html.getInScriptJs()};Parser.prototype._parseTs=function(text,curFile,curFileType){if(curFile){this.curFile=curFile}if(curFileType){this.curFileType=curFileType}return this._Ts.parse(text,curFile,curFileType)};Parser.prototype._parseJson=function(text,curFile,curFileType){if(curFile){this.curFile=curFile}if(curFileType){this.curFileType=curFileType}return this._Json.parse(text,curFile,curFileType)};Parser.prototype._parseJsonOnly=function(text,curFile,curFileType){return this._Json.parseOnly(text,curFile,curFileType)};Parser.prototype._parseMd=function(text,curFile,curFileType){if(curFile){this.curFile=curFile}if(curFileType){this.curFileType=curFileType}return this._Md.parse(text,curFile,curFileType)};Parser.prototype.setCssUtils=function(utils){this.cssUtils=utils};Parser.prototype._setConstants=function(constants){for(let con in constants){this[con]=constants[con]}};module.exports=Parser;
|
package/lib/RegTypes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
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={ELEM:"elem",TAG:"tag",OJTAG:"ojtag",WEBCOMP:"webcomp",GLOBTAG:"globtag",ATTR:"attr",ATTREXPR:"attrexpr",CLASS:"class",EVENT:"event",COMMENT:"comment",PROCSTMT:"procstmt",DIRECTIVE:"directive",DOCTYPE:"doctype",PHASE_FILE:"file",PHASE_STARTUP:"startup",PHASE_CLOSEDOWN:"closedown",PHASE_STARTUP_RULEPACK:"startupRP",PHASE_CLOSEDOWN_RULEPACK:"closedownRP",PHASE_START_AUDIT:"startaudit",PHASE_END_AUDIT:"endaudit"};
|
|
6
|
+
module.exports={ELEM:"elem",TAG:"tag",OJTAG:"ojtag",BINDING_TAG:"bindingtag",WEBCOMP:"webcomp",GLOBTAG:"globtag",ATTR:"attr",ATTREXPR:"attrexpr",CLASS:"class",EVENT:"event",COMMENT:"comment",PROCSTMT:"procstmt",DIRECTIVE:"directive",DOCTYPE:"doctype",PHASE_FILE:"file",PHASE_STARTUP:"startup",PHASE_CLOSEDOWN:"closedown",PHASE_STARTUP_RULEPACK:"startupRP",PHASE_CLOSEDOWN_RULEPACK:"closedownRP",PHASE_START_AUDIT:"startaudit",PHASE_END_AUDIT:"endaudit"};
|
package/lib/Registry.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
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 Registry=function(appCtx){this._registry={};this._appCtx=appCtx;this._info=appCtx.info;this._assert=appCtx.assert};Registry.prototype.getRegisteredCallbacks=function(type){
|
|
6
|
+
const RULE_RE=new RegExp(/[~`!#$%\^&*+\[\]\\';,/{}|\\"\?]/);var Registry=function(appCtx){this._registry={};this._regexps={};this._reObjs={};this._appCtx=appCtx;this._info=appCtx.info;this._assert=appCtx.assert};Registry.prototype.getRegisteredCallbacks=function(type){var reo,ret;ret=this._registry[type];if(!type.startsWith("css-")&&type.indexOf("-")>0&&type.indexOf("|")<0){ret={...ret};type=type.substring(1,type.length-1).trim();for(re in this._regexps){reo=this._reObjs[re];if(reo&&reo.test(type)){if(!ret){ret={}}for(x in this._regexps[re]){ret[x]=this._regexps[re][x]}}};}return ret};Registry.prototype.isRegisteredCallback=function(type){return!!this._registry[type]};Registry.prototype.isRegisteredCallbackRE=function(elem){var ret,i;if(ret=this.isRegisteredCallback(elem)){return ret}elem=elem.startsWith("<")?elem.substring(1,elem.length-1):elem;for(re in this._regexps){if(this._reObjs[re].test(elem)){return true}}return false};Registry.prototype.setRuleCallback=function(ruleName,ruleRegs,rsi){var typeObj,regType,rt,callbacks,func,args,elem;for(regType in ruleRegs){func=ruleRegs[regType];if(typeof func!=="function"){this._info(`Rule ${ruleName} : registered '${regType}' is not a function`);continue}rt=elem=regType;if(regType.charAt(0)==="<"){rt=regType.substring(1,regType.length-1).trim();args=rt.split(" ");if(args.length>1){attrib=args[args.length-1];if(attrib.endsWith("=")){rt=args[0]+"|"+attrib.substring(0,attrib.length-1)}elem=args[0]}else{elem=rt.endsWith("=")?null:rt}regType=`<${rt}>`}if(!elem||!_isRE(elem)){if(!(typeObj=this._registry[regType])){this._registry[regType]=typeObj={}}}else{if(!(typeObj=this._regexps[rt])){this._regexps[rt]=typeObj={}}if(!this._reObjs[rt]){this._reObjs[rt]=new RegExp(rt)}}if(!(callbacks=typeObj[ruleName])){typeObj[ruleName]=callbacks=[]}callbacks.push({cb:func,rsi:rsi})}};Registry.prototype.XXsetRuleCallback=function(ruleName,ruleRegs,rsi){var typeObj,callbackType,ruleCallbacks,func;if(Array.isArray(ruleRegs)){var jj=this._setRuleCallback2(ruleName,ruleRegs)}else if(typeof ruleRegs!=="object"){return}else if(ruleRegs.cb){let regs=this._setExtended(ruleName,ruleRegs,rsi);if(regs){ruleRegs=regs}}for(callbackType in ruleRegs){func=ruleRegs[callbackType];if(typeof func!=="function"){this._info("Rule "+ruleName+" : registered '"+callbackType+"' is not a function");continue}typeObj=this._registry[callbackType];if(!typeObj){this._registry[callbackType]=typeObj={}}ruleCallbacks=typeObj[ruleName];if(!ruleCallbacks){typeObj[ruleName]=ruleCallbacks=[]}ruleCallbacks.push({cb:func,rsi:rsi})}};Registry.prototype.XXsetRuleCallback2=function(ruleName,regs,rsi){var a,i,j,props,prop,reg,val;for(i=0;i<regs.length;i++){reg=regs[i];if(!reg.cb){if(!a){a=[]}a.push(reg);continue}props=Object.keys(reg);if(props.length===2){for(j=0;j<props.length;j++){prop=props[j];if(prop!=="cb"){val=reg[prop];if(typeof val==="boolean"&&val){a.push({prop:val});break}}}continue}}};Registry.prototype.dump=function(){var type,rule,vals,tagWidth,tagLen=0,indent,isFirst,s="";var list2={},ruleWidth,ruleLen=0,source,i;for(type in this._registry){if(type.length>tagLen){tagLen=type.length}}for(type in this._regexps){if(type.length>tagLen){tagLen=type.length}}tagWidth=tagLen+3;indent=" ".repeat(tagWidth);s="\n"+ljustify("--- Tags ---",indent.length,indent)+"----- rules -----";source=this._registry;for(i=0;i<2;i++){for(type in source){s+="\n"+ljustify(type,tagWidth,indent);vals=source[type];isFirst=true;for(rule in vals){s+=(isFirst?"":indent)+rule+"\n";isFirst=false;if(!list2[rule]){list2[rule]=[]}list2[rule].push(type);if(rule.length>ruleLen){ruleLen=rule.length}}}source=this._regexps}ruleWidth=ruleLen+2;indent=" ".repeat(ruleWidth);s+="\n"+ljustify("----- Rules -----",indent.length,indent)+"--- Tags ---";for(rule in list2){vals=list2[rule];s+="\n"+ljustify(rule,ruleWidth,indent);isFirst=true;for(i=0;i<vals.length;i++){s+=(isFirst?"":indent)+vals[i]+"\n";isFirst=false}}return s+"\n"};function ljustify(n,w,blanks){var s=n.toString();var l=s.length;return s+blanks.substr(0,w-l)};function _isRE(s){return RULE_RE.test(s)};module.exports=Registry;
|
package/lib/Reporter.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
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 FORMAT_JSON="json";var Reporter=function(msgCtx){this._issues=[];this._msgCtx=msgCtx;this._msgFilter=null;this._severity=null};Reporter.prototype.addIssue=function(issue,ruleCtx,severity){var sev,usev,id,offset;if(!issue||!ruleCtx){return}var rulePack=ruleCtx.rulePack;var opts=rulePack.getRuleOptions(ruleCtx.ruleName,null,true);issue.severity=severity&&this._severity.isValidRuleSeverity(severity)?severity:issue.severity?issue.severity:opts.severity;if(!issue.msgId){issue.msgId=ruleCtx.getMsgId(ruleCtx,issue.msgKey)}issue.prefix=rulePack.getPrefix();id=issue.prefix+"-"+issue.msgId;if(this._msgFilter&&!this._isMsgFiltered(id)){return}sev=this._severity.getMsgSev(id);usev=sev?this._severity.unmap(sev):issue.severity;if(!this._severity.matchSeverityLevel(usev)){this._msgCtx.debug("Reporter ignoring issue because of severity");return}issue.severity=sev||usev;issue.rsi=ruleCtx._rsi;offset=ruleCtx.position?ruleCtx.position.offset:0;offset=typeof offset==="number"?offset:0;if(issue.index!==undefined){if(issue.index.start===undefined){issue.index.start=ruleCtx.position.start;issue.index.end=ruleCtx.position.end}}else{issue.index=ruleCtx.position}if(issue.index&&issue.index.start!==undefined){issue.index.start+=offset;issue.index.end+=offset}issue.$hook=opts.$hook;if(this._outFormat===FORMAT_JSON){issue.name=ruleCtx.filepath}issue.ruleName=ruleCtx.ruleName;issue.token=this._parseData;issue.tokType=this._parseType;if(ruleCtx.filepath){issue.filepath=ruleCtx.filepath}issue.msg=issue.msg.replace(/</g,"<");issue.msg=issue.msg.replace(/>/g,">");this._issues.push(issue)};Reporter.prototype.getIssues=function(){return this._issues};Reporter.prototype.getCount=function(){return this._issues.length};Reporter.prototype.clearIssues=function(){return this._issues.length=0};Reporter.prototype.setParseData=function(parseData,parseType){this._parseData=parseData;this._parseType=parseType};Reporter.prototype.getFormat=function(){return this._outFormat};Reporter.prototype.setOutFormat=function(format){return this._outFormat=format};Reporter.prototype.setSevInstance=function(sevInst){this._severity=sevInst};Reporter.prototype.setMessageFilter=function(messages){var a,am,i;if(messages){a=messages.accept?messages.accept:messages.reject?messages.reject:null;if(a&&a.length){am=[];for(i=0;i<a.length;i++){am.push(new RegExp(a[i]))}}if(am){if(messages.reject){this._msgFilter={reject:am}}else if(messages.accept){this._msgFilter={accept:am}}}}if(!am){this._msgFilter=null}};Reporter.prototype._isMsgFiltered=function(msgId){var a,b=false,i;if(!this._msgFilter){return true}a=this._msgFilter.accept?this._msgFilter.accept:this._msgFilter.reject?this._msgFilter.reject:null;if(a){for(i=0;i<a.length;i++){if(a[i].test(msgId)){b=true;break}}}return this._msgFilter.accept?b:!b};module.exports=Reporter;
|
|
6
|
+
const FORMAT_JSON="json";var Reporter=function(msgCtx){this._issues=[];this._msgCtx=msgCtx;this._msgFilter=null;this._severity=null};Reporter.prototype.addIssue=function(issue,ruleCtx,severity){var sev,usev,id,offset;if(!issue||!ruleCtx){return}var rulePack=ruleCtx.rulePack;var opts=rulePack.getRuleOptions(ruleCtx.ruleName,null,true);issue.severity=severity&&this._severity.isValidRuleSeverity(severity)?severity:issue.severity?issue.severity:opts.severity;if(!issue.msgId){issue.msgId=ruleCtx.getMsgId(ruleCtx,issue.msgKey)}issue.prefix=rulePack.getPrefix();id=issue.prefix+"-"+issue.msgId;if(this._msgFilter&&!this._isMsgFiltered(id)){return}sev=this._severity.getMsgSev(id);usev=sev?this._severity.unmap(sev):issue.severity;if(!this._severity.matchSeverityLevel(usev)){this._msgCtx.debug("Reporter ignoring issue because of severity");return}issue.severity=sev||usev;issue.rsi=ruleCtx._rsi;offset=ruleCtx.position?ruleCtx.position.offset:0;offset=typeof offset==="number"?offset:0;if(issue.index!==undefined){if(issue.index.start===undefined){issue.index.start=ruleCtx.position.start;issue.index.end=ruleCtx.position.end}}else{issue.index=ruleCtx.position}if(issue.index&&issue.index.start!==undefined){issue.index.start+=offset;issue.index.end+=offset}issue.$hook=opts.$hook;if(this._outFormat===FORMAT_JSON){issue.name=issue.filepath?issue.filepath:ruleCtx.filepath}issue.ruleName=ruleCtx.ruleName;issue.token=this._parseData;issue.tokType=this._parseType;if(ruleCtx.filepath&&!issue.filepath){issue.filepath=ruleCtx.filepath}issue.msg=issue.msg.replace(/</g,"<");issue.msg=issue.msg.replace(/>/g,">");this._issues.push(issue)};Reporter.prototype.getIssues=function(){return this._issues};Reporter.prototype.getCount=function(){return this._issues.length};Reporter.prototype.clearIssues=function(){return this._issues.length=0};Reporter.prototype.setParseData=function(parseData,parseType){this._parseData=parseData;this._parseType=parseType};Reporter.prototype.getFormat=function(){return this._outFormat};Reporter.prototype.setOutFormat=function(format){return this._outFormat=format};Reporter.prototype.setSevInstance=function(sevInst){this._severity=sevInst};Reporter.prototype.setMessageFilter=function(messages){var a,am,i;if(messages){a=messages.accept?messages.accept:messages.reject?messages.reject:null;if(a&&a.length){am=[];for(i=0;i<a.length;i++){am.push(new RegExp(a[i]))}}if(am){if(messages.reject){this._msgFilter={reject:am}}else if(messages.accept){this._msgFilter={accept:am}}}}if(!am){this._msgFilter=null}};Reporter.prototype._isMsgFiltered=function(msgId){var a,b=false,i;if(!this._msgFilter){return true}a=this._msgFilter.accept?this._msgFilter.accept:this._msgFilter.reject?this._msgFilter.reject:null;if(a){for(i=0;i<a.length;i++){if(a[i].test(msgId)){b=true;break}}}return this._msgFilter.accept?b:!b};module.exports=Reporter;
|
package/lib/RuleContext.js
CHANGED
package/lib/RulePack.js
CHANGED