axyseo 2.0.0-alpha.0.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.
Files changed (3) hide show
  1. package/README.md +228 -0
  2. package/package.json +41 -0
  3. package/src/index.js +60 -0
package/README.md ADDED
@@ -0,0 +1,228 @@
1
+ # AvadaXYoastSEO.js
2
+
3
+ Text analysis and assessment library in JavaScript. This library can generate interesting metrics about a text and assess these metrics to give you an assessment which can be used to improve the text.
4
+
5
+ ![Screenshot of the assessment of the given text](images/assessments.png)
6
+
7
+ Also included is a preview of the Google search results which can be assessed using the library.
8
+
9
+ ## Documentation
10
+ * A list of all the [assessors](https://github.com/Yoast/wordpress-seo/blob/trunk/packages/yoastseo/src/scoring/assessors/ASSESSORS%20OVERVIEW.md)
11
+ * Information on the [scoring system of the assessments](https://github.com/Yoast/wordpress-seo/blob/trunk/packages/yoastseo/src/scoring/assessments/README.md)
12
+ * [SEO analysis scoring](https://github.com/Yoast/wordpress-seo/blob/trunk/packages/yoastseo/src/scoring/assessments/SCORING%20SEO.md)
13
+ * [Readability analysis scoring](https://github.com/Yoast/wordpress-seo/blob/trunk/packages/yoastseo/src/scoring/assessments/SCORING%20READABILITY.md)
14
+ * [Inclusive language analysis scoring](https://github.com/Yoast/wordpress-seo/blob/trunk/packages/yoastseo/src/scoring/assessments/SCORING%20INCLUSIVE%20LANGUAGE.md)
15
+ * [How keyphrase matching works](https://github.com/Yoast/wordpress-seo/blob/trunk/packages/yoastseo/src/scoring/assessments/KEYPHRASE%20MATCHING.md)
16
+ * [Scoring on taxonomy pages](https://github.com/Yoast/wordpress-seo/blob/trunk/packages/yoastseo/src/scoring/assessments/SCORING%20TAXONOMY.md)
17
+ * The data that will be analyzed by YoastSEO.js can be modified by plugins. Plugins can also add new research and assessments. To find out how to do this, checkout out the [customization documentation](https://github.com/Yoast/wordpress-seo/blob/trunk/packages/yoastseo/docs/Customization.md).
18
+ * Information on the design decisions within the package can be found [here](https://github.com/Yoast/wordpress-seo/blob/trunk/packages/yoastseo/DESIGN%20DECISIONS.md).
19
+ * Information on how morphology works in `yoastseo` package can be found [here](https://github.com/Yoast/wordpress-seo/blob/trunk/packages/yoastseo/MORPHOLOGY.md).
20
+
21
+
22
+ ## Installation
23
+
24
+ You can install YoastSEO.js using npm:
25
+
26
+ ```bash
27
+ npm install yoastseo
28
+ ```
29
+
30
+ Or using yarn:
31
+
32
+ ```bash
33
+ yarn add yoastseo
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ You can either use YoastSEO.js using the web worker API or use the internal components directly.
39
+
40
+ Because a web worker must be a separate script in the browser you first need to create a script for inside the web worker:
41
+
42
+ ```js
43
+ import { AnalysisWebWorker } from "yoastseo";
44
+
45
+ const worker = new AnalysisWebWorker( self );
46
+ worker.register();
47
+ ```
48
+
49
+ Then in a different script you have the following code:
50
+
51
+ ```js
52
+ import { AnalysisWorkerWrapper, createWorker, Paper } from "yoastseo";
53
+
54
+ // `url` needs to be the full URL to the script for the browser to know where to load the worker script from.
55
+ // This should be the script created by the previous code-snippet.
56
+ const url = "https://my-site-url.com/path-to-webworker-script.js"
57
+
58
+ const worker = new AnalysisWorkerWrapper( createWorker( url ) );
59
+
60
+ worker.initialize( {
61
+ locale: "en_US",
62
+ contentAnalysisActive: true,
63
+ keywordAnalysisActive: true,
64
+ logLevel: "ERROR",
65
+ } ).then( () => {
66
+ // The worker has been configured, we can now analyze a Paper.
67
+ const paper = new Paper( "Text to analyze", {
68
+ keyword: "analyze",
69
+ } );
70
+
71
+ return worker.analyze( paper );
72
+ } ).then( ( results ) => {
73
+ console.log( 'Analysis results:' );
74
+ console.log( results );
75
+ } ).catch( ( error ) => {
76
+ console.error( 'An error occured while analyzing the text:' );
77
+ console.error( error );
78
+ } );
79
+ ```
80
+
81
+ ### Usage of internal components
82
+
83
+ If you want to have a more bare-bones API, or are in an environment without access to Web Worker you can use the internal objects:
84
+
85
+ ```js
86
+ import { AbstractResearcher, Paper } from "yoastseo";
87
+
88
+ const paper = new Paper( "Text to analyze", {
89
+ keyword: "analyze",
90
+ } );
91
+ const researcher = new AbstractResearcher( paper );
92
+
93
+ console.log( researcher.getResearch( "wordCountInText" ) );
94
+ ```
95
+
96
+ **Note: This is currently a synchronous API, but will become an asynchronous API in the future.**
97
+
98
+ ## Supported languages
99
+
100
+ ### SEO analysis
101
+ **Function word support**, which is used for internal linking, insights, and keyphrase-related analysis, is available in the following languages:
102
+
103
+ English, German, Dutch, French, Spanish, Italian, Portuguese, Russian, Polish, Swedish, Hungarian, Indonesian, Arabic,
104
+ Hebrew, Farsi, Turkish, Norwegian, Czech, Slovak, Greek, Japanese
105
+
106
+ ### Readability analysis
107
+
108
+ | Language | Transition words | Flesch reading ease | Passive voice | Sentence beginnings | Sentence length<sup>1</sup> |
109
+ |------------ |------------------ |--------------------- |--------------- |--------------------- |----------------------------- |
110
+ | English | ✅ | ✅ | ✅ | ✅ | ✅ |
111
+ | German | ✅ | ✅ | ✅ | ✅ | ✅ |
112
+ | Dutch | ✅ | ✅ | ✅ | ✅ | ✅ |
113
+ | French | ✅ | ✅ | ✅ | ✅ | ✅ |
114
+ | Spanish | ✅ | ✅ | ✅ | ✅ | ✅ |
115
+ | Italian | ✅ | ✅ | ✅ | ✅ | ✅ |
116
+ | Portuguese | ✅ | ✅ | ✅ | ✅ | ✅ |
117
+ | Russian | ✅ | ✅ | ✅ | ✅ | ✅ |
118
+ | Catalan | ✅ | ❌<sup>3</sup> | ❌<sup>3</sup> | ❌<sup>3</sup> | ❌<sup>3</sup> |
119
+ | Polish | ✅ | ❌<sup>2</sup> | ✅ | ✅ | ✅ |
120
+ | Swedish | ✅ | ❌<sup>2</sup> | ✅ | ✅ | ✅ |
121
+ | Hungarian | ✅ | ❌<sup>2</sup> | ✅ | ✅ | ✅ |
122
+ | Indonesian | ✅ | ❌<sup>2</sup> | ✅ | ✅ | ✅ |
123
+ | Arabic | ✅ | ❌<sup>2</sup> | ✅ | ✅ | ✅ |
124
+ | Hebrew | ✅ | ❌<sup>2</sup> | ✅ | ✅ | ✅ |
125
+ | Farsi | ✅ | ❌<sup>2</sup> | ✅ | ✅ | ✅ |
126
+ | Turkish | ✅ | ❌<sup>2</sup> | ✅ | ✅ | ✅ |
127
+ | Norwegian | ✅ | ❌<sup>2</sup> | ✅ | ✅ | ✅ |
128
+ | Czech | ✅ | ❌<sup>2</sup> | ✅ | ✅ | ✅ |
129
+ | Slovak | ✅ | ❌<sup>2</sup> | ✅ | ✅ | ✅ |
130
+ | Greek | ✅ | ❌<sup>2</sup> | ✅ | ✅ | ✅ |
131
+ | Japanese | ✅ | ❌<sup>2</sup> | ❌<sup>4</sup> | ✅ | ✅ |
132
+
133
+ <sup>1</sup> This means the default upper limit of 20 words has been verified for this language, or the upper limit has been changed.
134
+
135
+ <sup>2</sup> There is no existing Flesch reading ease formula for these languages.
136
+
137
+ <sup>3</sup> This means that the functionality for this assessment is currently not available for these languages.
138
+
139
+ <sup>4</sup> The Passive voice check for Japanese is not implemented since the structure is the same as the potential form and can additionally be used for an honorific purpose. Identifying whether a verb is in its passive, honorific or potential form is problematic without contextual information.
140
+
141
+ The following readability assessments are available for all languages:
142
+ - sentence length (with a default upper limit of 20 words, see<sup>1</sup> above )
143
+ - paragraph length
144
+ - subheading distribution
145
+ - text presence
146
+
147
+ ### Inclusive language analysis
148
+
149
+ The inclusive language analysis is currently available in English.
150
+
151
+ ## Change log
152
+
153
+ Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
154
+
155
+ ## Testing
156
+
157
+ ```bash
158
+ npm test
159
+ ```
160
+
161
+ Or using yarn:
162
+
163
+ ```bash
164
+ yarn test
165
+ ```
166
+
167
+ Generate coverage using the `--coverage` flag.
168
+
169
+ ## Code style
170
+
171
+ To test your code style:
172
+
173
+ ```bash
174
+ yarn lint
175
+ ```
176
+
177
+ ## Testing with Yoast SEO
178
+
179
+ In the YoastSEO.js directory, run:
180
+
181
+ ```bash
182
+ npm link
183
+ ```
184
+
185
+ Or using yarn:
186
+
187
+ ```bash
188
+ yarn link
189
+ ```
190
+
191
+ Then, in the project directory where you want to test the package, assuming you have a complete development version, run:
192
+
193
+ ```bash
194
+ npm link yoastseo
195
+ ```
196
+ Or using yarn:
197
+
198
+ ```bash
199
+ yarn link yoastseo
200
+ ```
201
+
202
+ If you want to unlink, simply do:
203
+
204
+ ```bash
205
+ npm unlink yoastseo
206
+ ```
207
+ Or using yarn:
208
+
209
+ ```bash
210
+ yarn unlink yoastseo
211
+ ```
212
+
213
+ ## Contributing
214
+
215
+ Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
216
+
217
+ ## Security
218
+
219
+ If you discover any security related issues, please email security [at] yoast.com instead of using the issue tracker.
220
+
221
+ ## Credits
222
+
223
+ - [Team Yoast](https://github.com/orgs/Yoast/people)
224
+ - [All Contributors](https://github.com/Yoast/wordpress-seo/graphs/contributors)
225
+
226
+ ## License
227
+
228
+ We follow the GPL. Please see [License](LICENSE) file for more information.
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "axyseo",
3
+ "version": "2.0.0-alpha.0.0.1",
4
+ "main": "src/index.js",
5
+ "scripts": {
6
+ "build": "yarn clean && yarn build:js && yarn build:types",
7
+ "build:js": "babel src --copy-files --source-maps --out-dir build",
8
+ "build:types": "tsc",
9
+ "clean": "rm -rf build",
10
+ "lint": "eslint src spec --max-warnings 10"
11
+ },
12
+ "files": [
13
+ "build/"
14
+ ],
15
+ "dependencies": {
16
+ "@shopify/polaris-icons": "^8.2.0",
17
+ "htmlparser2": "^3.9.2",
18
+ "lodash": "^4.17.21",
19
+ "loglevel": "^1.8.1",
20
+ "parse5": "^7.1.2",
21
+ "tiny-segmenter": "^0.2.0",
22
+ "tokenizer2": "^2.0.1"
23
+ },
24
+ "devDependencies": {
25
+ "@babel/cli": "^7.25.9",
26
+ "@babel/core": "^7.26.0",
27
+ "@babel/preset-env": "^7.26.0",
28
+ "@babel/preset-react": "^7.26.3",
29
+ "@yoast/browserslist-config": "^1.2.3",
30
+ "blob-polyfill": "^7.0.20220408",
31
+ "console.table": "^0.10.0",
32
+ "eslint": "^9.16.0",
33
+ "eslint-config-yoast": "^6.0.0",
34
+ "globals": "^15.12.0",
35
+ "grunt": "^1.6.1",
36
+ "grunt-shell": "^4.0.0",
37
+ "js-yaml": "^4.1.0",
38
+ "load-grunt-config": "^1.0.0",
39
+ "typescript": "^5.6.3"
40
+ }
41
+ }
package/src/index.js ADDED
@@ -0,0 +1,60 @@
1
+ import * as assessments from './scoring/assessments';
2
+ import * as bundledPlugins from './bundledPlugins';
3
+ import * as helpers from './helpers';
4
+ import * as markers from './markers';
5
+ import * as interpreters from './scoring/interpreters';
6
+ import * as languageProcessing from './languageProcessing';
7
+ import * as values from './values';
8
+ import * as assessors from './scoring/assessors';
9
+ import Assessor from './scoring/assessors/assessor';
10
+ import ContentAssessor from './scoring/assessors/contentAssessor';
11
+ import SeoAssessor from './scoring/assessors/seoAssessor';
12
+ import Paper from './values/Paper';
13
+ import AssessmentResult from './values/AssessmentResult';
14
+ import Assessment from './scoring/assessments/assessment';
15
+ import {DIFFICULTY} from './languageProcessing/researches/getFleschReadingScore';
16
+
17
+ import Factory from './helpers/factory';
18
+
19
+ /*
20
+ * Everything exported here is put on the `yoast.analysis` global in the plugin.
21
+ */
22
+ export {
23
+ Assessor,
24
+ ContentAssessor,
25
+ SeoAssessor,
26
+ Paper,
27
+ AssessmentResult,
28
+ Assessment,
29
+ assessments,
30
+ assessors,
31
+ bundledPlugins,
32
+ helpers,
33
+ markers,
34
+ interpreters,
35
+ languageProcessing,
36
+ values,
37
+ DIFFICULTY,
38
+ Factory
39
+ };
40
+
41
+ /*
42
+ * Used for backwards compatibility reasons.
43
+ * For new exports, please add it as a named dependency above instead.
44
+ */
45
+ export default {
46
+ Assessor,
47
+ ContentAssessor,
48
+ SeoAssessor,
49
+
50
+ Paper,
51
+ AssessmentResult,
52
+
53
+ assessments,
54
+ bundledPlugins,
55
+ helpers,
56
+ markers,
57
+ interpreters,
58
+ languageProcessing,
59
+ values
60
+ };