axyseo 2.0.0-alpha.0.0.22 → 2.0.0-alpha.0.0.24
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/build/scoring/assessments/index.js +3 -1
- package/build/scoring/assessments/index.js.map +1 -1
- package/build/scoring/assessments/seo/SchemaAssessment.js +114 -0
- package/build/scoring/assessments/seo/SchemaAssessment.js.map +1 -0
- package/build/scoring/assessors/assessor.js +4 -2
- package/build/scoring/assessors/assessor.js.map +1 -1
- package/build/values/Paper.js +34 -0
- package/build/values/Paper.js.map +1 -1
- package/package.json +1 -1
|
@@ -27,6 +27,7 @@ var _UrlLengthAssessment = _interopRequireDefault(require("./seo/UrlLengthAssess
|
|
|
27
27
|
var _NumberInMetaTitleAssessment = _interopRequireDefault(require("./seo/NumberInMetaTitleAssessment"));
|
|
28
28
|
var _TextImagesAssessment = _interopRequireDefault(require("./seo/TextImagesAssessment"));
|
|
29
29
|
var _MetaTitleKeywordAssessment = _interopRequireDefault(require("./seo/MetaTitleKeywordAssessment"));
|
|
30
|
+
var _SchemaAssessment = _interopRequireDefault(require("./seo/SchemaAssessment"));
|
|
30
31
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
31
32
|
// Readability assessments.
|
|
32
33
|
|
|
@@ -59,6 +60,7 @@ const seo = exports.seo = {
|
|
|
59
60
|
SubheadingsKeywordAssessment: _SubHeadingsKeywordAssessment.default,
|
|
60
61
|
TextLengthAssessment: _TextLengthAssessment.default,
|
|
61
62
|
SlugKeywordAssessment: _UrlKeywordAssessment.default,
|
|
62
|
-
KeyphraseAssessment: _KeyphraseAssessment.default
|
|
63
|
+
KeyphraseAssessment: _KeyphraseAssessment.default,
|
|
64
|
+
SchemaAssessment: _SchemaAssessment.default
|
|
63
65
|
};
|
|
64
66
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_ParagraphTooLongAssessment","_interopRequireDefault","require","_SentenceBeginningsAssessment","_SentenceLengthInTextAssessment","_TransitionWordsAssessment","_InternalLinksAssessment","_IntroductionKeywordAssessment","_KeyphraseLengthAssessment","_KeywordDensityAssessment","_MetaDescriptionKeywordAssessment","_MetaDescriptionLengthAssessment","_OutboundLinksAssessment","_PageTitleWidthAssessment","_SingleH1Assessment","_SubHeadingsKeywordAssessment","_TextLengthAssessment","_UrlKeywordAssessment","_ImageCountAssessment","_KeyphraseAssessment","_SingleTitleAssessment","_UrlLengthAssessment","_NumberInMetaTitleAssessment","_TextImagesAssessment","_MetaTitleKeywordAssessment","e","__esModule","default","readability","exports","ParagraphTooLongAssessment","SentenceBeginningsAssessment","SentenceLengthInTextAssessment","TransitionWordsAssessment","seo","ImageCountAssessment","NumberInMetaTitleAssessment","InternalLinksAssessment","TextImagesAssessment","MetaTitleKeywordAssessment","IntroductionKeywordAssessment","SingleTitleAssessment","KeyphraseLengthAssessment","UrlLengthAssessment","KeyphraseDensityAssessment","MetaDescriptionKeywordAssessment","MetaDescriptionLengthAssessment","OutboundLinksAssessment","PageTitleWidthAssessment","SingleH1Assessment","SubheadingsKeywordAssessment","TextLengthAssessment","SlugKeywordAssessment","KeyphraseAssessment"],"sources":["../../../src/scoring/assessments/index.js"],"sourcesContent":["// Readability assessments.\nimport ParagraphTooLongAssessment from './readability/ParagraphTooLongAssessment';\nimport SentenceBeginningsAssessment from './readability/SentenceBeginningsAssessment';\nimport SentenceLengthInTextAssessment from './readability/SentenceLengthInTextAssessment';\nimport TransitionWordsAssessment from './readability/TransitionWordsAssessment';\n\n// SEO assessments.\nimport InternalLinksAssessment from './seo/InternalLinksAssessment';\nimport IntroductionKeywordAssessment from './seo/IntroductionKeywordAssessment';\nimport KeyphraseLengthAssessment from './seo/KeyphraseLengthAssessment';\nimport KeyphraseDensityAssessment from './seo/KeywordDensityAssessment';\nimport MetaDescriptionKeywordAssessment from './seo/MetaDescriptionKeywordAssessment';\nimport MetaDescriptionLengthAssessment from './seo/MetaDescriptionLengthAssessment';\nimport OutboundLinksAssessment from './seo/OutboundLinksAssessment';\nimport PageTitleWidthAssessment from './seo/PageTitleWidthAssessment';\nimport SingleH1Assessment from './seo/SingleH1Assessment';\nimport SubheadingsKeywordAssessment from './seo/SubHeadingsKeywordAssessment';\nimport TextLengthAssessment from './seo/TextLengthAssessment';\nimport SlugKeywordAssessment from './seo/UrlKeywordAssessment';\nimport ImageCountAssessment from './seo/ImageCountAssessment';\nimport KeyphraseAssessment from './seo/KeyphraseAssessment';\nimport SingleTitleAssessment from './seo/SingleTitleAssessment';\nimport UrlLengthAssessment from './seo/UrlLengthAssessment';\nimport NumberInMetaTitleAssessment from './seo/NumberInMetaTitleAssessment';\nimport TextImagesAssessment from './seo/TextImagesAssessment';\nimport MetaTitleKeywordAssessment from './seo/MetaTitleKeywordAssessment';\n\nconst readability = {\n ParagraphTooLongAssessment,\n SentenceBeginningsAssessment,\n SentenceLengthInTextAssessment,\n TransitionWordsAssessment\n};\n\n// We expose the deprecated assessments for backwards compatibility.\nconst seo = {\n ImageCountAssessment,\n NumberInMetaTitleAssessment,\n InternalLinksAssessment,\n TextImagesAssessment,\n MetaTitleKeywordAssessment,\n IntroductionKeywordAssessment,\n SingleTitleAssessment,\n KeyphraseLengthAssessment,\n UrlLengthAssessment,\n KeyphraseDensityAssessment,\n MetaDescriptionKeywordAssessment,\n MetaDescriptionLengthAssessment,\n OutboundLinksAssessment,\n PageTitleWidthAssessment,\n SingleH1Assessment,\n SubheadingsKeywordAssessment,\n TextLengthAssessment,\n SlugKeywordAssessment,\n KeyphraseAssessment\n};\n\nexport {readability, seo};\n"],"mappings":";;;;;;AACA,IAAAA,2BAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,6BAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,+BAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,0BAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAGA,IAAAI,wBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,8BAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,0BAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,yBAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,iCAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,gCAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,wBAAA,GAAAX,sBAAA,CAAAC,OAAA;AACA,IAAAW,yBAAA,GAAAZ,sBAAA,CAAAC,OAAA;AACA,IAAAY,mBAAA,GAAAb,sBAAA,CAAAC,OAAA;AACA,IAAAa,6BAAA,GAAAd,sBAAA,CAAAC,OAAA;AACA,IAAAc,qBAAA,GAAAf,sBAAA,CAAAC,OAAA;AACA,IAAAe,qBAAA,GAAAhB,sBAAA,CAAAC,OAAA;AACA,IAAAgB,qBAAA,GAAAjB,sBAAA,CAAAC,OAAA;AACA,IAAAiB,oBAAA,GAAAlB,sBAAA,CAAAC,OAAA;AACA,IAAAkB,sBAAA,GAAAnB,sBAAA,CAAAC,OAAA;AACA,IAAAmB,oBAAA,GAAApB,sBAAA,CAAAC,OAAA;AACA,IAAAoB,4BAAA,GAAArB,sBAAA,CAAAC,OAAA;AACA,IAAAqB,qBAAA,GAAAtB,sBAAA,CAAAC,OAAA;AACA,IAAAsB,2BAAA,GAAAvB,sBAAA,CAAAC,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","names":["_ParagraphTooLongAssessment","_interopRequireDefault","require","_SentenceBeginningsAssessment","_SentenceLengthInTextAssessment","_TransitionWordsAssessment","_InternalLinksAssessment","_IntroductionKeywordAssessment","_KeyphraseLengthAssessment","_KeywordDensityAssessment","_MetaDescriptionKeywordAssessment","_MetaDescriptionLengthAssessment","_OutboundLinksAssessment","_PageTitleWidthAssessment","_SingleH1Assessment","_SubHeadingsKeywordAssessment","_TextLengthAssessment","_UrlKeywordAssessment","_ImageCountAssessment","_KeyphraseAssessment","_SingleTitleAssessment","_UrlLengthAssessment","_NumberInMetaTitleAssessment","_TextImagesAssessment","_MetaTitleKeywordAssessment","_SchemaAssessment","e","__esModule","default","readability","exports","ParagraphTooLongAssessment","SentenceBeginningsAssessment","SentenceLengthInTextAssessment","TransitionWordsAssessment","seo","ImageCountAssessment","NumberInMetaTitleAssessment","InternalLinksAssessment","TextImagesAssessment","MetaTitleKeywordAssessment","IntroductionKeywordAssessment","SingleTitleAssessment","KeyphraseLengthAssessment","UrlLengthAssessment","KeyphraseDensityAssessment","MetaDescriptionKeywordAssessment","MetaDescriptionLengthAssessment","OutboundLinksAssessment","PageTitleWidthAssessment","SingleH1Assessment","SubheadingsKeywordAssessment","TextLengthAssessment","SlugKeywordAssessment","KeyphraseAssessment","SchemaAssessment"],"sources":["../../../src/scoring/assessments/index.js"],"sourcesContent":["// Readability assessments.\nimport ParagraphTooLongAssessment from './readability/ParagraphTooLongAssessment';\nimport SentenceBeginningsAssessment from './readability/SentenceBeginningsAssessment';\nimport SentenceLengthInTextAssessment from './readability/SentenceLengthInTextAssessment';\nimport TransitionWordsAssessment from './readability/TransitionWordsAssessment';\n\n// SEO assessments.\nimport InternalLinksAssessment from './seo/InternalLinksAssessment';\nimport IntroductionKeywordAssessment from './seo/IntroductionKeywordAssessment';\nimport KeyphraseLengthAssessment from './seo/KeyphraseLengthAssessment';\nimport KeyphraseDensityAssessment from './seo/KeywordDensityAssessment';\nimport MetaDescriptionKeywordAssessment from './seo/MetaDescriptionKeywordAssessment';\nimport MetaDescriptionLengthAssessment from './seo/MetaDescriptionLengthAssessment';\nimport OutboundLinksAssessment from './seo/OutboundLinksAssessment';\nimport PageTitleWidthAssessment from './seo/PageTitleWidthAssessment';\nimport SingleH1Assessment from './seo/SingleH1Assessment';\nimport SubheadingsKeywordAssessment from './seo/SubHeadingsKeywordAssessment';\nimport TextLengthAssessment from './seo/TextLengthAssessment';\nimport SlugKeywordAssessment from './seo/UrlKeywordAssessment';\nimport ImageCountAssessment from './seo/ImageCountAssessment';\nimport KeyphraseAssessment from './seo/KeyphraseAssessment';\nimport SingleTitleAssessment from './seo/SingleTitleAssessment';\nimport UrlLengthAssessment from './seo/UrlLengthAssessment';\nimport NumberInMetaTitleAssessment from './seo/NumberInMetaTitleAssessment';\nimport TextImagesAssessment from './seo/TextImagesAssessment';\nimport MetaTitleKeywordAssessment from './seo/MetaTitleKeywordAssessment';\nimport SchemaAssessment from './seo/SchemaAssessment';\n\nconst readability = {\n ParagraphTooLongAssessment,\n SentenceBeginningsAssessment,\n SentenceLengthInTextAssessment,\n TransitionWordsAssessment\n};\n\n// We expose the deprecated assessments for backwards compatibility.\nconst seo = {\n ImageCountAssessment,\n NumberInMetaTitleAssessment,\n InternalLinksAssessment,\n TextImagesAssessment,\n MetaTitleKeywordAssessment,\n IntroductionKeywordAssessment,\n SingleTitleAssessment,\n KeyphraseLengthAssessment,\n UrlLengthAssessment,\n KeyphraseDensityAssessment,\n MetaDescriptionKeywordAssessment,\n MetaDescriptionLengthAssessment,\n OutboundLinksAssessment,\n PageTitleWidthAssessment,\n SingleH1Assessment,\n SubheadingsKeywordAssessment,\n TextLengthAssessment,\n SlugKeywordAssessment,\n KeyphraseAssessment,\n SchemaAssessment\n};\n\nexport {readability, seo};\n"],"mappings":";;;;;;AACA,IAAAA,2BAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,6BAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,+BAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,0BAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAGA,IAAAI,wBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,8BAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,0BAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,yBAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,iCAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IA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AA1BA,mCAA0B;EAC1BC,6BAA6B,EAA7BA,sCAA6B;EAC7BC,qBAAqB,EAArBA,8BAAqB;EACrBC,yBAAyB,EAAzBA,kCAAyB;EACzBC,mBAAmB,EAAnBA,4BAAmB;EACnBC,0BAA0B,EAA1BA,iCAA0B;EAC1BC,gCAAgC,EAAhCA,yCAAgC;EAChCC,+BAA+B,EAA/BA,wCAA+B;EAC/BC,uBAAuB,EAAvBA,gCAAuB;EACvBC,wBAAwB,EAAxBA,iCAAwB;EACxBC,kBAAkB,EAAlBA,2BAAkB;EAClBC,4BAA4B,EAA5BA,qCAA4B;EAC5BC,oBAAoB,EAApBA,6BAAoB;EACpBC,qBAAqB,EAArBA,6BAAqB;EACrBC,mBAAmB,EAAnBA,4BAAmB;EACnBC,gBAAgB,EAAhBA;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _lodash = require("lodash");
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _polaris = require("@shopify/polaris");
|
|
10
|
+
var _AssessmentResult = _interopRequireDefault(require("../../../values/AssessmentResult"));
|
|
11
|
+
var _assessment = _interopRequireDefault(require("../assessment"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
/**
|
|
14
|
+
* Represents the assessment that checks shop has schema.
|
|
15
|
+
*/
|
|
16
|
+
class SchemaAssessment extends _assessment.default {
|
|
17
|
+
/**
|
|
18
|
+
* Sets the identifier and the config.
|
|
19
|
+
*
|
|
20
|
+
* @param {object} config The configuration to use.
|
|
21
|
+
*
|
|
22
|
+
* @returns {void}
|
|
23
|
+
*/
|
|
24
|
+
constructor(config = {}) {
|
|
25
|
+
super();
|
|
26
|
+
const defaultConfig = {
|
|
27
|
+
id: 'schema',
|
|
28
|
+
priority: 'high',
|
|
29
|
+
docUrl: 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#schema',
|
|
30
|
+
ctaType: 'contactUs',
|
|
31
|
+
title: 'Schema',
|
|
32
|
+
content: {
|
|
33
|
+
good: 'Schema markup is applied effectively.',
|
|
34
|
+
improve: '',
|
|
35
|
+
bad: 'No schema markup applied. Add schema to optimize visibility for search engines.'
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
this.identifier = 'schema';
|
|
39
|
+
this._config = (0, _lodash.merge)(defaultConfig, config);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @param paper
|
|
45
|
+
* @returns {{score: number, body: React.JSX.Element, status: string}}
|
|
46
|
+
*/
|
|
47
|
+
calculateResult(paper) {
|
|
48
|
+
let status = '';
|
|
49
|
+
const url = paper.getSlug();
|
|
50
|
+
const shopSettings = paper.getShopSettings();
|
|
51
|
+
if (url.includes('product') || url.includes('collection')) {
|
|
52
|
+
if (paper.hasProductSchema()) {
|
|
53
|
+
status = 'good';
|
|
54
|
+
} else {
|
|
55
|
+
status = 'bad';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (url.includes('blogs')) {
|
|
59
|
+
if (shopSettings?.blogPostsAndArticle?.status) {
|
|
60
|
+
status = 'good';
|
|
61
|
+
} else {
|
|
62
|
+
status = 'bad';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const score = this.getScore(this._config.priority, status);
|
|
66
|
+
return {
|
|
67
|
+
score,
|
|
68
|
+
status,
|
|
69
|
+
body: /*#__PURE__*/_react.default.createElement(_polaris.Text, {
|
|
70
|
+
as: 'span'
|
|
71
|
+
}, this._config.content[status], ' ', this._config.docUrl && /*#__PURE__*/_react.default.createElement("a", {
|
|
72
|
+
href: this._config.docUrl,
|
|
73
|
+
target: "_blank",
|
|
74
|
+
rel: "noreferrer"
|
|
75
|
+
}, "Learn more"))
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @param paper
|
|
82
|
+
* @param researcher
|
|
83
|
+
* @param config
|
|
84
|
+
* @param i18n
|
|
85
|
+
* @returns {AssessmentResult}
|
|
86
|
+
*/
|
|
87
|
+
getResult({
|
|
88
|
+
paper,
|
|
89
|
+
researcher,
|
|
90
|
+
i18n
|
|
91
|
+
}) {
|
|
92
|
+
const calculatedResult = this.calculateResult(paper);
|
|
93
|
+
const assessmentResult = new _AssessmentResult.default({
|
|
94
|
+
config: this._config
|
|
95
|
+
});
|
|
96
|
+
assessmentResult.setStatus(calculatedResult.status);
|
|
97
|
+
assessmentResult.setStatus(calculatedResult.status);
|
|
98
|
+
assessmentResult.setBody(calculatedResult.body);
|
|
99
|
+
return assessmentResult;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Checks if the sentence beginnings assessment is applicable to the paper.
|
|
104
|
+
*
|
|
105
|
+
* @param {Object} paper The paper to check.
|
|
106
|
+
* @param {Researcher} researcher The researcher object.
|
|
107
|
+
* @returns {boolean} Returns true if the language is available and the paper is not empty.
|
|
108
|
+
*/
|
|
109
|
+
isApplicable(paper, researcher) {
|
|
110
|
+
return paper.hasShopSettings() && paper.hasSlug();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.default = SchemaAssessment;
|
|
114
|
+
//# sourceMappingURL=SchemaAssessment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaAssessment.js","names":["_lodash","require","_react","_interopRequireDefault","_polaris","_AssessmentResult","_assessment","e","__esModule","default","SchemaAssessment","Assessment","constructor","config","defaultConfig","id","priority","docUrl","ctaType","title","content","good","improve","bad","identifier","_config","merge","calculateResult","paper","status","url","getSlug","shopSettings","getShopSettings","includes","hasProductSchema","blogPostsAndArticle","score","getScore","body","createElement","Text","as","href","target","rel","getResult","researcher","i18n","calculatedResult","assessmentResult","AssessmentResult","setStatus","setBody","isApplicable","hasShopSettings","hasSlug","exports"],"sources":["../../../../src/scoring/assessments/seo/SchemaAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport React from 'react';\nimport {Text} from '@shopify/polaris';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\n\n/**\n * Represents the assessment that checks shop has schema.\n */\nexport default class SchemaAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {object} config The configuration to use.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'schema',\n priority: 'high',\n docUrl: 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#schema',\n ctaType: 'contactUs',\n title: 'Schema',\n content: {\n good: 'Schema markup is applied effectively.',\n improve: '',\n bad: 'No schema markup applied. Add schema to optimize visibility for search engines.'\n }\n };\n\n this.identifier = 'schema';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n *\n * @param paper\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult(paper) {\n let status = '';\n const url = paper.getSlug();\n const shopSettings = paper.getShopSettings();\n if (url.includes('product') || url.includes('collection')) {\n if (paper.hasProductSchema()) {\n status = 'good';\n } else {\n status = 'bad';\n }\n }\n if (url.includes('blogs')) {\n if (shopSettings?.blogPostsAndArticle?.status) {\n status = 'good';\n } else {\n status = 'bad';\n }\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n Learn more\n </a>\n )}\n </Text>\n )\n };\n }\n\n /**\n *\n * @param paper\n * @param researcher\n * @param config\n * @param i18n\n * @returns {AssessmentResult}\n */\n getResult({paper, researcher, i18n}) {\n const calculatedResult = this.calculateResult(paper);\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setStatus(calculatedResult.status);\n assessmentResult.setStatus(calculatedResult.status);\n assessmentResult.setBody(calculatedResult.body);\n\n return assessmentResult;\n }\n\n /**\n * Checks if the sentence beginnings assessment is applicable to the paper.\n *\n * @param {Object} paper The paper to check.\n * @param {Researcher} researcher The researcher object.\n * @returns {boolean} Returns true if the language is available and the paper is not empty.\n */\n isApplicable(paper, researcher) {\n return paper.hasShopSettings() && paper.hasSlug();\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,WAAA,GAAAH,sBAAA,CAAAF,OAAA;AAAuC,SAAAE,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEvC;AACA;AACA;AACe,MAAMG,gBAAgB,SAASC,mBAAU,CAAC;EACvD;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,QAAQ;MACZC,QAAQ,EAAE,MAAM;MAChBC,MAAM,EAAE,oFAAoF;MAC5FC,OAAO,EAAE,WAAW;MACpBC,KAAK,EAAE,QAAQ;MACfC,OAAO,EAAE;QACPC,IAAI,EAAE,uCAAuC;QAC7CC,OAAO,EAAE,EAAE;QACXC,GAAG,EAAE;MACP;IACF,CAAC;IAED,IAAI,CAACC,UAAU,GAAG,QAAQ;IAC1B,IAAI,CAACC,OAAO,GAAG,IAAAC,aAAK,EAACZ,aAAa,EAAED,MAAM,CAAC;EAC7C;;EAEA;AACF;AACA;AACA;AACA;EACEc,eAAeA,CAACC,KAAK,EAAE;IACrB,IAAIC,MAAM,GAAG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CAACC,KAAK,CAAC;IACpD,MAAMsB,gBAAgB,GAAG,IAAIC,yBAAgB,CAAC;MAACtC,MAAM,EAAE,IAAI,CAACY;IAAO,CAAC,CAAC;IAErEyB,gBAAgB,CAACE,SAAS,CAACH,gBAAgB,CAACpB,MAAM,CAAC;IACnDqB,gBAAgB,CAACE,SAAS,CAACH,gBAAgB,CAACpB,MAAM,CAAC;IACnDqB,gBAAgB,CAACG,OAAO,CAACJ,gBAAgB,CAACV,IAAI,CAAC;IAE/C,OAAOW,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEI,YAAYA,CAAC1B,KAAK,EAAEmB,UAAU,EAAE;IAC9B,OAAOnB,KAAK,CAAC2B,eAAe,CAAC,CAAC,IAAI3B,KAAK,CAAC4B,OAAO,CAAC,CAAC;EACnD;AACF;AAACC,OAAA,CAAAhD,OAAA,GAAAC,gBAAA","ignoreList":[]}
|
|
@@ -31,7 +31,6 @@ class Assessor {
|
|
|
31
31
|
this.type = 'assessor';
|
|
32
32
|
this.setResearcher(researcher);
|
|
33
33
|
this._assessments = [];
|
|
34
|
-
this._config = config || {};
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
/**
|
|
@@ -66,6 +65,10 @@ class Assessor {
|
|
|
66
65
|
* @returns {boolean} Whether or not the Assessment is applicable.
|
|
67
66
|
*/
|
|
68
67
|
isApplicable(assessment, paper, researcher) {
|
|
68
|
+
const ignoreAssessments = paper.getIgnoredAssessments();
|
|
69
|
+
if (ignoreAssessments.includes(assessment._config.id)) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
69
72
|
if (assessment.hasOwnProperty('isApplicable') || typeof assessment.isApplicable === 'function') {
|
|
70
73
|
return assessment.isApplicable(paper, researcher);
|
|
71
74
|
}
|
|
@@ -154,7 +157,6 @@ class Assessor {
|
|
|
154
157
|
result = assessment.getResult({
|
|
155
158
|
paper,
|
|
156
159
|
researcher,
|
|
157
|
-
config: this._config,
|
|
158
160
|
i18n
|
|
159
161
|
});
|
|
160
162
|
result.setIdentifier(assessment._config.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assessor.js","names":["_lodash","require","_AssessmentResult","_interopRequireDefault","_build","_LanguageProcessor","_missingArgument","_errors","e","__esModule","default","ScoreRating","Assessor","constructor","researcher","config","type","setResearcher","_assessments","_config","isUndefined","MissingArgument","_researcher","getAvailableAssessments","isApplicable","assessment","paper","hasOwnProperty","hasMarker","isFunction","marker","getMarks","getSpecificMarker","getPaper","_lastPaper","assess","i18n","setPaper","languageProcessor","LanguageProcessor","shortcodes","_attributes","setTree","build","assessments","results","filter","bind","map","executeAssessment","result","title","translate","id","content","good","improve","bad","getResult","setIdentifier","assessmentError","showTrace","AssessmentResult","setScore","getValidResults","isValidResult","assessmentResult","hasScore","hasText","calculateOverallScore","totalScore","reduce","total","getScore","Math","round","length","addAssessment","name","identifier","getAssessment","removeAssessment","push","toDelete","findIndex","splice","find","getApplicableAssessments","availableAssessments","availableAssessment","_default","exports"],"sources":["../../../src/scoring/assessors/assessor.js"],"sourcesContent":["// External dependencies.\nimport {filter, find, findIndex, isFunction, isUndefined, map} from 'lodash';\n\n// Internal dependencies.\nimport AssessmentResult from '../../values/AssessmentResult.js';\nimport {build} from '../../parse/build';\nimport LanguageProcessor from '../../parse/language/LanguageProcessor.js';\nimport MissingArgument from '../../errors/missingArgument.js';\nimport {showTrace} from '../../helpers/errors.js';\n\n// The maximum score of individual assessment is 9. This is why we set the \"score rating\" here to 9.\nconst ScoreRating = 9;\n\n/**\n * The Assessor is a base class for all assessors.\n */\nclass Assessor {\n /**\n * Creates a new Assessor instance.\n * @param {Researcher}\tresearcher\tThe researcher to use.\n * @param {Object}\t\t[config]\tThe assessor config.\n */\n constructor(researcher, config) {\n this.type = 'assessor';\n this.setResearcher(researcher);\n this._assessments = [];\n\n this._config = config || {};\n }\n\n /**\n * Checks if the researcher is defined and sets it.\n *\n * @param {Researcher} researcher The researcher to use in the assessor.\n *\n * @throws {MissingArgument} Parameter needs to be a valid researcher object.\n * @returns {void}\n */\n setResearcher(researcher) {\n if (isUndefined(researcher)) {\n throw new MissingArgument('The assessor requires a researcher.');\n }\n this._researcher = researcher;\n }\n\n /**\n * Gets all available assessments.\n * @returns {Assessment[]} assessment\n */\n getAvailableAssessments() {\n return this._assessments;\n }\n\n /**\n * Checks whether the Assessment is applicable.\n *\n * @param {Assessment} assessment The Assessment object that needs to be checked.\n * @param {Paper} paper The Paper object to check against.\n * @param {Researcher} [researcher] The Researcher object containing additional information.\n * @returns {boolean} Whether or not the Assessment is applicable.\n */\n isApplicable(assessment, paper, researcher) {\n if (\n assessment.hasOwnProperty('isApplicable') ||\n typeof assessment.isApplicable === 'function'\n ) {\n return assessment.isApplicable(paper, researcher);\n }\n\n return true;\n }\n\n /**\n * Determines whether an assessment has a marker.\n *\n * @param {Assessment} assessment The assessment to check for.\n * @returns {boolean} Whether or not the assessment has a marker.\n */\n hasMarker(assessment) {\n return (\n isFunction(this._config.marker) &&\n (assessment.hasOwnProperty('getMarks') || typeof assessment.getMarks === 'function')\n );\n }\n\n /**\n * Returns the specific marker for this assessor.\n *\n * @returns {Function} The specific marker for this assessor.\n */\n getSpecificMarker() {\n return this._config.marker;\n }\n\n /**\n * Returns the paper that was most recently assessed.\n *\n * @returns {Paper} The paper that was most recently assessed.\n */\n getPaper() {\n return this._lastPaper;\n }\n\n /**\n * Runs the researches defined in the task list or the default researches.\n *\n * @param {Paper} paper The paper to run assessments on.\n * @param i18n\n * @returns {void}\n */\n assess(paper, i18n) {\n this._researcher.setPaper(paper);\n\n const languageProcessor = new LanguageProcessor(this._researcher);\n const shortcodes = paper._attributes && paper._attributes.shortcodes;\n paper.setTree(build(paper, languageProcessor, shortcodes));\n\n let assessments = this.getAvailableAssessments();\n this.results = [];\n\n assessments = filter(\n assessments,\n function(assessment) {\n return this.isApplicable(assessment, paper, this._researcher);\n }.bind(this)\n );\n\n this.results = map(assessments, assessment =>\n this.executeAssessment({\n paper,\n researcher: this._researcher,\n assessment,\n i18n\n })\n );\n this._lastPaper = paper;\n }\n\n /**\n * Executes an assessment and returns the AssessmentResult.\n *\n * @param {Paper} paper The paper to pass to the assessment.\n * @param {Researcher} researcher The researcher to pass to the assessment.\n * @param {Assessment} assessment The assessment to execute.\n * @param i18n\n * @returns {AssessmentResult} The result of the assessment.\n */\n executeAssessment({paper, researcher, assessment, i18n}) {\n let result;\n\n try {\n if (i18n) {\n assessment._config.title = i18n.translate(`Axyseo.${assessment._config.id}.title`);\n assessment._config.content = {\n good: i18n.translate(`Axyseo.${assessment._config.id}.good`),\n improve: i18n.translate(`Axyseo.${assessment._config.id}.improve`),\n bad: i18n.translate(`Axyseo.${assessment._config.id}.bad`)\n };\n }\n result = assessment.getResult({paper, researcher, config: this._config, i18n});\n result.setIdentifier(assessment._config.id);\n } catch (assessmentError) {\n showTrace(assessmentError);\n\n result = new AssessmentResult();\n\n result.setScore(-1);\n }\n return result;\n }\n\n /**\n * Filters out all assessment results that have no score and no text.\n *\n * @returns {AssessmentResult[]} The array with all the valid assessments.\n */\n getValidResults() {\n return filter(\n this.results,\n function(result) {\n return this.isValidResult(result);\n }.bind(this)\n );\n }\n\n /**\n * Returns if an assessmentResult is valid.\n *\n * @param {AssessmentResult} assessmentResult The assessmentResult to validate.\n * @returns {boolean} whether or not the result is valid.\n */\n isValidResult(assessmentResult) {\n return assessmentResult.hasScore() && assessmentResult.hasText();\n }\n\n /**\n * Returns the overall score. Calculates the total score by adding all scores and dividing these\n * by the number of results times the ScoreRating.\n *\n * @returns {number} The overall score.\n */\n calculateOverallScore() {\n const results = this.getValidResults();\n\n const totalScore = results.reduce(\n (total, assessmentResult) => total + assessmentResult.getScore(),\n 0\n );\n\n return Math.round((totalScore / (results.length * ScoreRating)) * 100) || 0;\n }\n\n /**\n * Registers an assessment and adds it to the internal assessments object.\n *\n * @param {string} name The name of the assessment.\n * @param {Assessment} assessment The object containing function to run as an assessment and it's requirements.\n * @returns {boolean} Whether registering the assessment was successful.\n */\n addAssessment(name, assessment) {\n if (!assessment.hasOwnProperty('identifier')) {\n assessment.identifier = name;\n }\n // If the assessor already has the same assessment, remove it and replace it with the new assessment with the same identifier.\n if (this.getAssessment(assessment.identifier)) {\n this.removeAssessment(assessment.identifier);\n }\n\n this._assessments.push(assessment);\n return true;\n }\n\n /**\n * Removes a specific Assessment from the list of Assessments.\n *\n * @param {string} name The Assessment to remove from the list of assessments.\n * @returns {void}\n */\n removeAssessment(name) {\n const toDelete = findIndex(this._assessments, function(assessment) {\n return assessment.hasOwnProperty('identifier') && name === assessment.identifier;\n });\n\n if (-1 !== toDelete) {\n this._assessments.splice(toDelete, 1);\n }\n }\n\n /**\n * Returns an assessment by identifier\n *\n * @param {string} identifier The identifier of the assessment.\n * @returns {undefined|Assessment} The object if found, otherwise undefined.\n */\n getAssessment(identifier) {\n return find(this._assessments, function(assessment) {\n return assessment.hasOwnProperty('identifier') && identifier === assessment.identifier;\n });\n }\n\n /**\n * Checks which of the available assessments are applicable and returns an array with applicable assessments.\n *\n * @returns {Assessment[]} The array with applicable assessments.\n */\n getApplicableAssessments() {\n const availableAssessments = this.getAvailableAssessments();\n return filter(\n availableAssessments,\n function(availableAssessment) {\n return this.isApplicable(availableAssessment, this.getPaper(), this._researcher);\n }.bind(this)\n );\n }\n}\n\nexport default Assessor;\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAGA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,gBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AAAkD,SAAAE,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AARlD;;AAGA;;AAOA;AACA,MAAMG,WAAW,GAAG,CA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AACF;AACA;AACA;AACA;AACA;EACEH,aAAaA,CAACD,UAAU,EAAE;IACxB,OAAO,IAAAO,YAAI,EAAC,IAAI,CAACpE,YAAY,EAAE,UAASO,UAAU,EAAE;MAClD,OAAOA,UAAU,CAACE,cAAc,CAAC,YAAY,CAAC,IAAIoD,UAAU,KAAKtD,UAAU,CAACsD,UAAU;IACxF,CAAC,CAAC;EACJ;;EAEA;AACF;AACA;AACA;AACA;EACEQ,wBAAwBA,CAAA,EAAG;IACzB,MAAMC,oBAAoB,GAAG,IAAI,CAACjE,uBAAuB,CAAC,CAAC;IAC3D,OAAO,IAAAuB,cAAM,EACX0C,oBAAoB,EACpB,UAASC,mBAAmB,EAAE;MAC5B,OAAO,IAAI,CAACjE,YAAY,CAACiE,mBAAmB,EAAE,IAAI,CAACxD,QAAQ,CAAC,CAAC,EAAE,IAAI,CAACX,WAAW,CAAC;IAClF,CAAC,CAACyB,IAAI,CAAC,IAAI,CACb,CAAC;EACH;AACF;AAAC,IAAA2C,QAAA,GAAAC,OAAA,CAAAjF,OAAA,GAEcE,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"assessor.js","names":["_lodash","require","_AssessmentResult","_interopRequireDefault","_build","_LanguageProcessor","_missingArgument","_errors","e","__esModule","default","ScoreRating","Assessor","constructor","researcher","config","type","setResearcher","_assessments","isUndefined","MissingArgument","_researcher","getAvailableAssessments","isApplicable","assessment","paper","ignoreAssessments","getIgnoredAssessments","includes","_config","id","hasOwnProperty","hasMarker","isFunction","marker","getMarks","getSpecificMarker","getPaper","_lastPaper","assess","i18n","setPaper","languageProcessor","LanguageProcessor","shortcodes","_attributes","setTree","build","assessments","results","filter","bind","map","executeAssessment","result","title","translate","content","good","improve","bad","getResult","setIdentifier","assessmentError","showTrace","AssessmentResult","setScore","getValidResults","isValidResult","assessmentResult","hasScore","hasText","calculateOverallScore","totalScore","reduce","total","getScore","Math","round","length","addAssessment","name","identifier","getAssessment","removeAssessment","push","toDelete","findIndex","splice","find","getApplicableAssessments","availableAssessments","availableAssessment","_default","exports"],"sources":["../../../src/scoring/assessors/assessor.js"],"sourcesContent":["// External dependencies.\nimport {filter, find, findIndex, isFunction, isUndefined, map} from 'lodash';\n\n// Internal dependencies.\nimport AssessmentResult from '../../values/AssessmentResult.js';\nimport {build} from '../../parse/build';\nimport LanguageProcessor from '../../parse/language/LanguageProcessor.js';\nimport MissingArgument from '../../errors/missingArgument.js';\nimport {showTrace} from '../../helpers/errors.js';\n\n// The maximum score of individual assessment is 9. This is why we set the \"score rating\" here to 9.\nconst ScoreRating = 9;\n\n/**\n * The Assessor is a base class for all assessors.\n */\nclass Assessor {\n /**\n * Creates a new Assessor instance.\n * @param {Researcher}\tresearcher\tThe researcher to use.\n * @param {Object}\t\t[config]\tThe assessor config.\n */\n constructor(researcher, config) {\n this.type = 'assessor';\n this.setResearcher(researcher);\n this._assessments = [];\n }\n\n /**\n * Checks if the researcher is defined and sets it.\n *\n * @param {Researcher} researcher The researcher to use in the assessor.\n *\n * @throws {MissingArgument} Parameter needs to be a valid researcher object.\n * @returns {void}\n */\n setResearcher(researcher) {\n if (isUndefined(researcher)) {\n throw new MissingArgument('The assessor requires a researcher.');\n }\n this._researcher = researcher;\n }\n\n /**\n * Gets all available assessments.\n * @returns {Assessment[]} assessment\n */\n getAvailableAssessments() {\n return this._assessments;\n }\n\n /**\n * Checks whether the Assessment is applicable.\n *\n * @param {Assessment} assessment The Assessment object that needs to be checked.\n * @param {Paper} paper The Paper object to check against.\n * @param {Researcher} [researcher] The Researcher object containing additional information.\n * @returns {boolean} Whether or not the Assessment is applicable.\n */\n isApplicable(assessment, paper, researcher) {\n const ignoreAssessments = paper.getIgnoredAssessments();\n\n if (ignoreAssessments.includes(assessment._config.id)) {\n return false;\n }\n\n if (\n assessment.hasOwnProperty('isApplicable') ||\n typeof assessment.isApplicable === 'function'\n ) {\n return assessment.isApplicable(paper, researcher);\n }\n\n return true;\n }\n\n /**\n * Determines whether an assessment has a marker.\n *\n * @param {Assessment} assessment The assessment to check for.\n * @returns {boolean} Whether or not the assessment has a marker.\n */\n hasMarker(assessment) {\n return (\n isFunction(this._config.marker) &&\n (assessment.hasOwnProperty('getMarks') || typeof assessment.getMarks === 'function')\n );\n }\n\n /**\n * Returns the specific marker for this assessor.\n *\n * @returns {Function} The specific marker for this assessor.\n */\n getSpecificMarker() {\n return this._config.marker;\n }\n\n /**\n * Returns the paper that was most recently assessed.\n *\n * @returns {Paper} The paper that was most recently assessed.\n */\n getPaper() {\n return this._lastPaper;\n }\n\n /**\n * Runs the researches defined in the task list or the default researches.\n *\n * @param {Paper} paper The paper to run assessments on.\n * @param i18n\n * @returns {void}\n */\n assess(paper, i18n) {\n this._researcher.setPaper(paper);\n\n const languageProcessor = new LanguageProcessor(this._researcher);\n const shortcodes = paper._attributes && paper._attributes.shortcodes;\n paper.setTree(build(paper, languageProcessor, shortcodes));\n\n let assessments = this.getAvailableAssessments();\n this.results = [];\n\n assessments = filter(\n assessments,\n function(assessment) {\n return this.isApplicable(assessment, paper, this._researcher);\n }.bind(this)\n );\n\n this.results = map(assessments, assessment =>\n this.executeAssessment({\n paper,\n researcher: this._researcher,\n assessment,\n i18n\n })\n );\n this._lastPaper = paper;\n }\n\n /**\n * Executes an assessment and returns the AssessmentResult.\n *\n * @param {Paper} paper The paper to pass to the assessment.\n * @param {Researcher} researcher The researcher to pass to the assessment.\n * @param {Assessment} assessment The assessment to execute.\n * @param i18n\n * @returns {AssessmentResult} The result of the assessment.\n */\n executeAssessment({paper, researcher, assessment, i18n}) {\n let result;\n\n try {\n if (i18n) {\n assessment._config.title = i18n.translate(`Axyseo.${assessment._config.id}.title`);\n assessment._config.content = {\n good: i18n.translate(`Axyseo.${assessment._config.id}.good`),\n improve: i18n.translate(`Axyseo.${assessment._config.id}.improve`),\n bad: i18n.translate(`Axyseo.${assessment._config.id}.bad`)\n };\n }\n result = assessment.getResult({paper, researcher, i18n});\n result.setIdentifier(assessment._config.id);\n } catch (assessmentError) {\n showTrace(assessmentError);\n\n result = new AssessmentResult();\n\n result.setScore(-1);\n }\n return result;\n }\n\n /**\n * Filters out all assessment results that have no score and no text.\n *\n * @returns {AssessmentResult[]} The array with all the valid assessments.\n */\n getValidResults() {\n return filter(\n this.results,\n function(result) {\n return this.isValidResult(result);\n }.bind(this)\n );\n }\n\n /**\n * Returns if an assessmentResult is valid.\n *\n * @param {AssessmentResult} assessmentResult The assessmentResult to validate.\n * @returns {boolean} whether or not the result is valid.\n */\n isValidResult(assessmentResult) {\n return assessmentResult.hasScore() && assessmentResult.hasText();\n }\n\n /**\n * Returns the overall score. Calculates the total score by adding all scores and dividing these\n * by the number of results times the ScoreRating.\n *\n * @returns {number} The overall score.\n */\n calculateOverallScore() {\n const results = this.getValidResults();\n\n const totalScore = results.reduce(\n (total, assessmentResult) => total + assessmentResult.getScore(),\n 0\n );\n\n return Math.round((totalScore / (results.length * ScoreRating)) * 100) || 0;\n }\n\n /**\n * Registers an assessment and adds it to the internal assessments object.\n *\n * @param {string} name The name of the assessment.\n * @param {Assessment} assessment The object containing function to run as an assessment and it's requirements.\n * @returns {boolean} Whether registering the assessment was successful.\n */\n addAssessment(name, assessment) {\n if (!assessment.hasOwnProperty('identifier')) {\n assessment.identifier = name;\n }\n // If the assessor already has the same assessment, remove it and replace it with the new assessment with the same identifier.\n if (this.getAssessment(assessment.identifier)) {\n this.removeAssessment(assessment.identifier);\n }\n\n this._assessments.push(assessment);\n return true;\n }\n\n /**\n * Removes a specific Assessment from the list of Assessments.\n *\n * @param {string} name The Assessment to remove from the list of assessments.\n * @returns {void}\n */\n removeAssessment(name) {\n const toDelete = findIndex(this._assessments, function(assessment) {\n return assessment.hasOwnProperty('identifier') && name === assessment.identifier;\n });\n\n if (-1 !== toDelete) {\n this._assessments.splice(toDelete, 1);\n }\n }\n\n /**\n * Returns an assessment by identifier\n *\n * @param {string} identifier The identifier of the assessment.\n * @returns {undefined|Assessment} The object if found, otherwise undefined.\n */\n getAssessment(identifier) {\n return find(this._assessments, function(assessment) {\n return assessment.hasOwnProperty('identifier') && identifier === assessment.identifier;\n });\n }\n\n /**\n * Checks which of the available assessments are applicable and returns an array with applicable assessments.\n *\n * @returns {Assessment[]} The array with applicable assessments.\n */\n getApplicableAssessments() {\n const availableAssessments = this.getAvailableAssessments();\n return filter(\n availableAssessments,\n function(availableAssessment) {\n return this.isApplicable(availableAssessment, this.getPaper(), this._researcher);\n }.bind(this)\n );\n }\n}\n\nexport default Assessor;\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAGA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,gBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AAAkD,SAAAE,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AARlD;;AAGA;;AAOA;AACA,MAAMG,WAAW,GAAG,CAAC;;AAErB;AACA;AACA;AACA,MAAMC,QAAQ,CAAC;EACb;AACF;AACA;AACA;AACA;EACEC,WAAWA,CAACC,UAAU,EAAEC,MAAM,EAAE;IAC9B,IAAI,CAACC,IAAI,GAAG,UAAU;IACtB,IAAI,CAACC,aAAa,CAACH,UAAU,CAAC;IAC9B,IAAI,CAACI,YAAY,GAAG,EAAE;EACxB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACED,aAAaA,CAACH,UAAU,EAAE;IACxB,IAAI,IAAAK,mBAAW,EAACL,UAAU,CAAC,EAAE;MAC3B,MAAM,IAAIM,wBAAe,CAAC,qCAAqC,CAAC;IAClE;IACA,IAAI,CAACC,WAAW,GAAGP,UAAU;EAC/B;;EAEA;AACF;AACA;AACA;EACEQ,uBAAuBA,CAAA,EAAG;IACxB,OAAO,IAAI,CAACJ,YAAY;E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AO,IAAI,CAACrE,YAAY,CAACqE,mBAAmB,EAAE,IAAI,CAACvD,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAChB,WAAW,CAAC;IAClF,CAAC,CAAC8B,IAAI,CAAC,IAAI,CACb,CAAC;EACH;AACF;AAAC,IAAA0C,QAAA,GAAAC,OAAA,CAAApF,OAAA,GAEcE,QAAQ","ignoreList":[]}
|
package/build/values/Paper.js
CHANGED
|
@@ -53,7 +53,9 @@ class Paper {
|
|
|
53
53
|
* @param {string} [attributes.permalink] The full URL for any given post, page, or other pieces of content on a site.
|
|
54
54
|
* @param {string} [attributes.date] The date.
|
|
55
55
|
* @param {Object[]} [attributes.wpBlocks] The array of texts, encoded in WordPress block editor blocks.
|
|
56
|
+
* @param {Object[]} [attributes.ignoredAssessments] The array of texts, show which assessments should be ignored.
|
|
56
57
|
* @param {Object} [attributes.customData] Custom data.
|
|
58
|
+
* @param {Object} [attributes.shopSettings] Shop's settings.
|
|
57
59
|
* @param {string} [attributes.textTitle] The title of the text.
|
|
58
60
|
* @param {string} [attributes.writingDirection=LTR] The writing direction of the paper. Defaults to left to right (LTR).
|
|
59
61
|
* @param {boolean} [attributes.isFrontPage=false] Whether the current page is the front page of the site. Defaults to false.
|
|
@@ -248,6 +250,14 @@ class Paper {
|
|
|
248
250
|
return this._attributes.slug !== '';
|
|
249
251
|
}
|
|
250
252
|
|
|
253
|
+
/**
|
|
254
|
+
* Checks whether a shop settings is available.
|
|
255
|
+
* @returns {boolean} Returns true if the Paper has a shop settings.
|
|
256
|
+
*/
|
|
257
|
+
hasShopSettings() {
|
|
258
|
+
return !(0, _lodash.isEmpty)(this._attributes?.shopSettings || {});
|
|
259
|
+
}
|
|
260
|
+
|
|
251
261
|
/**
|
|
252
262
|
* Gets the paper's slug, or an empty string if no slug is available.
|
|
253
263
|
* @returns {string} Returns the slug.
|
|
@@ -256,6 +266,30 @@ class Paper {
|
|
|
256
266
|
return this._attributes.slug;
|
|
257
267
|
}
|
|
258
268
|
|
|
269
|
+
/**
|
|
270
|
+
*
|
|
271
|
+
* @returns {(function(): *)|boolean}
|
|
272
|
+
*/
|
|
273
|
+
hasProductSchema() {
|
|
274
|
+
return this._attributes?.hasProductSchema || false;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
*
|
|
279
|
+
* @returns {Object[String]|*[String]}
|
|
280
|
+
*/
|
|
281
|
+
getIgnoredAssessments() {
|
|
282
|
+
return this._attributes?.ignoredAssessments || [];
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
*
|
|
287
|
+
* @returns {*|{}}
|
|
288
|
+
*/
|
|
289
|
+
getShopSettings() {
|
|
290
|
+
return this._attributes?.shopSettings || {};
|
|
291
|
+
}
|
|
292
|
+
|
|
259
293
|
/**
|
|
260
294
|
* Checks if currently edited page is a front page.
|
|
261
295
|
* @returns {boolean} Returns true if the current page is a front page.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Paper.js","names":["_lodash","require","defaultAttributes","keyword","synonyms","description","title","titleWidth","titleCount","h1Count","slug","domain","locale","permalink","date","customData","textTitle","writingDirection","wpBlocks","isFrontPage","Paper","constructor","text","attributes","_text","_tree","defaults","hasOwnProperty","url","onlyLetters","replace","isEmpty","_attributes","hasKeyword","getKeyword","getAttributes","hasSynonyms","getSynonyms","hasH1Count","isNull","getH1Count","hasTitleCount","getTitleCount","hasText","getText","getDomain","setTree","tree","getTree","hasDescription","getDescription","hasTitle","getTitle","hasTitleWidth","getTitleWidth","hasSlug","getSlug","hasUrl","console","warn","getUrl","hasLocale","getLocale","getWritingDirection","hasPermalink","getPermalink","hasDate","getDate","hasCustomData","getCustomData","hasTextTitle","isNil","getTextTitle","serialize","_parseClass","equals","paper","isEqual","parse","serialized","exports","default"],"sources":["../../src/values/Paper.js"],"sourcesContent":["import {defaults, isEmpty, isEqual, isNil, isNull} from 'lodash';\n\n/**\n * Default attributes to be used by the Paper if they are left undefined.\n * @type {{keyword: string, synonyms: string, description: string, title: string, titleWidth: number,\n * \t\t slug: string, locale: string, permalink: string, date: string, customData: object, textTitle: string,\n * \t\t writingDirection: \"LTR\", isFrontPage: boolean }}\n */\nconst defaultAttributes = {\n keyword: '',\n synonyms: '',\n description: '',\n title: '',\n titleWidth: 0,\n titleCount: null,\n h1Count: null,\n slug: '',\n domain: '',\n locale: 'en_US',\n permalink: '',\n date: '',\n customData: {},\n textTitle: '',\n writingDirection: 'LTR',\n wpBlocks: [],\n isFrontPage: false\n};\n\n/**\n * Represents an object where the analysis data is stored.\n */\nexport default class Paper {\n /**\n * Constructs the Paper object and sets its attributes.\n *\n * @param {string} text The text to use in the analysis.\n * @param {object} [attributes] The object containing all attributes.\n * @param {string} [attributes.keyword] The main keyword or keyphrase of the text.\n * @param {string} [attributes.synonyms] The synonyms of the main keyword or keyphrase. It should be separated by commas if multiple synonyms are added.\n * @param {string} [attributes.description] The SEO meta description.\n * @param {string} [attributes.title] The SEO title.\n * @param {string} [attributes.domain] The shop domain.\n * @param {number|null} [attributes.titleCount=null] The title tag count value.\n * @param {number|null} [attributes.h1Count=null] The h1 tag count value.\n * @param {number} [attributes.titleWidth=0] The width of the title in pixels.\n * @param {string} [attributes.slug] The slug.\n * @param {string} [attributes.locale=en_US] The locale.\n * @param {string} [attributes.permalink] The full URL for any given post, page, or other pieces of content on a site.\n * @param {string} [attributes.date] The date.\n * @param {Object[]} [attributes.wpBlocks] The array of texts, encoded in WordPress block editor blocks.\n * @param {Object} [attributes.customData] Custom data.\n * @param {string} [attributes.textTitle] The title of the text.\n * @param {string} [attributes.writingDirection=LTR] The writing direction of the paper. Defaults to left to right (LTR).\n * @param {boolean} [attributes.isFrontPage=false] Whether the current page is the front page of the site. Defaults to false.\n */\n constructor(text, attributes) {\n this._text = text || '';\n\n this._tree = null;\n\n attributes = attributes || {};\n defaults(attributes, defaultAttributes);\n\n if (attributes.locale === '') {\n attributes.locale = defaultAttributes.locale;\n }\n\n if (attributes.hasOwnProperty('url')) {\n attributes.slug = attributes.url || attributes.slug;\n }\n\n const onlyLetters = attributes.keyword.replace(\n /[‘’“”\"'.?!:;,¿¡«»&*@#±^%|~`[\\](){}⟨⟩<>/\\\\–\\-\\u2014\\u00d7\\u002b\\s]/g,\n ''\n );\n\n if (isEmpty(onlyLetters)) {\n attributes.keyword = defaultAttributes.keyword;\n }\n\n this._attributes = attributes;\n }\n\n /**\n * Checks whether a keyword is available.\n * @returns {boolean} Returns true if the Paper has a keyword.\n */\n hasKeyword() {\n return this._attributes.keyword !== '';\n }\n\n /**\n * Returns the associated keyword or an empty string if no keyword is available.\n * @returns {string} Returns Keyword\n */\n getKeyword() {\n return this._attributes.keyword;\n }\n\n /**\n *\n * @returns {*|{keyword?: string, synonyms?: string, description?: string, title?: string, titleCount?: (number|null), h1Count?: (number|null), titleWidth?: number, slug?: string, locale?: string, permalink?: string, date?: string, wpBlocks?: Object[], customData?: Object, textTitle?: string, writingDirection?: string, isFrontPage?: boolean}|{}|{}}\n */\n getAttributes() {\n return this._attributes;\n }\n\n /**\n * Checks whether synonyms are available.\n * @returns {boolean} Returns true if the Paper has synonyms.\n */\n hasSynonyms() {\n return this._attributes.synonyms !== '';\n }\n\n /**\n * Returns the associated synonyms or an empty string if no synonyms is available.\n * @returns {string} Returns synonyms.\n */\n getSynonyms() {\n return this._attributes.synonyms;\n }\n\n /**\n * Checks whether the h1 count value is available.\n * @returns {boolean} Returns true if the paper has a h1 count value.\n */\n hasH1Count() {\n return !isNull(this._attributes.h1Count);\n }\n\n /**\n * Returns the h1 tag count value.\n * @returns {number | null}\n */\n getH1Count() {\n return this._attributes.h1Count;\n }\n\n /**\n * Checks whether the title count value is available.\n * @returns {boolean} Returns true if the paper has a title count.\n */\n hasTitleCount() {\n return !isNull(this._attributes.titleCount);\n }\n\n /**\n * Returns the title count value.\n * @returns {number | null}\n */\n getTitleCount() {\n return this._attributes.titleCount;\n }\n\n /**\n * Checks whether the text is available.\n * @returns {boolean} Returns true if the paper has a text.\n */\n hasText() {\n return this._text !== '';\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getText() {\n return this._text;\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getDomain() {\n return this._attributes.domain;\n }\n\n /**\n * Sets the tree.\n *\n * @param {Node} tree The tree to set.\n *\n * @returns {void}\n */\n setTree(tree) {\n this._tree = tree;\n }\n\n /**\n * Returns the tree.\n *\n * @returns {Node} The tree.\n */\n getTree() {\n return this._tree;\n }\n\n /**\n * Checks whether a description is available.\n * @returns {boolean} Returns true if the paper has a description.\n */\n hasDescription() {\n return this._attributes.description !== '';\n }\n\n /**\n * Returns the description or an empty string if no description is available.\n * @returns {string} Returns the description.\n */\n getDescription() {\n return this._attributes.description;\n }\n\n /**\n * Checks whether an SEO title is available\n * @returns {boolean} Returns true if the Paper has an SEO title.\n */\n hasTitle() {\n return this._attributes.title !== '';\n }\n\n /**\n * Returns the SEO title, or an empty string if no title is available.\n * @returns {string} Returns the SEO title.\n */\n getTitle() {\n return this._attributes.title;\n }\n\n /**\n * Checks whether an SEO title width in pixels is available.\n * @returns {boolean} Returns true if the Paper's SEO title is wider than 0 pixels.\n */\n hasTitleWidth() {\n return this._attributes.titleWidth !== 0;\n }\n\n /**\n * Gets the SEO title width in pixels, or an empty string of no title width in pixels is available.\n * @returns {number} Returns the SEO title width in pixels.\n */\n getTitleWidth() {\n return this._attributes.titleWidth;\n }\n\n /**\n * Checks whether a slug is available.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasSlug() {\n return this._attributes.slug !== '';\n }\n\n /**\n * Gets the paper's slug, or an empty string if no slug is available.\n * @returns {string} Returns the slug.\n */\n getSlug() {\n return this._attributes.slug;\n }\n\n /**\n * Checks if currently edited page is a front page.\n * @returns {boolean} Returns true if the current page is a front page.\n */\n isFrontPage() {\n return this._attributes.isFrontPage;\n }\n\n /**\n * Checks whether an url is available\n * @deprecated Since version 1.19.1. Use hasSlug instead.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasUrl() {\n console.warn('This function is deprecated, use hasSlug instead');\n return this.hasSlug();\n }\n\n /**\n * Returns the url, or an empty string if no url is available.\n * @deprecated Since version 1.19.1. Use getSlug instead.\n * @returns {string} Returns the url\n */\n getUrl() {\n console.warn('This function is deprecated, use getSlug instead');\n return this.getSlug();\n }\n\n /**\n * Checks whether a locale is available.\n * @returns {boolean} Returns true if the paper has a locale.\n */\n hasLocale() {\n return this._attributes.locale !== '';\n }\n\n /**\n * Returns the locale or an empty string if no locale is available\n * @returns {string} Returns the locale.\n */\n getLocale() {\n return this._attributes.locale;\n }\n\n /**\n * Gets the information of the writing direction of the paper.\n * It returns \"LTR\" (left to right) if this attribute is not provided.\n *\n * @returns {string} Returns the information of the writing direction of the paper.\n */\n getWritingDirection() {\n return this._attributes.writingDirection;\n }\n\n /**\n * Checks whether a permalink is available.\n * @returns {boolean} Returns true if the Paper has a permalink.\n */\n hasPermalink() {\n return this._attributes.permalink !== '';\n }\n\n /**\n * Returns the permalink, or an empty string if no permalink is available.\n * @returns {string} Returns the permalink.\n */\n getPermalink() {\n return this._attributes.permalink;\n }\n\n /**\n * Checks whether a date is available.\n * @returns {boolean} Returns true if the Paper has a date.\n */\n hasDate() {\n return this._attributes.date !== '';\n }\n\n /**\n * Returns the date, or an empty string if no date is available.\n * @returns {string} Returns the date.\n */\n getDate() {\n return this._attributes.date;\n }\n\n /**\n * Checks whether custom data is available.\n * @returns {boolean} Returns true if the Paper has custom data.\n */\n hasCustomData() {\n return !isEmpty(this._attributes.customData);\n }\n\n /**\n * Returns the custom data, or an empty object if no data is available.\n * @returns {Object} Returns the custom data.\n */\n getCustomData() {\n return this._attributes.customData;\n }\n\n /**\n * Checks whether a text title is available.\n * @returns {boolean} Returns true if the Paper has a text title.\n */\n hasTextTitle() {\n return this._attributes.textTitle !== '' && !isNil(this._attributes.textTitle);\n }\n\n /**\n * Returns the text title, or an empty string if no data is available.\n * @returns {string} Returns the text title.\n */\n getTextTitle() {\n return this._attributes.textTitle;\n }\n\n /**\n * Serializes the Paper instance to an object.\n *\n * @returns {Object} The serialized Paper.\n */\n serialize() {\n return {\n _parseClass: 'Paper',\n text: this._text,\n ...this._attributes\n };\n }\n\n /**\n * Checks whether the given paper has the same properties as this instance.\n *\n * @param {Paper} paper The paper to compare to.\n *\n * @returns {boolean} Whether the given paper is identical or not.\n */\n equals(paper) {\n return this._text === paper.getText() && isEqual(this._attributes, paper._attributes);\n }\n\n /**\n * Parses the object to a Paper.\n *\n * @param {Object|Paper} serialized The serialized object or Paper instance.\n *\n * @returns {Paper} The parsed Paper.\n */\n static parse(serialized) {\n // For ease of use, check if it is not already a Paper instance.\n if (serialized instanceof Paper) {\n return serialized;\n }\n\n // _parseClass is taken here, so it doesn't end up in the attributes.\n // eslint-disable-next-line no-unused-vars\n const {text, _parseClass, ...attributes} = serialized;\n\n return new Paper(text, attributes);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAG;EACxBC,OAAO,EAAE,EAAE;EACXC,QAAQ,EAAE,EAAE;EACZC,WAAW,EAAE,EAAE;EACfC,KAAK,EAAE,EAAE;EACTC,UAAU,EAAE,CAAC;EACbC,UAAU,EAAE,IAAI;EAChBC,OAAO,EAAE,IAAI;EACbC,IAAI,EAAE,EAAE;EACRC,MAAM,EAAE,EAAE;EACVC,MAAM,EAAE,OAAO;EACfC,SAAS,EAAE,EAAE;EACbC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE,CAAC,CAAC;EACdC,SAAS,EAAE,EAAE;EACbC,gBAAgB,EAAE,KAAK;EACvBC,QAAQ,EAAE,EAAE;EACZC,WAAW,EAAE;AACf,CAAC;;AAED;AACA;AACA;AACe,MAAMC,KAAK,CAAC;EACzB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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KAAK,KAAKoD,KAAK,CAAChC,OAAO,CAAC,CAAC,IAAI,IAAAiC,eAAO,EAAC,IAAI,CAAC7C,WAAW,EAAE4C,KAAK,CAAC5C,WAAW,CAAC;EACvF;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACE,OAAO8C,KAAKA,CAACC,UAAU,EAAE;IACvB;IACA,IAAIA,UAAU,YAAY3D,KAAK,EAAE;MAC/B,OAAO2D,UAAU;IACnB;;IAEA;IACA;IACA,MAAM;MAACzD,IAAI;MAAEoD,WAAW;MAAE,GAAGnD;IAAU,CAAC,GAAGwD,UAAU;IAErD,OAAO,IAAI3D,KAAK,CAACE,IAAI,EAAEC,UAAU,CAAC;EACpC;AACF;AAACyD,OAAA,CAAAC,OAAA,GAAA7D,KAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Paper.js","names":["_lodash","require","defaultAttributes","keyword","synonyms","description","title","titleWidth","titleCount","h1Count","slug","domain","locale","permalink","date","customData","textTitle","writingDirection","wpBlocks","isFrontPage","Paper","constructor","text","attributes","_text","_tree","defaults","hasOwnProperty","url","onlyLetters","replace","isEmpty","_attributes","hasKeyword","getKeyword","getAttributes","hasSynonyms","getSynonyms","hasH1Count","isNull","getH1Count","hasTitleCount","getTitleCount","hasText","getText","getDomain","setTree","tree","getTree","hasDescription","getDescription","hasTitle","getTitle","hasTitleWidth","getTitleWidth","hasSlug","hasShopSettings","shopSettings","getSlug","hasProductSchema","getIgnoredAssessments","ignoredAssessments","getShopSettings","hasUrl","console","warn","getUrl","hasLocale","getLocale","getWritingDirection","hasPermalink","getPermalink","hasDate","getDate","hasCustomData","getCustomData","hasTextTitle","isNil","getTextTitle","serialize","_parseClass","equals","paper","isEqual","parse","serialized","exports","default"],"sources":["../../src/values/Paper.js"],"sourcesContent":["import {defaults, isEmpty, isEqual, isNil, isNull} from 'lodash';\n\n/**\n * Default attributes to be used by the Paper if they are left undefined.\n * @type {{keyword: string, synonyms: string, description: string, title: string, titleWidth: number,\n * \t\t slug: string, locale: string, permalink: string, date: string, customData: object, textTitle: string,\n * \t\t writingDirection: \"LTR\", isFrontPage: boolean }}\n */\nconst defaultAttributes = {\n keyword: '',\n synonyms: '',\n description: '',\n title: '',\n titleWidth: 0,\n titleCount: null,\n h1Count: null,\n slug: '',\n domain: '',\n locale: 'en_US',\n permalink: '',\n date: '',\n customData: {},\n textTitle: '',\n writingDirection: 'LTR',\n wpBlocks: [],\n isFrontPage: false\n};\n\n/**\n * Represents an object where the analysis data is stored.\n */\nexport default class Paper {\n /**\n * Constructs the Paper object and sets its attributes.\n *\n * @param {string} text The text to use in the analysis.\n * @param {object} [attributes] The object containing all attributes.\n * @param {string} [attributes.keyword] The main keyword or keyphrase of the text.\n * @param {string} [attributes.synonyms] The synonyms of the main keyword or keyphrase. It should be separated by commas if multiple synonyms are added.\n * @param {string} [attributes.description] The SEO meta description.\n * @param {string} [attributes.title] The SEO title.\n * @param {string} [attributes.domain] The shop domain.\n * @param {number|null} [attributes.titleCount=null] The title tag count value.\n * @param {number|null} [attributes.h1Count=null] The h1 tag count value.\n * @param {number} [attributes.titleWidth=0] The width of the title in pixels.\n * @param {string} [attributes.slug] The slug.\n * @param {string} [attributes.locale=en_US] The locale.\n * @param {string} [attributes.permalink] The full URL for any given post, page, or other pieces of content on a site.\n * @param {string} [attributes.date] The date.\n * @param {Object[]} [attributes.wpBlocks] The array of texts, encoded in WordPress block editor blocks.\n * @param {Object[]} [attributes.ignoredAssessments] The array of texts, show which assessments should be ignored.\n * @param {Object} [attributes.customData] Custom data.\n * @param {Object} [attributes.shopSettings] Shop's settings.\n * @param {string} [attributes.textTitle] The title of the text.\n * @param {string} [attributes.writingDirection=LTR] The writing direction of the paper. Defaults to left to right (LTR).\n * @param {boolean} [attributes.isFrontPage=false] Whether the current page is the front page of the site. Defaults to false.\n */\n constructor(text, attributes) {\n this._text = text || '';\n\n this._tree = null;\n\n attributes = attributes || {};\n defaults(attributes, defaultAttributes);\n\n if (attributes.locale === '') {\n attributes.locale = defaultAttributes.locale;\n }\n\n if (attributes.hasOwnProperty('url')) {\n attributes.slug = attributes.url || attributes.slug;\n }\n\n const onlyLetters = attributes.keyword.replace(\n /[‘’“”\"'.?!:;,¿¡«»&*@#±^%|~`[\\](){}⟨⟩<>/\\\\–\\-\\u2014\\u00d7\\u002b\\s]/g,\n ''\n );\n\n if (isEmpty(onlyLetters)) {\n attributes.keyword = defaultAttributes.keyword;\n }\n\n this._attributes = attributes;\n }\n\n /**\n * Checks whether a keyword is available.\n * @returns {boolean} Returns true if the Paper has a keyword.\n */\n hasKeyword() {\n return this._attributes.keyword !== '';\n }\n\n /**\n * Returns the associated keyword or an empty string if no keyword is available.\n * @returns {string} Returns Keyword\n */\n getKeyword() {\n return this._attributes.keyword;\n }\n\n /**\n *\n * @returns {*|{keyword?: string, synonyms?: string, description?: string, title?: string, titleCount?: (number|null), h1Count?: (number|null), titleWidth?: number, slug?: string, locale?: string, permalink?: string, date?: string, wpBlocks?: Object[], customData?: Object, textTitle?: string, writingDirection?: string, isFrontPage?: boolean}|{}|{}}\n */\n getAttributes() {\n return this._attributes;\n }\n\n /**\n * Checks whether synonyms are available.\n * @returns {boolean} Returns true if the Paper has synonyms.\n */\n hasSynonyms() {\n return this._attributes.synonyms !== '';\n }\n\n /**\n * Returns the associated synonyms or an empty string if no synonyms is available.\n * @returns {string} Returns synonyms.\n */\n getSynonyms() {\n return this._attributes.synonyms;\n }\n\n /**\n * Checks whether the h1 count value is available.\n * @returns {boolean} Returns true if the paper has a h1 count value.\n */\n hasH1Count() {\n return !isNull(this._attributes.h1Count);\n }\n\n /**\n * Returns the h1 tag count value.\n * @returns {number | null}\n */\n getH1Count() {\n return this._attributes.h1Count;\n }\n\n /**\n * Checks whether the title count value is available.\n * @returns {boolean} Returns true if the paper has a title count.\n */\n hasTitleCount() {\n return !isNull(this._attributes.titleCount);\n }\n\n /**\n * Returns the title count value.\n * @returns {number | null}\n */\n getTitleCount() {\n return this._attributes.titleCount;\n }\n\n /**\n * Checks whether the text is available.\n * @returns {boolean} Returns true if the paper has a text.\n */\n hasText() {\n return this._text !== '';\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getText() {\n return this._text;\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getDomain() {\n return this._attributes.domain;\n }\n\n /**\n * Sets the tree.\n *\n * @param {Node} tree The tree to set.\n *\n * @returns {void}\n */\n setTree(tree) {\n this._tree = tree;\n }\n\n /**\n * Returns the tree.\n *\n * @returns {Node} The tree.\n */\n getTree() {\n return this._tree;\n }\n\n /**\n * Checks whether a description is available.\n * @returns {boolean} Returns true if the paper has a description.\n */\n hasDescription() {\n return this._attributes.description !== '';\n }\n\n /**\n * Returns the description or an empty string if no description is available.\n * @returns {string} Returns the description.\n */\n getDescription() {\n return this._attributes.description;\n }\n\n /**\n * Checks whether an SEO title is available\n * @returns {boolean} Returns true if the Paper has an SEO title.\n */\n hasTitle() {\n return this._attributes.title !== '';\n }\n\n /**\n * Returns the SEO title, or an empty string if no title is available.\n * @returns {string} Returns the SEO title.\n */\n getTitle() {\n return this._attributes.title;\n }\n\n /**\n * Checks whether an SEO title width in pixels is available.\n * @returns {boolean} Returns true if the Paper's SEO title is wider than 0 pixels.\n */\n hasTitleWidth() {\n return this._attributes.titleWidth !== 0;\n }\n\n /**\n * Gets the SEO title width in pixels, or an empty string of no title width in pixels is available.\n * @returns {number} Returns the SEO title width in pixels.\n */\n getTitleWidth() {\n return this._attributes.titleWidth;\n }\n\n /**\n * Checks whether a slug is available.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasSlug() {\n return this._attributes.slug !== '';\n }\n\n /**\n * Checks whether a shop settings is available.\n * @returns {boolean} Returns true if the Paper has a shop settings.\n */\n hasShopSettings() {\n return !isEmpty(this._attributes?.shopSettings || {});\n }\n\n /**\n * Gets the paper's slug, or an empty string if no slug is available.\n * @returns {string} Returns the slug.\n */\n getSlug() {\n return this._attributes.slug;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasProductSchema() {\n return this._attributes?.hasProductSchema || false;\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getIgnoredAssessments() {\n return this._attributes?.ignoredAssessments || [];\n }\n\n /**\n *\n * @returns {*|{}}\n */\n getShopSettings() {\n return this._attributes?.shopSettings || {};\n }\n\n /**\n * Checks if currently edited page is a front page.\n * @returns {boolean} Returns true if the current page is a front page.\n */\n isFrontPage() {\n return this._attributes.isFrontPage;\n }\n\n /**\n * Checks whether an url is available\n * @deprecated Since version 1.19.1. Use hasSlug instead.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasUrl() {\n console.warn('This function is deprecated, use hasSlug instead');\n return this.hasSlug();\n }\n\n /**\n * Returns the url, or an empty string if no url is available.\n * @deprecated Since version 1.19.1. Use getSlug instead.\n * @returns {string} Returns the url\n */\n getUrl() {\n console.warn('This function is deprecated, use getSlug instead');\n return this.getSlug();\n }\n\n /**\n * Checks whether a locale is available.\n * @returns {boolean} Returns true if the paper has a locale.\n */\n hasLocale() {\n return this._attributes.locale !== '';\n }\n\n /**\n * Returns the locale or an empty string if no locale is available\n * @returns {string} Returns the locale.\n */\n getLocale() {\n return this._attributes.locale;\n }\n\n /**\n * Gets the information of the writing direction of the paper.\n * It returns \"LTR\" (left to right) if this attribute is not provided.\n *\n * @returns {string} Returns the information of the writing direction of the paper.\n */\n getWritingDirection() {\n return this._attributes.writingDirection;\n }\n\n /**\n * Checks whether a permalink is available.\n * @returns {boolean} Returns true if the Paper has a permalink.\n */\n hasPermalink() {\n return this._attributes.permalink !== '';\n }\n\n /**\n * Returns the permalink, or an empty string if no permalink is available.\n * @returns {string} Returns the permalink.\n */\n getPermalink() {\n return this._attributes.permalink;\n }\n\n /**\n * Checks whether a date is available.\n * @returns {boolean} Returns true if the Paper has a date.\n */\n hasDate() {\n return this._attributes.date !== '';\n }\n\n /**\n * Returns the date, or an empty string if no date is available.\n * @returns {string} Returns the date.\n */\n getDate() {\n return this._attributes.date;\n }\n\n /**\n * Checks whether custom data is available.\n * @returns {boolean} Returns true if the Paper has custom data.\n */\n hasCustomData() {\n return !isEmpty(this._attributes.customData);\n }\n\n /**\n * Returns the custom data, or an empty object if no data is available.\n * @returns {Object} Returns the custom data.\n */\n getCustomData() {\n return this._attributes.customData;\n }\n\n /**\n * Checks whether a text title is available.\n * @returns {boolean} Returns true if the Paper has a text title.\n */\n hasTextTitle() {\n return this._attributes.textTitle !== '' && !isNil(this._attributes.textTitle);\n }\n\n /**\n * Returns the text title, or an empty string if no data is available.\n * @returns {string} Returns the text title.\n */\n getTextTitle() {\n return this._attributes.textTitle;\n }\n\n /**\n * Serializes the Paper instance to an object.\n *\n * @returns {Object} The serialized Paper.\n */\n serialize() {\n return {\n _parseClass: 'Paper',\n text: this._text,\n ...this._attributes\n };\n }\n\n /**\n * Checks whether the given paper has the same properties as this instance.\n *\n * @param {Paper} paper The paper to compare to.\n *\n * @returns {boolean} Whether the given paper is identical or not.\n */\n equals(paper) {\n return this._text === paper.getText() && isEqual(this._attributes, paper._attributes);\n }\n\n /**\n * Parses the object to a Paper.\n *\n * @param {Object|Paper} serialized The serialized object or Paper instance.\n *\n * @returns {Paper} The parsed Paper.\n */\n static parse(serialized) {\n // For ease of use, check if it is not already a Paper instance.\n if (serialized instanceof Paper) {\n return serialized;\n }\n\n // _parseClass is taken here, so it doesn't end up in the attributes.\n // eslint-disable-next-line no-unused-vars\n const {text, _parseClass, ...attributes} = serialized;\n\n return new Paper(text, attributes);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAG;EACxBC,OAAO,EAAE,EAAE;EACXC,QAAQ,EAAE,EAAE;EACZC,WAAW,EAAE,EAAE;EACfC,KAAK,EAAE,EAAE;EACTC,UAAU,EAAE,CAAC;EACbC,UAAU,EAAE,IAAI;EAChBC,OAAO,E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