@inzombieland/nuxt-common 1.18.12 → 1.18.13

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.18.12",
3
+ "version": "1.18.13",
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.18.12";
5
+ const version = "1.18.13";
6
6
 
7
7
  const module = defineNuxtModule({
8
8
  meta: {
@@ -1,6 +1,7 @@
1
1
  import bus from "./bus.mjs";
2
- import { useApiActions, useUser, useVisitor } from "./composables/index.mjs";
2
+ import { useUser, useVisitor } from "./composables/index.mjs";
3
3
  import { apiHelper, once } from "./helpers/index.mjs";
4
+ import { useApiActions } from "./index.mjs";
4
5
  export { bus };
5
6
  let token = null;
6
7
  export const setUser = (newUser) => {
@@ -116,7 +117,7 @@ const fetchRequest = (url, options = {}, fetch, config) => {
116
117
  const { status } = error?.response ?? { status: 500 };
117
118
  if (status === 401 && url !== "/account/1/offline") {
118
119
  const apiActions = useApiActions();
119
- await apiActions.value?.refreshToken?.();
120
+ await apiActions?.value?.refreshToken?.();
120
121
  return request();
121
122
  }
122
123
  throw errorHandler(error);
@@ -1,7 +1,7 @@
1
1
  import { Centrifuge } from "centrifuge";
2
2
  import { bus, getToken } from "./api-client.mjs";
3
- import { useApiActions } from "./composables/index.mjs";
4
3
  import { apiHelper } from "./helpers/index.mjs";
4
+ import { useApiActions } from "./index.mjs";
5
5
  if (typeof window !== "undefined" && import.meta.env.MODE !== "production") {
6
6
  window.wsPublish = (eventName, data) => {
7
7
  setTimeout(() => bus.publish(`WS.${eventName}`, data), 0);
@@ -27,7 +27,7 @@ export function newCometClient(user, cometServerURL) {
27
27
  debug: import.meta.env.MODE !== "production",
28
28
  getToken: async () => {
29
29
  const apiActions = useApiActions();
30
- return await apiActions.value?.refreshToken?.() ?? "";
30
+ return await apiActions?.value?.refreshToken?.() ?? "";
31
31
  }
32
32
  });
33
33
  const publish = (eventName, data) => () => {
@@ -1,6 +1,5 @@
1
1
  export * from "../helpers/composables";
2
2
  export { useActiveSessions } from "./use-active-sessions";
3
- export { useApiActions } from "./use-api-actions";
4
3
  export { useAppLocale } from "./use-app-locale";
5
4
  export { useSubscribe } from "./use-subscribe";
6
5
  export { useThemeMode } from "./use-theme-mode";
@@ -1,6 +1,5 @@
1
1
  export * from "../helpers/composables.mjs";
2
2
  export { useActiveSessions } from "./use-active-sessions.mjs";
3
- export { useApiActions } from "./use-api-actions.mjs";
4
3
  export { useAppLocale } from "./use-app-locale.mjs";
5
4
  export { useSubscribe } from "./use-subscribe.mjs";
6
5
  export { useThemeMode } from "./use-theme-mode.mjs";
@@ -1,7 +1,8 @@
1
1
  import { useLocalStorage } from "@vueuse/core";
2
2
  import { flush, getToken, setUser } from "./api-client.mjs";
3
- import { useApiActions, useUser } from "./composables/index.mjs";
3
+ import { useUser } from "./composables/index.mjs";
4
4
  import { createSingletonAsync, once } from "./helpers/index.mjs";
5
+ import { useApiActions } from "./index.mjs";
5
6
  async function getUserRequest(fetch, config) {
6
7
  const token = getToken();
7
8
  const user = useUser();
@@ -16,8 +17,8 @@ async function getUserRequest(fetch, config) {
16
17
  }
17
18
  try {
18
19
  const apiActions = useApiActions();
19
- await apiActions.value?.getVisitorIdentifier?.();
20
- await apiActions.value?.refreshToken?.();
20
+ await apiActions?.value?.getVisitorIdentifier?.();
21
+ await apiActions?.value?.refreshToken?.();
21
22
  } catch {
22
23
  flush();
23
24
  return { token: null, user: null };
@@ -4,6 +4,10 @@ export { defineVuePlugins } from "./define-vue-plugins";
4
4
  export { default as AppProvider } from "./AppProvider.vue";
5
5
  export * from "./composables";
6
6
  export * from "./types";
7
+ type ApiActions = {
8
+ getVisitorIdentifier?: () => Promise<void>;
9
+ refreshToken?: () => Promise<string>;
10
+ };
7
11
  export declare function initApiFetch($fetch: Fetch, config: FetchConfig): {
8
12
  fetch: Fetch;
9
13
  getUser: () => Promise<import("./types").GetUserResponse>;
@@ -65,3 +69,4 @@ export declare const useUserActions: () => Ref<{
65
69
  locale: string;
66
70
  }) => Promise<void>;
67
71
  }> | undefined;
72
+ export declare const useApiActions: () => Ref<ApiActions, ApiActions> | undefined;
@@ -2,7 +2,6 @@ import { useLocalStorage } from "@vueuse/core";
2
2
  import { ref } from "vue";
3
3
  import { bus, createApiFetch } from "./api-client.mjs";
4
4
  import { newCometClient } from "./comet-client.mjs";
5
- import { useApiActions } from "./composables/index.mjs";
6
5
  import { createApiGetUser } from "./get-user.mjs";
7
6
  import { createApiGetVisitorIdentifier } from "./get-visitor.mjs";
8
7
  import { createInitApplication } from "./init-application.mjs";
@@ -12,8 +11,8 @@ export { defineVuePlugins } from "./define-vue-plugins.mjs";
12
11
  export { default as AppProvider } from "./AppProvider.vue";
13
12
  export * from "./composables/index.mjs";
14
13
  export * from "./types.mjs";
15
- const apiActions = useApiActions();
16
14
  let userActions;
15
+ let apiActions;
17
16
  export function initApiFetch($fetch, config) {
18
17
  const fetch = createApiFetch($fetch, config);
19
18
  const getUser = createApiGetUser(fetch, config);
@@ -21,11 +20,7 @@ export function initApiFetch($fetch, config) {
21
20
  const initApplication = createInitApplication();
22
21
  const refreshToken = createApiRefreshToken(fetch, config);
23
22
  userActions = ref(createApiUserActions(fetch, config, getUser));
24
- apiActions.value = {
25
- initialized: true,
26
- getVisitorIdentifier,
27
- refreshToken
28
- };
23
+ apiActions = ref({ getVisitorIdentifier, refreshToken });
29
24
  if (typeof window !== "undefined") {
30
25
  const loggedIn = useLocalStorage("lin", "no");
31
26
  const cometServerURL = config.cometServerURL;
@@ -54,3 +49,6 @@ export function initApiFetch($fetch, config) {
54
49
  export const useUserActions = () => {
55
50
  return userActions;
56
51
  };
52
+ export const useApiActions = () => {
53
+ return apiActions;
54
+ };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/core",
3
- "version": "1.18.12",
3
+ "version": "1.18.13",
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.18.12",
3
+ "version": "1.18.13",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,13 +0,0 @@
1
- export declare const useApiActions: () => import("vue").Ref<{
2
- initialized: boolean;
3
- getVisitorIdentifier?: (() => Promise<void>) | undefined;
4
- refreshToken?: (() => Promise<string>) | undefined;
5
- }, {
6
- initialized: boolean;
7
- getVisitorIdentifier?: () => Promise<void>;
8
- refreshToken?: () => Promise<string>;
9
- } | {
10
- initialized: boolean;
11
- getVisitorIdentifier?: (() => Promise<void>) | undefined;
12
- refreshToken?: (() => Promise<string>) | undefined;
13
- }>;
@@ -1,5 +0,0 @@
1
- import { ref } from "vue";
2
- const apiActions = ref({ initialized: false });
3
- export const useApiActions = () => {
4
- return apiActions;
5
- };