@doki-land/live2d 0.0.6 → 0.0.7
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/package.json +1 -1
- package/src/fs/index.ts +18 -13
package/package.json
CHANGED
package/src/fs/index.ts
CHANGED
|
@@ -45,17 +45,20 @@ export function allowShowLive2D(currentPath: string, includePaths: string[], exc
|
|
|
45
45
|
*/
|
|
46
46
|
export function findAllModels(folder: string, depth: number = 99): string[] {
|
|
47
47
|
const models: string[] = [];
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (
|
|
53
|
-
|
|
48
|
+
if (fs.existsSync(folder)) {
|
|
49
|
+
for (const file of fs.readdirSync(folder)) {
|
|
50
|
+
const filePath = path.join(folder, file);
|
|
51
|
+
const stat = fs.statSync(filePath);
|
|
52
|
+
if (stat.isDirectory()) {
|
|
53
|
+
if (depth > 0) {
|
|
54
|
+
models.push(...findAllModels(filePath, depth - 1));
|
|
55
|
+
}
|
|
56
|
+
} else if (file.endsWith('.model.json') || file.endsWith('.model3.json')) {
|
|
57
|
+
models.push(filePath);
|
|
54
58
|
}
|
|
55
|
-
} else if (file.endsWith('.model.json') || file.endsWith('.model3.json')) {
|
|
56
|
-
models.push(filePath);
|
|
57
59
|
}
|
|
58
|
-
|
|
60
|
+
}
|
|
61
|
+
|
|
59
62
|
return models;
|
|
60
63
|
}
|
|
61
64
|
|
|
@@ -73,14 +76,16 @@ export function findAllModels(folder: string, depth: number = 99): string[] {
|
|
|
73
76
|
*
|
|
74
77
|
* 本地模型的优先级更高, 本地模型根据自然序(Natural Sort)排列
|
|
75
78
|
*/
|
|
76
|
-
export function mergeModels(base: string, local: string[], remote: ModelOptions[]):
|
|
77
|
-
const models:
|
|
79
|
+
export function mergeModels(base: string, local: string[], remote: ModelOptions[]): ModelOptions[] {
|
|
80
|
+
const models: ModelOptions[] = [];
|
|
78
81
|
const url = new URL(base);
|
|
79
82
|
for (const model of local) {
|
|
80
|
-
models.push(
|
|
83
|
+
models.push({
|
|
84
|
+
model_url: new URL(model, url).href,
|
|
85
|
+
});
|
|
81
86
|
}
|
|
82
87
|
for (const model of remote) {
|
|
83
|
-
models.push(model
|
|
88
|
+
models.push(model);
|
|
84
89
|
}
|
|
85
90
|
return models
|
|
86
91
|
}
|