@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/fs/index.ts +18 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doki-land/live2d",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "keywords": [
5
5
  "live2d",
6
6
  "pixi",
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
- for (const file of fs.readdirSync(folder)) {
49
- const filePath = path.join(folder, file);
50
- const stat = fs.statSync(filePath);
51
- if (stat.isDirectory()) {
52
- if (depth > 0) {
53
- models.push(...findAllModels(filePath, depth - 1));
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[]): string[] {
77
- const models: string[] = [];
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(new URL(model, url).href);
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.model_url);
88
+ models.push(model);
84
89
  }
85
90
  return models
86
91
  }