@inzombieland/core 1.18.5 → 1.18.8

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.
@@ -0,0 +1,4 @@
1
+ import type { createApp } from "vue";
2
+ type App = ReturnType<typeof createApp>;
3
+ export declare function defineVuePlugins(app: App): void;
4
+ export {};
@@ -0,0 +1,4 @@
1
+ import { defineVarletPlugin } from "./plugins/index.mjs";
2
+ export function defineVuePlugins(app) {
3
+ defineVarletPlugin(app);
4
+ }
package/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { type Ref } from "vue";
2
2
  import type { Fetch, FetchConfig } from "./types";
3
+ export { defineVuePlugins } from "./define-vue-plugins";
3
4
  export { default as AppProvider } from "./AppProvider.vue";
4
5
  export * from "./composables";
5
6
  export * from "./types";
@@ -19,6 +20,12 @@ export declare function initApiFetch($fetch: Fetch, config: FetchConfig): {
19
20
  fetchActiveSessions: () => Promise<{
20
21
  sessions: import("./types").ActiveSession[];
21
22
  }>;
23
+ changeTheme: (body: {
24
+ theme: "light" | "dark";
25
+ }) => Promise<void>;
26
+ changeLocale: (body: {
27
+ locale: string;
28
+ }) => Promise<void>;
22
29
  };
23
30
  };
24
31
  export declare const useUserActions: () => Ref<{
@@ -33,6 +40,12 @@ export declare const useUserActions: () => Ref<{
33
40
  fetchActiveSessions: () => Promise<{
34
41
  sessions: import("./types").ActiveSession[];
35
42
  }>;
43
+ changeTheme: (body: {
44
+ theme: "light" | "dark";
45
+ }) => Promise<void>;
46
+ changeLocale: (body: {
47
+ locale: string;
48
+ }) => Promise<void>;
36
49
  }, {
37
50
  signIn: (body: {
38
51
  username: string;
@@ -45,4 +58,10 @@ export declare const useUserActions: () => Ref<{
45
58
  fetchActiveSessions: () => Promise<{
46
59
  sessions: import("./types").ActiveSession[];
47
60
  }>;
61
+ changeTheme: (body: {
62
+ theme: "light" | "dark";
63
+ }) => Promise<void>;
64
+ changeLocale: (body: {
65
+ locale: string;
66
+ }) => Promise<void>;
48
67
  }> | undefined;
package/index.mjs CHANGED
@@ -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 { defineVuePlugins } from "./define-vue-plugins.mjs";
12
13
  export { default as AppProvider } from "./AppProvider.vue";
13
14
  export * from "./composables/index.mjs";
14
15
  export * from "./types.mjs";
@@ -14,6 +14,7 @@ function initApplication() {
14
14
  const theme = useThemeMode();
15
15
  const locale = useAppLocale();
16
16
  const i18n = useI18n();
17
+ const userActions = useUserActions();
17
18
  watch(user, (user2) => {
18
19
  if (user2 && user2.theme !== theme.value?.value) {
19
20
  theme.value = { value: user2.theme };
@@ -34,6 +35,7 @@ function initApplication() {
34
35
  document.documentElement.classList.add("light", "van-theme-light");
35
36
  StyleProvider(null);
36
37
  }
38
+ userActions?.value.changeTheme({ theme: theme2?.value });
37
39
  },
38
40
  { immediate: true }
39
41
  );
@@ -51,6 +53,7 @@ function initApplication() {
51
53
  VantLocale.use(locale2, ruRU);
52
54
  VarletLocale.add("en-US", VarletLocale.enUS);
53
55
  }
56
+ userActions?.value.changeLocale({ locale: locale2?.value });
54
57
  },
55
58
  { immediate: true }
56
59
  );
@@ -73,7 +76,6 @@ function initApplication() {
73
76
  }
74
77
  const visitor = useVisitor();
75
78
  if (session?.status === "SignedOut" && session?.visitorId === visitor.value?.id) {
76
- const userActions = useUserActions();
77
79
  const data = await userActions?.value.fetchActiveSessions();
78
80
  const isCurrentSession = data?.sessions.some((s) => s.isCurrentSession && s.id === session?.sessionId);
79
81
  if (isCurrentSession) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/core",
3
- "version": "1.18.5",
3
+ "version": "1.18.8",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "main": "./index.mjs",
@@ -0,0 +1 @@
1
+ export * from "./varlet-ui";
@@ -0,0 +1 @@
1
+ export * from "./varlet-ui.mjs";
@@ -0,0 +1,9 @@
1
+ import type { createApp } from "vue";
2
+ import "@varlet/ui/es/button/style/index";
3
+ import "@varlet/ui/es/chip/style/index";
4
+ import "@varlet/ui/es/icon/style/index";
5
+ import "@varlet/ui/es/link/style/index";
6
+ import "@varlet/ui/es/styles/elevation.css";
7
+ type App = ReturnType<typeof createApp>;
8
+ export declare function defineVarletPlugin(app: App): void;
9
+ export {};
@@ -0,0 +1,12 @@
1
+ import { Button, Chip, Icon, Link } from "@varlet/ui";
2
+ import "@varlet/ui/es/button/style/index";
3
+ import "@varlet/ui/es/chip/style/index";
4
+ import "@varlet/ui/es/icon/style/index";
5
+ import "@varlet/ui/es/link/style/index";
6
+ import "@varlet/ui/es/styles/elevation.css";
7
+ export function defineVarletPlugin(app) {
8
+ app.use(Button);
9
+ app.use(Chip);
10
+ app.use(Icon);
11
+ app.use(Link);
12
+ }
package/user-actions.d.ts CHANGED
@@ -12,4 +12,10 @@ export declare const createApiUserActions: (fetch: Fetch, config: FetchConfig, g
12
12
  fetchActiveSessions: () => Promise<{
13
13
  sessions: ActiveSession[];
14
14
  }>;
15
+ changeTheme: (body: {
16
+ theme: "light" | "dark";
17
+ }) => Promise<void>;
18
+ changeLocale: (body: {
19
+ locale: string;
20
+ }) => Promise<void>;
15
21
  };
package/user-actions.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { flush, setToken } from "./api-client.mjs";
1
+ import { flush, setToken, updateUser } from "./api-client.mjs";
2
2
  import { useUser } from "./composables/index.mjs";
3
3
  import { once } from "./helpers/index.mjs";
4
4
  export const createApiUserActions = once(
@@ -32,6 +32,20 @@ export const createApiUserActions = once(
32
32
  },
33
33
  fetchActiveSessions: async () => {
34
34
  return await fetch("/account/1/sessions");
35
+ },
36
+ changeTheme: async (body) => {
37
+ const user = useUser();
38
+ if (user.value) {
39
+ await fetch("/account/1/change/theme", { body, method: "POST" });
40
+ updateUser(body);
41
+ }
42
+ },
43
+ changeLocale: async (body) => {
44
+ const user = useUser();
45
+ if (user.value) {
46
+ await fetch("/account/1/change/locale", { body, method: "POST" });
47
+ updateUser(body);
48
+ }
35
49
  }
36
50
  };
37
51
  }