@jam-comments/server-utilities 5.8.3 → 5.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.logError = exports.log = exports.removeFalseyValues = exports.fetchAll = exports.markupFetcher = void 0;
6
+ exports.store = exports.logError = exports.log = exports.removeFalseyValues = exports.fetchAll = exports.markupFetcher = void 0;
7
+ const store_1 = __importDefault(require("./store"));
8
+ exports.store = store_1.default;
4
9
  var markupFetcher_1 = require("./markupFetcher");
5
10
  Object.defineProperty(exports, "markupFetcher", { enumerable: true, get: function () { return markupFetcher_1.markupFetcher; } });
6
11
  Object.defineProperty(exports, "fetchAll", { enumerable: true, get: function () { return markupFetcher_1.fetchAll; } });
@@ -46,6 +46,7 @@ async function fetchAll({ tz = undefined, dateFormat = undefined, domain, apiKey
46
46
  store_1.default.clear();
47
47
  throw error;
48
48
  }
49
+ return store_1.default.store;
49
50
  }
50
51
  function batchMarkupFetcher(platform, fetchImplementation = fetch) {
51
52
  return async ({ tz, copy, domain, apiKey, dateFormat, baseUrl = BASE_URL, environment = (0, utils_1.getEnvironment)(), page = 1, }) => {
package/dist/cjs/store.js CHANGED
@@ -1,30 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- globalThis.jamCommentsStore = null;
3
+ let STORE = null;
4
4
  const store = {
5
5
  init() {
6
- globalThis.jamCommentsStore = new Map();
6
+ if (!STORE) {
7
+ STORE = new Map();
8
+ }
7
9
  },
8
10
  isInitialized() {
9
- return globalThis.jamCommentsStore !== null;
11
+ return STORE !== null;
10
12
  },
11
13
  set(path, markup) {
12
- globalThis.jamCommentsStore.set(store.toPathKey(path), markup);
14
+ STORE.set(store.toPathKey(path), markup);
13
15
  },
14
16
  get(path) {
15
- return globalThis.jamCommentsStore.get(store.toPathKey(path)) || null;
17
+ return STORE.get(store.toPathKey(path)) || null;
16
18
  },
17
19
  clear() {
18
- if (globalThis.jamCommentsStore) {
19
- globalThis.jamCommentsStore.clear();
20
- globalThis.jamCommentsStore = null;
20
+ if (STORE) {
21
+ STORE.clear();
22
+ STORE = null;
21
23
  }
22
24
  },
23
25
  getEmptyMarkup() {
24
- return globalThis.jamCommentsStore.get("EMPTY");
26
+ return STORE.get("EMPTY");
25
27
  },
26
28
  toPathKey(path) {
27
29
  return path.replace(/^\//, "").replace(/\//g, "::");
28
30
  },
31
+ get store() {
32
+ return STORE;
33
+ },
29
34
  };
30
35
  exports.default = store;
package/dist/esm/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ import store from "./store";
1
2
  export { markupFetcher, fetchAll } from "./markupFetcher";
2
3
  export { removeFalseyValues } from "./utils";
3
4
  export { log, logError } from "./log";
5
+ export { store };
@@ -36,6 +36,7 @@ export async function fetchAll({ tz = undefined, dateFormat = undefined, domain,
36
36
  store.clear();
37
37
  throw error;
38
38
  }
39
+ return store.store;
39
40
  }
40
41
  export function batchMarkupFetcher(platform, fetchImplementation = fetch) {
41
42
  return async ({ tz, copy, domain, apiKey, dateFormat, baseUrl = BASE_URL, environment = getEnvironment(), page = 1, }) => {
package/dist/esm/store.js CHANGED
@@ -1,28 +1,33 @@
1
- globalThis.jamCommentsStore = null;
1
+ let STORE = null;
2
2
  const store = {
3
3
  init() {
4
- globalThis.jamCommentsStore = new Map();
4
+ if (!STORE) {
5
+ STORE = new Map();
6
+ }
5
7
  },
6
8
  isInitialized() {
7
- return globalThis.jamCommentsStore !== null;
9
+ return STORE !== null;
8
10
  },
9
11
  set(path, markup) {
10
- globalThis.jamCommentsStore.set(store.toPathKey(path), markup);
12
+ STORE.set(store.toPathKey(path), markup);
11
13
  },
12
14
  get(path) {
13
- return globalThis.jamCommentsStore.get(store.toPathKey(path)) || null;
15
+ return STORE.get(store.toPathKey(path)) || null;
14
16
  },
15
17
  clear() {
16
- if (globalThis.jamCommentsStore) {
17
- globalThis.jamCommentsStore.clear();
18
- globalThis.jamCommentsStore = null;
18
+ if (STORE) {
19
+ STORE.clear();
20
+ STORE = null;
19
21
  }
20
22
  },
21
23
  getEmptyMarkup() {
22
- return globalThis.jamCommentsStore.get("EMPTY");
24
+ return STORE.get("EMPTY");
23
25
  },
24
26
  toPathKey(path) {
25
27
  return path.replace(/^\//, "").replace(/\//g, "::");
26
28
  },
29
+ get store() {
30
+ return STORE;
31
+ },
27
32
  };
28
33
  export default store;
@@ -1,4 +1,6 @@
1
1
  export type { CustomCopy } from "./markupFetcher";
2
+ import store from "./store";
2
3
  export { markupFetcher, fetchAll } from "./markupFetcher";
3
4
  export { removeFalseyValues } from "./utils";
4
5
  export { log, logError } from "./log";
6
+ export { store };
@@ -48,7 +48,7 @@ interface IBatchResponse {
48
48
  total: number;
49
49
  };
50
50
  }
51
- export declare function fetchAll({ tz, dateFormat, domain, apiKey, baseUrl, environment, copy, }: IBatchFetchData, platform: string, fetchImplementation?: any, batchMarkupFetcherImpl?: any): Promise<void>;
51
+ export declare function fetchAll({ tz, dateFormat, domain, apiKey, baseUrl, environment, copy, }: IBatchFetchData, platform: string, fetchImplementation?: any, batchMarkupFetcherImpl?: any): Promise<Map<string, string>>;
52
52
  export declare function batchMarkupFetcher(platform: string, fetchImplementation?: typeof fetch): (args: IBatchFetchData) => Promise<IBatchResponse>;
53
53
  export declare function fetchFreshMarkup({ tz, path, copy, domain, apiKey, dateFormat, baseUrl, environment, }: IFetchData, fetchImplementation: typeof fetch, platform: string): Promise<string>;
54
54
  export declare function makeMarkupRequest<T extends Partial<IBatchFetchData & IFetchData>>({ tz, path, page, domain, apiKey, dateFormat, copy, baseUrl, environment, }: T, baseServicePath: string, fetchImplementation: typeof fetch, platform: string): Promise<Response>;
@@ -6,5 +6,6 @@ declare const store: {
6
6
  clear(): void;
7
7
  getEmptyMarkup(): any;
8
8
  toPathKey(path: string): string;
9
+ readonly store: any;
9
10
  };
10
11
  export default store;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jam-comments/server-utilities",
3
- "version": "5.8.3",
3
+ "version": "5.9.1",
4
4
  "description": "Various JavaScript utilities for JamComments.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",