@purpleschool/gptbot 0.7.37-texteditor → 0.7.38-texteditor

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.
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CHARACTERS_PER_PAGE = void 0;
4
+ exports.pagesToCharacters = pagesToCharacters;
5
+ exports.charactersToPages = charactersToPages;
6
+ const WORD_FONT_SIZE_PT = 14;
7
+ const WORD_LINE_SPACING = 1.5;
8
+ const A4_WIDTH_MM = 210;
9
+ const A4_HEIGHT_MM = 297;
10
+ const MARGIN_TOP_MM = 20;
11
+ const MARGIN_BOTTOM_MM = 20;
12
+ const MARGIN_LEFT_MM = 30;
13
+ const MARGIN_RIGHT_MM = 10;
14
+ const FIRST_LINE_INDENT_MM = 12.5;
15
+ const MM_PER_POINT = 0.3527777778;
16
+ const TEXT_WIDTH_MM = A4_WIDTH_MM - MARGIN_LEFT_MM - MARGIN_RIGHT_MM;
17
+ const TEXT_HEIGHT_MM = A4_HEIGHT_MM - MARGIN_TOP_MM - MARGIN_BOTTOM_MM;
18
+ const LINE_HEIGHT_MM = WORD_FONT_SIZE_PT * WORD_LINE_SPACING * MM_PER_POINT;
19
+ const LINES_PER_PAGE = Math.floor(TEXT_HEIGHT_MM / LINE_HEIGHT_MM);
20
+ const AVG_CHAR_WIDTH_EM = 0.58;
21
+ const AVG_CHAR_WIDTH_MM = WORD_FONT_SIZE_PT * AVG_CHAR_WIDTH_EM * MM_PER_POINT;
22
+ const CHARS_PER_LINE = Math.floor(TEXT_WIDTH_MM / AVG_CHAR_WIDTH_MM);
23
+ const AVG_PARAGRAPHS_PER_PAGE = 4; // average paragraph count across typical student papers
24
+ const INDENT_CHARS_LOSS = Math.round((FIRST_LINE_INDENT_MM / AVG_CHAR_WIDTH_MM) * AVG_PARAGRAPHS_PER_PAGE);
25
+ const LAYOUT_FUDGE_FACTOR = 0.96;
26
+ exports.CHARACTERS_PER_PAGE = Math.round((LINES_PER_PAGE * CHARS_PER_LINE - INDENT_CHARS_LOSS) * LAYOUT_FUDGE_FACTOR);
27
+ function pagesToCharacters(pages) {
28
+ if (!Number.isFinite(pages) || pages <= 0)
29
+ return 0;
30
+ return Math.max(0, Math.round(pages * exports.CHARACTERS_PER_PAGE));
31
+ }
32
+ function charactersToPages(characters) {
33
+ if (!Number.isFinite(characters) || characters <= 0)
34
+ return 0;
35
+ const raw = characters / exports.CHARACTERS_PER_PAGE;
36
+ return Math.max(0, Math.ceil(raw));
37
+ }
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./calculate-writer-ai-action-price.util"), exports);
18
18
  __exportStar(require("./calculate-writer-content-generation-price.util"), exports);
19
+ __exportStar(require("./calculate-page-count.util"), exports);
@@ -0,0 +1,46 @@
1
+ const WORD_FONT_SIZE_PT = 14;
2
+ const WORD_LINE_SPACING = 1.5;
3
+
4
+ const A4_WIDTH_MM = 210;
5
+ const A4_HEIGHT_MM = 297;
6
+
7
+ const MARGIN_TOP_MM = 20;
8
+ const MARGIN_BOTTOM_MM = 20;
9
+ const MARGIN_LEFT_MM = 30;
10
+ const MARGIN_RIGHT_MM = 10;
11
+
12
+ const FIRST_LINE_INDENT_MM = 12.5;
13
+
14
+ const MM_PER_POINT = 0.3527777778;
15
+
16
+ const TEXT_WIDTH_MM = A4_WIDTH_MM - MARGIN_LEFT_MM - MARGIN_RIGHT_MM;
17
+ const TEXT_HEIGHT_MM = A4_HEIGHT_MM - MARGIN_TOP_MM - MARGIN_BOTTOM_MM;
18
+
19
+ const LINE_HEIGHT_MM = WORD_FONT_SIZE_PT * WORD_LINE_SPACING * MM_PER_POINT;
20
+ const LINES_PER_PAGE = Math.floor(TEXT_HEIGHT_MM / LINE_HEIGHT_MM);
21
+
22
+ const AVG_CHAR_WIDTH_EM = 0.58;
23
+ const AVG_CHAR_WIDTH_MM = WORD_FONT_SIZE_PT * AVG_CHAR_WIDTH_EM * MM_PER_POINT;
24
+
25
+ const CHARS_PER_LINE = Math.floor(TEXT_WIDTH_MM / AVG_CHAR_WIDTH_MM);
26
+ const AVG_PARAGRAPHS_PER_PAGE = 4; // average paragraph count across typical student papers
27
+ const INDENT_CHARS_LOSS = Math.round(
28
+ (FIRST_LINE_INDENT_MM / AVG_CHAR_WIDTH_MM) * AVG_PARAGRAPHS_PER_PAGE,
29
+ );
30
+
31
+ const LAYOUT_FUDGE_FACTOR = 0.96;
32
+
33
+ export const CHARACTERS_PER_PAGE = Math.round(
34
+ (LINES_PER_PAGE * CHARS_PER_LINE - INDENT_CHARS_LOSS) * LAYOUT_FUDGE_FACTOR,
35
+ );
36
+
37
+ export function pagesToCharacters(pages: number): number {
38
+ if (!Number.isFinite(pages) || pages <= 0) return 0;
39
+ return Math.max(0, Math.round(pages * CHARACTERS_PER_PAGE));
40
+ }
41
+
42
+ export function charactersToPages(characters: number): number {
43
+ if (!Number.isFinite(characters) || characters <= 0) return 0;
44
+ const raw = characters / CHARACTERS_PER_PAGE;
45
+ return Math.max(0, Math.ceil(raw));
46
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './calculate-writer-ai-action-price.util';
2
2
  export * from './calculate-writer-content-generation-price.util';
3
+ export * from './calculate-page-count.util';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.7.37-texteditor",
3
+ "version": "0.7.38-texteditor",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",