mm_os 2.9.9 → 3.0.0

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/lib/app.js DELETED
@@ -1,145 +0,0 @@
1
- const Base = require("./base.js");
2
-
3
- /**
4
- * 应用管理器
5
- */
6
- class App extends Base {
7
- constructor() {
8
- super();
9
- this.path = "./app".fullname();
10
- // 文件拓展名
11
- this.extension = "app.json";
12
- // 重新加载
13
- this.reload = false;
14
- this.init();
15
- }
16
- }
17
-
18
- /**
19
- * 补全脚本
20
- * @param {Object} action
21
- */
22
- App.prototype.fullAction = function(action) {
23
- if (action.data.state === undefined) {
24
- action.data.state = 1;
25
- }
26
- if (!action.methods.init_before) {
27
- action.init_before = function() {
28
- // 创建插件
29
- this.plugin = $.plugin_admin(action.key, action.title || action.name);
30
- }
31
- }
32
- if (!action.methods.start_after) {
33
- action.start_after = function() {
34
- this.plugin.update(action.jsonFile.dirname()).then(() => {
35
- this.plugin.run(null, 'init').then(() => {
36
- this.plugin.run(null, 'start');
37
- });
38
- });
39
- }
40
- }
41
- return action;
42
- }
43
-
44
- /**
45
- * 应用管理器初始化后
46
- */
47
- App.prototype.init_after = function() {
48
- for (var k in this.dict) {
49
- var cs = this.dict[k];
50
- var key = cs.jsonFile.dirname().basename();
51
- cs.key = key;
52
- this[key] = cs;
53
- }
54
- }
55
-
56
- /**
57
- * 初始化应用
58
- */
59
- App.prototype.initApp = async function() {
60
- for (var k in this.dict) {
61
- var o = this.dict[k];
62
- if (o.state) {
63
- try {
64
- await o.run('init');
65
- } catch (e) {
66
- $.log.error("初始化应用错误", e);
67
- }
68
- }
69
- }
70
- }
71
-
72
- /**
73
- * 运行应用
74
- */
75
- App.prototype.runApp = async function() {
76
- for (var k in this.dict) {
77
- var o = this.dict[k];
78
- if (o.state) {
79
- try {
80
- await o.run('start');
81
- } catch (e) {
82
- $.log.error("初始化应用错误", e);
83
- }
84
- }
85
- }
86
- }
87
-
88
- /**
89
- * 启动应用
90
- */
91
- App.prototype.startApp = async function() {
92
- for (var k in this.dict) {
93
- var o = this.dict[k];
94
- try {
95
- o.state = 1;
96
- await o.run('start');
97
- } catch (e) {
98
- $.log.error("启动应用错误", e);
99
- }
100
- }
101
- }
102
-
103
- /**
104
- * 停止应用
105
- */
106
- App.prototype.stopApp = async function() {
107
- for (var k in this.dict) {
108
- var o = this.dict[k];
109
- try {
110
- o.state = 0;
111
- await o.run('stop');
112
- } catch (e) {
113
- $.log.error("停止应用错误", e);
114
- }
115
- }
116
- }
117
-
118
- /**
119
- * 安装应用
120
- */
121
- App.prototype.install = async function(name, ...args) {
122
- return await this.exec(name, 'install', ...args);
123
- }
124
-
125
- /**
126
- * 卸载
127
- */
128
- App.prototype.uninstall = async function(name, ...args) {
129
- return await this.exec(name, 'uninstall', ...args);
130
- }
131
-
132
- /**
133
- * 启动
134
- */
135
- App.prototype.start = async function(name, ...args) {
136
- return await this.exec(name, 'start', ...args);
137
- }
138
-
139
- /**
140
- * 停止
141
- */
142
- App.prototype.stop = async function(name, ...args) {
143
- return await this.exec(name, 'stop', ...args);
144
- }
145
- module.exports = App;
package/lib/game.js DELETED
@@ -1,29 +0,0 @@
1
- const Base = require("./base.js");
2
-
3
- /**
4
- * 游戏管理器
5
- */
6
- class Game extends Base {
7
- constructor() {
8
- super();
9
- this.path = "./game".fullname();
10
- // 文件拓展名
11
- this.extension = "game.json";
12
- // 重新加载
13
- this.reload = false;
14
- this.init();
15
- }
16
- }
17
-
18
- /**
19
- * 游戏管理器初始化后
20
- */
21
- Game.prototype.init_after = function() {
22
- for (var k in this.dict) {
23
- var cs = this.dict[k];
24
- var key = cs.jsonFile.dirname().basename();
25
- this[key] = cs;
26
- }
27
- }
28
-
29
- module.exports = Game;