clickgo 3.16.16 → 3.16.18

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 (63) hide show
  1. package/README.md +1 -1
  2. package/dist/app/demo/form/method/native/native.js +26 -0
  3. package/dist/app/demo/form/method/native/native.xml +2 -0
  4. package/dist/clickgo.d.ts +17 -0
  5. package/dist/clickgo.js +1 -1
  6. package/dist/control/arteditor.cgc +0 -0
  7. package/dist/control/box.cgc +0 -0
  8. package/dist/control/captcha.cgc +0 -0
  9. package/dist/control/common.cgc +0 -0
  10. package/dist/control/desc.cgc +0 -0
  11. package/dist/control/drawer.cgc +0 -0
  12. package/dist/control/echarts.cgc +0 -0
  13. package/dist/control/form.cgc +0 -0
  14. package/dist/control/iconview.cgc +0 -0
  15. package/dist/control/jodit.cgc +0 -0
  16. package/dist/control/map.cgc +0 -0
  17. package/dist/control/monaco.cgc +0 -0
  18. package/dist/control/mpegts.cgc +0 -0
  19. package/dist/control/nav.cgc +0 -0
  20. package/dist/control/page.cgc +0 -0
  21. package/dist/control/pdf.cgc +0 -0
  22. package/dist/control/property.cgc +0 -0
  23. package/dist/control/qrcode.cgc +0 -0
  24. package/dist/control/table.cgc +0 -0
  25. package/dist/control/task.cgc +0 -0
  26. package/dist/control/tplink.cgc +0 -0
  27. package/dist/control/tuieditor.cgc +0 -0
  28. package/dist/control/tuiviewer.cgc +0 -0
  29. package/dist/control/xterm.cgc +0 -0
  30. package/dist/index.d.ts +51 -0
  31. package/dist/lib/control.d.ts +53 -0
  32. package/dist/lib/core.d.ts +47 -0
  33. package/dist/lib/dom.d.ts +74 -0
  34. package/dist/lib/dom.js +7 -7
  35. package/dist/lib/form.d.ts +222 -0
  36. package/dist/lib/fs.d.ts +35 -0
  37. package/dist/lib/fs.js +2 -2
  38. package/dist/lib/native.d.ts +36 -0
  39. package/dist/lib/native.js +8 -0
  40. package/dist/lib/storage.d.ts +6 -0
  41. package/dist/lib/task.d.ts +32 -0
  42. package/dist/lib/task.js +7 -1
  43. package/dist/lib/theme.d.ts +8 -0
  44. package/dist/lib/tool.d.ts +120 -0
  45. package/dist/lib/zip.d.ts +40 -0
  46. package/dist/theme/blue.cgt +0 -0
  47. package/dist/theme/byterun.cgt +0 -0
  48. package/dist/theme/light.cgt +0 -0
  49. package/package.json +7 -5
  50. package/dist/clickgo.ts +0 -68
  51. package/dist/index.ts +0 -282
  52. package/dist/lib/control.ts +0 -751
  53. package/dist/lib/core.ts +0 -1145
  54. package/dist/lib/dom.ts +0 -2728
  55. package/dist/lib/form.ts +0 -3829
  56. package/dist/lib/fs.ts +0 -1324
  57. package/dist/lib/native.ts +0 -236
  58. package/dist/lib/storage.ts +0 -229
  59. package/dist/lib/task.ts +0 -2160
  60. package/dist/lib/theme.ts +0 -199
  61. package/dist/lib/tool.ts +0 -1278
  62. package/dist/lib/zip.ts +0 -444
  63. package/eslint.config.js +0 -22
package/dist/lib/theme.ts DELETED
@@ -1,199 +0,0 @@
1
- /**
2
- * Copyright 2024 Han Guoshuai <zohegs@gmail.com>
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * https://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import * as types from '../../types';
17
- import * as zip from './zip';
18
- import * as tool from './tool';
19
- import * as task from './task';
20
- import * as dom from './dom';
21
-
22
- /** --- 当前全局主题,App 模式下无效 --- */
23
- export let global: types.ITheme | null = null;
24
-
25
- /**
26
- * --- cgt 文件 blob 转 IThemePkg 对象,会自动创建 object url,请注意释放 ---
27
- * @param blob blob 对象
28
- */
29
- export async function read(blob: Blob): Promise<types.ITheme | false> {
30
- const z = await zip.get(blob);
31
- if (!z) {
32
- return false;
33
- }
34
- const configContent = await z.getContent('config.json');
35
- if (!configContent) {
36
- return false;
37
- }
38
- const config: types.IThemeConfig = JSON.parse(configContent);
39
- const files: Record<string, Blob | string> = {};
40
- // --- 读取包文件 ---
41
- const list = z.readDir('/', {
42
- 'hasChildren': true
43
- });
44
- for (const file of list) {
45
- const mime = tool.getMimeByPath(file.name);
46
- if (['txt', 'json', 'js', 'css', 'xml', 'html'].includes(mime.ext)) {
47
- const fab = await z.getContent(file.path + file.name, 'string');
48
- if (!fab) {
49
- continue;
50
- }
51
- files[file.path + file.name] = fab.replace(/^\ufeff/, '');
52
- }
53
- else {
54
- const fab = await z.getContent(file.path + file.name, 'arraybuffer');
55
- if (!fab) {
56
- continue;
57
- }
58
- files[file.path + file.name] = new Blob([fab], {
59
- 'type': mime.mime
60
- });
61
- }
62
- }
63
- return {
64
- 'type': 'theme',
65
- 'config': config,
66
- 'files': files
67
- };
68
- }
69
-
70
- /**
71
- * --- 加载 theme 给任务(App 模式下必须设置 theme,不能用来加载所谓的全局主题) ---
72
- * @param theme ITheme 对象,undefined 代表加载全局的默认主题,但 App 模式下必须设置此项
73
- * @param taskId 要给某任务 ID 加载主题,App 模式下无效
74
- */
75
- export async function load(theme?: types.ITheme, taskId?: number): Promise<boolean> {
76
- if (!taskId) {
77
- return false;
78
- }
79
- const t = task.list[taskId];
80
- if (!t) {
81
- return false;
82
- }
83
- /** --- 是否加载全局的主题到本任务 --- */
84
- const isGlobal = theme ? false : true;
85
- // --- 如果当前是自定,来设置的是全局,则不修改 ---
86
- if (t.customTheme && isGlobal) {
87
- return true;
88
- }
89
- if (!theme) {
90
- // --- 等同于 if (isGlobal) { ---
91
- // --- 设置系统主题 ---
92
- if (!global) {
93
- // --- 但系统主题不存在,也算设置成功了 ---
94
- return true;
95
- }
96
- // --- 当前任务非自定,可以设置为系统主题 ---
97
- theme = global;
98
- }
99
- let style = theme.files[theme.config.style + '.css'] as string;
100
- if (!style) {
101
- return false;
102
- }
103
- style = tool.stylePrepend(style, `cg-theme-task${taskId}-`).style;
104
- style = await tool.styleUrl2DataUrl(theme.config.style, style, theme.files);
105
- // --- 替换 [CGTMP-GLOBAL] ---
106
- style = style.replace(/\[CGTMP-GLOBAL\] +::selection/g, `#cg-form-list > [data-task-id="${taskId}"] ::selection, #cg-pop-list > [data-task-id="${taskId}"] ::selection`);
107
- style = style.replace(/\[CGTMP-GLOBAL\]/g, `#cg-form-list > [data-task-id="${taskId}"], #cg-pop-list > [data-task-id="${taskId}"]`);
108
- if (!t.customTheme) {
109
- // --- 如果当前 task 不是自定主题 ---
110
- if (!isGlobal) {
111
- // --- 但当前设置为自定,则任务标识设置为自定 ---
112
- t.customTheme = true;
113
- }
114
- // --- 只要 task 之前是全局主题,本次就要清除原主题所有内容 ---
115
- dom.removeStyle(taskId, 'theme');
116
- }
117
- dom.pushStyle(taskId, style, 'theme', theme.config.name);
118
- return true;
119
- }
120
-
121
- /**
122
- * --- 移除当前 task 的 theme(只能移除自定的) ---
123
- * @param name 要移除的主题
124
- * @param taskId 任务 ID,App 模式下无效
125
- */
126
- export async function remove(name: string, taskId?: number): Promise<void> {
127
- if (!taskId) {
128
- return;
129
- }
130
- const t = task.list[taskId];
131
- if (!t) {
132
- return;
133
- }
134
- if (!t.customTheme) {
135
- // --- 当前是系统主题,无权限移除 ---
136
- return;
137
- }
138
- dom.removeStyle(taskId, 'theme', name);
139
- // --- 判断是否所有自定主题都被移除干净 ---
140
- if (dom.getStyleCount(taskId, 'theme') === 0) {
141
- // --- 全部干净了,切换为系统主题 ---
142
- t.customTheme = false;
143
- if (global) {
144
- await load(undefined, taskId);
145
- }
146
- }
147
- }
148
-
149
- /**
150
- * --- 清除一个 task 中所有加载的 theme(只能清除自定) ---
151
- * @param taskId 要清除的任务 id,App 模式下无效
152
- */
153
- export async function clear(taskId?: number): Promise<void> {
154
- if (!taskId) {
155
- return;
156
- }
157
- const t = task.list[taskId];
158
- if (!t) {
159
- return;
160
- }
161
- // --- 当前自定才可清除 ---
162
- if (!t.customTheme) {
163
- // --- 当前是系统,则不许清除 ---
164
- return;
165
- }
166
- dom.removeStyle(taskId, 'theme');
167
- t.customTheme = false;
168
- if (global) {
169
- await load(undefined, taskId);
170
- }
171
- }
172
-
173
- /**
174
- * --- 将 cgt 主题设置到全局所有任务 ---
175
- * @param theme 主题对象
176
- */
177
- export async function setGlobal(theme: types.ITheme): Promise<void> {
178
- global = theme;
179
- for (const taskId in task.list) {
180
- await load(undefined, parseInt(taskId));
181
- }
182
- }
183
-
184
- /**
185
- * --- 清除全局主题 ---
186
- */
187
- export function clearGlobal(): void {
188
- if (!global) {
189
- return;
190
- }
191
- global = null;
192
- for (const taskId in task.list) {
193
- const t = task.list[taskId];
194
- if (t.customTheme) {
195
- continue;
196
- }
197
- dom.removeStyle(t.id, 'theme');
198
- }
199
- }