@dobot-plus/template 1.2.7 → 1.2.9

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 (69) hide show
  1. package/.dobot/components/DobotPlusApp.tsx +78 -78
  2. package/.dobot/http/axios.ts +52 -52
  3. package/.dobot/http/http.ts +22 -22
  4. package/.dobot/index.ts +2 -2
  5. package/.dobot/protocol/methodsHandler.ts +15 -15
  6. package/.dobot/protocol/postMessageHandler.ts +289 -289
  7. package/.dobot/protocol/websocketHandler.ts +3 -3
  8. package/.dobot/shim.d.ts +3 -3
  9. package/.dobot/store/actions/toolActions.ts +69 -69
  10. package/.dobot/store/actions/userManagementActions.ts +25 -0
  11. package/.dobot/store/reducers/index.ts +8 -8
  12. package/.dobot/store/reducers/toolReducer.ts +152 -152
  13. package/.dobot/store/reducers/userManagementReducer.ts +35 -0
  14. package/.dobot/store/types.ts +237 -240
  15. package/.dobot/template/default.tsx.mustache +19 -19
  16. package/.dobot/template/entry.css +25 -25
  17. package/.dobot/template/entry.tsx +53 -53
  18. package/.dobot/template/index.html +23 -23
  19. package/.dobot/template/index.scss +5 -5
  20. package/.dobot/utils/i18n.ts +31 -31
  21. package/.dobot/utils/mqtt.ts +61 -61
  22. package/.dobot/utils/rem.js +21 -21
  23. package/.dobot/utils/tool.ts +15 -15
  24. package/.eslintrc.cjs +18 -18
  25. package/.luarc.json +8 -8
  26. package/.vscode/Api.schema.json +103 -103
  27. package/.vscode/Blocks.schema.json +94 -94
  28. package/.vscode/Main.schema.json +42 -42
  29. package/.vscode/Script.schema.json +22 -22
  30. package/.vscode/Toolbar.schema.json +19 -19
  31. package/.vscode/extensions.json +8 -8
  32. package/.vscode/settings.json +51 -51
  33. package/Resources/i18n/client/de.json +11 -11
  34. package/Resources/i18n/client/en.json +11 -11
  35. package/Resources/i18n/client/es.json +11 -11
  36. package/Resources/i18n/client/hk.json +11 -11
  37. package/Resources/i18n/client/ja.json +11 -11
  38. package/Resources/i18n/client/ko.json +11 -11
  39. package/Resources/i18n/client/ru.json +11 -11
  40. package/Resources/i18n/client/zh.json +11 -11
  41. package/Resources/i18n/plugin/de.json +3 -3
  42. package/Resources/i18n/plugin/en.json +3 -3
  43. package/Resources/i18n/plugin/es.json +3 -3
  44. package/Resources/i18n/plugin/hk.json +3 -3
  45. package/Resources/i18n/plugin/ja.json +3 -3
  46. package/Resources/i18n/plugin/ko.json +3 -3
  47. package/Resources/i18n/plugin/ru.json +3 -3
  48. package/Resources/i18n/plugin/zh.json +3 -3
  49. package/configs/Blocks.json +21 -21
  50. package/configs/Main.json +5 -5
  51. package/configs/Scripts.json +7 -7
  52. package/configs/Toolbar.json +5 -5
  53. package/dpt.json +4 -4
  54. package/lua/control.lua +18 -18
  55. package/lua/daemon.lua +22 -22
  56. package/lua/httpAPI.lua +66 -66
  57. package/lua/userAPI.lua +51 -51
  58. package/lua/utils/mqtt.lua +16 -16
  59. package/lua/utils/num_convert.lua +41 -41
  60. package/lua/utils/tcp.lua +30 -30
  61. package/lua/utils/util.lua +30 -30
  62. package/package.json +58 -49
  63. package/project.json +3 -3
  64. package/tsconfig.json +26 -26
  65. package/ui/Blocks.tsx +5 -5
  66. package/ui/Main.tsx +31 -31
  67. package/ui/Toolbar.tsx +5 -5
  68. package/.dobot/store/actions/userMagamentActions.ts +0 -25
  69. package/.dobot/store/reducers/userMagamentReducer.ts +0 -38
@@ -1,23 +1,23 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Document</title>
7
- <style>
8
- body,
9
- html {
10
- height: 100%;
11
- }
12
- body,
13
- html {
14
- margin: 0;
15
- padding: 0;
16
- }
17
- </style>
18
- </head>
19
-
20
- <body>
21
- <div id="root"></div>
22
- </body>
23
- </html>
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Document</title>
7
+ <style>
8
+ body,
9
+ html {
10
+ height: 100%;
11
+ }
12
+ body,
13
+ html {
14
+ margin: 0;
15
+ padding: 0;
16
+ }
17
+ </style>
18
+ </head>
19
+
20
+ <body>
21
+ <div id="root"></div>
22
+ </body>
23
+ </html>
@@ -1,5 +1,5 @@
1
- body,
2
- html {
3
- padding: 0;
4
- margin: 0;
5
- }
1
+ body,
2
+ html {
3
+ padding: 0;
4
+ margin: 0;
5
+ }
@@ -1,31 +1,31 @@
1
- import zh from '../../Resources/i18n/plugin/zh.json'
2
- import de from '../../Resources/i18n/plugin/de.json'
3
- import ja from '../../Resources/i18n/plugin/ja.json'
4
- import ko from '../../Resources/i18n/plugin/ko.json'
5
- import en from '../../Resources/i18n/plugin/en.json'
6
- import ru from '../../Resources/i18n/plugin/ru.json'
7
- import es from '../../Resources/i18n/plugin/es.json'
8
- import hk from '../../Resources/i18n/plugin/hk.json'
9
-
10
- import i18n from 'i18next'
11
- import { initReactI18next } from 'react-i18next'
12
-
13
- i18n.use(initReactI18next).init({
14
- resources: {
15
- en: { translation: en },
16
- zh: { translation: zh },
17
- de: { translation: de },
18
- ja: { translation: ja },
19
- ko: { translation: ko },
20
- ru: { translation: ru },
21
- es: { translation: es },
22
- hk: { translation: hk }
23
- },
24
- lng: 'zh',
25
- interpolation: {
26
- escapeValue: false
27
- },
28
- fallbackLng: 'en'
29
- })
30
-
31
- export default i18n
1
+ import zh from '../../Resources/i18n/plugin/zh.json'
2
+ import de from '../../Resources/i18n/plugin/de.json'
3
+ import ja from '../../Resources/i18n/plugin/ja.json'
4
+ import ko from '../../Resources/i18n/plugin/ko.json'
5
+ import en from '../../Resources/i18n/plugin/en.json'
6
+ import ru from '../../Resources/i18n/plugin/ru.json'
7
+ import es from '../../Resources/i18n/plugin/es.json'
8
+ import hk from '../../Resources/i18n/plugin/hk.json'
9
+
10
+ import i18n from 'i18next'
11
+ import { initReactI18next } from 'react-i18next'
12
+
13
+ i18n.use(initReactI18next).init({
14
+ resources: {
15
+ en: { translation: en },
16
+ zh: { translation: zh },
17
+ de: { translation: de },
18
+ ja: { translation: ja },
19
+ ko: { translation: ko },
20
+ ru: { translation: ru },
21
+ es: { translation: es },
22
+ hk: { translation: hk }
23
+ },
24
+ lng: 'zh',
25
+ interpolation: {
26
+ escapeValue: false
27
+ },
28
+ fallbackLng: 'en'
29
+ })
30
+
31
+ export default i18n
@@ -1,61 +1,61 @@
1
- import { connect, MqttClient, IClientOptions } from 'mqtt'
2
- export class MqttWebSocketClient {
3
- private client!: MqttClient
4
- private receiveMessageHandle!: (topic: string, msg: Buffer) => void
5
- private serverUrl: string
6
- private clientId: string
7
- private options: IClientOptions
8
- public constructor(serverUrl: string, clientId: string, options?: IClientOptions) {
9
- this.serverUrl = serverUrl
10
- this.clientId = clientId
11
- this.options = options || {}
12
- }
13
-
14
- //连接
15
- public connect(): void {
16
- this.client = connect(this.serverUrl, {
17
- clientId: this.clientId,
18
- ...this.options
19
- })
20
- this.client.on('connect', this.onConnect)
21
- this.client.on('message', this.onMessage) //接收消息
22
- this.client.on('error', this.onError)
23
- }
24
- //断开连接
25
- public disconnect(): void {
26
- if (this.client) {
27
- this.client.end()
28
- }
29
- }
30
-
31
- // 订阅
32
- public subscribe(topic: string, receiveMessageHandle?: (topic: string, msg: Buffer) => void): void {
33
- if (this.client) {
34
- this.client.subscribe(topic)
35
- if (receiveMessageHandle) {
36
- this.receiveMessageHandle = receiveMessageHandle
37
- }
38
- }
39
- }
40
- //取消订阅
41
- public unsubscribe(topic: string): void {
42
- if (this.client) {
43
- this.client.unsubscribe(topic)
44
- }
45
- }
46
- // 发布消息
47
- public publish(topic: string, message: string | Buffer): void {
48
- if (this.client) {
49
- this.client.publish(topic, message)
50
- }
51
- }
52
- private onConnect = (): void => {}
53
- private onMessage = (topic: string, message: Buffer): void => {
54
- if (this.receiveMessageHandle) {
55
- this.receiveMessageHandle(topic, message)
56
- }
57
- }
58
- private onError = (error: Error): void => {
59
- console.log('连接错误:', error)
60
- }
61
- }
1
+ import { connect, MqttClient, IClientOptions } from 'mqtt'
2
+ export class MqttWebSocketClient {
3
+ private client!: MqttClient
4
+ private receiveMessageHandle!: (topic: string, msg: Buffer) => void
5
+ private serverUrl: string
6
+ private clientId: string
7
+ private options: IClientOptions
8
+ public constructor(serverUrl: string, clientId: string, options?: IClientOptions) {
9
+ this.serverUrl = serverUrl
10
+ this.clientId = clientId
11
+ this.options = options || {}
12
+ }
13
+
14
+ //连接
15
+ public connect(): void {
16
+ this.client = connect(this.serverUrl, {
17
+ clientId: this.clientId,
18
+ ...this.options
19
+ })
20
+ this.client.on('connect', this.onConnect)
21
+ this.client.on('message', this.onMessage) //接收消息
22
+ this.client.on('error', this.onError)
23
+ }
24
+ //断开连接
25
+ public disconnect(): void {
26
+ if (this.client) {
27
+ this.client.end()
28
+ }
29
+ }
30
+
31
+ // 订阅
32
+ public subscribe(topic: string, receiveMessageHandle?: (topic: string, msg: Buffer) => void): void {
33
+ if (this.client) {
34
+ this.client.subscribe(topic)
35
+ if (receiveMessageHandle) {
36
+ this.receiveMessageHandle = receiveMessageHandle
37
+ }
38
+ }
39
+ }
40
+ //取消订阅
41
+ public unsubscribe(topic: string): void {
42
+ if (this.client) {
43
+ this.client.unsubscribe(topic)
44
+ }
45
+ }
46
+ // 发布消息
47
+ public publish(topic: string, message: string | Buffer): void {
48
+ if (this.client) {
49
+ this.client.publish(topic, message)
50
+ }
51
+ }
52
+ private onConnect = (): void => {}
53
+ private onMessage = (topic: string, message: Buffer): void => {
54
+ if (this.receiveMessageHandle) {
55
+ this.receiveMessageHandle(topic, message)
56
+ }
57
+ }
58
+ private onError = (error: Error): void => {
59
+ console.log('连接错误:', error)
60
+ }
61
+ }
@@ -1,21 +1,21 @@
1
- ;(function (doc, win) {
2
- var docEl = doc.documentElement,
3
- resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
4
- recalc = function () {
5
- var clientWidth = docEl.clientWidth
6
- var clientHeight = docEl.clientHeight
7
- if (!clientWidth) return
8
- if (clientWidth >= 596 && clientHeight >= 624) {
9
- docEl.style.fontSize = '100px'
10
- } else if (clientWidth < 596 && clientHeight >= 624) {
11
- docEl.style.fontSize = 100 * (clientWidth / 596) + 'px'
12
- } else if (clientWidth >= 596 && clientHeight < 624) {
13
- docEl.style.fontSize = 100 * (clientHeight / 624) + 'px'
14
- } else {
15
- docEl.style.fontSize = 100 * (clientWidth / 624) + 'px'
16
- }
17
- }
18
- if (!doc.addEventListener) return
19
- win.addEventListener(resizeEvt, recalc, false)
20
- doc.addEventListener('DOMContentLoaded', recalc, false)
21
- })(document, window)
1
+ ;(function (doc, win) {
2
+ var docEl = doc.documentElement,
3
+ resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
4
+ recalc = function () {
5
+ var clientWidth = docEl.clientWidth
6
+ var clientHeight = docEl.clientHeight
7
+ if (!clientWidth) return
8
+ if (clientWidth >= 596 && clientHeight >= 624) {
9
+ docEl.style.fontSize = '100px'
10
+ } else if (clientWidth < 596 && clientHeight >= 624) {
11
+ docEl.style.fontSize = 100 * (clientWidth / 596) + 'px'
12
+ } else if (clientWidth >= 596 && clientHeight < 624) {
13
+ docEl.style.fontSize = 100 * (clientHeight / 624) + 'px'
14
+ } else {
15
+ docEl.style.fontSize = 100 * (clientWidth / 624) + 'px'
16
+ }
17
+ }
18
+ if (!doc.addEventListener) return
19
+ win.addEventListener(resizeEvt, recalc, false)
20
+ doc.addEventListener('DOMContentLoaded', recalc, false)
21
+ })(document, window)
@@ -1,15 +1,15 @@
1
- export const isInIframe = window.self !== window.top
2
-
3
- export const jsonSafeParse = (data: string|object) => {
4
- if (typeof data === 'string') {
5
- try {
6
- const obj = JSON.parse(data)
7
- if (typeof obj === 'object' && obj) {
8
- return obj
9
- }
10
- } catch (e) {
11
- return data
12
- }
13
- }
14
- return data
15
- }
1
+ export const isInIframe = window.self !== window.top
2
+
3
+ export const jsonSafeParse = (data: string|object) => {
4
+ if (typeof data === 'string') {
5
+ try {
6
+ const obj = JSON.parse(data)
7
+ if (typeof obj === 'object' && obj) {
8
+ return obj
9
+ }
10
+ } catch (e) {
11
+ return data
12
+ }
13
+ }
14
+ return data
15
+ }
package/.eslintrc.cjs CHANGED
@@ -1,18 +1,18 @@
1
- module.exports = {
2
- root: true,
3
- env: { browser: true, es2020: true },
4
- extends: [
5
- 'eslint:recommended',
6
- 'plugin:@typescript-eslint/recommended',
7
- 'plugin:react-hooks/recommended',
8
- ],
9
- ignorePatterns: ['dist', '.eslintrc.cjs'],
10
- parser: '@typescript-eslint/parser',
11
- plugins: ['react-refresh'],
12
- rules: {
13
- 'react-refresh/only-export-components': [
14
- 'warn',
15
- { allowConstantExport: true },
16
- ]
17
- },
18
- }
1
+ module.exports = {
2
+ root: true,
3
+ env: { browser: true, es2020: true },
4
+ extends: [
5
+ 'eslint:recommended',
6
+ 'plugin:@typescript-eslint/recommended',
7
+ 'plugin:react-hooks/recommended',
8
+ ],
9
+ ignorePatterns: ['dist', '.eslintrc.cjs'],
10
+ parser: '@typescript-eslint/parser',
11
+ plugins: ['react-refresh'],
12
+ rules: {
13
+ 'react-refresh/only-export-components': [
14
+ 'warn',
15
+ { allowConstantExport: true },
16
+ ]
17
+ },
18
+ }
package/.luarc.json CHANGED
@@ -1,8 +1,8 @@
1
- {
2
- "workspace.library": ["./node_modules/@dobot-plus/lua"],
3
- "workspace.ignoreDir": [".vscode", "node_modules", "configs", "Resources", "ui", "dist"],
4
- "runtime.version": "Lua 5.4",
5
- "diagnostics": {
6
- "enable": true
7
- }
8
- }
1
+ {
2
+ "workspace.library": ["./node_modules/@dobot-plus/lua"],
3
+ "workspace.ignoreDir": [".vscode", "node_modules", "configs", "Resources", "ui", "dist"],
4
+ "runtime.version": "Lua 5.4",
5
+ "diagnostics": {
6
+ "enable": true
7
+ }
8
+ }
@@ -1,103 +1,103 @@
1
- {
2
- "title": "AxiosRequestConfig",
3
- "type": "object",
4
- "description": "The request config.",
5
- "patternProperties": {
6
- "^[a-zA-Z_][a-zA-Z0-9_]*$": {
7
- "type": "object",
8
- "properties": {
9
- "url": {
10
- "type": "string",
11
- "description": "The URL to send the request to."
12
- },
13
- "method": {
14
- "type": "string",
15
- "description": "The HTTP method to use for the request.",
16
- "enum": ["get", "post", "put", "delete", "patch", "options", "head"]
17
- },
18
- "baseURL": {
19
- "type": "string",
20
- "description": "The base URL to be used in requests."
21
- },
22
- "headers": {
23
- "type": "object",
24
- "description": "HTTP headers to be sent with the request.",
25
- "additionalProperties": {
26
- "type": "string"
27
- }
28
- },
29
- "params": {
30
- "type": "object",
31
- "description": "URL parameters to be sent with the request.",
32
- "additionalProperties": {
33
- "type": ["string", "number", "boolean", "null", "array", "object"]
34
- }
35
- },
36
- "data": {
37
- "description": "The data to be sent as the request body.",
38
- "type": ["string", "object", "array", "null"]
39
- },
40
- "timeout": {
41
- "type": "number",
42
- "description": "The number of milliseconds before the request times out."
43
- },
44
- "withCredentials": {
45
- "type": "boolean",
46
- "description": "Indicates whether or not cross-site Access-Control requests should be made using credentials."
47
- },
48
- "responseType": {
49
- "type": "string",
50
- "description": "Indicates the type of data that the server will respond with.",
51
- "enum": ["arraybuffer", "document", "json", "text", "stream", "blob"]
52
- },
53
- "maxContentLength": {
54
- "type": "number",
55
- "description": "Specifies the max number of bytes for the content of the request."
56
- },
57
- "validateStatus": {
58
- "description": "Defines whether to resolve or reject the promise for a given HTTP status code.",
59
- "instanceof": "Function"
60
- },
61
- "maxRedirects": {
62
- "type": "number",
63
- "description": "The maximum number of redirects to follow in node.js."
64
- },
65
- "socketPath": {
66
- "type": "string",
67
- "description": "The UNIX socket to be used in node.js."
68
- },
69
- "proxy": {
70
- "type": "object",
71
- "description": "Proxy configuration to use for the request.",
72
- "properties": {
73
- "host": {
74
- "type": "string"
75
- },
76
- "port": {
77
- "type": "number"
78
- },
79
- "auth": {
80
- "type": "object",
81
- "properties": {
82
- "username": {
83
- "type": "string"
84
- },
85
- "password": {
86
- "type": "string"
87
- }
88
- },
89
- "required": ["username", "password"]
90
- }
91
- },
92
- "required": ["host", "port"]
93
- },
94
- "cancelToken": {
95
- "description": "A cancel token that can be used to cancel the request.",
96
- "instanceof": "CancelToken"
97
- }
98
- },
99
- "required": [],
100
- "additionalProperties": false
101
- }
102
- }
103
- }
1
+ {
2
+ "title": "AxiosRequestConfig",
3
+ "type": "object",
4
+ "description": "The request config.",
5
+ "patternProperties": {
6
+ "^[a-zA-Z_][a-zA-Z0-9_]*$": {
7
+ "type": "object",
8
+ "properties": {
9
+ "url": {
10
+ "type": "string",
11
+ "description": "The URL to send the request to."
12
+ },
13
+ "method": {
14
+ "type": "string",
15
+ "description": "The HTTP method to use for the request.",
16
+ "enum": ["get", "post", "put", "delete", "patch", "options", "head"]
17
+ },
18
+ "baseURL": {
19
+ "type": "string",
20
+ "description": "The base URL to be used in requests."
21
+ },
22
+ "headers": {
23
+ "type": "object",
24
+ "description": "HTTP headers to be sent with the request.",
25
+ "additionalProperties": {
26
+ "type": "string"
27
+ }
28
+ },
29
+ "params": {
30
+ "type": "object",
31
+ "description": "URL parameters to be sent with the request.",
32
+ "additionalProperties": {
33
+ "type": ["string", "number", "boolean", "null", "array", "object"]
34
+ }
35
+ },
36
+ "data": {
37
+ "description": "The data to be sent as the request body.",
38
+ "type": ["string", "object", "array", "null"]
39
+ },
40
+ "timeout": {
41
+ "type": "number",
42
+ "description": "The number of milliseconds before the request times out."
43
+ },
44
+ "withCredentials": {
45
+ "type": "boolean",
46
+ "description": "Indicates whether or not cross-site Access-Control requests should be made using credentials."
47
+ },
48
+ "responseType": {
49
+ "type": "string",
50
+ "description": "Indicates the type of data that the server will respond with.",
51
+ "enum": ["arraybuffer", "document", "json", "text", "stream", "blob"]
52
+ },
53
+ "maxContentLength": {
54
+ "type": "number",
55
+ "description": "Specifies the max number of bytes for the content of the request."
56
+ },
57
+ "validateStatus": {
58
+ "description": "Defines whether to resolve or reject the promise for a given HTTP status code.",
59
+ "instanceof": "Function"
60
+ },
61
+ "maxRedirects": {
62
+ "type": "number",
63
+ "description": "The maximum number of redirects to follow in node.js."
64
+ },
65
+ "socketPath": {
66
+ "type": "string",
67
+ "description": "The UNIX socket to be used in node.js."
68
+ },
69
+ "proxy": {
70
+ "type": "object",
71
+ "description": "Proxy configuration to use for the request.",
72
+ "properties": {
73
+ "host": {
74
+ "type": "string"
75
+ },
76
+ "port": {
77
+ "type": "number"
78
+ },
79
+ "auth": {
80
+ "type": "object",
81
+ "properties": {
82
+ "username": {
83
+ "type": "string"
84
+ },
85
+ "password": {
86
+ "type": "string"
87
+ }
88
+ },
89
+ "required": ["username", "password"]
90
+ }
91
+ },
92
+ "required": ["host", "port"]
93
+ },
94
+ "cancelToken": {
95
+ "description": "A cancel token that can be used to cancel the request.",
96
+ "instanceof": "CancelToken"
97
+ }
98
+ },
99
+ "required": [],
100
+ "additionalProperties": false
101
+ }
102
+ }
103
+ }