verteilen-core 1.3.34 → 1.3.36

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.
@@ -5,8 +5,8 @@ export type SocketGetter = (uuid: string) => WebsocketPack | undefined;
5
5
  export interface PluginLoader {
6
6
  load_all: () => Promise<PluginPageData>;
7
7
  get_plugins: () => Promise<PluginPageData>;
8
- get_project: (name: string, group: string, filename: string) => string | undefined;
9
- get_database: (name: string, group: string, filename: string) => string | undefined;
8
+ get_project: (name: string, group: string, filename: string) => Promise<string> | undefined;
9
+ get_database: (name: string, group: string, filename: string) => Promise<string> | undefined;
10
10
  import_plugin: (name: string, url: string, token: string) => Promise<PluginPageData>;
11
11
  delete_plugin: (name: string) => Promise<void>;
12
12
  plugin_download: (uuid: string, plugin: string, tokens: string) => Promise<void>;
@@ -10,7 +10,7 @@ const GetCurrentPlugin = async (loader) => {
10
10
  if (!loader.exists(root))
11
11
  await loader.mkdir(root);
12
12
  const plugin_folder = await loader.read_dir_dir(root);
13
- const plugin_folder_files = await Promise.all(plugin_folder.map(x => loader.read_dir_file(x)));
13
+ const plugin_folder_files = await Promise.all(plugin_folder.map(x => loader.read_dir_file(loader.join(root, x))));
14
14
  for (let i = 0; i < plugin_folder_files.length; i++) {
15
15
  const files = plugin_folder_files[i];
16
16
  const dirname = plugin_folder[i];
@@ -58,22 +58,12 @@ const CreatePluginLoader = (loader, memory, socket, feedback) => {
58
58
  return memory;
59
59
  },
60
60
  get_project: (name, group, filename) => {
61
- const plugin = memory.plugins.find(x => x.title == name);
62
- if (plugin == undefined)
63
- return undefined;
64
- const result = plugin.projects.find(x => x.group == group && x.filename == filename);
65
- if (result == undefined)
66
- return undefined;
67
- return JSON.stringify(result);
61
+ const path = loader.join(loader.root, "plugin", name, "project", filename);
62
+ return loader.exists(path) ? loader.read_string(path) : undefined;
68
63
  },
69
64
  get_database: (name, group, filename) => {
70
- const plugin = memory.plugins.find(x => x.title == name);
71
- if (plugin == undefined)
72
- return undefined;
73
- const result = plugin.databases.find(x => x.group == group && x.filename == filename);
74
- if (result == undefined)
75
- return undefined;
76
- return JSON.stringify(result);
65
+ const path = loader.join(loader.root, "plugin", name, "database", filename);
66
+ return loader.exists(path) ? loader.read_string(path) : undefined;
77
67
  },
78
68
  import_plugin: async (name, url, token) => {
79
69
  const error_children = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "verteilen-core",
3
- "version": "1.3.34",
3
+ "version": "1.3.36",
4
4
  "license": "MIT",
5
5
  "homepage": "https://verteilen.github.io/wiki/",
6
6
  "author": "Elly",
@@ -41,14 +41,14 @@ export interface PluginLoader {
41
41
  * @param group Group search
42
42
  * @param filename Template filename
43
43
  */
44
- get_project: (name:string, group:string, filename:string) => string | undefined
44
+ get_project: (name:string, group:string, filename:string) => Promise<string> | undefined
45
45
  /**
46
46
  * Get database template
47
47
  * @param name Plugin name
48
48
  * @param group Group search
49
49
  * @param filename Template filename
50
50
  */
51
- get_database: (name:string, group:string, filename:string) => string | undefined
51
+ get_database: (name:string, group:string, filename:string) => Promise<string> | undefined
52
52
  /**
53
53
  * Import plugin from web
54
54
  * @param name Plugin name
@@ -90,7 +90,7 @@ export const GetCurrentPlugin = async (loader:RecordIOBase):Promise<PluginPageDa
90
90
  if(!loader.exists(root)) await loader.mkdir(root)
91
91
 
92
92
  const plugin_folder = await loader.read_dir_dir(root)
93
- const plugin_folder_files = await Promise.all(plugin_folder.map(x => loader.read_dir_file(x)))
93
+ const plugin_folder_files = await Promise.all(plugin_folder.map(x => loader.read_dir_file(loader.join(root, x))))
94
94
  for(let i = 0; i < plugin_folder_files.length; i++){
95
95
  const files = plugin_folder_files[i]
96
96
  const dirname = plugin_folder[i]
@@ -136,19 +136,13 @@ export const CreatePluginLoader = (loader:RecordIOBase, memory:PluginPageData, s
136
136
  get_plugins: async ():Promise<PluginPageData> => {
137
137
  return memory
138
138
  },
139
- get_project: (name:string, group:string, filename:string):string | undefined => {
140
- const plugin = memory.plugins.find(x => x.title == name)
141
- if(plugin == undefined) return undefined
142
- const result = plugin.projects.find(x => x.group == group && x.filename == filename)
143
- if(result == undefined) return undefined
144
- return JSON.stringify(result)
139
+ get_project: (name:string, group:string, filename:string):Promise<string> | undefined => {
140
+ const path = loader.join(loader.root, "plugin", name, "project", filename)
141
+ return loader.exists(path) ? loader.read_string(path) : undefined
145
142
  },
146
- get_database: (name:string, group:string, filename:string):string | undefined => {
147
- const plugin = memory.plugins.find(x => x.title == name)
148
- if(plugin == undefined) return undefined
149
- const result = plugin.databases.find(x => x.group == group && x.filename == filename)
150
- if(result == undefined) return undefined
151
- return JSON.stringify(result)
143
+ get_database: (name:string, group:string, filename:string):Promise<string> | undefined => {
144
+ const path = loader.join(loader.root, "plugin", name, "database", filename)
145
+ return loader.exists(path) ? loader.read_string(path) : undefined
152
146
  },
153
147
  import_plugin: async (name:string, url:string, token:string):Promise<PluginPageData> => {
154
148
  const error_children:Array<[string, string]> = []