@inzombieland/nuxt-common 1.16.14 → 1.16.15

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.14",
3
+ "version": "1.16.15",
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.14";
5
+ const version = "1.16.15";
6
6
 
7
7
  const module = defineNuxtModule({
8
8
  meta: {
@@ -1,5 +1,4 @@
1
- import { type User } from "./composables/use-user";
2
- import type { Fetch, FetchConfig, FetchExtraOptions as FetchOptions } from "./types";
1
+ import type { Fetch, FetchConfig, FetchExtraOptions as FetchOptions, User } from "./types";
3
2
  export declare const setUser: (newUser?: User | null) => void;
4
3
  export declare const updateUser: (newUser: Partial<User>) => void;
5
4
  export declare const getToken: () => string | null | undefined;
@@ -1,5 +1,4 @@
1
1
  import bus from "./bus.mjs";
2
- import { newCometClient } from "./comet-client.mjs";
3
2
  import { useApiActions } from "./composables/use-api-actions.mjs";
4
3
  import { useUser } from "./composables/use-user.mjs";
5
4
  import { getVisitor } from "./get-visitor.mjs";
@@ -127,21 +126,5 @@ const fetchRequest = (url, options = {}, fetch, config) => {
127
126
  return request();
128
127
  };
129
128
  export const createApiFetch = once((fetch, config) => {
130
- if (typeof window !== "undefined") {
131
- const cometServerURL = config.cometServerURL;
132
- let cometClient;
133
- bus.subscribe("user:onUpdated", (user) => {
134
- if (user) {
135
- cometClient || (cometClient = newCometClient(user, cometServerURL));
136
- if (!cometClient.isStarted) {
137
- cometClient.start();
138
- cometClient.isStarted = true;
139
- }
140
- } else if (cometClient) {
141
- cometClient.stop();
142
- cometClient.isStarted = false;
143
- }
144
- });
145
- }
146
129
  return (url, options) => fetchRequest(url, options, fetch, config);
147
130
  });
@@ -1,4 +1,4 @@
1
- import type { User } from "./composables/use-user";
1
+ import type { User } from "./types";
2
2
  declare global {
3
3
  interface Window {
4
4
  wsPublish: (eventName: string, data: unknown) => void;
@@ -1,19 +1,4 @@
1
- export declare type User = {
2
- id: string;
3
- firstName: string;
4
- lastName: string;
5
- middleName: string;
6
- email: string;
7
- emailVerified: boolean;
8
- phone: string;
9
- phoneVerified: boolean;
10
- gender: "" | "male" | "female";
11
- birthday: Date;
12
- passwordLastSet: Date;
13
- theme: "light" | "dark";
14
- locale: string;
15
- avatar: string;
16
- };
1
+ import type { User } from "../types";
17
2
  export declare function useUser(): import("vue").Ref<{
18
3
  id: string;
19
4
  firstName: string;
@@ -1,6 +1,6 @@
1
- import type { ActiveSession, Fetch, FetchConfig } from "./types";
2
- export type { ActiveSession, Fetch, FetchConfig };
3
- export { useUser, type User } from "./composables/use-user";
1
+ import type { ActiveSession, Fetch, FetchConfig, User } from "./types";
2
+ export type { ActiveSession, Fetch, FetchConfig, User };
3
+ export { useUser } from "./composables/use-user";
4
4
  export { useSubscribe } from "./composables/use-subscribe";
5
5
  export { getVisitor, getVisitorId, type Visitor } from "./get-visitor";
6
6
  export declare function initApiFetch($fetch: Fetch, config: FetchConfig): {
@@ -1,4 +1,6 @@
1
1
  import { createApiFetch } from "./api-client.mjs";
2
+ import bus from "./bus.mjs";
3
+ import { newCometClient } from "./comet-client.mjs";
2
4
  import { useApiActions } from "./composables/use-api-actions.mjs";
3
5
  import { createApiGetUser } from "./get-user.mjs";
4
6
  import { createApiGetVisitorIdentifier } from "./get-visitor.mjs";
@@ -20,5 +22,21 @@ export function initApiFetch($fetch, config) {
20
22
  getVisitorIdentifier,
21
23
  refreshToken
22
24
  };
25
+ if (typeof window !== "undefined") {
26
+ const cometServerURL = config.cometServerURL;
27
+ let cometClient;
28
+ bus.subscribe("user:onUpdated", (user) => {
29
+ if (user) {
30
+ cometClient || (cometClient = newCometClient(user, cometServerURL));
31
+ if (!cometClient.isStarted) {
32
+ cometClient.start();
33
+ cometClient.isStarted = true;
34
+ }
35
+ } else if (cometClient) {
36
+ cometClient.stop();
37
+ cometClient.isStarted = false;
38
+ }
39
+ });
40
+ }
23
41
  return { fetch, getUser, getVisitorIdentifier, useApiFetch, userActions };
24
42
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/api",
3
- "version": "1.16.14",
3
+ "version": "1.16.15",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "main": "./index.mjs",
@@ -1,4 +1,3 @@
1
- import type { User } from "./composables/use-user";
2
1
  import type { FetchOptions, FetchRequest, FetchResponse } from "ofetch";
3
2
  import type { ZodError } from "zod";
4
3
  export type FetchExtraOptions = FetchOptions & {
@@ -41,6 +40,22 @@ export type GetUserResponse = {
41
40
  token?: string | null;
42
41
  user?: User | null;
43
42
  };
43
+ export type User = {
44
+ id: string;
45
+ firstName: string;
46
+ lastName: string;
47
+ middleName: string;
48
+ email: string;
49
+ emailVerified: boolean;
50
+ phone: string;
51
+ phoneVerified: boolean;
52
+ gender: "" | "male" | "female";
53
+ birthday: Date;
54
+ passwordLastSet: Date;
55
+ theme: "light" | "dark";
56
+ locale: string;
57
+ avatar: string;
58
+ };
44
59
  export type ActiveSession = {
45
60
  id: string;
46
61
  visitorId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/nuxt-common",
3
- "version": "1.16.14",
3
+ "version": "1.16.15",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "exports": {