@inzombieland/nuxt-common 1.18.12 → 1.18.14

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.14",
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.14";
6
6
 
7
7
  const module = defineNuxtModule({
8
8
  meta: {
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
- import { onMounted, ref } from "vue"
3
- import { bus } from "./api-client"
2
+ import { onBeforeMount, onMounted, ref } from "vue"
3
+ import bus from "./bus"
4
4
  import { useThemeMode, useUser } from "./index"
5
5
  import type { ConfigProviderTheme } from "vant"
6
6
  import "@vant/touch-emulator"
@@ -9,12 +9,18 @@ const theme = useThemeMode()
9
9
  const user = useUser()
10
10
  const appLoading = ref(Boolean(user.value))
11
11
 
12
+ onBeforeMount(() => {
13
+ bus.publish("app:beforeMount", true)
14
+ })
15
+
12
16
  onMounted(() => {
13
17
  appLoading.value = false
14
18
  })
19
+ </script>
15
20
 
16
- if (typeof window !== "undefined") {
17
- bus.publish("app:mounted", true)
21
+ <script lang="ts">
22
+ export const useBus = () => {
23
+ return bus
18
24
  }
19
25
  </script>
20
26
 
@@ -1,6 +1,4 @@
1
- import bus from "./bus";
2
1
  import type { Fetch, FetchConfig, FetchExtraOptions as FetchOptions, User } from "./types";
3
- export { bus };
4
2
  export declare const setUser: (newUser?: User | null) => void;
5
3
  export declare const updateUser: (newUser: Partial<User>) => void;
6
4
  export declare const getToken: () => string | null | undefined;
@@ -1,11 +1,11 @@
1
- import bus from "./bus.mjs";
2
1
  import { useApiActions, useUser, useVisitor } from "./composables/index.mjs";
3
2
  import { apiHelper, once } from "./helpers/index.mjs";
4
- export { bus };
3
+ import { useBus } from "./index.mjs";
5
4
  let token = null;
6
5
  export const setUser = (newUser) => {
7
6
  const user = useUser();
8
7
  user.value = newUser;
8
+ const bus = useBus();
9
9
  bus.publish("user:onUpdated", user.value);
10
10
  };
11
11
  export const updateUser = (newUser) => {
@@ -26,6 +26,7 @@ export const flush = () => {
26
26
  };
27
27
  const eventHandler = (requestID, eventName) => {
28
28
  return new Promise((resolve, reject) => {
29
+ const bus = useBus();
29
30
  const subscription = bus.subscribe(eventName, (data) => {
30
31
  if (requestID !== data?.requestID) {
31
32
  return;
@@ -1,9 +1,11 @@
1
1
  import { Centrifuge } from "centrifuge";
2
- import { bus, getToken } from "./api-client.mjs";
2
+ import { getToken } from "./api-client.mjs";
3
3
  import { useApiActions } from "./composables/index.mjs";
4
4
  import { apiHelper } from "./helpers/index.mjs";
5
+ import { useBus } from "./index.mjs";
5
6
  if (typeof window !== "undefined" && import.meta.env.MODE !== "production") {
6
7
  window.wsPublish = (eventName, data) => {
8
+ const bus = useBus();
7
9
  setTimeout(() => bus.publish(`WS.${eventName}`, data), 0);
8
10
  };
9
11
  }
@@ -31,6 +33,7 @@ export function newCometClient(user, cometServerURL) {
31
33
  }
32
34
  });
33
35
  const publish = (eventName, data) => () => {
36
+ const bus = useBus();
34
37
  bus.publish(`WS.${eventName}`, apiHelper.convertToClient(data));
35
38
  };
36
39
  let userSubscription;
@@ -1,4 +1,4 @@
1
- import { type Subscription } from "../bus";
1
+ import type { Subscription } from "rxjs";
2
2
  export declare const useSubscribe: <T>(eventName: string, func: (data: T) => void, options?: {
3
3
  once?: boolean;
4
4
  unsubscribeOnUnmount?: boolean;
@@ -1,6 +1,7 @@
1
1
  import { onMounted, onUnmounted } from "vue";
2
- import bus from "../bus.mjs";
2
+ import { useBus } from "../index.mjs";
3
3
  export const useSubscribe = (eventName, func, options = { once: false, unsubscribeOnUnmount: true }) => {
4
+ const bus = useBus();
4
5
  let subscription;
5
6
  onMounted(() => {
6
7
  subscription = bus.subscribe(eventName, (data) => {
@@ -1,7 +1,7 @@
1
1
  import { type Ref } from "vue";
2
2
  import type { Fetch, FetchConfig } from "./types";
3
3
  export { defineVuePlugins } from "./define-vue-plugins";
4
- export { default as AppProvider } from "./AppProvider.vue";
4
+ export { default as AppProvider, useBus } from "./AppProvider.vue";
5
5
  export * from "./composables";
6
6
  export * from "./types";
7
7
  export declare function initApiFetch($fetch: Fetch, config: FetchConfig): {
@@ -1,6 +1,7 @@
1
1
  import { useLocalStorage } from "@vueuse/core";
2
2
  import { ref } from "vue";
3
- import { bus, createApiFetch } from "./api-client.mjs";
3
+ import { createApiFetch } from "./api-client.mjs";
4
+ import { useBus } from "./AppProvider.vue";
4
5
  import { newCometClient } from "./comet-client.mjs";
5
6
  import { useApiActions } from "./composables/index.mjs";
6
7
  import { createApiGetUser } from "./get-user.mjs";
@@ -9,7 +10,7 @@ import { createInitApplication } from "./init-application.mjs";
9
10
  import { createApiRefreshToken } from "./refresh-token.mjs";
10
11
  import { createApiUserActions } from "./user-actions.mjs";
11
12
  export { defineVuePlugins } from "./define-vue-plugins.mjs";
12
- export { default as AppProvider } from "./AppProvider.vue";
13
+ export { default as AppProvider, useBus } from "./AppProvider.vue";
13
14
  export * from "./composables/index.mjs";
14
15
  export * from "./types.mjs";
15
16
  const apiActions = useApiActions();
@@ -30,6 +31,7 @@ export function initApiFetch($fetch, config) {
30
31
  const loggedIn = useLocalStorage("lin", "no");
31
32
  const cometServerURL = config.cometServerURL;
32
33
  let cometClient;
34
+ const bus = useBus();
33
35
  bus.subscribe("user:onUpdated", (user) => {
34
36
  if (user) {
35
37
  cometClient || (cometClient = newCometClient(user, cometServerURL));
@@ -43,7 +45,8 @@ export function initApiFetch($fetch, config) {
43
45
  }
44
46
  loggedIn.value = user ? "yes" : "no";
45
47
  });
46
- bus.subscribe("app:mounted", () => {
48
+ bus.subscribe("app:beforeMount", () => {
49
+ console.log("Service started in mode", import.meta.env.MODE);
47
50
  getVisitorIdentifier();
48
51
  initApplication();
49
52
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/core",
3
- "version": "1.18.12",
3
+ "version": "1.18.14",
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.14",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "exports": {