@inzombieland/nuxt-common 1.17.0 → 1.17.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/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/nuxt-common",
3
- "version": "1.17.0",
3
+ "version": "1.17.1",
4
4
  "configKey": "nuxt-common",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.6.0",
package/dist/module.mjs CHANGED
@@ -2,7 +2,7 @@ import { fileURLToPath } from 'node:url';
2
2
  import { defineNuxtModule, createResolver, addServerHandler, addImportsDir, addPlugin, addComponent } from '@nuxt/kit';
3
3
 
4
4
  const name = "@inzombieland/nuxt-common";
5
- const version = "1.17.0";
5
+ const version = "1.17.1";
6
6
 
7
7
  const module = defineNuxtModule({
8
8
  meta: {
@@ -7,5 +7,5 @@ export declare type Visitor = {
7
7
  };
8
8
  export declare const getVisitorId: () => string | undefined;
9
9
  export declare const getVisitor: () => Visitor | null;
10
- export declare const getVisitorIdentifier: (config: FetchConfig) => Promise<void>;
10
+ export declare const getVisitorRequest: (config: FetchConfig) => Promise<void>;
11
11
  export declare const createApiGetVisitorIdentifier: (config: FetchConfig) => () => Promise<void>;
@@ -11,7 +11,23 @@ export const getVisitor = () => {
11
11
  const setVisitor = (newVisitor) => {
12
12
  visitor = !visitor ? newVisitor : { ...visitor, ...newVisitor };
13
13
  };
14
- export const getVisitorIdentifier = async (config) => {
14
+ let gettingInProgress = false;
15
+ let gettingPromise = null;
16
+ function getVisitorIdentifier(config) {
17
+ if (gettingInProgress && gettingPromise) {
18
+ return gettingPromise;
19
+ }
20
+ return gettingVisitorStart(config);
21
+ }
22
+ function gettingVisitorStart(config) {
23
+ gettingInProgress = true;
24
+ gettingPromise = getVisitorRequest(config).finally(() => {
25
+ gettingInProgress = false;
26
+ gettingPromise = null;
27
+ });
28
+ return gettingPromise;
29
+ }
30
+ export const getVisitorRequest = async (config) => {
15
31
  if (typeof window === "undefined" || visitor) {
16
32
  return;
17
33
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/api",
3
- "version": "1.17.0",
3
+ "version": "1.17.1",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "main": "./index.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/nuxt-common",
3
- "version": "1.17.0",
3
+ "version": "1.17.1",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "exports": {