karin-plugin-mys-core 1.0.16 → 1.0.20

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ShowBindAccountCmdFunc
3
- } from "../chunk-5ZBRGVPY.js";
3
+ } from "../chunk-SOLISSTT.js";
4
4
  import "../chunk-S3ALDDWH.js";
5
5
  import {
6
6
  UserInfo,
@@ -9,11 +9,11 @@ import {
9
9
  getTokenByGameToken,
10
10
  getUserFullInfo,
11
11
  queryQRcode
12
- } from "../chunk-F42OUZOV.js";
13
- import "../chunk-ER4WMJJ6.js";
12
+ } from "../chunk-32QZ2PSX.js";
14
13
  import "../chunk-5LRGHP36.js";
15
- import "../chunk-SXPDBSIW.js";
16
- import "../chunk-UIPRZFST.js";
14
+ import "../chunk-HI6OZTI2.js";
15
+ import "../chunk-BLE3V6QR.js";
16
+ import "../chunk-ER4WMJJ6.js";
17
17
  import {
18
18
  common_exports
19
19
  } from "../chunk-RX4VMVAI.js";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  DeviceInfo,
3
3
  UserInfo
4
- } from "../chunk-F42OUZOV.js";
5
- import "../chunk-ER4WMJJ6.js";
4
+ } from "../chunk-32QZ2PSX.js";
6
5
  import "../chunk-5LRGHP36.js";
7
- import "../chunk-SXPDBSIW.js";
8
- import "../chunk-UIPRZFST.js";
6
+ import "../chunk-HI6OZTI2.js";
7
+ import "../chunk-BLE3V6QR.js";
8
+ import "../chunk-ER4WMJJ6.js";
9
9
  import "../chunk-RX4VMVAI.js";
10
10
  import "../chunk-SHLPPEAY.js";
11
11
  import "../chunk-MLKGABMK.js";
@@ -5,13 +5,13 @@ import {
5
5
  ShowBindAccountCmdFunc,
6
6
  UnbindAccount,
7
7
  UnbindUID
8
- } from "../chunk-5ZBRGVPY.js";
8
+ } from "../chunk-SOLISSTT.js";
9
9
  import "../chunk-S3ALDDWH.js";
10
- import "../chunk-F42OUZOV.js";
11
- import "../chunk-ER4WMJJ6.js";
10
+ import "../chunk-32QZ2PSX.js";
12
11
  import "../chunk-5LRGHP36.js";
13
- import "../chunk-SXPDBSIW.js";
14
- import "../chunk-UIPRZFST.js";
12
+ import "../chunk-HI6OZTI2.js";
13
+ import "../chunk-BLE3V6QR.js";
14
+ import "../chunk-ER4WMJJ6.js";
15
15
  import "../chunk-RX4VMVAI.js";
16
16
  import "../chunk-SHLPPEAY.js";
17
17
  import "../chunk-MLKGABMK.js";
@@ -1,11 +1,11 @@
1
+ import {
2
+ DeviceCfg
3
+ } from "./chunk-HI6OZTI2.js";
1
4
  import {
2
5
  MysAccountInfoDB,
3
6
  MysDeviceInfoDB,
4
7
  MysUserInfoDB
5
8
  } from "./chunk-ER4WMJJ6.js";
6
- import {
7
- DeviceCfg
8
- } from "./chunk-SXPDBSIW.js";
9
9
  import {
10
10
  common_exports
11
11
  } from "./chunk-RX4VMVAI.js";
@@ -132,30 +132,25 @@ var Config = class {
132
132
  }
133
133
  return result;
134
134
  }
135
- /**
136
- * @description 获取配置路径对应的默认配置
137
- */
138
135
  getDef(path2) {
139
136
  const defConfig = JSON.parse(JSON.stringify(this.#DefaultConfig));
140
- return lodash2.get(defConfig, path2);
137
+ return path2 ? lodash2.get(defConfig, path2) : defConfig;
141
138
  }
142
139
  get(path2, isArray = false, def) {
143
140
  const conf = JSON.parse(JSON.stringify(this.#ConfigCache));
144
- const result = path2 ? lodash2.get(conf, path2, def) : conf;
141
+ const pathStr = String(path2);
142
+ const result = pathStr ? lodash2.get(conf, pathStr, def) : conf;
145
143
  if (isArray) {
146
144
  if (!Array.isArray(result)) {
147
- logger2.error(`\u914D\u7F6E\u8DEF\u5F84 ${path2} \u4E0D\u662F\u6570\u7EC4\u7C7B\u578B`);
148
- return new EnhancedArray(this, [], path2);
145
+ logger2.error(`\u914D\u7F6E\u8DEF\u5F84 ${pathStr} \u4E0D\u662F\u6570\u7EC4\u7C7B\u578B`);
146
+ return new EnhancedArray(this, [], pathStr);
149
147
  }
150
- return new EnhancedArray(this, result, path2);
148
+ return new EnhancedArray(this, result, pathStr);
151
149
  }
152
150
  return result;
153
151
  }
154
- /**
155
- * @param save 是否立即保存
156
- */
157
152
  set(path2, value, save) {
158
- lodash2.set(this.#ConfigCache, path2, value);
153
+ lodash2.set(this.#ConfigCache, String(path2), value);
159
154
  save && this.save();
160
155
  }
161
156
  /**
@@ -1,16 +1,19 @@
1
1
  import {
2
2
  Config
3
- } from "./chunk-UIPRZFST.js";
3
+ } from "./chunk-BLE3V6QR.js";
4
4
  import {
5
5
  dir
6
6
  } from "./chunk-SHLPPEAY.js";
7
7
 
8
8
  // src/core/config/config.ts
9
- var defaultConfig = {
10
- githubProxyUrl: "https://gh-proxy.org"
9
+ var defaultCoreConfig = {
10
+ proxy: {
11
+ github: "https://gh-proxy.org",
12
+ ["hoyolab" /* os */]: ""
13
+ }
11
14
  };
12
15
  var defaultConfigDefine = {};
13
- var CoreCfg = new Config(`${dir.name}:config`, dir.ConfigDir, defaultConfig, defaultConfigDefine).watch();
16
+ var CoreCfg = new Config(`${dir.name}:config`, dir.ConfigDir, defaultCoreConfig, defaultConfigDefine).watch();
14
17
 
15
18
  // src/core/config/device.ts
16
19
  var DefaultDevice = {
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  MysGame,
8
8
  UserInfo
9
- } from "./chunk-F42OUZOV.js";
9
+ } from "./chunk-32QZ2PSX.js";
10
10
  import {
11
11
  dir
12
12
  } from "./chunk-SHLPPEAY.js";
@@ -1,7 +1,11 @@
1
1
  import { Config } from '../exports/config/index.js';
2
+ import { M as MysAccountType } from '../mysAccountInfo-B7u5Sl8f.js';
2
3
 
3
4
  interface DefaultCoreConfigType {
4
- githubProxyUrl: string;
5
+ proxy: {
6
+ github: string;
7
+ [MysAccountType.os]: string;
8
+ };
5
9
  }
6
10
  interface DefaultCoreConfigDefineType {
7
11
  }
package/lib/core/index.js CHANGED
@@ -2,8 +2,9 @@ import "../chunk-5LRGHP36.js";
2
2
  import {
3
3
  CoreCfg,
4
4
  DeviceCfg
5
- } from "../chunk-SXPDBSIW.js";
6
- import "../chunk-UIPRZFST.js";
5
+ } from "../chunk-HI6OZTI2.js";
6
+ import "../chunk-BLE3V6QR.js";
7
+ import "../chunk-ER4WMJJ6.js";
7
8
  import "../chunk-RX4VMVAI.js";
8
9
  import "../chunk-SHLPPEAY.js";
9
10
  import "../chunk-MLKGABMK.js";
@@ -1,24 +1,44 @@
1
- declare class Config<C extends Record<string, any>> {
1
+ type ToString<T> = T extends string | number ? `${T}` : never;
2
+ type PathImpl<T, Key extends keyof T> = Key extends string | number ? T[Key] extends Record<string, any> ? T[Key] extends ArrayLike<any> ? ToString<Key> | `${ToString<Key>}.${PathImpl<T[Key], Exclude<keyof T[Key], keyof any[]>>}` : ToString<Key> | `${ToString<Key>}.${PathImpl<T[Key], keyof T[Key]>}` : ToString<Key> : never;
3
+ type Path<T> = PathImpl<T, keyof T> | keyof T;
4
+ type PathValue<T, P> = P extends keyof T ? T[P] : P extends `${infer K}.${infer Rest}` ? K extends keyof T ? PathValue<T[K], Rest> : {
5
+ [Key in keyof T]: ToString<Key> extends K ? PathValue<T[Key], Rest> : never;
6
+ }[keyof T] : never;
7
+ declare class Config<C extends {
8
+ [key: string]: any;
9
+ }> {
2
10
  #private;
3
11
  /**
4
12
  * @param name 插件名称:配置名称
5
13
  */
6
- constructor(name: `${string}:${string}`, ConfigDir: string, DefaultConfig: C, DefineConfig: Record<string, any>);
14
+ constructor(name: `${string}:${string}`, ConfigDir: string, DefaultConfig: C, DefineConfig: {
15
+ [key: string]: any;
16
+ });
7
17
  loadConfig(): C;
8
18
  mergeWithDefaults(userConfig: C, defaultConfig: C, DefineConfig: Record<string, any>): C;
9
19
  /**
10
20
  * @description 获取配置路径对应的默认配置
21
+ * @param path 配置路径,支持任意深度的嵌套路径,传入空字符串''可获取整个配置对象
11
22
  */
12
- getDef<T>(path: string): T;
23
+ getDef(path: ''): C;
24
+ getDef<P extends Path<C>>(path: P): PathValue<C, P>;
13
25
  /**
14
26
  * @description 获取配置路径对应的配置
27
+ * @param path 配置路径,支持任意深度的嵌套路径,传入空字符串''可获取整个配置对象
28
+ * @param isArray 是否返回 EnhancedArray 类型
29
+ * @param def 默认值
15
30
  */
16
- get<T>(path: string, isArray?: false, def?: T): T;
17
- get<T>(path: string, isArray: true, def?: T[]): EnhancedArray<T>;
31
+ get(path: '', isArray?: false, def?: C): C;
32
+ get<P extends Path<C>>(path: P, isArray?: false, def?: PathValue<C, P>): PathValue<C, P>;
33
+ get<P extends Path<C>, T = PathValue<C, P>>(path: P, isArray: true, def?: T[]): EnhancedArray<T extends any[] ? T[number] : T, C>;
18
34
  /**
35
+ * @description 设置配置项的值
36
+ * @param path 配置路径,支持任意深度的嵌套路径
37
+ * @param value 要设置的值,类型会根据路径自动推断
19
38
  * @param save 是否立即保存
20
39
  */
21
- set<T>(path: string, value: T, save: boolean): void;
40
+ set(path: '', value: C, save: boolean): void;
41
+ set<P extends Path<C>>(path: P, value: PathValue<C, P>, save: boolean): void;
22
42
  /**
23
43
  * @description 立即保存配置
24
44
  */
@@ -26,9 +46,11 @@ declare class Config<C extends Record<string, any>> {
26
46
  watch(fnc?: (self: Config<C>, oldData: C, newData: C) => Promise<void> | void): this;
27
47
  }
28
48
 
29
- declare class EnhancedArray<T> extends Array<T> {
49
+ declare class EnhancedArray<T, C extends {
50
+ [key: string]: any;
51
+ }> extends Array<T> {
30
52
  #private;
31
- constructor(cfg: Config<any>, items: T[], path: string);
53
+ constructor(cfg: Config<C>, items: T[], path: string);
32
54
  /**
33
55
  * @param element - string | number
34
56
  * @returns
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Config,
3
3
  EnhancedArray
4
- } from "../../chunk-UIPRZFST.js";
4
+ } from "../../chunk-BLE3V6QR.js";
5
5
  import "../../chunk-RX4VMVAI.js";
6
6
  import "../../chunk-MLKGABMK.js";
7
7
  export {
@@ -1,6 +1,8 @@
1
- import { D as DatabaseType, a as DatabaseClassInstance, b as Dialect, c as DatabaseClassStatic, M as ModelAttributes, d as DatabaseReturn, e as MysAccountInfoTableType, f as MysDeviceInfoTableType, B as BaseUserInfoTableType, g as BaseGameUIDInfoTableType } from '../../mysUserInfo-BsyEENbc.js';
2
- export { l as BindUidsItemType, h as DatabaseArray, i as MysAccountType, j as MysDeviceInfoDatabaseBaseType, k as MysDeviceInfoDatabaseIdFpType, U as UidPermission } from '../../mysUserInfo-BsyEENbc.js';
1
+ import { D as DatabaseType, a as DatabaseClassInstance, b as Dialect, c as DatabaseClassStatic, M as ModelAttributes, d as DatabaseReturn, e as MysDeviceInfoTableType, B as BaseUserInfoTableType, f as BaseGameUIDInfoTableType } from '../../mysUserInfo-CPIjniyl.js';
2
+ export { j as BindUidsItemType, g as DatabaseArray, h as MysDeviceInfoDatabaseBaseType, i as MysDeviceInfoDatabaseIdFpType, U as UidPermission } from '../../mysUserInfo-CPIjniyl.js';
3
3
  import { DataTypes, ModelAttributeColumnOptions, Model, ModelStatic } from 'sequelize';
4
+ import { a as MysAccountInfoTableType } from '../../mysAccountInfo-B7u5Sl8f.js';
5
+ export { M as MysAccountType } from '../../mysAccountInfo-B7u5Sl8f.js';
4
6
 
5
7
  type DatabaseFn = <T extends Record<string, any>, D extends DatabaseType>() => DatabaseClassInstance<T, D>;
6
8
 
@@ -1,6 +1,7 @@
1
- import { j as MysDeviceInfoDatabaseBaseType, k as MysDeviceInfoDatabaseIdFpType, i as MysAccountType, f as MysDeviceInfoTableType, B as BaseUserInfoTableType, e as MysAccountInfoTableType, d as DatabaseReturn, D as DatabaseType, h as DatabaseArray, U as UidPermission, g as BaseGameUIDInfoTableType } from '../../mysUserInfo-BsyEENbc.js';
1
+ import { M as MysAccountType, a as MysAccountInfoTableType } from '../../mysAccountInfo-B7u5Sl8f.js';
2
2
  import { SendMessage } from 'node-karin';
3
3
  import { AxiosRequestConfig, AxiosResponse } from 'node-karin/axios';
4
+ import { h as MysDeviceInfoDatabaseBaseType, i as MysDeviceInfoDatabaseIdFpType, e as MysDeviceInfoTableType, B as BaseUserInfoTableType, d as DatabaseReturn, D as DatabaseType, g as DatabaseArray, U as UidPermission, f as BaseGameUIDInfoTableType } from '../../mysUserInfo-CPIjniyl.js';
4
5
  import 'sequelize';
5
6
 
6
7
  declare const MysApp: Readonly<{
@@ -15,11 +15,11 @@ import {
15
15
  getUserFullInfo,
16
16
  getUserGameRolesByCookie,
17
17
  queryQRcode
18
- } from "../../chunk-F42OUZOV.js";
19
- import "../../chunk-ER4WMJJ6.js";
18
+ } from "../../chunk-32QZ2PSX.js";
20
19
  import "../../chunk-5LRGHP36.js";
21
- import "../../chunk-SXPDBSIW.js";
22
- import "../../chunk-UIPRZFST.js";
20
+ import "../../chunk-HI6OZTI2.js";
21
+ import "../../chunk-BLE3V6QR.js";
22
+ import "../../chunk-ER4WMJJ6.js";
23
23
  import "../../chunk-RX4VMVAI.js";
24
24
  import "../../chunk-SHLPPEAY.js";
25
25
  import "../../chunk-MLKGABMK.js";
@@ -0,0 +1,14 @@
1
+ declare const enum MysAccountType {
2
+ cn = "mihoyo",
3
+ os = "hoyolab"
4
+ }
5
+ interface MysAccountInfoTableType {
6
+ ltuid: string;
7
+ type: MysAccountType;
8
+ cookie: string;
9
+ stoken: string;
10
+ /** 绑定的设备md5 */
11
+ deviceMd5: string;
12
+ }
13
+
14
+ export { MysAccountType as M, type MysAccountInfoTableType as a };
@@ -122,19 +122,6 @@ declare class DatabaseArray<T> extends Array<T> {
122
122
  clear(): this;
123
123
  }
124
124
 
125
- declare const enum MysAccountType {
126
- cn = "mihoyo",
127
- os = "hoyolab"
128
- }
129
- interface MysAccountInfoTableType {
130
- ltuid: string;
131
- type: MysAccountType;
132
- cookie: string;
133
- stoken: string;
134
- /** 绑定的设备md5 */
135
- deviceMd5: string;
136
- }
137
-
138
125
  interface MysDeviceInfoDatabaseBaseType {
139
126
  name: string;
140
127
  board: string;
@@ -181,4 +168,4 @@ type BaseGameUIDInfoTableType<Game extends string> = {
181
168
  [P in `${Game}-uids`]: Partial<Record<string, BindUidsItemType>>;
182
169
  };
183
170
 
184
- export { type BaseUserInfoTableType as B, DatabaseType as D, type ModelAttributes as M, UidPermission as U, type DatabaseClassInstance as a, Dialect as b, type DatabaseClassStatic as c, type DatabaseReturn as d, type MysAccountInfoTableType as e, type MysDeviceInfoTableType as f, type BaseGameUIDInfoTableType as g, DatabaseArray as h, MysAccountType as i, type MysDeviceInfoDatabaseBaseType as j, type MysDeviceInfoDatabaseIdFpType as k, type BindUidsItemType as l };
171
+ export { type BaseUserInfoTableType as B, DatabaseType as D, type ModelAttributes as M, UidPermission as U, type DatabaseClassInstance as a, Dialect as b, type DatabaseClassStatic as c, type DatabaseReturn as d, type MysDeviceInfoTableType as e, type BaseGameUIDInfoTableType as f, DatabaseArray as g, type MysDeviceInfoDatabaseBaseType as h, type MysDeviceInfoDatabaseIdFpType as i, type BindUidsItemType as j };
package/lib/web.config.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  CoreCfg,
3
3
  DeviceCfg
4
- } from "./chunk-SXPDBSIW.js";
5
- import "./chunk-UIPRZFST.js";
4
+ } from "./chunk-HI6OZTI2.js";
5
+ import "./chunk-BLE3V6QR.js";
6
+ import "./chunk-ER4WMJJ6.js";
6
7
  import "./chunk-RX4VMVAI.js";
7
8
  import {
8
9
  dir
@@ -42,13 +43,17 @@ var web_config_default = defineConfig({
42
43
  components.accordion.create("accordion-config-key" /* Config */, {
43
44
  label: "\u57FA\u7840\u8BBE\u7F6E",
44
45
  children: [
45
- components.accordion.createItem("accordion-githubProxy-item-key", {
46
- title: "GitHub \u4EE3\u7406\u8BBE\u7F6E",
47
- subtitle: "\u7528\u4E8E\u4E0B\u8F7D\u63D2\u4EF6\u8D44\u6E90",
46
+ components.accordion.createItem("accordion-proxy-item-key", {
47
+ title: "\u4EE3\u7406\u8BBE\u7F6E",
48
+ subtitle: "\u7528\u4E8E\u4E0B\u8F7D\u63D2\u4EF6\u8D44\u6E90\u6216api\u8BF7\u6C42",
48
49
  children: [
49
- components.input.url("githubProxyUrl", {
50
+ components.input.url("proxy-github", {
50
51
  label: "GitHub \u4EE3\u7406\u5730\u5740",
51
- defaultValue: CoreCfg.get("githubProxyUrl")
52
+ defaultValue: CoreCfg.get("proxy.github")
53
+ }),
54
+ components.input.url(`proxy-${"hoyolab" /* os */}`, {
55
+ label: "Hoyolab \u7C73\u6E38\u793E API \u4EE3\u7406",
56
+ defaultValue: CoreCfg.get(`proxy.${"hoyolab" /* os */}`)
52
57
  })
53
58
  ]
54
59
  })
@@ -111,7 +116,15 @@ var web_config_default = defineConfig({
111
116
  try {
112
117
  lodash.forEach(changeConfig, (childrenValue, accordionKey) => {
113
118
  switch (accordionKey) {
114
- case "accordion-config-key" /* Config */:
119
+ case "accordion-config-key" /* Config */: {
120
+ childrenValue.forEach((children) => {
121
+ lodash.forEach(children, (value, childrenKey) => {
122
+ const { key, value: formatValue } = FormatValue(childrenKey, value);
123
+ CfgMap[accordionKey].set(key, formatValue, false);
124
+ });
125
+ });
126
+ break;
127
+ }
115
128
  case "accordion-device-key" /* Device */: {
116
129
  childrenValue.forEach((children) => {
117
130
  lodash.forEach(children, (value, childrenKey) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "karin-plugin-mys-core",
3
- "version": "1.0.16",
3
+ "version": "1.0.20",
4
4
  "author": "babanbang",
5
5
  "type": "module",
6
6
  "description": "karin-plugin-mys-core",
@@ -107,7 +107,7 @@
107
107
  }
108
108
 
109
109
  /*
110
- ! tailwindcss v3.4.18 | MIT License | https://tailwindcss.com
110
+ ! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com
111
111
  */
112
112
 
113
113
  /*