@mytools-all/mytools-ctool 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MyTools Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,21 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # Ctool
2
+
3
+ Ctool
4
+
5
+ 版本:0.1.0;适用于 MyTools,不能作为独立网页调用宿主能力。
6
+
7
+ ## 安装
8
+
9
+ 在 MyTools 插件管理的 npm 安装入口输入 `@mytools-all/mytools-ctool@0.1.0`。也可以下载本仓库,在开发者页面选择“安装本地目录”。
10
+
11
+ ## 开发
12
+
13
+ 直接编辑本目录的 HTML、JavaScript 和样式,无需依赖宿主源码或其他插件仓库。修改后重新安装本地目录。运行 `npm test` 检查包内契约和逻辑。插件 API 规范见 [mytools](https://github.com/mytools-all/mytools/tree/main/docs)。
14
+
15
+ ## 权限
16
+
17
+ 声明的宿主能力:clipboard.write。目录和危险操作仍需用户授权。
18
+
19
+ ## 许可
20
+
21
+ 项目代码使用 MIT;随附的第三方代码遵循各自随附的许可证。
package/THIRD_PARTY.md ADDED
@@ -0,0 +1,25 @@
1
+ # 离线依赖与许可
2
+
3
+ 这些库只用于插件页面,许可证随每个使用它的独立包分发。资源随各插件独立维护。
4
+ 不复制或分发 Rubick 参考插件的实现或图标。
5
+
6
+ | 库 | 版本 | 用途 | 上游 | 许可证 |
7
+ |---|---|---|---|---|
8
+ | marked | 18.1.2 | Markdown 解析 | https://github.com/markedjs/marked | MIT,marked.LICENSE |
9
+ | DOMPurify | 3.4.17 | Markdown HTML 清洗 | https://github.com/cure53/DOMPurify | Apache-2.0 OR MPL-2.0,purify.LICENSE |
10
+ | js-yaml | 5.5.0 | JSON / YAML 转换 | https://github.com/nodeca/js-yaml | MIT,yaml.LICENSE |
11
+ | js-md5 | 0.9.2 | MD5 与讯飞 WebAPI 签名 | https://github.com/emn178/js-md5 | MIT,md5.LICENSE |
12
+
13
+ 各库版权与完整条款以对应 LICENSE 文件为准。依赖本地载入,不从 CDN 动态执行代码。
14
+
15
+ ## 优先修复使用的编辑器组件
16
+
17
+ | 组件 | 版本 | 来源 | 许可证 |
18
+ |---|---|---|---|
19
+ | md-editor-v3 | 2.11.3 | https://github.com/imzbf/md-editor-v3 | MIT,md-editor.LICENSE |
20
+ | Vue | 3.5.42 | https://github.com/vuejs/core | MIT,vue.LICENSE |
21
+ | Cropper.js | 1.5.13 | https://github.com/fengyuanchen/cropperjs | MIT,cropper.LICENSE |
22
+ | screenfull | 5.2.0 | https://github.com/sindresorhus/screenfull | MIT,screenfull.LICENSE |
23
+ | highlight.js | 11.7.0 | https://github.com/highlightjs/highlight.js | BSD-3-Clause,highlight.LICENSE |
24
+
25
+ 这些资源由 Markdown 包本地携带。`md-editor.mjs` 仅将 Vue 导入改为本地 `./vue.mjs`;图标脚本为该系列编辑器的默认图标资源。其余编辑器扩展通过本地实例注入,不在运行时向 CDN 请求脚本。
package/app.mjs ADDED
@@ -0,0 +1,222 @@
1
+ import { $, $$, action, copy, status, escapeHtml } from "./common.mjs";
2
+ import md5 from "./md5.mjs";
3
+ import { load as yamlLoad, dump as yamlDump } from "./yaml.mjs";
4
+ const definitions = [
5
+ ["base64", "Base64 编解码", ["编码", "解码"]],
6
+ ["url", "URL 编解码", ["编码", "解码"]],
7
+ ["hash", "哈希 / 摘要", ["MD5", "SHA-1", "SHA-256", "SHA-512"]],
8
+ ["time", "时间戳转换", ["时间戳 → 日期", "日期 → 时间戳"]],
9
+ ["regex", "正则测试", ["匹配"]],
10
+ ["json", "JSON 工具", ["格式化", "压缩", "转义", "反转义"]],
11
+ ["yaml", "JSON ↔ YAML", ["JSON → YAML", "YAML → JSON"]],
12
+ ["urlparse", "URL 解析", ["解析"]],
13
+ ["radix", "进制转换", ["10 → 2", "10 → 16", "16 → 10", "2 → 10"]],
14
+ ["uuid", "UUID 生成", ["生成"]],
15
+ ["text", "文本处理", ["去重行", "排序行", "大写", "小写", "统计"]],
16
+ ];
17
+ let current = definitions[0],
18
+ revision = 0;
19
+ function menu() {
20
+ const q = $("#tool-search").value.toLowerCase();
21
+ $("#tools").innerHTML = definitions
22
+ .filter((d) => d[1].toLowerCase().includes(q))
23
+ .map(
24
+ (d) =>
25
+ '<button class="' +
26
+ (d === current ? "active" : "") +
27
+ '" data-id="' +
28
+ d[0] +
29
+ '">' +
30
+ d[1] +
31
+ "</button>",
32
+ )
33
+ .join("");
34
+ $$("#tools button").forEach((b) => (b.onclick = () => select(b.dataset.id)));
35
+ }
36
+ function select(id) {
37
+ current = definitions.find((d) => d[0] === id);
38
+ menu();
39
+ $("#title").textContent = current[1];
40
+ $("#operation").innerHTML = current[2]
41
+ .map((x, i) => '<option value="' + i + '">' + escapeHtml(x) + "</option>")
42
+ .join("");
43
+ $("#extra").innerHTML =
44
+ id === "regex"
45
+ ? '<div class="row"><input id="pattern" placeholder="正则表达式" value="\\w+" style="flex:1"><input id="flags" placeholder="标志" value="g" style="width:65px"></div>'
46
+ : id === "time"
47
+ ? '<label>时间戳单位 <select id="unit"><option value="seconds">秒</option><option value="milliseconds">毫秒</option></select></label>'
48
+ : "";
49
+ $("#output").value = "";
50
+ status("输入后点击执行 · Ctrl+Enter");
51
+ }
52
+ async function run() {
53
+ const rev = ++revision;
54
+ const text = $("#input").value,
55
+ op = Number($("#operation").value);
56
+ let output = "";
57
+ switch (current[0]) {
58
+ case "base64":
59
+ output = op
60
+ ? new TextDecoder("utf-8", { fatal: true }).decode(
61
+ Uint8Array.from(atob(text.replace(/\s/g, "")), (c) =>
62
+ c.charCodeAt(0),
63
+ ),
64
+ )
65
+ : btoa(
66
+ Array.from(new TextEncoder().encode(text), (b) =>
67
+ String.fromCharCode(b),
68
+ ).join(""),
69
+ );
70
+ break;
71
+ case "url":
72
+ output = op ? decodeURIComponent(text) : encodeURIComponent(text);
73
+ break;
74
+ case "hash":
75
+ output = op
76
+ ? [
77
+ ...new Uint8Array(
78
+ await crypto.subtle.digest(
79
+ current[2][op],
80
+ new TextEncoder().encode(text),
81
+ ),
82
+ ),
83
+ ]
84
+ .map((b) => b.toString(16).padStart(2, "0"))
85
+ .join("")
86
+ : md5(text);
87
+ break;
88
+ case "time": {
89
+ let d;
90
+ if (op === 0) {
91
+ if (!/^\d+$/.test(text.trim())) throw Error("请输入数字时间戳");
92
+ d = new Date(
93
+ Number(text) * ($("#unit").value === "seconds" ? 1000 : 1),
94
+ );
95
+ } else d = new Date(text);
96
+ if (Number.isNaN(d.getTime())) throw Error("日期无效");
97
+ output = op
98
+ ? String(
99
+ $("#unit").value === "seconds"
100
+ ? Math.floor(d.getTime() / 1000)
101
+ : d.getTime(),
102
+ )
103
+ : "本地时间:" + d.toLocaleString() + "\nUTC:" + d.toISOString();
104
+ break;
105
+ }
106
+ case "regex": {
107
+ if (text.length > 200000) throw Error("正则测试输入不能超过 200 KB");
108
+ output = await new Promise((resolve, reject) => {
109
+ const worker = new Worker(
110
+ new URL("./regex-worker.mjs", import.meta.url),
111
+ { type: "module" },
112
+ );
113
+ const timer = setTimeout(() => {
114
+ worker.terminate();
115
+ reject(Error("正则运行超过 1 秒,已停止"));
116
+ }, 1000);
117
+ worker.onmessage = (e) => {
118
+ clearTimeout(timer);
119
+ worker.terminate();
120
+ e.data.error ? reject(Error(e.data.error)) : resolve(e.data.result);
121
+ };
122
+ worker.onerror = () => {
123
+ clearTimeout(timer);
124
+ worker.terminate();
125
+ reject(Error("正则测试失败"));
126
+ };
127
+ worker.postMessage({
128
+ text,
129
+ pattern: $("#pattern").value,
130
+ flags: $("#flags").value,
131
+ });
132
+ });
133
+ break;
134
+ }
135
+ case "json":
136
+ output =
137
+ op === 0
138
+ ? JSON.stringify(JSON.parse(text), null, 2)
139
+ : op === 1
140
+ ? JSON.stringify(JSON.parse(text))
141
+ : op === 2
142
+ ? JSON.stringify(text)
143
+ : JSON.parse(text);
144
+ break;
145
+ case "yaml":
146
+ output = op
147
+ ? JSON.stringify(yamlLoad(text), null, 2)
148
+ : yamlDump(JSON.parse(text));
149
+ break;
150
+ case "urlparse": {
151
+ const u = new URL(text);
152
+ output = JSON.stringify(
153
+ {
154
+ protocol: u.protocol,
155
+ host: u.host,
156
+ hostname: u.hostname,
157
+ port: u.port,
158
+ pathname: u.pathname,
159
+ hash: u.hash,
160
+ query: [...u.searchParams],
161
+ },
162
+ null,
163
+ 2,
164
+ );
165
+ break;
166
+ }
167
+ case "radix": {
168
+ const n = BigInt(
169
+ op === 2
170
+ ? "0x" + text.replace(/^0x/i, "")
171
+ : op === 3
172
+ ? "0b" + text.replace(/^0b/i, "")
173
+ : text,
174
+ );
175
+ output = n.toString(op === 0 ? 2 : op === 1 ? 16 : 10);
176
+ break;
177
+ }
178
+ case "uuid":
179
+ output = crypto.randomUUID();
180
+ break;
181
+ case "text": {
182
+ const lines = text.split("\n");
183
+ output =
184
+ op === 0
185
+ ? [...new Set(lines)].join("\n")
186
+ : op === 1
187
+ ? lines.sort((a, b) => a.localeCompare(b, "zh-CN")).join("\n")
188
+ : op === 2
189
+ ? text.toUpperCase()
190
+ : op === 3
191
+ ? text.toLowerCase()
192
+ : JSON.stringify(
193
+ {
194
+ 字符数: [...text].length,
195
+ 字节数: new TextEncoder().encode(text).length,
196
+ 行数: lines.length,
197
+ },
198
+ null,
199
+ 2,
200
+ );
201
+ break;
202
+ }
203
+ }
204
+ if (rev === revision) {
205
+ $("#output").value =
206
+ typeof output === "string" ? output : JSON.stringify(output, null, 2);
207
+ status("执行完成");
208
+ }
209
+ }
210
+ $("#run").onclick = action(run);
211
+ $("#copy").onclick = action(() => copy($("#output").value));
212
+ $("#swap").onclick = () => {
213
+ $("#input").value = $("#output").value;
214
+ };
215
+ $("#tool-search").oninput = menu;
216
+ document.onkeydown = (e) => {
217
+ if ((e.ctrlKey || e.metaKey) && e.key === "Enter") {
218
+ e.preventDefault();
219
+ $("#run").click();
220
+ }
221
+ };
222
+ select("base64");
package/common.mjs ADDED
@@ -0,0 +1,69 @@
1
+ export const $ = (selector) => document.querySelector(selector);
2
+ export const $$ = (selector) => [...document.querySelectorAll(selector)];
3
+ export function status(text, error = false) {
4
+ const el = $("#status");
5
+ if (el) {
6
+ el.textContent = text;
7
+ el.dataset.error = String(error);
8
+ }
9
+ }
10
+ export function action(fn) {
11
+ return async (...args) => {
12
+ try {
13
+ return await fn(...args);
14
+ } catch (e) {
15
+ status(e.message || String(e), true);
16
+ }
17
+ };
18
+ }
19
+ export async function call(id, args = {}) {
20
+ if (!window.mytools) throw Error("请从 MyTools 打开此工具");
21
+ return window.mytools.call(id, args);
22
+ }
23
+ export const copy = async (text) => {
24
+ await call("clipboard.write", { text: String(text) });
25
+ status("已复制到剪贴板");
26
+ };
27
+ export function ready(fn) {
28
+ if (window.mytools) window.mytools.onPluginReady(action(fn));
29
+ else status("预览模式:系统能力需从 MyTools 使用");
30
+ }
31
+ export const escapeHtml = (text) =>
32
+ String(text).replace(
33
+ /[&<>"']/g,
34
+ (c) =>
35
+ ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[
36
+ c
37
+ ],
38
+ );
39
+ export function download(name, text, type = "text/plain") {
40
+ const url = URL.createObjectURL(new Blob([text], { type }));
41
+ const a = document.createElement("a");
42
+ a.href = url;
43
+ a.download = name;
44
+ a.click();
45
+ setTimeout(() => URL.revokeObjectURL(url), 1000);
46
+ }
47
+ export function debounce(fn, ms = 200) {
48
+ let timer;
49
+ return (...args) => {
50
+ clearTimeout(timer);
51
+ timer = setTimeout(() => fn(...args), ms);
52
+ };
53
+ }
54
+ export const formatBytes = (n) =>
55
+ n < 1024
56
+ ? n + " B"
57
+ : n < 1048576
58
+ ? (n / 1024).toFixed(1) + " KB"
59
+ : (n / 1048576).toFixed(1) + " MB";
60
+ const savedTheme = localStorage.getItem("tool-theme");
61
+ document.documentElement.dataset.theme =
62
+ savedTheme ||
63
+ (matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
64
+ $("#theme")?.addEventListener("click", () => {
65
+ const theme =
66
+ document.documentElement.dataset.theme === "dark" ? "light" : "dark";
67
+ document.documentElement.dataset.theme = theme;
68
+ localStorage.setItem("tool-theme", theme);
69
+ });
package/index.html ADDED
@@ -0,0 +1,53 @@
1
+ <!doctype html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
6
+ <title>Ctool</title>
7
+ <link rel="stylesheet" href="tool.css" />
8
+ <style></style>
9
+ </head>
10
+ <body>
11
+ <main>
12
+ <div class="toolbar">
13
+ <strong>Ctool</strong
14
+ ><input
15
+ id="tool-search"
16
+ placeholder="搜索工具"
17
+ aria-label="搜索工具"
18
+ /><span class="spacer"></span><button id="copy">复制结果</button
19
+ ><button id="theme">◐</button>
20
+ </div>
21
+ <div class="workspace">
22
+ <nav id="tools" class="sidebar"></nav>
23
+ <section class="content stack">
24
+ <div class="row">
25
+ <strong id="title"></strong><span class="spacer"></span
26
+ ><select id="operation" aria-label="操作"></select
27
+ ><button id="run" class="primary">执行</button>
28
+ </div>
29
+ <div id="extra"></div>
30
+ <textarea
31
+ id="input"
32
+ style="flex: 1"
33
+ placeholder="输入内容…"
34
+ aria-label="工具输入"
35
+ spellcheck="false"
36
+ ></textarea>
37
+ <div class="row">
38
+ <span class="muted">结果</span><span class="spacer"></span
39
+ ><button id="swap">结果作为输入 ↑</button>
40
+ </div>
41
+ <textarea
42
+ id="output"
43
+ style="flex: 1"
44
+ readonly
45
+ aria-label="工具结果"
46
+ ></textarea>
47
+ </section>
48
+ </div>
49
+ <footer id="status" class="status" role="status"></footer>
50
+ </main>
51
+ <script type="module" src="app.mjs"></script>
52
+ </body>
53
+ </html>
package/md5.LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014-2026 Chen, Yi-Cyuan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/md5.mjs ADDED
@@ -0,0 +1,10 @@
1
+ function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var r,e={exports:{}};
2
+ /**
3
+ * [js-md5]{@link https://github.com/emn178/js-md5}
4
+ *
5
+ * @namespace md5
6
+ * @version 0.9.2
7
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
8
+ * @copyright Chen, Yi-Cyuan 2014-2026
9
+ * @license MIT
10
+ */r=e,function(){var t="input is invalid type",e="object"==typeof window,i=e?window:{};i.JS_MD5_NO_WINDOW&&(e=!1),"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(i=self);var h=!i.JS_MD5_NO_COMMON_JS&&r.exports,s=!i.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,a="0123456789abcdef".split(""),n=[128,32768,8388608,-2147483648],o=[0,8,16,24],f=["hex","array","digest","arrayBuffer"];f.push("buffer"),f.push("base64");var u,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),y=[];if(s){var c=new ArrayBuffer(68);u=new Uint8Array(c),y=new Uint32Array(c)}var l=Array.isArray;!i.JS_MD5_NO_NODE_JS&&l||(l=function(t){return"[object Array]"===Object.prototype.toString.call(t)});var d=ArrayBuffer.isView;!s||!i.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&d||(d=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});var b=function(r){var e=typeof r;if("string"===e)return[r,!0];if("object"!==e||null===r)throw new Error(t);if(s&&r.constructor===ArrayBuffer)return[new Uint8Array(r),!1];if(!l(r)&&!d(r))throw new Error(t);return[r,!1]},v=function(t){return function(r){return new A(!0).update(r)[t]()}},w=function(t){return function(r,e){return new _(r,!0).update(e)[t]()}};function A(t){if(t)y[0]=y[16]=y[1]=y[2]=y[3]=y[4]=y[5]=y[6]=y[7]=y[8]=y[9]=y[10]=y[11]=y[12]=y[13]=y[14]=y[15]=0,this.blocks=y,this.buffer8=u;else if(s){var r=new ArrayBuffer(68);this.buffer8=new Uint8Array(r),this.blocks=new Uint32Array(r)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}function _(t,r){var e,i=b(t);if(t=i[0],i[1]){var h,s=[],a=t.length,n=0;for(e=0;e<a;++e)(h=t.charCodeAt(e))<128?s[n++]=h:h<2048?(s[n++]=192|h>>>6,s[n++]=128|63&h):h<55296||h>=57344?(s[n++]=224|h>>>12,s[n++]=128|h>>>6&63,s[n++]=128|63&h):(h=65536+((1023&h)<<10|1023&t.charCodeAt(++e)),s[n++]=240|h>>>18,s[n++]=128|h>>>12&63,s[n++]=128|h>>>6&63,s[n++]=128|63&h);t=s}t.length>64&&(t=new A(!0).update(t).array());var o=[],f=[];for(e=0;e<64;++e){var u=t[e]||0;o[e]=92^u,f[e]=54^u}A.call(this,r),this.update(f),this.oKeyPad=o,this.inner=!0,this.sharedMemory=r}A.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var r=b(t);t=r[0];for(var e,i,h=r[1],a=0,n=t.length,f=this.blocks,u=this.buffer8;a<n;){if(this.hashed&&(this.hashed=!1,f[0]=f[16],f[16]=f[1]=f[2]=f[3]=f[4]=f[5]=f[6]=f[7]=f[8]=f[9]=f[10]=f[11]=f[12]=f[13]=f[14]=f[15]=0),h)if(s)for(i=this.start;a<n&&i<64;++a)(e=t.charCodeAt(a))<128?u[i++]=e:e<2048?(u[i++]=192|e>>>6,u[i++]=128|63&e):e<55296||e>=57344?(u[i++]=224|e>>>12,u[i++]=128|e>>>6&63,u[i++]=128|63&e):(e=65536+((1023&e)<<10|1023&t.charCodeAt(++a)),u[i++]=240|e>>>18,u[i++]=128|e>>>12&63,u[i++]=128|e>>>6&63,u[i++]=128|63&e);else for(i=this.start;a<n&&i<64;++a)(e=t.charCodeAt(a))<128?f[i>>>2]|=e<<o[3&i++]:e<2048?(f[i>>>2]|=(192|e>>>6)<<o[3&i++],f[i>>>2]|=(128|63&e)<<o[3&i++]):e<55296||e>=57344?(f[i>>>2]|=(224|e>>>12)<<o[3&i++],f[i>>>2]|=(128|e>>>6&63)<<o[3&i++],f[i>>>2]|=(128|63&e)<<o[3&i++]):(e=65536+((1023&e)<<10|1023&t.charCodeAt(++a)),f[i>>>2]|=(240|e>>>18)<<o[3&i++],f[i>>>2]|=(128|e>>>12&63)<<o[3&i++],f[i>>>2]|=(128|e>>>6&63)<<o[3&i++],f[i>>>2]|=(128|63&e)<<o[3&i++]);else if(s)for(i=this.start;a<n&&i<64;++a)u[i++]=t[a];else for(i=this.start;a<n&&i<64;++a)f[i>>>2]|=t[a]<<o[3&i++];this.lastByteIndex=i,this.bytes+=i-this.start,i>=64?(this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},A.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,r=this.lastByteIndex;t[r>>>2]|=n[3&r],r>=56&&(this.hashed||this.hash(),t[0]=t[16],t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.bytes<<3,t[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},A.prototype.hash=function(){var t,r,e,i,h,s,a=this.blocks;this.first?r=((r=((t=((t=a[0]-680876937)<<7|t>>>25)-271733879|0)^(e=((e=(-271733879^(i=((i=(-1732584194^2004318071&t)+a[1]-117830708)<<12|i>>>20)+t|0)&(-271733879^t))+a[2]-1126478375)<<17|e>>>15)+i|0)&(i^t))+a[3]-1316259209)<<22|r>>>10)+e|0:(t=this.h0,r=this.h1,e=this.h2,r=((r+=((t=((t+=((i=this.h3)^r&(e^i))+a[0]-680876936)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[1]-389564586)<<12|i>>>20)+t|0)&(t^r))+a[2]+606105819)<<17|e>>>15)+i|0)&(i^t))+a[3]-1044525330)<<22|r>>>10)+e|0),r=((r+=((t=((t+=(i^r&(e^i))+a[4]-176418897)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[5]+1200080426)<<12|i>>>20)+t|0)&(t^r))+a[6]-1473231341)<<17|e>>>15)+i|0)&(i^t))+a[7]-45705983)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+a[8]+1770035416)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[9]-1958414417)<<12|i>>>20)+t|0)&(t^r))+a[10]-42063)<<17|e>>>15)+i|0)&(i^t))+a[11]-1990404162)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+a[12]+1804603682)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[13]-40341101)<<12|i>>>20)+t|0)&(t^r))+a[14]-1502002290)<<17|e>>>15)+i|0)&(i^t))+a[15]+1236535329)<<22|r>>>10)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[1]-165796510)<<5|t>>>27)+r|0)^r))+a[6]-1069501632)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[11]+643717713)<<14|e>>>18)+i|0)^i))+a[0]-373897302)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[5]-701558691)<<5|t>>>27)+r|0)^r))+a[10]+38016083)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[15]-660478335)<<14|e>>>18)+i|0)^i))+a[4]-405537848)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[9]+568446438)<<5|t>>>27)+r|0)^r))+a[14]-1019803690)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[3]-187363961)<<14|e>>>18)+i|0)^i))+a[8]+1163531501)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[13]-1444681467)<<5|t>>>27)+r|0)^r))+a[2]-51403784)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[7]+1735328473)<<14|e>>>18)+i|0)^i))+a[12]-1926607734)<<20|r>>>12)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[5]-378558)<<4|t>>>28)+r|0))+a[8]-2022574463)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[11]+1839030562)<<16|e>>>16)+i|0))+a[14]-35309556)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[1]-1530992060)<<4|t>>>28)+r|0))+a[4]+1272893353)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[7]-155497632)<<16|e>>>16)+i|0))+a[10]-1094730640)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[13]+681279174)<<4|t>>>28)+r|0))+a[0]-358537222)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[3]-722521979)<<16|e>>>16)+i|0))+a[6]+76029189)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[9]-640364487)<<4|t>>>28)+r|0))+a[12]-421815835)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[15]+530742520)<<16|e>>>16)+i|0))+a[2]-995338651)<<23|r>>>9)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[0]-198630844)<<6|t>>>26)+r|0)|~e))+a[7]+1126891415)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[14]-1416354905)<<15|e>>>17)+i|0)|~t))+a[5]-57434055)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[12]+1700485571)<<6|t>>>26)+r|0)|~e))+a[3]-1894986606)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[10]-1051523)<<15|e>>>17)+i|0)|~t))+a[1]-2054922799)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[8]+1873313359)<<6|t>>>26)+r|0)|~e))+a[15]-30611744)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[6]-1560198380)<<15|e>>>17)+i|0)|~t))+a[13]+1309151649)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[4]-145523070)<<6|t>>>26)+r|0)|~e))+a[11]-1120210379)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[2]+718787259)<<15|e>>>17)+i|0)|~t))+a[9]-343485551)<<21|r>>>11)+e|0,this.first?(this.h0=t+1732584193|0,this.h1=r-271733879|0,this.h2=e-1732584194|0,this.h3=i+271733878|0,this.first=!1):(this.h0=this.h0+t|0,this.h1=this.h1+r|0,this.h2=this.h2+e|0,this.h3=this.h3+i|0)},A.prototype.hex=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return a[t>>>4&15]+a[15&t]+a[t>>>12&15]+a[t>>>8&15]+a[t>>>20&15]+a[t>>>16&15]+a[t>>>28&15]+a[t>>>24&15]+a[r>>>4&15]+a[15&r]+a[r>>>12&15]+a[r>>>8&15]+a[r>>>20&15]+a[r>>>16&15]+a[r>>>28&15]+a[r>>>24&15]+a[e>>>4&15]+a[15&e]+a[e>>>12&15]+a[e>>>8&15]+a[e>>>20&15]+a[e>>>16&15]+a[e>>>28&15]+a[e>>>24&15]+a[i>>>4&15]+a[15&i]+a[i>>>12&15]+a[i>>>8&15]+a[i>>>20&15]+a[i>>>16&15]+a[i>>>28&15]+a[i>>>24&15]},A.prototype.toString=A.prototype.hex,A.prototype.digest=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&r,r>>>8&255,r>>>16&255,r>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&i,i>>>8&255,i>>>16&255,i>>>24&255]},A.prototype.array=A.prototype.digest,A.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(16),r=new Uint32Array(t);return r[0]=this.h0,r[1]=this.h1,r[2]=this.h2,r[3]=this.h3,t},A.prototype.buffer=A.prototype.arrayBuffer,A.prototype.base64=function(){for(var t,r,e,i="",h=this.array(),s=0;s<15;)t=h[s++],r=h[s++],e=h[s++],i+=p[t>>>2]+p[63&(t<<4|r>>>4)]+p[63&(r<<2|e>>>6)]+p[63&e];return t=h[s],i+=p[t>>>2]+p[t<<4&63]+"=="},_.prototype=new A,_.prototype.finalize=function(){if(A.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();A.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(t),A.prototype.finalize.call(this)}};var B=function(){var t=v("hex");t.create=function(){return new A},t.update=function(r){return t.create().update(r)};for(var r=0;r<f.length;++r){var e=f[r];t[e]=v(e)}return t}();B.md5=B,B.md5.hmac=function(){var t=w("hex");t.create=function(t){return new _(t)},t.update=function(r,e){return t.create(r).update(e)};for(var r=0;r<f.length;++r){var e=f[r];t[e]=w(e)}return t}(),h?r.exports=B:i.md5=B}();var i=t(e.exports);export{i as default,i as md5};
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
- {
2
- "name": "@mytools-all/mytools-ctool",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
1
+ {
2
+ "name": "@mytools-all/mytools-ctool",
3
+ "version": "0.1.0",
4
+ "description": "Ctool",
5
+ "type": "module",
6
+ "main": "index.html",
7
+ "license": "MIT",
8
+ "author": "MyTools Contributors",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/mytools-all/mytools-ctool.git"
12
+ },
13
+ "homepage": "https://github.com/mytools-all/mytools-ctool#readme",
14
+ "bugs": {
15
+ "url": "https://github.com/mytools-all/mytools-ctool/issues"
16
+ },
17
+ "publishConfig": {
18
+ "access": "public",
19
+ "registry": "https://registry.npmjs.org/"
20
+ },
21
+ "files": [
22
+ "plugin.json",
23
+ "*.html",
24
+ "*.css",
25
+ "*.svg",
26
+ "*.png",
27
+ "vendor/",
28
+ "LICENSE",
29
+ "THIRD_PARTY.md",
30
+ "README.md",
31
+ "app.mjs",
32
+ "common.mjs",
33
+ "md5.mjs",
34
+ "regex-worker.mjs",
35
+ "utils.mjs",
36
+ "yaml.mjs",
37
+ "*.js",
38
+ "*.LICENSE"
39
+ ],
40
+ "scripts": {
41
+ "test": "node --test"
42
+ }
43
+ }
package/plugin.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "mytools-ctool",
3
+ "description": "Ctool",
4
+ "apiVersion": 1,
5
+ "main": "index.html",
6
+ "pluginName": "Ctool",
7
+ "version": "0.1.0",
8
+ "capabilities": [
9
+ "clipboard.write"
10
+ ],
11
+ "features": [
12
+ {
13
+ "code": "ctool",
14
+ "explain": "打开Ctool",
15
+ "cmds": [
16
+ "Ctool",
17
+ "开发工具",
18
+ "编码",
19
+ "Base64",
20
+ "时间戳",
21
+ "哈希",
22
+ "正则"
23
+ ]
24
+ }
25
+ ]
26
+ }
@@ -0,0 +1,23 @@
1
+ self.onmessage = ({ data: { text, pattern, flags } }) => {
2
+ try {
3
+ const re = new RegExp(pattern, flags);
4
+ const results = [];
5
+ if (re.global) {
6
+ let match;
7
+ while ((match = re.exec(text)) && results.length < 2000) {
8
+ results.push({
9
+ index: match.index,
10
+ match: match[0],
11
+ groups: match.slice(1),
12
+ });
13
+ if (!match[0]) re.lastIndex++;
14
+ }
15
+ } else {
16
+ const m = re.exec(text);
17
+ if (m) results.push({ index: m.index, match: m[0], groups: m.slice(1) });
18
+ }
19
+ self.postMessage({ result: JSON.stringify(results, null, 2) });
20
+ } catch (e) {
21
+ self.postMessage({ error: e.message });
22
+ }
23
+ };