@inzombieland/nuxt-common 1.16.27 → 1.16.28

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.16.27",
3
+ "version": "1.16.28",
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.16.27";
5
+ const version = "1.16.28";
6
6
 
7
7
  const module = defineNuxtModule({
8
8
  meta: {
@@ -54,7 +54,7 @@ const module = defineNuxtModule({
54
54
  addPlugin(resolve(runtimeDir, "plugins/sanitize-url"));
55
55
  addComponent({
56
56
  name: "NuxtAppProvider",
57
- filePath: resolve(runtimeDir, "AppProvider.vue")
57
+ filePath: resolve(runtimeDir, "packages/api/AppProvider.vue")
58
58
  });
59
59
  addComponent({
60
60
  name: "NuxtLayerManager",
@@ -121,7 +121,7 @@ export const changeTheme = async (body) => {
121
121
  updateUser(body);
122
122
  }
123
123
  if (typeof window !== "undefined") {
124
- const theme = useLocalStorage("app-preferences-theme", JSON.stringify({ value: "" }));
124
+ const theme = useLocalStorage("app-preferences-theme", "");
125
125
  theme.value = JSON.stringify({ value: body.theme });
126
126
  }
127
127
  };
@@ -1,18 +1,16 @@
1
1
  <script setup lang="ts">
2
2
  import { StyleProvider, Themes } from "@varlet/ui"
3
3
  import { useLocalStorage } from "@vueuse/core"
4
- import { useNuxtApp } from "#imports"
5
4
  import { onMounted, ref, watch } from "vue"
6
- import { useUser } from "./packages/api"
7
- import bus from "./packages/api/bus"
5
+ import bus from "./bus"
6
+ import { useUser } from "./index"
8
7
  import type { ConfigProviderTheme } from "vant"
9
8
  import "@vant/touch-emulator"
10
9
 
11
10
  const theme = ref("")
12
- const appPreferencesTheme = useLocalStorage("app-preferences-theme", JSON.stringify({ value: "" }))
11
+ const appPreferencesTheme = useLocalStorage("app-preferences-theme", "")
13
12
  const user = useUser()
14
13
  const appLoading = ref(Boolean(user.value))
15
- const { $mobileApp } = useNuxtApp()
16
14
 
17
15
  onMounted(() => {
18
16
  watch(
@@ -41,10 +39,6 @@ onMounted(() => {
41
39
  document.documentElement.classList.add("light", "van-theme-light")
42
40
  StyleProvider(null)
43
41
  }
44
-
45
- if ($mobileApp?.changeTheme && typeof $mobileApp.changeTheme === "function") {
46
- $mobileApp.changeTheme({ theme: theme.value })
47
- }
48
42
  },
49
43
  { immediate: true }
50
44
  )
@@ -1,6 +1,7 @@
1
1
  import { type Ref } from "vue";
2
2
  import type { ActiveSession, Fetch, FetchConfig, User } from "./types";
3
3
  export type { ActiveSession, Fetch, FetchConfig, User };
4
+ export { default as AppProvider } from "./AppProvider.vue";
4
5
  export { useUser } from "./composables/use-user";
5
6
  export { useSubscribe } from "./composables/use-subscribe";
6
7
  export { useActiveSessions } from "./composables/use-active-sessions";
@@ -9,6 +9,7 @@ import { createApiGetVisitorIdentifier } from "./get-visitor.mjs";
9
9
  import { createInitApplication } from "./init-application.mjs";
10
10
  import { createApiRefreshToken } from "./refresh-token.mjs";
11
11
  import { createApiUserActions } from "./user-actions.mjs";
12
+ export { default as AppProvider } from "./AppProvider.vue";
12
13
  export { useUser } from "./composables/use-user.mjs";
13
14
  export { useSubscribe } from "./composables/use-subscribe.mjs";
14
15
  export { useActiveSessions } from "./composables/use-active-sessions.mjs";
@@ -14,16 +14,18 @@ import { getVisitorId, useUserActions } from "./index.mjs";
14
14
  function initApplication() {
15
15
  const router = useRouter();
16
16
  const user = useUser();
17
- const theme = useLocalStorage("app-preferences-theme", JSON.stringify({ value: "" }));
17
+ const theme = useLocalStorage("app-preferences-theme", "");
18
18
  const locale = useLocalStorage("app-preferences-locale", JSON.stringify({ value: "en" }));
19
19
  const i18n = useI18n();
20
20
  watch(
21
21
  user,
22
22
  (user2) => {
23
23
  try {
24
- const { value } = JSON.parse(theme.value);
25
- if (user2 && user2.theme !== value) {
26
- theme.value = JSON.stringify({ value: user2.theme });
24
+ if (theme.value) {
25
+ const { value } = JSON.parse(theme.value);
26
+ if (user2 && user2.theme !== value) {
27
+ theme.value = JSON.stringify({ value: user2.theme });
28
+ }
27
29
  }
28
30
  } catch (error) {
29
31
  console.error(`Error parsing app preferences theme:`, error);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/api",
3
- "version": "1.16.27",
3
+ "version": "1.16.28",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "main": "./index.mjs",
@@ -1,5 +1,7 @@
1
+ import { useLocalStorage } from "@vueuse/core";
1
2
  import { addRouteMiddleware, defineNuxtPlugin } from "#app";
2
- import { useRequestHeaders, useRuntimeConfig, useState } from "#imports";
3
+ import { useNuxtApp, useRequestHeaders, useRuntimeConfig, useState } from "#imports";
4
+ import { watch } from "vue";
3
5
  import { fetch, getUser } from "./api/index.mjs";
4
6
  import { authMiddleware, guestMiddleware, localeMiddleware } from "./middleware/index.mjs";
5
7
  import { flush, setToken, setUser } from "./packages/api/api-client.mjs";
@@ -9,6 +11,8 @@ const useAuth = () => {
9
11
  export default defineNuxtPlugin(async (nuxtApp) => {
10
12
  const auth = useAuth();
11
13
  const runtimeConfig = useRuntimeConfig();
14
+ const { $mobileApp } = useNuxtApp();
15
+ const theme = useLocalStorage("app-preferences-theme", "");
12
16
  if (runtimeConfig.public.ssr && import.meta.server || !runtimeConfig.public.ssr) {
13
17
  flush();
14
18
  if (import.meta.server) {
@@ -26,6 +30,22 @@ export default defineNuxtPlugin(async (nuxtApp) => {
26
30
  }
27
31
  nuxtApp.hook("app:beforeMount", () => {
28
32
  auth.value = null;
33
+ watch(
34
+ theme,
35
+ (theme2) => {
36
+ try {
37
+ if (theme2) {
38
+ const { value } = JSON.parse(theme2);
39
+ if ($mobileApp && "changeTheme" in $mobileApp && typeof $mobileApp.changeTheme === "function") {
40
+ $mobileApp.changeTheme({ theme: value });
41
+ }
42
+ }
43
+ } catch (error) {
44
+ console.error(`Error parsing app preferences theme:`, error);
45
+ }
46
+ },
47
+ { immediate: true }
48
+ );
29
49
  });
30
50
  addRouteMiddleware("auth", authMiddleware, { global: false });
31
51
  addRouteMiddleware("guest", guestMiddleware, { global: false });
@@ -9,7 +9,7 @@ export default defineNuxtPlugin(() => {
9
9
  ...device,
10
10
  getInfo: async () => {
11
11
  const { $mobileApp } = useNuxtApp();
12
- if (device.isMobileApp && $mobileApp && typeof $mobileApp.getInfo === "function") {
12
+ if (device.isMobileApp && $mobileApp && "getInfo" in $mobileApp && typeof $mobileApp.getInfo === "function") {
13
13
  const device2 = await $mobileApp.getInfo();
14
14
  return device2.name;
15
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/nuxt-common",
3
- "version": "1.16.27",
3
+ "version": "1.16.28",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "exports": {