@inzombieland/nuxt-common 1.16.5 → 1.16.6

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.5",
3
+ "version": "1.16.6",
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.5";
5
+ const version = "1.16.6";
6
6
 
7
7
  const module = defineNuxtModule({
8
8
  meta: {
@@ -2,13 +2,13 @@ import { type Fetch } from "../packages/api";
2
2
  export { type ActiveSession, type Fetch, type User, type Visitor } from "../packages/api";
3
3
  export { getVisitor, getVisitorId, useUser } from "../packages/api";
4
4
  export declare const config: {
5
- getApiBaseURL: () => string;
6
- getCometServerURL: () => string;
7
- getAppClientID: () => string;
8
- getAppClientSecret: () => string;
9
- getIsMobileApp: () => boolean;
10
- getIsDesktopApp: () => boolean;
11
- getAppName: () => string;
5
+ apiBaseURL: string;
6
+ cometServerURL: string;
7
+ appClientID: string;
8
+ appClientSecret: string;
9
+ isMobileApp: boolean;
10
+ isDesktopApp: boolean;
11
+ appName: string;
12
12
  getHostname: () => string;
13
13
  getDevice: () => Promise<any>;
14
14
  useRequestHeaders: (include?: string[]) => {
@@ -1,14 +1,15 @@
1
- import { useNuxtApp, useRequestHeaders, useRequestURL, useRuntimeConfig } from "#imports";
1
+ import { useNuxtApp, useRequestHeaders, useRequestURL } from "#imports";
2
2
  import { initApiFetch } from "../packages/api/index.mjs";
3
3
  export { getVisitor, getVisitorId, useUser } from "../packages/api/index.mjs";
4
+ const getBoolean = (value) => value === "true";
4
5
  export const config = {
5
- getApiBaseURL: () => String(useRuntimeConfig().public.apiBaseURL),
6
- getCometServerURL: () => String(useRuntimeConfig().public.cometServer),
7
- getAppClientID: () => String(useRuntimeConfig().public.appClientID),
8
- getAppClientSecret: () => String(useRuntimeConfig().public.appClientSecret),
9
- getIsMobileApp: () => useRuntimeConfig().public.isMobileApp === true,
10
- getIsDesktopApp: () => useRuntimeConfig().public.isDesktopApp === true,
11
- getAppName: () => String(useRuntimeConfig().public.appName),
6
+ apiBaseURL: String(import.meta.env.VITE_API_BASE_URL),
7
+ cometServerURL: String(import.meta.env.VITE_COMET_SERVER_URL),
8
+ appClientID: String(import.meta.env.VITE_APP_CLIENT_ID),
9
+ appClientSecret: String(import.meta.env.VITE_APP_CLIENT_SECRET),
10
+ isMobileApp: getBoolean(import.meta.env.VITE_IS_MOBILE_APP),
11
+ isDesktopApp: getBoolean(import.meta.env.VITE_IS_DESKTOP_APP),
12
+ appName: String(import.meta.env.VITE_APP_NAME),
12
13
  getHostname: () => useRequestURL().hostname,
13
14
  getDevice: async () => {
14
15
  const { $device } = useNuxtApp();
@@ -72,22 +72,22 @@ const errorHandler = (error) => {
72
72
  return new Error(message);
73
73
  };
74
74
  const optionsHandler = (options = {}, config) => {
75
- const { getApiBaseURL, getAppClientID, getAppClientSecret, getIsMobileApp, getIsDesktopApp, getHostname } = config;
75
+ const { apiBaseURL, appClientID, appClientSecret, isMobileApp, isDesktopApp, getHostname } = config;
76
76
  const baseURL = "/api";
77
77
  const headers = {};
78
78
  const visitor = { platform: "web", hostname: getHostname() };
79
79
  if (token) {
80
80
  headers.authorization = `JWT ${token}`;
81
- } else if (typeof window !== "undefined" && getAppClientID() && getAppClientSecret()) {
82
- const credentials = btoa(`${getAppClientID()}:${getAppClientSecret()}`);
81
+ } else if (typeof window !== "undefined" && appClientID && appClientSecret) {
82
+ const credentials = btoa(`${appClientID}:${appClientSecret}`);
83
83
  headers.authorization = `Basic ${credentials}`;
84
84
  }
85
- if (getIsMobileApp()) {
86
- options.baseURL = getApiBaseURL();
85
+ if (isMobileApp) {
86
+ options.baseURL = apiBaseURL;
87
87
  visitor.platform = "mobile";
88
88
  }
89
- if (getIsDesktopApp()) {
90
- options.baseURL = getApiBaseURL();
89
+ if (isDesktopApp) {
90
+ options.baseURL = apiBaseURL;
91
91
  visitor.platform = "desktop";
92
92
  }
93
93
  if (typeof window !== "undefined") {
@@ -128,7 +128,7 @@ const fetchRequest = (url, options = {}, fetch, config) => {
128
128
  };
129
129
  export const createApiFetch = once((fetch, config) => {
130
130
  if (typeof window !== "undefined") {
131
- const cometServerURL = config.getCometServerURL();
131
+ const cometServerURL = config.cometServerURL;
132
132
  let cometClient;
133
133
  bus.subscribe("user:onUpdated", (user) => {
134
134
  if (user) {
@@ -24,7 +24,7 @@ export const getVisitorIdentifier = async (config) => {
24
24
  setVisitor({ ip: data?.ip ?? "unknown" });
25
25
  });
26
26
  const device = await config.getDevice() || "unknown";
27
- const appName = config.getAppName() || "unknown";
27
+ const appName = config.appName || "unknown";
28
28
  setVisitor({ id, ip, device, appName });
29
29
  };
30
30
  export const createApiGetVisitorIdentifier = once((config) => {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/api",
3
- "version": "1.16.5",
3
+ "version": "1.16.6",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "main": "./index.mjs",
@@ -25,13 +25,13 @@ export interface Fetch {
25
25
  create: (defaults: FetchOptions & FetchExtraOptions) => Fetch;
26
26
  }
27
27
  export type FetchConfig = {
28
- getApiBaseURL: () => string;
29
- getCometServerURL: () => string;
30
- getAppClientID: () => string;
31
- getAppClientSecret: () => string;
32
- getIsMobileApp: () => boolean;
33
- getIsDesktopApp: () => boolean;
34
- getAppName: () => string;
28
+ apiBaseURL: string;
29
+ cometServerURL: string;
30
+ appClientID: string;
31
+ appClientSecret: string;
32
+ isMobileApp: boolean;
33
+ isDesktopApp: boolean;
34
+ appName: string;
35
35
  getHostname: () => string;
36
36
  getDevice: () => Promise<string>;
37
37
  useRequestHeaders?: (include: string[]) => {};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/helpers",
3
- "version": "1.16.5",
3
+ "version": "1.16.6",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "main": "./index.mjs",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/layer-manager",
3
- "version": "1.16.5",
3
+ "version": "1.16.6",
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.16.5",
3
+ "version": "1.16.6",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "exports": {