astro-accelerator-utils 0.2.35 → 0.2.36

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.
@@ -11,6 +11,7 @@ export class Accelerator {
11
11
  siteUrl: string;
12
12
  subfolder: string;
13
13
  useTrailingUrlSlash: boolean;
14
+ captureStatistics: boolean;
14
15
  get authors(): Authors;
15
16
  get cache(): Cache;
16
17
  get dateFormatter(): DateFormatter;
@@ -20,6 +21,7 @@ export class Accelerator {
20
21
  get posts(): Posts;
21
22
  get taxonomy(): Taxonomy;
22
23
  get urlFormatter(): UrlFormatter;
24
+ get statistics(): typeof StatisticsStub;
23
25
  }
24
26
  export type Site = import("../../types/Site").Site;
25
27
  import { Authors } from "./authors.mjs";
@@ -31,3 +33,4 @@ import { Paging } from "./paging.mjs";
31
33
  import { Posts } from "./posts.mjs";
32
34
  import { Taxonomy } from "./taxonomy.mjs";
33
35
  import { UrlFormatter } from "./urls.mjs";
36
+ import { StatisticsStub } from "./statistics-stub.mjs";
@@ -8,6 +8,7 @@ import { Posts } from './posts.mjs';
8
8
  import { Taxonomy } from './taxonomy.mjs';
9
9
  import { UrlFormatter } from './urls.mjs';
10
10
  import { Statistics } from './statistics.mjs';
11
+ import { StatisticsStub } from './statistics-stub.mjs';
11
12
 
12
13
  /**
13
14
  * @typedef { import("../../types/Site").Site } Site
@@ -63,6 +64,8 @@ export class Accelerator {
63
64
  }
64
65
 
65
66
  get statistics() {
66
- return Statistics;
67
+ return (this.captureStatistics)
68
+ ? Statistics
69
+ : StatisticsStub;
67
70
  }
68
71
  }
@@ -30,9 +30,9 @@ export class Cache {
30
30
  */
31
31
  clear(): Promise<void>;
32
32
  /**
33
- * Get's the path of the cache files
34
- * @returns {string}
35
- */
33
+ * Get's the path of the cache files
34
+ * @returns {string}
35
+ */
36
36
  getCachePath(): string;
37
37
  /**
38
38
  * Gets the file path for a cache item
@@ -0,0 +1,5 @@
1
+ export class StatisticsStub {
2
+ constructor(operation: any);
3
+ start(): void;
4
+ stop(): void;
5
+ }
@@ -0,0 +1,10 @@
1
+ export class StatisticsStub {
2
+ constructor(operation) {
3
+ }
4
+
5
+ start() {
6
+ }
7
+
8
+ stop() {
9
+ }
10
+ }
@@ -0,0 +1,39 @@
1
+ export class Statistics {
2
+ /**
3
+ * Clears the stats file
4
+ */
5
+ static purge(): void;
6
+ /**
7
+ * Get's the path of the log files
8
+ * @returns {string}
9
+ */
10
+ static getLogPath(): string;
11
+ /**
12
+ * Gets the file path for a log item
13
+ * @returns {string}
14
+ */
15
+ static getItemPath(): string;
16
+ /**
17
+ * Creates a new stats instance - all instances append to the stats file
18
+ * Use Statistics.purge() to reset the file
19
+ * After creating a timer, use start() and stop() to record an event
20
+ * @param {string} operation
21
+ */
22
+ constructor(operation: string);
23
+ operation: string;
24
+ /**
25
+ * Gets high resolution time in ms
26
+ * @returns number
27
+ */
28
+ getMilliseconds(): number;
29
+ /**
30
+ * Start the timer
31
+ */
32
+ start(): void;
33
+ /**
34
+ * Stop the timer (logs to .logs/statistics.csv)
35
+ */
36
+ stop(): void;
37
+ end: number;
38
+ duration: number;
39
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-accelerator-utils",
3
- "version": "0.2.35",
3
+ "version": "0.2.36",
4
4
  "description": "Astro utilities for Astro Accelerator.",
5
5
  "main": "index.mjs",
6
6
  "type": "module",
package/types/Site.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export type Site = {
2
2
  url: string;
3
3
  useTrailingUrlSlash?: boolean;
4
+ captureStatistics: boolean;
4
5
  dateOptions: Intl.DateTimeFormatOptions;
5
6
  subfolder: string;
6
7
  feedUrl: string;