karin-plugin-mys-core 1.0.11 → 1.0.13

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.
Files changed (156) hide show
  1. package/README.md +1 -1
  2. package/lib/apps/MiHoYoLogin.js +7 -38
  3. package/lib/apps/MysDevice.js +6 -37
  4. package/lib/apps/UIDManage.js +7 -38
  5. package/lib/{chunk-4BTKE3LO.js → chunk-567NAKP4.js} +300 -189
  6. package/lib/{chunk-BBJ4U2IY.js → chunk-A5FZEOIN.js} +75 -4
  7. package/lib/{chunk-AFLOM3CG.js → chunk-G564WWA7.js} +6 -10
  8. package/lib/chunk-HKSHKXRI.js +21 -0
  9. package/lib/chunk-IASM5MM5.js +639 -0
  10. package/lib/{chunk-5DXIT7UB.js → chunk-RX4VMVAI.js} +0 -5
  11. package/lib/chunk-UIPRZFST.js +184 -0
  12. package/lib/core/index.d.ts +20 -0
  13. package/lib/core/index.js +10 -0
  14. package/lib/exports/config/index.d.ts +56 -1
  15. package/lib/exports/config/index.js +3 -9
  16. package/lib/exports/database/index.d.ts +78 -12
  17. package/lib/exports/database/index.js +12 -40
  18. package/lib/exports/mys/index.d.ts +379 -14
  19. package/lib/exports/mys/index.js +10 -43
  20. package/lib/exports/render/index.d.ts +36 -3
  21. package/lib/exports/render/index.js +3 -8
  22. package/lib/exports/utils/index.d.ts +45 -2
  23. package/lib/exports/utils/index.js +1 -4
  24. package/lib/{exports/database/types/dbs/base.d.ts → mysUserInfo-BsyEENbc.d.ts} +60 -1
  25. package/package.json +6 -1
  26. package/resources/image/frame-logo.webp +0 -0
  27. package/resources/image/launcher-icon//345/216/237/347/245/236.webp +0 -0
  28. package/resources/image/launcher-icon//345/264/251/345/235/2173.webp +0 -0
  29. package/resources/image/launcher-icon//345/264/251/345/235/217/345/255/246/345/233/2552.webp +0 -0
  30. package/resources/image/launcher-icon//345/264/251/345/235/217/357/274/232/345/233/240/347/274/230/347/262/276/347/201/265.webp +0 -0
  31. package/resources/image/launcher-icon//345/264/251/345/235/217/357/274/232/346/230/237/347/251/271/351/223/201/351/201/223.webp +0 -0
  32. package/resources/image/launcher-icon//346/230/237/345/270/203/350/260/267/345/234/260.webp +0 -0
  33. package/resources/image/launcher-icon//346/234/252/345/256/232/344/272/213/344/273/266/347/260/277.webp +0 -0
  34. package/resources/image/launcher-icon//347/273/235/345/214/272/351/233/266.webp +0 -0
  35. package/resources/image/mys-core-logo.webp +0 -0
  36. package/resources/image/mys-logo.webp +0 -0
  37. package/lib/chunk-2BVJS5VE.js +0 -49
  38. package/lib/chunk-3ERB3ILC.js +0 -0
  39. package/lib/chunk-3JN5WYUN.js +0 -135
  40. package/lib/chunk-7KEG6SDX.js +0 -0
  41. package/lib/chunk-7VAWV6ZE.js +0 -0
  42. package/lib/chunk-ARLTXJFJ.js +0 -0
  43. package/lib/chunk-CFS2WFOO.js +0 -0
  44. package/lib/chunk-DMJ5OQR6.js +0 -73
  45. package/lib/chunk-EDNBKOMS.js +0 -30
  46. package/lib/chunk-FBWSEBAW.js +0 -0
  47. package/lib/chunk-FOAQZIZ2.js +0 -0
  48. package/lib/chunk-G5W5WAY5.js +0 -64
  49. package/lib/chunk-G7TMVDGP.js +0 -68
  50. package/lib/chunk-HJ6HX5HB.js +0 -29
  51. package/lib/chunk-I7XZONDN.js +0 -13
  52. package/lib/chunk-JRH4JC43.js +0 -0
  53. package/lib/chunk-JVJQKRJ4.js +0 -89
  54. package/lib/chunk-K5U2O3HH.js +0 -0
  55. package/lib/chunk-KQVWWGRH.js +0 -31
  56. package/lib/chunk-LBLGKL3W.js +0 -77
  57. package/lib/chunk-LJSDSOY6.js +0 -0
  58. package/lib/chunk-LYTNREAI.js +0 -0
  59. package/lib/chunk-MPZP23EX.js +0 -219
  60. package/lib/chunk-MWYDWDR4.js +0 -0
  61. package/lib/chunk-PMFOX5HA.js +0 -80
  62. package/lib/chunk-PYTECG57.js +0 -0
  63. package/lib/chunk-SEWEEPJN.js +0 -0
  64. package/lib/chunk-SHW6FHIB.js +0 -10
  65. package/lib/chunk-T7W4DXRM.js +0 -0
  66. package/lib/chunk-TTN7NFCA.js +0 -109
  67. package/lib/chunk-W4DBT7AD.js +0 -0
  68. package/lib/chunk-WCX7WZAQ.js +0 -0
  69. package/lib/chunk-Z5I6A73Y.js +0 -0
  70. package/lib/chunk-ZTOR2DXG.js +0 -38
  71. package/lib/common-BlI5Gsw_.d.ts +0 -35
  72. package/lib/define-B9r20dK6.d.ts +0 -130
  73. package/lib/exports/config/array.d.ts +0 -1
  74. package/lib/exports/config/array.js +0 -7
  75. package/lib/exports/config/config.d.ts +0 -56
  76. package/lib/exports/config/config.js +0 -12
  77. package/lib/exports/database/database.d.ts +0 -30
  78. package/lib/exports/database/database.js +0 -22
  79. package/lib/exports/database/dbs/base.d.ts +0 -25
  80. package/lib/exports/database/dbs/base.js +0 -19
  81. package/lib/exports/database/dbs/index.d.ts +0 -4
  82. package/lib/exports/database/dbs/index.js +0 -29
  83. package/lib/exports/database/dbs/sqlite3.d.ts +0 -27
  84. package/lib/exports/database/dbs/sqlite3.js +0 -23
  85. package/lib/exports/database/dbs/table.d.ts +0 -20
  86. package/lib/exports/database/dbs/table.js +0 -25
  87. package/lib/exports/database/tables/index.d.ts +0 -9
  88. package/lib/exports/database/tables/index.js +0 -40
  89. package/lib/exports/database/tables/mysAccountInfo.d.ts +0 -9
  90. package/lib/exports/database/tables/mysAccountInfo.js +0 -27
  91. package/lib/exports/database/tables/mysDeviceInfo.d.ts +0 -9
  92. package/lib/exports/database/tables/mysDeviceInfo.js +0 -27
  93. package/lib/exports/database/tables/mysUserInfo.d.ts +0 -9
  94. package/lib/exports/database/tables/mysUserInfo.js +0 -27
  95. package/lib/exports/database/types/database.d.ts +0 -6
  96. package/lib/exports/database/types/database.js +0 -1
  97. package/lib/exports/database/types/dbs/base.js +0 -11
  98. package/lib/exports/database/types/dbs/index.d.ts +0 -2
  99. package/lib/exports/database/types/dbs/index.js +0 -12
  100. package/lib/exports/database/types/index.d.ts +0 -6
  101. package/lib/exports/database/types/index.js +0 -24
  102. package/lib/exports/database/types/tables/index.d.ts +0 -5
  103. package/lib/exports/database/types/tables/index.js +0 -13
  104. package/lib/exports/database/types/tables/mysAccountInfo.d.ts +0 -14
  105. package/lib/exports/database/types/tables/mysAccountInfo.js +0 -7
  106. package/lib/exports/database/types/tables/mysDeviceInfo.d.ts +0 -19
  107. package/lib/exports/database/types/tables/mysDeviceInfo.js +0 -1
  108. package/lib/exports/database/types/tables/mysUserInfo.d.ts +0 -32
  109. package/lib/exports/database/types/tables/mysUserInfo.js +0 -7
  110. package/lib/exports/mys/api/apis.d.ts +0 -82
  111. package/lib/exports/mys/api/apis.js +0 -56
  112. package/lib/exports/mys/api/app.d.ts +0 -60
  113. package/lib/exports/mys/api/app.js +0 -32
  114. package/lib/exports/mys/api/define.d.ts +0 -6
  115. package/lib/exports/mys/api/define.js +0 -42
  116. package/lib/exports/mys/api/index.d.ts +0 -11
  117. package/lib/exports/mys/api/index.js +0 -63
  118. package/lib/exports/mys/types/api/define.d.ts +0 -6
  119. package/lib/exports/mys/types/api/define.js +0 -1
  120. package/lib/exports/mys/types/api/index.d.ts +0 -6
  121. package/lib/exports/mys/types/api/index.js +0 -2
  122. package/lib/exports/mys/types/index.d.ts +0 -12
  123. package/lib/exports/mys/types/index.js +0 -6
  124. package/lib/exports/mys/types/user/game.d.ts +0 -23
  125. package/lib/exports/mys/types/user/game.js +0 -1
  126. package/lib/exports/mys/types/user/index.d.ts +0 -12
  127. package/lib/exports/mys/types/user/index.js +0 -3
  128. package/lib/exports/mys/types/user/userInfo.d.ts +0 -43
  129. package/lib/exports/mys/types/user/userInfo.js +0 -1
  130. package/lib/exports/mys/user/deviceInfo.d.ts +0 -11
  131. package/lib/exports/mys/user/deviceInfo.js +0 -30
  132. package/lib/exports/mys/user/game.d.ts +0 -40
  133. package/lib/exports/mys/user/game.js +0 -9
  134. package/lib/exports/mys/user/index.d.ts +0 -14
  135. package/lib/exports/mys/user/index.js +0 -52
  136. package/lib/exports/mys/user/userInfo.d.ts +0 -53
  137. package/lib/exports/mys/user/userInfo.js +0 -44
  138. package/lib/exports/render/render.d.ts +0 -38
  139. package/lib/exports/render/render.js +0 -12
  140. package/lib/exports/utils/common.d.ts +0 -1
  141. package/lib/exports/utils/common.js +0 -15
  142. package/lib/exports/utils/types/common.d.ts +0 -11
  143. package/lib/exports/utils/types/common.js +0 -1
  144. package/lib/exports/utils/types/index.d.ts +0 -1
  145. package/lib/exports/utils/types/index.js +0 -2
  146. package/resources/image/frame-logo.png +0 -0
  147. package/resources/image/launcher-icon//345/216/237/347/245/236.png +0 -0
  148. package/resources/image/launcher-icon//345/264/251/345/235/2173.png +0 -0
  149. package/resources/image/launcher-icon//345/264/251/345/235/217/345/255/246/345/233/2552.png +0 -0
  150. package/resources/image/launcher-icon//345/264/251/345/235/217/357/274/232/345/233/240/347/274/230/347/262/276/347/201/265.png +0 -0
  151. package/resources/image/launcher-icon//345/264/251/345/235/217/357/274/232/346/230/237/347/251/271/351/223/201/351/201/223.png +0 -0
  152. package/resources/image/launcher-icon//346/230/237/345/270/203/350/260/267/345/234/260.png +0 -0
  153. package/resources/image/launcher-icon//346/234/252/345/256/232/344/272/213/344/273/266/347/260/277.png +0 -0
  154. package/resources/image/launcher-icon//347/273/235/345/214/272/351/233/266.png +0 -0
  155. package/resources/image/mys-core-logo.png +0 -0
  156. package/resources/image/mys-logo.png +0 -0
@@ -1,77 +0,0 @@
1
- import {
2
- dir
3
- } from "./chunk-SHLPPEAY.js";
4
- import {
5
- common_exports
6
- } from "./chunk-5DXIT7UB.js";
7
-
8
- // src/exports/render/render.ts
9
- import karin, { config, existToMkdirSync, karinPathBase } from "node-karin";
10
- import fs from "fs";
11
- import path from "path";
12
- import React from "react";
13
- import { renderToString } from "react-dom/server";
14
- var ReactRender = class {
15
- #renderCfg;
16
- #pluginOptions;
17
- constructor(cfg, pluginOptions = {}) {
18
- this.#renderCfg = cfg;
19
- this.#pluginOptions = pluginOptions;
20
- }
21
- get plugin() {
22
- return {
23
- ...this.#pluginOptions,
24
- name: this.#renderCfg.name,
25
- version: this.#renderCfg.version,
26
- resources: {
27
- default: path.join(this.#renderCfg.pluginDir, "resources").replace(/\\/g, "/"),
28
- download: this.#renderCfg.ResourcesDir.replace(/\\/g, "/")
29
- }
30
- };
31
- }
32
- get karin() {
33
- return {
34
- version: config.pkg().version
35
- };
36
- }
37
- async template(template, component, props, options = {}) {
38
- const element = React.createElement(component, props);
39
- const appHtml = renderToString(element);
40
- const coreCssPath = path.join(dir.pluginDir, "resources", "styles", `${dir.name}.css`).replace(/\\/g, "/");
41
- const cssPath = this.#renderCfg.name !== dir.name ? path.join(this.plugin.resources.default, "styles", `${this.#renderCfg.name}.css`).replace(/\\/g, "/") : "";
42
- const Html = `
43
- <!DOCTYPE html>
44
- <html lang="zh-CN">
45
- <head>
46
- <meta charset="UTF-8">
47
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
48
- <link rel="stylesheet" href="${coreCssPath}">
49
- <link rel="stylesheet" href="${cssPath}">
50
- </head>
51
- <body>
52
- ${appHtml}
53
- </body>
54
- </html>
55
- `;
56
- const saveDir = path.join(karinPathBase, "temp", "html", this.#renderCfg.name, template);
57
- existToMkdirSync(saveDir);
58
- const savePath = path.join(saveDir, `${options.render?.name || template}-${common_exports.randomString(8, "Lower")}.html`).replace(/\\/g, "/");
59
- fs.writeFileSync(savePath, Html, "utf-8");
60
- const image = await karin.render({
61
- type: options.type || "jpeg",
62
- omitBackground: options.type === "png",
63
- selector: "container",
64
- setViewport: {
65
- deviceScaleFactor: 3
66
- },
67
- ...options.render || {},
68
- file: savePath
69
- });
70
- if (!image) return null;
71
- return "base64://" + image;
72
- }
73
- };
74
-
75
- export {
76
- ReactRender
77
- };
File without changes
File without changes
@@ -1,219 +0,0 @@
1
- import {
2
- DbBase
3
- } from "./chunk-3JN5WYUN.js";
4
- import {
5
- DatabaseArray
6
- } from "./chunk-JVJQKRJ4.js";
7
- import {
8
- dir
9
- } from "./chunk-SHLPPEAY.js";
10
-
11
- // src/exports/database/dbs/sqlite3.ts
12
- import { existsSync, json, logger, mkdirSync, rmSync } from "node-karin";
13
- import fs from "fs";
14
- import path from "path";
15
- import { DataTypes, Op, Sequelize } from "sequelize";
16
- var dialect = "sqlite" /* Sqlite */;
17
- var sequelize = new Sequelize({
18
- storage: path.join(dir.DataDir, "database", "sqlite3.db"),
19
- dialect,
20
- logging: false
21
- });
22
- var Sqlite3 = class extends DbBase {
23
- dialect = dialect;
24
- async check() {
25
- try {
26
- await sequelize.authenticate();
27
- return true;
28
- } catch (error) {
29
- logger.error(error);
30
- return false;
31
- }
32
- }
33
- async init(DataDir, modelName, modelSchema, modelSchemaDefine, type, primaryKey) {
34
- this.initBase(DataDir, modelName, modelSchema, modelSchemaDefine, type, primaryKey);
35
- if (this.databaseType === "db" /* Db */) {
36
- this.model = sequelize.define(this.modelName, this.modelSchema, {
37
- timestamps: false,
38
- freezeTableName: true
39
- });
40
- await this.model.sync();
41
- const queryInterface = sequelize.getQueryInterface();
42
- const tableDescription = await queryInterface.describeTable(this.modelName);
43
- for (const key in this.modelSchema) {
44
- if (!tableDescription[key]) {
45
- await queryInterface.addColumn(this.modelName, key, this.modelSchema[key]);
46
- if (typeof this.modelSchema[key] === "string") continue;
47
- const defaultValue = this.modelSchema[key].defaultValue;
48
- if (defaultValue !== void 0) {
49
- await this.model.update({ [key]: defaultValue }, { where: {} });
50
- }
51
- }
52
- }
53
- }
54
- return this;
55
- }
56
- async findByPk(pk, create = false) {
57
- if (this.databaseType !== "db" /* Db */) {
58
- const path2 = this.userPath(pk);
59
- if (!existsSync(path2)) {
60
- if (create) {
61
- const data = this.schemaToJSON(pk);
62
- if (this.databaseType === "dir" /* Dir */) {
63
- mkdirSync(path2);
64
- this.writeDirSync(pk, data);
65
- return {
66
- ...data,
67
- save: this.saveDir(pk),
68
- destroy: () => this.destroyPath(pk)
69
- };
70
- } else {
71
- json.writeSync(path2, data);
72
- return {
73
- ...data,
74
- save: this.saveFile(pk),
75
- destroy: () => this.destroyPath(pk)
76
- };
77
- }
78
- }
79
- return void 0;
80
- }
81
- if (this.databaseType === "dir" /* Dir */) {
82
- return this.readDirSync(pk);
83
- } else {
84
- return this.readSync(path2, pk);
85
- }
86
- } else {
87
- let result = await this.model.findByPk(pk);
88
- if (!result && create) {
89
- result = await this.model.create(this.schemaToJSON(pk));
90
- }
91
- if (!result) return void 0;
92
- return {
93
- ...result.toJSON(),
94
- save: this.saveSql(result, pk),
95
- destroy: () => this.destroySql(pk)
96
- };
97
- }
98
- }
99
- async findAllByPks(pks) {
100
- if (this.databaseType !== "db" /* Db */) {
101
- const result = [];
102
- pks.forEach((pk) => {
103
- const path2 = this.userPath(pk);
104
- if (existsSync(path2)) {
105
- if (this.databaseType === "dir" /* Dir */) {
106
- result.push(this.readDirSync(pk));
107
- } else {
108
- result.push(this.readSync(path2, pk));
109
- }
110
- }
111
- });
112
- return result;
113
- } else {
114
- const result = await this.model.findAll({
115
- where: {
116
- [this.model.primaryKeyAttribute]: pks
117
- }
118
- });
119
- return result.map((item) => ({
120
- ...item.toJSON(),
121
- save: this.saveSql(item, item[this.model.primaryKeyAttribute]),
122
- destroy: () => this.destroySql(item[this.model.primaryKeyAttribute])
123
- }));
124
- }
125
- }
126
- async findAll(excludePks) {
127
- const excludeSet = new Set(excludePks || []);
128
- if (this.databaseType !== "db" /* Db */) {
129
- const result = [];
130
- const files = fs.readdirSync(this.databasePath);
131
- if (this.databaseType === "dir" /* Dir */) {
132
- files.forEach((file) => {
133
- if (excludeSet.has(file)) return;
134
- const stat = fs.statSync(path.join(this.databasePath, file));
135
- if (stat.isDirectory()) {
136
- result.push(this.readDirSync(file));
137
- }
138
- });
139
- } else {
140
- files.forEach((file) => {
141
- if (!file.endsWith(".json")) return;
142
- const pk = file.replace(".json", "");
143
- if (excludeSet.has(pk)) return;
144
- result.push(this.readSync(this.userPath(pk), pk));
145
- });
146
- }
147
- return result;
148
- } else {
149
- const whereClause = excludePks && excludePks.length > 0 ? { [this.model.primaryKeyAttribute]: { [Op.notIn]: excludePks } } : {};
150
- const result = await this.model.findAll({ where: whereClause });
151
- return result.map((item) => ({
152
- ...item.toJSON(),
153
- save: this.saveSql(item, item[this.model.primaryKeyAttribute]),
154
- destroy: () => this.destroySql(item[this.model.primaryKeyAttribute])
155
- }));
156
- }
157
- }
158
- async destroy(pk) {
159
- if (this.databaseType !== "db" /* Db */) {
160
- rmSync(this.userPath(pk), { recursive: true });
161
- return true;
162
- } else {
163
- const destroyed = await this.model.destroy({
164
- where: { [this.model.primaryKeyAttribute]: pk }
165
- });
166
- return destroyed > 0;
167
- }
168
- }
169
- };
170
- var Sqlite3Static = new class Sqlite3Static2 {
171
- dialect = dialect;
172
- description = "\u63D2\u4EF6\u9ED8\u8BA4\u6570\u636E\u5E93";
173
- Column(type, def, option) {
174
- return {
175
- type: DataTypes[type],
176
- defaultValue: def,
177
- ...option
178
- };
179
- }
180
- ArrayColumn(key, fn) {
181
- return {
182
- ArrayColumn: true,
183
- type: DataTypes.STRING,
184
- defaultValue: [].join(","),
185
- get() {
186
- const data = this.getDataValue(key).split(",").filter(Boolean);
187
- return new DatabaseArray(data);
188
- },
189
- set(data) {
190
- const setData = (fn ? fn(data) : data) || [];
191
- this.setDataValue(key, setData.join(","));
192
- }
193
- };
194
- }
195
- JsonColumn(key, def) {
196
- return {
197
- JsonColumn: true,
198
- type: DataTypes.STRING,
199
- defaultValue: JSON.stringify(def),
200
- get() {
201
- let data = this.getDataValue(key);
202
- try {
203
- data = JSON.parse(data) || def;
204
- } catch (e) {
205
- data = def;
206
- }
207
- return data;
208
- },
209
- set(data) {
210
- this.setDataValue(key, JSON.stringify(data));
211
- }
212
- };
213
- }
214
- }();
215
-
216
- export {
217
- Sqlite3,
218
- Sqlite3Static
219
- };
File without changes
@@ -1,80 +0,0 @@
1
- // src/exports/config/array.ts
2
- import { logger } from "node-karin";
3
- import lodash from "node-karin/lodash";
4
- var EnhancedArray = class _EnhancedArray extends Array {
5
- #keyPath;
6
- #cfg;
7
- constructor(cfg, items, path) {
8
- super();
9
- Object.setPrototypeOf(this, _EnhancedArray.prototype);
10
- if (Array.isArray(items)) {
11
- this.push(...items);
12
- }
13
- this.#cfg = cfg;
14
- this.#keyPath = path;
15
- }
16
- /**
17
- * @param element - string | number
18
- * @returns
19
- */
20
- has(element) {
21
- return new Set(this).has(element);
22
- }
23
- /**
24
- * @param isEqual 是否不添加重复元素
25
- * @param save 是否立即保存
26
- */
27
- add(element, isEqual, save) {
28
- if (isEqual) {
29
- const existingSet = new Set(this.map((item) => JSON.stringify(item)));
30
- if (existingSet.has(JSON.stringify(element))) return this;
31
- }
32
- this.push(element);
33
- this.#cfg.set(this.#keyPath, this.slice(), save);
34
- return this;
35
- }
36
- /**
37
- * @param isEqual 是否不添加重复元素
38
- * @param save 是否立即保存
39
- */
40
- addSome(elements, isEqual, save) {
41
- if (isEqual) {
42
- const existingSet = new Set(this.map((item) => JSON.stringify(item)));
43
- elements = elements.filter((element) => !existingSet.has(JSON.stringify(element)));
44
- if (elements.length === 0) return this;
45
- }
46
- this.push(...elements);
47
- this.#cfg.set(this.#keyPath, this.slice(), save);
48
- return this;
49
- }
50
- /** @description 删除指定索引 */
51
- pullAt(idx, save) {
52
- if (idx < 0 || idx >= this.length) {
53
- logger.error(`\u7D22\u5F15 ${idx} \u8D85\u51FA\u8303\u56F4 [0, ${this.length - 1}]`);
54
- return this;
55
- }
56
- lodash.pullAt(this, idx);
57
- this.#cfg.set(this.#keyPath, this.slice(), save);
58
- return this;
59
- }
60
- /** @description 删除指定元素 */
61
- pullAll(elements, save) {
62
- lodash.pullAll(this, elements);
63
- this.#cfg.set(this.#keyPath, this.slice(), save);
64
- return this;
65
- }
66
- /** @description 使用条件函数删除元素 */
67
- remove(predicate, save) {
68
- lodash.remove(this, predicate);
69
- this.#cfg.set(this.#keyPath, this.slice(), save);
70
- return this;
71
- }
72
- clear() {
73
- this.length = 0;
74
- return this;
75
- }
76
- };
77
-
78
- export {
79
- EnhancedArray
80
- };
File without changes
File without changes
@@ -1,10 +0,0 @@
1
- // src/exports/database/types/tables/mysAccountInfo.ts
2
- var MysAccountType = /* @__PURE__ */ ((MysAccountType2) => {
3
- MysAccountType2["cn"] = "mihoyo";
4
- MysAccountType2["os"] = "hoyolab";
5
- return MysAccountType2;
6
- })(MysAccountType || {});
7
-
8
- export {
9
- MysAccountType
10
- };
File without changes
@@ -1,109 +0,0 @@
1
- import {
2
- common_exports
3
- } from "./chunk-5DXIT7UB.js";
4
- import {
5
- EnhancedArray
6
- } from "./chunk-PMFOX5HA.js";
7
-
8
- // src/exports/config/config.ts
9
- import { existsSync, existToMkdirSync, logger, requireFileSync, watch, writeJsonSync } from "node-karin";
10
- import lodash from "node-karin/lodash";
11
- import path from "path";
12
- var Config = class {
13
- #cfgName;
14
- /**
15
- * @description 配置缓存
16
- */
17
- #ConfigCache = null;
18
- /**
19
- * @description 默认配置
20
- */
21
- #DefaultConfig;
22
- #DefineConfig;
23
- /**
24
- * @description 配置保存路径
25
- */
26
- #ConfigPath;
27
- /**
28
- * @param name 插件名称:配置名称
29
- */
30
- constructor(name, ConfigDir, DefaultConfig, DefineConfig) {
31
- this.#cfgName = name;
32
- const splitName = name.split(":");
33
- if (!splitName[1]) {
34
- throw new Error("\u914D\u7F6E\u540D\u79F0\u683C\u5F0F\u9519\u8BEF\uFF0C\u5E94\u4E3A \u63D2\u4EF6\u540D\u79F0:\u914D\u7F6E\u540D\u79F0");
35
- }
36
- this.#ConfigPath = path.join(ConfigDir, `${splitName[1]}.json`);
37
- this.#DefaultConfig = DefaultConfig;
38
- this.#DefineConfig = DefineConfig;
39
- existToMkdirSync(ConfigDir);
40
- !existsSync(this.#ConfigPath) && writeJsonSync(this.#ConfigPath, DefaultConfig, true);
41
- this.loadConfig();
42
- }
43
- loadConfig() {
44
- const config = requireFileSync(this.#ConfigPath);
45
- const mergedConfig = this.mergeWithDefaults(config, this.#DefaultConfig, this.#DefineConfig);
46
- this.#ConfigCache = mergedConfig;
47
- return mergedConfig;
48
- }
49
- mergeWithDefaults(userConfig, defaultConfig, DefineConfig) {
50
- const filteredUserConfig = common_exports.filterData(userConfig, defaultConfig, DefineConfig);
51
- const result = lodash.merge({}, defaultConfig, filteredUserConfig);
52
- if (!lodash.isEqual(result, userConfig)) {
53
- try {
54
- writeJsonSync(this.#ConfigPath, result);
55
- } catch (err) {
56
- logger.error(err);
57
- }
58
- }
59
- return result;
60
- }
61
- /**
62
- * @description 获取配置路径对应的默认配置
63
- */
64
- getDef(path2) {
65
- const defConfig = JSON.parse(JSON.stringify(this.#DefaultConfig));
66
- return lodash.get(defConfig, path2);
67
- }
68
- get(path2, isArray = false, def) {
69
- const conf = JSON.parse(JSON.stringify(this.#ConfigCache));
70
- const result = path2 ? lodash.get(conf, path2, def) : conf;
71
- if (isArray) {
72
- if (!Array.isArray(result)) {
73
- logger.error(`\u914D\u7F6E\u8DEF\u5F84 ${path2} \u4E0D\u662F\u6570\u7EC4\u7C7B\u578B`);
74
- return new EnhancedArray(this, [], path2);
75
- }
76
- return new EnhancedArray(this, result, path2);
77
- }
78
- return result;
79
- }
80
- /**
81
- * @param save 是否立即保存
82
- */
83
- set(path2, value, save) {
84
- lodash.set(this.#ConfigCache, path2, value);
85
- save && this.save();
86
- }
87
- /**
88
- * @description 立即保存配置
89
- */
90
- save() {
91
- try {
92
- logger.debug(`[${this.#cfgName}] \u4FDD\u5B58\u914D\u7F6E`, this.#ConfigCache);
93
- writeJsonSync(this.#ConfigPath, this.#ConfigCache);
94
- } catch (err) {
95
- logger.error(err);
96
- }
97
- }
98
- watch(fnc) {
99
- watch(this.#ConfigPath, async (oldData, newData) => {
100
- fnc && await fnc(this, oldData, newData);
101
- this.loadConfig();
102
- });
103
- return this;
104
- }
105
- };
106
-
107
- export {
108
- Config
109
- };
File without changes
File without changes
File without changes
@@ -1,38 +0,0 @@
1
- import {
2
- createTable
3
- } from "./chunk-G7TMVDGP.js";
4
- import {
5
- Database
6
- } from "./chunk-DMJ5OQR6.js";
7
- import {
8
- dir
9
- } from "./chunk-SHLPPEAY.js";
10
- import {
11
- common_exports
12
- } from "./chunk-5DXIT7UB.js";
13
-
14
- // src/exports/database/tables/mysDeviceInfo.ts
15
- var MysDeviceInfoTable = createTable(
16
- dir.DataDir,
17
- "mys_device_info_data",
18
- "db" /* Db */
19
- );
20
- var MysDeviceInfoDB = await MysDeviceInfoTable.init(
21
- {
22
- md5: Database.PkColumn("STRING"),
23
- deviceId: Database.Column("STRING", common_exports.getDeviceGuid),
24
- deviceFp: Database.Column("STRING", ""),
25
- name: Database.Column("STRING", ""),
26
- board: Database.Column("STRING", ""),
27
- model: Database.Column("STRING", ""),
28
- oaid: Database.Column("STRING", ""),
29
- version: Database.Column("INTEGER", 12),
30
- fingerprint: Database.Column("STRING", ""),
31
- product: Database.Column("STRING", "")
32
- }
33
- );
34
-
35
- export {
36
- MysDeviceInfoTable,
37
- MysDeviceInfoDB
38
- };
@@ -1,35 +0,0 @@
1
- /**
2
- * @description 生成随机字符串
3
- * @param length - 字符串长度
4
- */
5
- declare const randomString: (length: number, type: "Lower" | "Upper" | "All") => string;
6
- /**
7
- * @description 生成设备guid
8
- */
9
- declare const getDeviceGuid: () => string;
10
- /**
11
- * @description 将字符串解析为key-value键值对
12
- * @param Str - 字符串
13
- * @param sep - 分隔符
14
- */
15
- declare const StrToObj: <D extends {
16
- [key: string]: string;
17
- }>(Str: string, sep: string | RegExp) => Partial<D>;
18
- /**
19
- * @description 将key-value键值对解析为字符串
20
- * @param obj - key-value键值对
21
- * @param sep - 分隔符
22
- */
23
- declare const ObjToStr: (obj: Record<string, string | number>, sep: string) => string;
24
- declare function filterData(user: any, defaults: any, Define: any): any;
25
-
26
- declare const common_ObjToStr: typeof ObjToStr;
27
- declare const common_StrToObj: typeof StrToObj;
28
- declare const common_filterData: typeof filterData;
29
- declare const common_getDeviceGuid: typeof getDeviceGuid;
30
- declare const common_randomString: typeof randomString;
31
- declare namespace common {
32
- export { common_ObjToStr as ObjToStr, common_StrToObj as StrToObj, common_filterData as filterData, common_getDeviceGuid as getDeviceGuid, common_randomString as randomString };
33
- }
34
-
35
- export { ObjToStr as O, StrToObj as S, common as c, filterData as f, getDeviceGuid as g, randomString as r };