@inzombieland/nuxt-common 1.16.8 → 1.16.10
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 +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/SidebarProvider.vue +2 -2
- package/dist/runtime/api/index.d.ts +1 -1
- package/dist/runtime/api/index.mjs +4 -3
- package/dist/runtime/composables/use-device.d.ts +3 -0
- package/dist/runtime/composables/use-device.mjs +5 -0
- package/dist/runtime/packages/api/helpers/device-helper.d.ts +43 -0
- package/dist/runtime/packages/api/helpers/device-helper.mjs +15 -0
- package/dist/runtime/packages/api/helpers/index.d.ts +1 -1
- package/dist/runtime/packages/api/helpers/index.mjs +1 -1
- package/dist/runtime/packages/api/package.json +1 -1
- package/dist/runtime/packages/api/types.d.ts +1 -1
- package/dist/runtime/plugins/device.d.ts +29 -65
- package/dist/runtime/plugins/device.mjs +4 -12
- package/package.json +1 -1
package/dist/module.json
CHANGED
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
|
+
const version = "1.16.10";
|
|
6
6
|
|
|
7
7
|
const module = defineNuxtModule({
|
|
8
8
|
meta: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { useSwipe, type UseSwipeDirection } from "@vueuse/core"
|
|
3
3
|
import { onMounted, ref, watch } from "vue"
|
|
4
|
-
import {
|
|
4
|
+
import { useDevice } from "./composables/use-device"
|
|
5
5
|
import { useToggleSidebar } from "./composables/use-toggle-sidebar"
|
|
6
6
|
|
|
7
7
|
const sidebarRef = ref<HTMLElement | null>(null)
|
|
@@ -10,7 +10,7 @@ const sidebarBackdropRef = ref<HTMLElement | null>(null)
|
|
|
10
10
|
|
|
11
11
|
const sidebar = ref("hidden")
|
|
12
12
|
const toggleSidebar = useToggleSidebar()
|
|
13
|
-
const
|
|
13
|
+
const $device = useDevice()
|
|
14
14
|
const sidebarClass = ref({
|
|
15
15
|
sidebar: true,
|
|
16
16
|
"sidebar-open": sidebar.value === "open",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRequestHeaders, useRequestURL } from "#imports";
|
|
2
|
+
import { useDevice } from "../composables/use-device.mjs";
|
|
2
3
|
import { initApiFetch } from "../packages/api/index.mjs";
|
|
3
4
|
export { getVisitor, getVisitorId, useUser } from "../packages/api/index.mjs";
|
|
4
5
|
export const config = {
|
|
@@ -11,8 +12,8 @@ export const config = {
|
|
|
11
12
|
appName: import.meta.env.VITE_APP_NAME,
|
|
12
13
|
getHostname: () => useRequestURL().hostname,
|
|
13
14
|
getDevice: async () => {
|
|
14
|
-
const
|
|
15
|
-
return await
|
|
15
|
+
const device = useDevice();
|
|
16
|
+
return await device.getInfo();
|
|
16
17
|
},
|
|
17
18
|
useRequestHeaders: (include = []) => {
|
|
18
19
|
return {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface Device {
|
|
2
|
+
mobile: () => boolean;
|
|
3
|
+
tablet: () => boolean;
|
|
4
|
+
desktop: () => boolean;
|
|
5
|
+
ios: () => boolean;
|
|
6
|
+
macos: () => boolean;
|
|
7
|
+
ipad: () => boolean;
|
|
8
|
+
iphone: () => boolean;
|
|
9
|
+
ipod: () => boolean;
|
|
10
|
+
android: () => boolean;
|
|
11
|
+
androidPhone: () => boolean;
|
|
12
|
+
androidTablet: () => boolean;
|
|
13
|
+
blackberry: () => boolean;
|
|
14
|
+
blackberryPhone: () => boolean;
|
|
15
|
+
blackberryTablet: () => boolean;
|
|
16
|
+
windows: () => boolean;
|
|
17
|
+
windowsPhone: () => boolean;
|
|
18
|
+
windowsTablet: () => boolean;
|
|
19
|
+
fxos: () => boolean;
|
|
20
|
+
fxosPhone: () => boolean;
|
|
21
|
+
fxosTablet: () => boolean;
|
|
22
|
+
meego: () => boolean;
|
|
23
|
+
television: () => boolean;
|
|
24
|
+
isMobileApp: boolean;
|
|
25
|
+
mobileApp: () => boolean;
|
|
26
|
+
iosMobileApp: () => boolean;
|
|
27
|
+
androidMobileApp: () => boolean;
|
|
28
|
+
tabletApp: () => boolean;
|
|
29
|
+
iosTabletApp: () => boolean;
|
|
30
|
+
androidTabletApp: () => boolean;
|
|
31
|
+
landscape: () => boolean;
|
|
32
|
+
portrait: () => boolean;
|
|
33
|
+
onChangeOrientation: (cb: (newOrientation: DeviceOrientation) => void) => void;
|
|
34
|
+
noConflict: (currentDevice: Device) => void;
|
|
35
|
+
type: DeviceType;
|
|
36
|
+
orientation: DeviceOrientation;
|
|
37
|
+
os: DeviceOs;
|
|
38
|
+
osName: () => string;
|
|
39
|
+
}
|
|
40
|
+
export type DeviceType = "mobile" | "tablet" | "desktop" | "unknown";
|
|
41
|
+
export type DeviceOrientation = "landscape" | "portrait" | "unknown";
|
|
42
|
+
export type DeviceOs = "ios" | "macos" | "iphone" | "ipad" | "ipod" | "android" | "blackberry" | "windows" | "fxos" | "meego" | "television" | "unknown";
|
|
43
|
+
export declare const deviceHelper: () => Device;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { device as currentDevice } from "./current-device.mjs";
|
|
2
|
+
export const deviceHelper = () => {
|
|
3
|
+
const device = currentDevice;
|
|
4
|
+
const isMobileApp = import.meta.env.VITE_IS_MOBILE_APP === "true" || import.meta.env.VITE_IS_MOBILE_APP === true;
|
|
5
|
+
return {
|
|
6
|
+
...device,
|
|
7
|
+
isMobileApp,
|
|
8
|
+
mobileApp: () => isMobileApp && device.mobile(),
|
|
9
|
+
iosMobileApp: () => isMobileApp && device.mobile() && device.ios(),
|
|
10
|
+
androidMobileApp: () => isMobileApp && device.androidPhone(),
|
|
11
|
+
tabletApp: () => isMobileApp && device.tablet(),
|
|
12
|
+
iosTabletApp: () => isMobileApp && device.tablet() && device.ios(),
|
|
13
|
+
androidTabletApp: () => isMobileApp && device.androidTablet()
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { apiHelper } from "./api-helper";
|
|
2
2
|
export { dateHelper } from "./date-helper";
|
|
3
|
-
export {
|
|
3
|
+
export { deviceHelper, type Device } from "./device-helper";
|
|
4
4
|
export declare function once<T extends (...args: any[]) => any>(fn: T): T;
|
|
@@ -33,7 +33,7 @@ export type FetchConfig = {
|
|
|
33
33
|
isDesktopApp: boolean;
|
|
34
34
|
appName: string;
|
|
35
35
|
getHostname: () => string;
|
|
36
|
-
getDevice: () => Promise<string
|
|
36
|
+
getDevice: () => Promise<string> | string;
|
|
37
37
|
useRequestHeaders?: (include: string[]) => {};
|
|
38
38
|
};
|
|
39
39
|
export type ActiveSession = {
|
|
@@ -1,52 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
mobile: () => boolean;
|
|
3
|
-
tablet: () => boolean;
|
|
4
|
-
desktop: () => boolean;
|
|
5
|
-
ios: () => boolean;
|
|
6
|
-
macos: () => boolean;
|
|
7
|
-
ipad: () => boolean;
|
|
8
|
-
iphone: () => boolean;
|
|
9
|
-
ipod: () => boolean;
|
|
10
|
-
android: () => boolean;
|
|
11
|
-
androidPhone: () => boolean;
|
|
12
|
-
androidTablet: () => boolean;
|
|
13
|
-
blackberry: () => boolean;
|
|
14
|
-
blackberryPhone: () => boolean;
|
|
15
|
-
blackberryTablet: () => boolean;
|
|
16
|
-
windows: () => boolean;
|
|
17
|
-
windowsPhone: () => boolean;
|
|
18
|
-
windowsTablet: () => boolean;
|
|
19
|
-
fxos: () => boolean;
|
|
20
|
-
fxosPhone: () => boolean;
|
|
21
|
-
fxosTablet: () => boolean;
|
|
22
|
-
meego: () => boolean;
|
|
23
|
-
television: () => boolean;
|
|
24
|
-
mobileApp: () => boolean;
|
|
25
|
-
iosMobileApp: () => boolean;
|
|
26
|
-
androidMobileApp: () => boolean;
|
|
27
|
-
tabletApp: () => boolean;
|
|
28
|
-
iosTabletApp: () => boolean;
|
|
29
|
-
androidTabletApp: () => boolean;
|
|
30
|
-
landscape: () => boolean;
|
|
31
|
-
portrait: () => boolean;
|
|
32
|
-
onChangeOrientation: (cb: (newOrientation: DeviceOrientation) => void) => void;
|
|
33
|
-
noConflict: (currentDevice: Device) => void;
|
|
34
|
-
type: DeviceType;
|
|
35
|
-
orientation: DeviceOrientation;
|
|
36
|
-
os: DeviceOs;
|
|
37
|
-
osName: () => string;
|
|
38
|
-
}
|
|
39
|
-
export type DeviceType = "mobile" | "tablet" | "desktop" | "unknown";
|
|
40
|
-
export type DeviceOrientation = "landscape" | "portrait" | "unknown";
|
|
41
|
-
export type DeviceOs = "ios" | "macos" | "iphone" | "ipad" | "ipod" | "android" | "blackberry" | "windows" | "fxos" | "meego" | "television" | "unknown";
|
|
1
|
+
import { deviceHelper } from "../packages/api/helpers";
|
|
42
2
|
declare const _default: import("#app").Plugin<{
|
|
43
3
|
device: {
|
|
44
|
-
mobileApp: () => boolean;
|
|
45
|
-
iosMobileApp: () => boolean;
|
|
46
|
-
androidMobileApp: () => boolean;
|
|
47
|
-
tabletApp: () => boolean;
|
|
48
|
-
iosTabletApp: () => boolean;
|
|
49
|
-
androidTabletApp: () => boolean;
|
|
50
4
|
getInfo: () => Promise<string>;
|
|
51
5
|
mobile: () => boolean;
|
|
52
6
|
tablet: () => boolean;
|
|
@@ -70,23 +24,24 @@ declare const _default: import("#app").Plugin<{
|
|
|
70
24
|
fxosTablet: () => boolean;
|
|
71
25
|
meego: () => boolean;
|
|
72
26
|
television: () => boolean;
|
|
73
|
-
|
|
74
|
-
portrait: () => boolean;
|
|
75
|
-
onChangeOrientation: (cb: (newOrientation: DeviceOrientation) => void) => void;
|
|
76
|
-
noConflict: (currentDevice: Device) => void;
|
|
77
|
-
type: DeviceType;
|
|
78
|
-
orientation: DeviceOrientation;
|
|
79
|
-
os: DeviceOs;
|
|
80
|
-
osName: () => string;
|
|
81
|
-
};
|
|
82
|
-
}> & import("#app").ObjectPlugin<{
|
|
83
|
-
device: {
|
|
27
|
+
isMobileApp: boolean;
|
|
84
28
|
mobileApp: () => boolean;
|
|
85
29
|
iosMobileApp: () => boolean;
|
|
86
30
|
androidMobileApp: () => boolean;
|
|
87
31
|
tabletApp: () => boolean;
|
|
88
32
|
iosTabletApp: () => boolean;
|
|
89
33
|
androidTabletApp: () => boolean;
|
|
34
|
+
landscape: () => boolean;
|
|
35
|
+
portrait: () => boolean;
|
|
36
|
+
onChangeOrientation: (cb: (newOrientation: import("src/runtime/packages/api/helpers/device-helper").DeviceOrientation) => void) => void;
|
|
37
|
+
noConflict: (currentDevice: import("src/runtime/packages/api/helpers/device-helper").Device) => void;
|
|
38
|
+
type: import("src/runtime/packages/api/helpers/device-helper").DeviceType;
|
|
39
|
+
orientation: import("src/runtime/packages/api/helpers/device-helper").DeviceOrientation;
|
|
40
|
+
os: import("src/runtime/packages/api/helpers/device-helper").DeviceOs;
|
|
41
|
+
osName: () => string;
|
|
42
|
+
};
|
|
43
|
+
}> & import("#app").ObjectPlugin<{
|
|
44
|
+
device: {
|
|
90
45
|
getInfo: () => Promise<string>;
|
|
91
46
|
mobile: () => boolean;
|
|
92
47
|
tablet: () => boolean;
|
|
@@ -110,22 +65,31 @@ declare const _default: import("#app").Plugin<{
|
|
|
110
65
|
fxosTablet: () => boolean;
|
|
111
66
|
meego: () => boolean;
|
|
112
67
|
television: () => boolean;
|
|
68
|
+
isMobileApp: boolean;
|
|
69
|
+
mobileApp: () => boolean;
|
|
70
|
+
iosMobileApp: () => boolean;
|
|
71
|
+
androidMobileApp: () => boolean;
|
|
72
|
+
tabletApp: () => boolean;
|
|
73
|
+
iosTabletApp: () => boolean;
|
|
74
|
+
androidTabletApp: () => boolean;
|
|
113
75
|
landscape: () => boolean;
|
|
114
76
|
portrait: () => boolean;
|
|
115
|
-
onChangeOrientation: (cb: (newOrientation: DeviceOrientation) => void) => void;
|
|
116
|
-
noConflict: (currentDevice: Device) => void;
|
|
117
|
-
type: DeviceType;
|
|
118
|
-
orientation: DeviceOrientation;
|
|
119
|
-
os: DeviceOs;
|
|
77
|
+
onChangeOrientation: (cb: (newOrientation: import("src/runtime/packages/api/helpers/device-helper").DeviceOrientation) => void) => void;
|
|
78
|
+
noConflict: (currentDevice: import("src/runtime/packages/api/helpers/device-helper").Device) => void;
|
|
79
|
+
type: import("src/runtime/packages/api/helpers/device-helper").DeviceType;
|
|
80
|
+
orientation: import("src/runtime/packages/api/helpers/device-helper").DeviceOrientation;
|
|
81
|
+
os: import("src/runtime/packages/api/helpers/device-helper").DeviceOs;
|
|
120
82
|
osName: () => string;
|
|
121
83
|
};
|
|
122
84
|
}>;
|
|
123
85
|
export default _default;
|
|
124
86
|
declare module "#app" {
|
|
125
87
|
interface NuxtApp {
|
|
126
|
-
$device:
|
|
88
|
+
$device: ReturnType<typeof deviceHelper> & {
|
|
89
|
+
getInfo: () => Promise<string> | string;
|
|
90
|
+
};
|
|
127
91
|
$mobileApp: {
|
|
128
|
-
getInfo
|
|
92
|
+
getInfo?: () => Promise<{
|
|
129
93
|
name: string;
|
|
130
94
|
}>;
|
|
131
95
|
changeTheme: ({ theme }: {
|
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
import { defineNuxtPlugin } from "#app";
|
|
2
|
-
import { useNuxtApp
|
|
3
|
-
import {
|
|
2
|
+
import { useNuxtApp } from "#imports";
|
|
3
|
+
import { deviceHelper } from "../packages/api/helpers/index.mjs";
|
|
4
4
|
export default defineNuxtPlugin(() => {
|
|
5
|
-
const device =
|
|
6
|
-
const runtimeConfig = useRuntimeConfig();
|
|
7
|
-
const isMobileApp = Boolean(runtimeConfig.public.isMobileApp);
|
|
5
|
+
const device = deviceHelper();
|
|
8
6
|
return {
|
|
9
7
|
provide: {
|
|
10
8
|
device: {
|
|
11
9
|
...device,
|
|
12
|
-
mobileApp: () => isMobileApp && device.mobile(),
|
|
13
|
-
iosMobileApp: () => isMobileApp && device.mobile() && device.ios(),
|
|
14
|
-
androidMobileApp: () => isMobileApp && device.androidPhone(),
|
|
15
|
-
tabletApp: () => isMobileApp && device.tablet(),
|
|
16
|
-
iosTabletApp: () => isMobileApp && device.tablet() && device.ios(),
|
|
17
|
-
androidTabletApp: () => isMobileApp && device.androidTablet(),
|
|
18
10
|
getInfo: async () => {
|
|
19
11
|
const { $mobileApp } = useNuxtApp();
|
|
20
|
-
if (isMobileApp && $mobileApp && typeof $mobileApp.getInfo === "function") {
|
|
12
|
+
if (device.isMobileApp && $mobileApp && typeof $mobileApp.getInfo === "function") {
|
|
21
13
|
const device2 = await $mobileApp.getInfo();
|
|
22
14
|
return device2.name;
|
|
23
15
|
}
|