mm_os 4.3.7 → 5.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.
Files changed (232) hide show
  1. package/README.md +101 -504
  2. package/index.js +26 -19
  3. package/lib/loader.js +787 -0
  4. package/lib/os.js +369 -0
  5. package/package.json +55 -84
  6. package/LICENSE +0 -21
  7. package/README_EN.md +0 -505
  8. package/adapter/adapter.js +0 -484
  9. package/adapter/custom_persistence.js +0 -661
  10. package/adapter/mqtt.js +0 -254
  11. package/adapter/socket.js +0 -244
  12. package/adapter/web.js +0 -92
  13. package/adapter/websocket.js +0 -43
  14. package/ai.js +0 -130
  15. package/com/api/README.md +0 -3
  16. package/com/api/com.json +0 -5
  17. package/com/api/config.tpl.json +0 -41
  18. package/com/api/drive.js +0 -732
  19. package/com/api/index.js +0 -201
  20. package/com/api/oauth.js +0 -200
  21. package/com/api/script.tpl.js +0 -32
  22. package/com/cmd/README.md +0 -11
  23. package/com/cmd/com.json +0 -5
  24. package/com/cmd/config.tpl.json +0 -48
  25. package/com/cmd/drive.js +0 -176
  26. package/com/cmd/index.js +0 -287
  27. package/com/cmd/job/config.json +0 -66
  28. package/com/cmd/job/index.js +0 -241
  29. package/com/cmd/job/test.js +0 -188
  30. package/com/cmd/msg.json +0 -48
  31. package/com/cmd/script.tpl.js +0 -12
  32. package/com/db/README.md +0 -3
  33. package/com/db/com.json +0 -5
  34. package/com/db/drive.js +0 -2206
  35. package/com/db/index.js +0 -241
  36. package/com/event/README.md +0 -4
  37. package/com/event/com.json +0 -5
  38. package/com/event/config.tpl.json +0 -20
  39. package/com/event/drive.js +0 -61
  40. package/com/event/index.js +0 -438
  41. package/com/event/script.tpl.js +0 -23
  42. package/com/mqtt/README.md +0 -47
  43. package/com/mqtt/com.json +0 -5
  44. package/com/mqtt/config.tpl.json +0 -42
  45. package/com/mqtt/drive.js +0 -704
  46. package/com/mqtt/index.js +0 -1052
  47. package/com/mqtt/index.test.js +0 -503
  48. package/com/mqtt/script.tpl.js +0 -719
  49. package/com/nav/README.md +0 -2
  50. package/com/nav/com.json +0 -5
  51. package/com/nav/config.tpl.json +0 -84
  52. package/com/nav/drive.js +0 -702
  53. package/com/nav/index.js +0 -228
  54. package/com/nav/tpl/admin_pc/page_channel.vue +0 -305
  55. package/com/nav/tpl/admin_pc/page_config.vue +0 -280
  56. package/com/nav/tpl/admin_pc/page_config_form.vue +0 -194
  57. package/com/nav/tpl/admin_pc/page_default.vue +0 -247
  58. package/com/nav/tpl/admin_pc/page_form.vue +0 -180
  59. package/com/nav/tpl/admin_pc/page_lang.vue +0 -264
  60. package/com/nav/tpl/admin_pc/page_nav.vue +0 -321
  61. package/com/nav/tpl/admin_pc/page_table.vue +0 -296
  62. package/com/nav/tpl/admin_pc/page_type.vue +0 -321
  63. package/com/nav/tpl/admin_pc/page_view.vue +0 -124
  64. package/com/nav/tpl/dev_pc/page_channel.vue +0 -253
  65. package/com/nav/tpl/dev_pc/page_config.vue +0 -253
  66. package/com/nav/tpl/dev_pc/page_default.vue +0 -247
  67. package/com/nav/tpl/dev_pc/page_form.vue +0 -162
  68. package/com/nav/tpl/dev_pc/page_nav.vue +0 -253
  69. package/com/nav/tpl/dev_pc/page_table.vue +0 -247
  70. package/com/nav/tpl/dev_pc/page_type.vue +0 -313
  71. package/com/nav/tpl/home_pc/page_channel.vue +0 -234
  72. package/com/nav/tpl/home_pc/page_default.vue +0 -234
  73. package/com/nav/tpl/home_pc/page_form.vue +0 -137
  74. package/com/nav/tpl/home_pc/page_list.vue +0 -234
  75. package/com/nav/tpl/home_pc/page_nav.vue +0 -221
  76. package/com/nav/tpl/home_pc/page_type.vue +0 -234
  77. package/com/nav/tpl/home_pc/page_view.vue +0 -125
  78. package/com/nav/tpl/home_phone/page_channel.vue +0 -234
  79. package/com/nav/tpl/home_phone/page_default.vue +0 -234
  80. package/com/nav/tpl/home_phone/page_form.vue +0 -137
  81. package/com/nav/tpl/home_phone/page_list.vue +0 -234
  82. package/com/nav/tpl/home_phone/page_nav.vue +0 -237
  83. package/com/nav/tpl/home_phone/page_type.vue +0 -234
  84. package/com/nav/tpl/home_phone/page_view.vue +0 -125
  85. package/com/nav/viewmodel.js +0 -446
  86. package/com/param/README.md +0 -2
  87. package/com/param/com.json +0 -5
  88. package/com/param/config.tpl.json +0 -136
  89. package/com/param/drive.js +0 -502
  90. package/com/param/index.js +0 -158
  91. package/com/param/script.tpl.js +0 -12
  92. package/com/pendant/README.md +0 -3
  93. package/com/pendant/com.json +0 -5
  94. package/com/pendant/config.tpl.json +0 -32
  95. package/com/pendant/drive.js +0 -204
  96. package/com/pendant/index.js +0 -467
  97. package/com/pendant/pendant.html +0 -16
  98. package/com/pendant/script.tpl.js +0 -18
  99. package/com/socket/README.md +0 -47
  100. package/com/socket/com.json +0 -5
  101. package/com/socket/config.tpl.json +0 -12
  102. package/com/socket/drive.js +0 -679
  103. package/com/socket/index.js +0 -402
  104. package/com/socket/script.tpl.js +0 -41
  105. package/com/sql/README.md +0 -3
  106. package/com/sql/com.json +0 -5
  107. package/com/sql/config.tpl.json +0 -74
  108. package/com/sql/drive.js +0 -1328
  109. package/com/sql/index.js +0 -152
  110. package/com/sql/script.tpl.js +0 -47
  111. package/com/static/README.md +0 -2
  112. package/com/static/com.json +0 -5
  113. package/com/static/config.tpl.json +0 -24
  114. package/com/static/drive.js +0 -194
  115. package/com/static/index.js +0 -237
  116. package/com/static/script.tpl.js +0 -28
  117. package/com/task/README.md +0 -3
  118. package/com/task/com.json +0 -5
  119. package/com/task/config.tpl.json +0 -24
  120. package/com/task/drive.js +0 -428
  121. package/com/task/index.js +0 -159
  122. package/com/task/script.tpl.js +0 -40
  123. package/com/template/com.json +0 -5
  124. package/com/template/config.tpl.json +0 -16
  125. package/com/template/drive.js +0 -81
  126. package/com/template/index.js +0 -141
  127. package/com.js +0 -237
  128. package/common/README.md +0 -2
  129. package/common/middleware/web_after/index.js +0 -26
  130. package/common/middleware/web_after/middleware.json +0 -9
  131. package/common/middleware/web_base/index.js +0 -113
  132. package/common/middleware/web_base/middleware.json +0 -19
  133. package/common/middleware/web_before/index.js +0 -33
  134. package/common/middleware/web_before/middleware.json +0 -9
  135. package/common/middleware/web_cors/index.js +0 -87
  136. package/common/middleware/web_cors/middleware.json +0 -24
  137. package/common/middleware/web_error/index.js +0 -131
  138. package/common/middleware/web_error/middleware.json +0 -19
  139. package/common/middleware/web_ip/index.js +0 -15
  140. package/common/middleware/web_ip/middleware.json +0 -14
  141. package/common/middleware/web_logger/index.js +0 -156
  142. package/common/middleware/web_logger/middleware.json +0 -14
  143. package/common/middleware/web_main/index.js +0 -26
  144. package/common/middleware/web_main/middleware.json +0 -9
  145. package/common/middleware/web_static/index.js +0 -73
  146. package/common/middleware/web_static/middleware.json +0 -54
  147. package/common/middleware/web_waf/index.js +0 -395
  148. package/common/middleware/web_waf/middleware.json +0 -13
  149. package/core/app/config.tpl.json +0 -67
  150. package/core/app/index.js +0 -711
  151. package/core/app/script.tpl.js +0 -52
  152. package/core/channel/index.js +0 -899
  153. package/core/channel/matcher.js +0 -585
  154. package/core/com/config.tpl.json +0 -16
  155. package/core/com/index.js +0 -77
  156. package/core/com/script.tpl.js +0 -5
  157. package/core/component/component.js +0 -42
  158. package/core/component/config.tpl.json +0 -63
  159. package/core/component/index.js +0 -273
  160. package/core/component/script.tpl.js +0 -19
  161. package/core/controller/config.tpl.json +0 -14
  162. package/core/controller/index.js +0 -371
  163. package/core/controller/script.tpl.js +0 -27
  164. package/core/factory/config.tpl.json +0 -14
  165. package/core/factory/entity.js +0 -275
  166. package/core/factory/index.js +0 -241
  167. package/core/factory/script.tpl.js +0 -16
  168. package/core/game/bat/index.js +0 -137
  169. package/core/game/bat/world.js +0 -622
  170. package/core/game/config.tpl.json +0 -16
  171. package/core/game/entity_admin.js +0 -230
  172. package/core/game/index.js +0 -186
  173. package/core/handler/config.tpl.json +0 -22
  174. package/core/handler/index.js +0 -181
  175. package/core/handler/script.tpl.js +0 -23
  176. package/core/logic/config.tpl.json +0 -14
  177. package/core/logic/index.js +0 -59
  178. package/core/logic/script.tpl.js +0 -19
  179. package/core/middleware/config.tpl.json +0 -16
  180. package/core/middleware/index.js +0 -117
  181. package/core/middleware/script.tpl.js +0 -37
  182. package/core/mod/config.tpl.json +0 -22
  183. package/core/mod/index.js +0 -136
  184. package/core/mod/script.tpl.js +0 -34
  185. package/core/model/config.tpl.json +0 -219
  186. package/core/model/index.js +0 -272
  187. package/core/model/model.js +0 -27
  188. package/core/model/script.tpl.js +0 -20
  189. package/core/notifier/config.tpl.json +0 -14
  190. package/core/notifier/index.js +0 -77
  191. package/core/notifier/script.tpl.js +0 -20
  192. package/core/plugin/config.tpl.json +0 -36
  193. package/core/plugin/index.js +0 -267
  194. package/core/plugin/script.tpl.js +0 -51
  195. package/core/pusher/config.tpl.json +0 -14
  196. package/core/pusher/index.js +0 -158
  197. package/core/pusher/script.tpl.js +0 -20
  198. package/core/room/bat/index.js +0 -170
  199. package/core/room/bat/room.js +0 -524
  200. package/core/room/config.tpl.json +0 -20
  201. package/core/room/index.js +0 -249
  202. package/core/room/room.js +0 -61
  203. package/core/scene/config.tpl.json +0 -14
  204. package/core/scene/index.js +0 -467
  205. package/core/scene/loop.js +0 -1306
  206. package/core/scene/map.js +0 -28
  207. package/core/scene/script.tpl.js +0 -22
  208. package/core/sender/config.tpl.json +0 -14
  209. package/core/sender/index.js +0 -79
  210. package/core/sender/script.tpl.js +0 -20
  211. package/core/service/config.tpl.json +0 -14
  212. package/core/service/index.js +0 -100
  213. package/core/service/script.tpl.js +0 -25
  214. package/core/store/config.tpl.json +0 -26
  215. package/core/store/index.js +0 -1794
  216. package/core/store/script.tpl.js +0 -22
  217. package/core/system/config.tpl.json +0 -18
  218. package/core/system/index.js +0 -312
  219. package/core/system/script.tpl.js +0 -77
  220. package/core/view/config.tpl.json +0 -14
  221. package/core/view/index.js +0 -91
  222. package/core/view/script.tpl.js +0 -20
  223. package/core/zone/bat/index.js +0 -744
  224. package/core/zone/config.tpl.json +0 -54
  225. package/core/zone/index.js +0 -655
  226. package/core/zone/script.tpl.js +0 -10
  227. package/core/zone/zone_bat.js +0 -136
  228. package/core//345/237/272/347/261/273/346/250/241/345/235/227/346/270/205/345/215/225.md +0 -24
  229. package/os.js +0 -53
  230. package/server.js +0 -602
  231. package/ulits/id_gen.js +0 -134
  232. package/ulits/word.js +0 -206
package/ulits/id_gen.js DELETED
@@ -1,134 +0,0 @@
1
- /**
2
- * ID生成器
3
- * 基于雪花算法实现,生成唯一ID
4
- */
5
- class IdGen {
6
- /**
7
- * 构造函数
8
- * @param {object} config 配置参数
9
- * @param {number} config.worker_id 工作机器ID (0-31)
10
- * @param {number} config.dc_id 数据中心ID (0-31)
11
- * @param {number} config.sequence 序列号
12
- */
13
- constructor(config = {}) {
14
- this.worker_id = config.worker_id || 0;
15
- this.dc_id = config.dc_id || 0;
16
- this.sequence = config.sequence || 0;
17
-
18
- this.worker_id_bits = 5;
19
- this.dc_id_bits = 5;
20
- this.max_worker_id = -1 ^ (-1 << this.worker_id_bits);
21
- this.max_dc_id = -1 ^ (-1 << this.dc_id_bits);
22
- this.sequence_bits = 12;
23
-
24
- this.worker_id_shift = this.sequence_bits;
25
- this.dc_id_shift = this.sequence_bits + this.worker_id_bits;
26
- this.timestamp_left_shift = this.sequence_bits + this.worker_id_bits + this.dc_id_bits;
27
- this.sequence_mask = -1 ^ (-1 << this.sequence_bits);
28
-
29
- this.last_timestamp = -1;
30
-
31
- this.twepoch = 1288834974657;
32
-
33
- if (this.worker_id > this.max_worker_id || this.worker_id < 0) {
34
- throw new TypeError(`工作机器ID必须在0-${this.max_worker_id}之间`);
35
- }
36
- if (this.dc_id > this.max_dc_id || this.dc_id < 0) {
37
- throw new TypeError(`数据中心ID必须在0-${this.max_dc_id}之间`);
38
- }
39
- }
40
- }
41
-
42
- /**
43
- * 获取当前时间戳
44
- * @returns {number} 当前时间戳
45
- */
46
- IdGen.prototype._timeGen = function () {
47
- return Date.now();
48
- };
49
-
50
- /**
51
- * 等待下一毫秒
52
- * @param {number} last_timestamp 上次时间戳
53
- * @returns {number} 新的时间戳
54
- */
55
- IdGen.prototype._tilNextMillis = function (last_timestamp) {
56
- var timestamp = this._timeGen();
57
- while (timestamp <= last_timestamp) {
58
- timestamp = this._timeGen();
59
- }
60
- return timestamp;
61
- };
62
-
63
- /**
64
- * 生成下一个ID
65
- * @returns {string} 唯一ID
66
- */
67
- IdGen.prototype.nextId = function () {
68
- var timestamp = this._timeGen();
69
-
70
- if (timestamp < this.last_timestamp) {
71
- throw new Error('时钟回拨,拒绝生成ID');
72
- }
73
-
74
- if (this.last_timestamp === timestamp) {
75
- this.sequence = (this.sequence + 1) & this.sequence_mask;
76
- if (this.sequence === 0) {
77
- timestamp = this._tilNextMillis(this.last_timestamp);
78
- }
79
- } else {
80
- this.sequence = 0;
81
- }
82
-
83
- this.last_timestamp = timestamp;
84
-
85
- var id = (BigInt(timestamp - this.twepoch) << BigInt(this.timestamp_left_shift))
86
- | (BigInt(this.dc_id) << BigInt(this.dc_id_shift))
87
- | (BigInt(this.worker_id) << BigInt(this.worker_id_shift))
88
- | BigInt(this.sequence);
89
-
90
- return id.toString();
91
- };
92
-
93
- /**
94
- * 生成带前缀的ID
95
- * @param {string} prefix 前缀
96
- * @returns {string} 带前缀的唯一ID
97
- */
98
- IdGen.prototype.genId = function (prefix) {
99
- if (typeof prefix !== 'string') {
100
- throw new TypeError('前缀必须是字符串');
101
- }
102
- return prefix + '_' + this.nextId();
103
- };
104
-
105
- /**
106
- * 解析ID信息
107
- * @param {string} id ID字符串
108
- * @returns {object} ID信息对象
109
- */
110
- IdGen.prototype.parseId = function (id) {
111
- if (typeof id !== 'string') {
112
- throw new TypeError('ID必须是字符串');
113
- }
114
- var num = BigInt(id.replace(/^[a-zA-Z_]+_/, ''));
115
- var timestamp = Number((num >> 22n) + BigInt(this.twepoch));
116
- var dc_id = Number((num >> 17n) & 31n);
117
- var worker_id = Number((num >> 12n) & 31n);
118
- var sequence = Number(num & 4095n);
119
-
120
- return {
121
- timestamp: timestamp,
122
- datetime: new Date(timestamp).toISOString(),
123
- dc_id: dc_id,
124
- worker_id: worker_id,
125
- sequence: sequence
126
- };
127
- };
128
-
129
- var idGen = new IdGen();
130
-
131
- module.exports = {
132
- IdGen,
133
- idGen
134
- };
package/ulits/word.js DELETED
@@ -1,206 +0,0 @@
1
- /**
2
- * 单词工具类
3
- * @class Word
4
- */
5
- class Word {
6
- /**
7
- * 构造函数
8
- */
9
- constructor() {
10
-
11
- }
12
- }
13
-
14
- /**
15
- * 分割单词
16
- * @param {string} name 名称
17
- * @returns {Array} 单词数组
18
- */
19
- Word.prototype.splitWords = function (name) {
20
- if (!name || name.length === 0) {
21
- return [];
22
- }
23
-
24
- var words = [];
25
- var current_word = '';
26
- var last_char_type = null;
27
-
28
- for (var i = 0; i < name.length; i++) {
29
- var char = name[i];
30
- var char_info = this._getCharInfo(char);
31
-
32
- // 处理下划线和数字
33
- if (char_info.is_under || char_info.is_digit) {
34
- last_char_type = this._handleSepa(words, current_word, char, char_info);
35
- current_word = '';
36
- continue;
37
- }
38
-
39
- // 处理第一个字符
40
- if (current_word.length === 0) {
41
- current_word = char;
42
- last_char_type = char_info.type;
43
- continue;
44
- }
45
-
46
- // 处理字符转换
47
- var result = this._handleCharTran(words, current_word, char, last_char_type, char_info.type);
48
- words = result.words;
49
- current_word = result.current_word;
50
- last_char_type = char_info.type;
51
- }
52
-
53
- // 添加最后一个单词
54
- if (current_word.length > 0) {
55
- words.push(current_word);
56
- }
57
-
58
- return words;
59
- };
60
-
61
- /**
62
- * 获取字符信息
63
- * @param {string} char 字符
64
- * @returns {object} 字符信息
65
- * @private
66
- */
67
- Word.prototype._getCharInfo = function (char) {
68
- var is_upper = char >= 'A' && char <= 'Z';
69
- var is_lower = char >= 'a' && char <= 'z';
70
- var is_digit = char >= '0' && char <= '9';
71
- var type = is_upper ? 'upper' : (is_lower ? 'lower' : (is_digit ? 'digit' : 'other'));
72
- return { is_upper, is_lower, is_digit, is_under: char === '_', type };
73
- };
74
-
75
- /**
76
- * 处理分隔符
77
- * @param {Array} words 单词数组
78
- * @param {string} current_word 当前单词
79
- * @param {string} char 字符
80
- * @param {object} char_info 字符信息
81
- * @returns {string} 新的字符类型
82
- * @private
83
- */
84
- Word.prototype._handleSepa = function (words, current_word, char, char_info) {
85
- if (current_word.length > 0) {
86
- words.push(current_word);
87
- }
88
- if (char_info.is_digit) {
89
- words.push(char);
90
- return 'digit';
91
- }
92
- return 'underscore';
93
- };
94
-
95
- /**
96
- * 处理字符转换
97
- * @param {Array} words 单词数组
98
- * @param {string} current_word 当前单词
99
- * @param {string} char 字符
100
- * @param {string} last_type 上一个字符类型
101
- * @param {string} current_type 当前字符类型
102
- * @returns {object} 处理结果
103
- * @private
104
- */
105
- Word.prototype._handleCharTran = function (
106
- words, current_word, char, last_type, current_type
107
- ) {
108
- var is_last_letter = last_type === 'upper' || last_type === 'lower';
109
- var is_current_letter = current_type === 'upper' || current_type === 'lower';
110
-
111
- if (!is_last_letter || !is_current_letter) {
112
- return { words, current_word: current_word + char };
113
- }
114
-
115
- if (last_type === 'upper' && current_type === 'lower') {
116
- // 大写转小写
117
- if (current_word.length > 1) {
118
- var last_char = current_word[current_word.length - 1];
119
- words.push(current_word.substring(0, current_word.length - 1));
120
- return { words, current_word: last_char + char };
121
- }
122
- return { words, current_word: current_word + char };
123
- }
124
-
125
- if (last_type === 'lower' && current_type === 'upper') {
126
- // 小写转大写
127
- words.push(current_word);
128
- return { words, current_word: char };
129
- }
130
-
131
- // 相同类型
132
- return { words, current_word: current_word + char };
133
- };
134
-
135
- /**
136
- * 将名称改为帕斯卡命名法
137
- * @param {string} name 名称
138
- * @returns {string} 帕斯卡命名法的名称
139
- */
140
- Word.prototype.toPascalCase = function (name) {
141
- var words = this.splitWords(name);
142
- for (let i = 0; i < words.length; i++) {
143
- words[i] = words[i].toLowerCase();
144
- words[i] = words[i].charAt(0).toUpperCase() + words[i].substring(1);
145
- }
146
- return words.join('');
147
- };
148
-
149
- /**
150
- * 将名称改为驼峰命名法
151
- * @param {string} name 名称
152
- * @returns {string} 驼峰命名法的名称
153
- */
154
- Word.prototype.toCamelCase = function (name) {
155
- var words = this.splitWords(name);
156
- for (let i = 0; i < words.length; i++) {
157
- words[i] = words[i].toLowerCase();
158
- if (i > 0) {
159
- words[i] = words[i].charAt(0).toUpperCase() + words[i].substring(1);
160
- }
161
- }
162
- return words.join('');
163
- };
164
-
165
- /**
166
- * 将名称改为小写蛇形(下划线)命名法
167
- * @param {string} name 名称
168
- * @returns {string} 小写蛇形(下划线)命名法的名称
169
- */
170
- Word.prototype.toSnakeCase = function (name) {
171
- var words = this.splitWords(name);
172
- for (let i = 0; i < words.length; i++) {
173
- words[i] = words[i].toLowerCase();
174
- }
175
- return words.join('_');
176
- };
177
-
178
- /**
179
- * 将名称改为大写蛇形(下划线)命名法
180
- * @param {string} name 名称
181
- * @returns {string} 大写蛇形(下划线)命名法的名称
182
- */
183
- Word.prototype.toUpperSnakeCase = function (name) {
184
- var words = this.splitWords(name);
185
- for (let i = 0; i < words.length; i++) {
186
- words[i] = words[i].toUpperCase();
187
- }
188
- return words.join('_');
189
- };
190
-
191
- /**
192
- * 将名称改为小写短横线(短横线)命名法
193
- * @param {string} name 名称
194
- * @returns {string} 小写短横线(短横线)命名法的名称
195
- */
196
- Word.prototype.toKebabCase = function (name) {
197
- var words = this.splitWords(name);
198
- for (let i = 0; i < words.length; i++) {
199
- words[i] = words[i].toLowerCase();
200
- }
201
- return words.join('-');
202
- };
203
-
204
- module.exports = {
205
- Word
206
- };