@inzombieland/nuxt-common 1.18.15 → 1.18.16
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 +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/packages/core/api-client.mjs +4 -1
- package/dist/runtime/packages/core/composables/use-api-actions.d.ts +0 -3
- package/dist/runtime/packages/core/composables/use-api-actions.mjs +1 -1
- package/dist/runtime/packages/core/get-user.mjs +0 -1
- package/dist/runtime/packages/core/get-visitor.mjs +1 -1
- package/dist/runtime/packages/core/index.mjs +3 -6
- package/dist/runtime/packages/core/package.json +1 -1
- package/package.json +1 -1
package/dist/module.json
CHANGED
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.18.
|
|
5
|
+
const version = "1.18.16";
|
|
6
6
|
|
|
7
7
|
const module = defineNuxtModule({
|
|
8
8
|
meta: {
|
|
@@ -109,6 +109,10 @@ const optionsHandler = (options = {}, config) => {
|
|
|
109
109
|
};
|
|
110
110
|
const fetchRequest = (url, options = {}, fetch, config) => {
|
|
111
111
|
const request = async () => {
|
|
112
|
+
const apiActions = useApiActions();
|
|
113
|
+
if (typeof window !== "undefined") {
|
|
114
|
+
await apiActions.value?.getVisitorIdentifier?.();
|
|
115
|
+
}
|
|
112
116
|
const opts = optionsHandler(options, config);
|
|
113
117
|
try {
|
|
114
118
|
const response = await fetch.raw(url, opts);
|
|
@@ -116,7 +120,6 @@ const fetchRequest = (url, options = {}, fetch, config) => {
|
|
|
116
120
|
} catch (error) {
|
|
117
121
|
const { status } = error?.response ?? { status: 500 };
|
|
118
122
|
if (status === 401 && url !== "/account/1/offline") {
|
|
119
|
-
const apiActions = useApiActions();
|
|
120
123
|
await apiActions.value?.refreshToken?.();
|
|
121
124
|
return request();
|
|
122
125
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
export declare const useApiActions: () => import("vue").Ref<{
|
|
2
|
-
initialized: boolean;
|
|
3
2
|
getVisitorIdentifier?: (() => Promise<void>) | undefined;
|
|
4
3
|
refreshToken?: (() => Promise<string>) | undefined;
|
|
5
4
|
}, {
|
|
6
|
-
initialized: boolean;
|
|
7
5
|
getVisitorIdentifier?: () => Promise<void>;
|
|
8
6
|
refreshToken?: () => Promise<string>;
|
|
9
7
|
} | {
|
|
10
|
-
initialized: boolean;
|
|
11
8
|
getVisitorIdentifier?: (() => Promise<void>) | undefined;
|
|
12
9
|
refreshToken?: (() => Promise<string>) | undefined;
|
|
13
10
|
}>;
|
|
@@ -22,11 +22,7 @@ export function initApiFetch($fetch, config) {
|
|
|
22
22
|
const initApplication = createInitApplication();
|
|
23
23
|
const refreshToken = createApiRefreshToken(fetch, config);
|
|
24
24
|
userActions = ref(createApiUserActions(fetch, config, getUser));
|
|
25
|
-
apiActions.value = {
|
|
26
|
-
initialized: true,
|
|
27
|
-
getVisitorIdentifier,
|
|
28
|
-
refreshToken
|
|
29
|
-
};
|
|
25
|
+
apiActions.value = { getVisitorIdentifier, refreshToken };
|
|
30
26
|
if (typeof window !== "undefined") {
|
|
31
27
|
const loggedIn = useLocalStorage("lin", "no");
|
|
32
28
|
const cometServerURL = config.cometServerURL;
|
|
@@ -45,7 +41,8 @@ export function initApiFetch($fetch, config) {
|
|
|
45
41
|
}
|
|
46
42
|
loggedIn.value = user ? "yes" : "no";
|
|
47
43
|
});
|
|
48
|
-
bus.subscribe("app:beforeMount", () => {
|
|
44
|
+
const subscription = bus.subscribe("app:beforeMount", () => {
|
|
45
|
+
subscription.unsubscribe();
|
|
49
46
|
console.log("Service started in mode", import.meta.env.MODE);
|
|
50
47
|
getVisitorIdentifier();
|
|
51
48
|
initApplication();
|