@maiyunnet/kebab 2.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/.VSCodeCounter/2025-02-14_14-46-44/details.md +82 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/diff-details.md +15 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/diff.csv +2 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/diff.md +19 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/diff.txt +22 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/results.csv +69 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/results.json +1 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/results.md +48 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/results.txt +118 -0
- package/.vscode/tasks.json +15 -0
- package/LICENSE +201 -0
- package/README.md +201 -0
- package/bin/kebab.js +2 -0
- package/eslint.config.js +22 -0
- package/index.js +19 -0
- package/index.ts +33 -0
- package/lib/buffer.js +108 -0
- package/lib/buffer.ts +152 -0
- package/lib/captcha/zcool-addict-italic.ttf +0 -0
- package/lib/captcha.js +71 -0
- package/lib/captcha.ts +63 -0
- package/lib/consistent.js +171 -0
- package/lib/consistent.ts +219 -0
- package/lib/core.js +663 -0
- package/lib/core.ts +880 -0
- package/lib/crypto.js +256 -0
- package/lib/crypto.ts +384 -0
- package/lib/db.js +521 -0
- package/lib/db.ts +719 -0
- package/lib/dns.js +321 -0
- package/lib/dns.ts +405 -0
- package/lib/fs.js +405 -0
- package/lib/fs.ts +527 -0
- package/lib/jwt.js +223 -0
- package/lib/jwt.ts +276 -0
- package/lib/kv.js +1004 -0
- package/lib/kv.ts +1489 -0
- package/lib/lan.js +99 -0
- package/lib/lan.ts +87 -0
- package/lib/net/cacert.pem +3480 -0
- package/lib/net/formdata.js +137 -0
- package/lib/net/formdata.ts +166 -0
- package/lib/net/request.js +102 -0
- package/lib/net/request.ts +150 -0
- package/lib/net/response.js +28 -0
- package/lib/net/response.ts +59 -0
- package/lib/net.js +462 -0
- package/lib/net.ts +662 -0
- package/lib/s3.js +180 -0
- package/lib/s3.ts +235 -0
- package/lib/scan.js +276 -0
- package/lib/scan.ts +364 -0
- package/lib/session.js +177 -0
- package/lib/session.ts +230 -0
- package/lib/sql.js +818 -0
- package/lib/sql.ts +1151 -0
- package/lib/ssh/sftp.js +373 -0
- package/lib/ssh/sftp.ts +508 -0
- package/lib/ssh/shell.js +109 -0
- package/lib/ssh/shell.ts +123 -0
- package/lib/ssh.js +171 -0
- package/lib/ssh.ts +191 -0
- package/lib/text/tld.json +1 -0
- package/lib/text.js +452 -0
- package/lib/text.ts +607 -0
- package/lib/time.js +216 -0
- package/lib/time.ts +254 -0
- package/lib/ws.js +373 -0
- package/lib/ws.ts +523 -0
- package/lib/zip.js +381 -0
- package/lib/zip.ts +447 -0
- package/lib/zlib.js +289 -0
- package/lib/zlib.ts +350 -0
- package/main.js +51 -0
- package/main.ts +27 -0
- package/package.json +37 -0
- package/sys/child.js +585 -0
- package/sys/child.ts +678 -0
- package/sys/cmd.js +226 -0
- package/sys/cmd.ts +225 -0
- package/sys/ctr.js +608 -0
- package/sys/ctr.ts +904 -0
- package/sys/master.js +314 -0
- package/sys/master.ts +355 -0
- package/sys/mod.js +1273 -0
- package/sys/mod.ts +1871 -0
- package/sys/route.js +922 -0
- package/sys/route.ts +1113 -0
- package/types/index.d.ts +283 -0
- package/www/example/ctr/main.js +42 -0
- package/www/example/ctr/main.ts +9 -0
- package/www/example/ctr/middle.js +57 -0
- package/www/example/ctr/middle.ts +26 -0
- package/www/example/ctr/test.js +2818 -0
- package/www/example/ctr/test.ts +3218 -0
- package/www/example/data/locale/en.test.json +8 -0
- package/www/example/data/locale/index.html +1 -0
- package/www/example/data/locale/ja.test.json +8 -0
- package/www/example/data/locale/sc.test.json +8 -0
- package/www/example/data/locale/tc.test.json +8 -0
- package/www/example/data/test.zip +0 -0
- package/www/example/kebab.json +24 -0
- package/www/example/mod/test.js +49 -0
- package/www/example/mod/test.ts +47 -0
- package/www/example/mod/testdata.js +11 -0
- package/www/example/mod/testdata.ts +30 -0
- package/www/example/route.json +6 -0
- package/www/example/view/test.ejs +11 -0
- package/www/example/ws/mproxy.js +49 -0
- package/www/example/ws/mproxy.ts +16 -0
- package/www/example/ws/rproxy.js +47 -0
- package/www/example/ws/rproxy.ts +14 -0
- package/www/example/ws/test.js +68 -0
- package/www/example/ws/test.ts +36 -0
package/lib/zip.js
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.Zip = void 0;
|
|
40
|
+
exports.get = get;
|
|
41
|
+
const jszip_1 = __importDefault(require("jszip"));
|
|
42
|
+
const mime = __importStar(require("@litert/mime"));
|
|
43
|
+
const lText = __importStar(require("~/lib/text"));
|
|
44
|
+
class Zip {
|
|
45
|
+
constructor(zip) {
|
|
46
|
+
this._path = '/';
|
|
47
|
+
this._list = {};
|
|
48
|
+
this._zip = zip;
|
|
49
|
+
this._refreshList();
|
|
50
|
+
}
|
|
51
|
+
async getContent(path, type = 'string') {
|
|
52
|
+
path = lText.urlResolve(this._path, path);
|
|
53
|
+
const f = this._zip.file(path.slice(1));
|
|
54
|
+
if (!f) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
if (type === 'string') {
|
|
58
|
+
return f.async('string');
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
return f.async(type);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
putContent(path, data, options = {}) {
|
|
65
|
+
path = lText.urlResolve(this._path, path);
|
|
66
|
+
this._zip.file(path.slice(1), data, {
|
|
67
|
+
'base64': options.base64,
|
|
68
|
+
'binary': options.binary,
|
|
69
|
+
'date': options.date
|
|
70
|
+
});
|
|
71
|
+
this._refreshList();
|
|
72
|
+
}
|
|
73
|
+
unlink(path) {
|
|
74
|
+
path = lText.urlResolve(this._path, path);
|
|
75
|
+
this._zip.remove(path.slice(1));
|
|
76
|
+
this._refreshList();
|
|
77
|
+
}
|
|
78
|
+
stats(path) {
|
|
79
|
+
path = lText.urlResolve(this._path, path);
|
|
80
|
+
let dirpath = path.endsWith('/') ? path : path + '/';
|
|
81
|
+
if (!this._list[dirpath]) {
|
|
82
|
+
if (path.endsWith('/')) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
const lio = path.lastIndexOf('/') + 1;
|
|
86
|
+
const dpath = path.slice(0, lio);
|
|
87
|
+
const fname = path.slice(lio);
|
|
88
|
+
if (!this._list[dpath]) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const file = this._list[dpath][fname];
|
|
92
|
+
if (!file) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
'compressedSize': file.compressedSize,
|
|
97
|
+
'uncompressedSize': file.uncompressedSize,
|
|
98
|
+
'date': file.date,
|
|
99
|
+
'isFile': true,
|
|
100
|
+
'isDirectory': false
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
if (dirpath === '/') {
|
|
105
|
+
return {
|
|
106
|
+
'compressedSize': 0,
|
|
107
|
+
'uncompressedSize': 0,
|
|
108
|
+
'date': new Date(),
|
|
109
|
+
'isFile': false,
|
|
110
|
+
'isDirectory': true
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
dirpath = dirpath.slice(0, -1);
|
|
114
|
+
const lio = dirpath.lastIndexOf('/') + 1;
|
|
115
|
+
const dpath = dirpath.slice(0, lio);
|
|
116
|
+
const fname = dirpath.slice(lio);
|
|
117
|
+
const pfolder = this._list[dpath];
|
|
118
|
+
const folder = pfolder[fname];
|
|
119
|
+
return {
|
|
120
|
+
'compressedSize': 0,
|
|
121
|
+
'uncompressedSize': 0,
|
|
122
|
+
'date': folder.date,
|
|
123
|
+
'isFile': false,
|
|
124
|
+
'isDirectory': true
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
isDir(path) {
|
|
129
|
+
const pstats = this.stats(path);
|
|
130
|
+
if (!pstats?.isDirectory) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
return pstats;
|
|
134
|
+
}
|
|
135
|
+
isFile(path) {
|
|
136
|
+
const pstats = this.stats(path);
|
|
137
|
+
if (!pstats?.isFile) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
return pstats;
|
|
141
|
+
}
|
|
142
|
+
readDir(path, opt = {}) {
|
|
143
|
+
if (opt.hasChildren === undefined) {
|
|
144
|
+
opt.hasChildren = false;
|
|
145
|
+
}
|
|
146
|
+
if (opt.hasDir === undefined) {
|
|
147
|
+
opt.hasDir = true;
|
|
148
|
+
}
|
|
149
|
+
if (opt.pathAsKey === undefined) {
|
|
150
|
+
opt.pathAsKey = false;
|
|
151
|
+
}
|
|
152
|
+
if (!path) {
|
|
153
|
+
path = this._path;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
path = lText.urlResolve(this._path, path);
|
|
157
|
+
}
|
|
158
|
+
if (!path.endsWith('/')) {
|
|
159
|
+
path += '/';
|
|
160
|
+
}
|
|
161
|
+
const folder = this._zip.folder(path.slice(1));
|
|
162
|
+
if (!folder) {
|
|
163
|
+
return opt.pathAsKey ? {} : [];
|
|
164
|
+
}
|
|
165
|
+
if (!this._list[path]) {
|
|
166
|
+
return opt.pathAsKey ? {} : [];
|
|
167
|
+
}
|
|
168
|
+
if (!opt.hasChildren) {
|
|
169
|
+
if (opt.pathAsKey) {
|
|
170
|
+
return this._list[path];
|
|
171
|
+
}
|
|
172
|
+
const list = [];
|
|
173
|
+
for (const k in this._list[path]) {
|
|
174
|
+
list.push(this._list[path][k]);
|
|
175
|
+
}
|
|
176
|
+
return list;
|
|
177
|
+
}
|
|
178
|
+
if (opt.pathAsKey) {
|
|
179
|
+
const list = {};
|
|
180
|
+
for (const k in this._list[path]) {
|
|
181
|
+
const item = this._list[path][k];
|
|
182
|
+
if (item.isFile || opt.hasDir) {
|
|
183
|
+
list[item.path + item.name] = item;
|
|
184
|
+
}
|
|
185
|
+
if (item.isDirectory) {
|
|
186
|
+
Object.assign(list, this._readDir(item, {
|
|
187
|
+
'hasDir': opt.hasDir,
|
|
188
|
+
'pathAsKey': opt.pathAsKey
|
|
189
|
+
}));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return list;
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
let list = [];
|
|
196
|
+
for (const k in this._list[path]) {
|
|
197
|
+
const item = this._list[path][k];
|
|
198
|
+
if (item.isFile || opt.hasDir) {
|
|
199
|
+
list.push(item);
|
|
200
|
+
}
|
|
201
|
+
if (item.isDirectory) {
|
|
202
|
+
list = list.concat(this._readDir(item, {
|
|
203
|
+
'hasDir': opt.hasDir,
|
|
204
|
+
'pathAsKey': opt.pathAsKey
|
|
205
|
+
}));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return list;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
_readDir(item, opt) {
|
|
212
|
+
if (opt.pathAsKey) {
|
|
213
|
+
const list = {};
|
|
214
|
+
if (!this._list[item.path + item.name + '/']) {
|
|
215
|
+
return {};
|
|
216
|
+
}
|
|
217
|
+
for (const k in this._list[item.path + item.name + '/']) {
|
|
218
|
+
const it = this._list[item.path + item.name + '/'][k];
|
|
219
|
+
if (it.isFile || opt.hasDir) {
|
|
220
|
+
list[it.path + it.name] = it;
|
|
221
|
+
}
|
|
222
|
+
if (it.isDirectory) {
|
|
223
|
+
Object.assign(list, this._readDir(it, {
|
|
224
|
+
'hasDir': opt.hasDir,
|
|
225
|
+
'pathAsKey': opt.pathAsKey
|
|
226
|
+
}));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return list;
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
let list = [];
|
|
233
|
+
if (!this._list[item.path + item.name + '/']) {
|
|
234
|
+
return [];
|
|
235
|
+
}
|
|
236
|
+
for (const k in this._list[item.path + item.name + '/']) {
|
|
237
|
+
const it = this._list[item.path + item.name + '/'][k];
|
|
238
|
+
if (it.isFile || opt.hasDir) {
|
|
239
|
+
list.push(it);
|
|
240
|
+
}
|
|
241
|
+
if (it.isDirectory) {
|
|
242
|
+
list = list.concat(this._readDir(it, {
|
|
243
|
+
'hasDir': opt.hasDir,
|
|
244
|
+
'pathAsKey': opt.pathAsKey
|
|
245
|
+
}));
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return list;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
_refreshList() {
|
|
252
|
+
const list = {};
|
|
253
|
+
this._zip.forEach(function (relativePath, item) {
|
|
254
|
+
if (relativePath.startsWith('/')) {
|
|
255
|
+
relativePath = relativePath.slice(1);
|
|
256
|
+
}
|
|
257
|
+
let parentPath = '/';
|
|
258
|
+
let name = '';
|
|
259
|
+
let s;
|
|
260
|
+
if (item.dir) {
|
|
261
|
+
s = relativePath.slice(0, -1).lastIndexOf('/');
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
s = relativePath.lastIndexOf('/');
|
|
265
|
+
}
|
|
266
|
+
if (s !== -1) {
|
|
267
|
+
parentPath = '/' + relativePath.slice(0, s + 1);
|
|
268
|
+
name = relativePath.slice(s + 1);
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
name = relativePath;
|
|
272
|
+
}
|
|
273
|
+
if (item.dir) {
|
|
274
|
+
name = name.slice(0, -1);
|
|
275
|
+
}
|
|
276
|
+
if (!list[parentPath]) {
|
|
277
|
+
list[parentPath] = {};
|
|
278
|
+
}
|
|
279
|
+
list[parentPath][name] = {
|
|
280
|
+
'name': name,
|
|
281
|
+
'compressedSize': item._data.compressedSize ?? 0,
|
|
282
|
+
'uncompressedSize': item._data.uncompressedSize ?? 0,
|
|
283
|
+
'date': item.date,
|
|
284
|
+
'isFile': !item.dir,
|
|
285
|
+
'isDirectory': item.dir,
|
|
286
|
+
'path': parentPath
|
|
287
|
+
};
|
|
288
|
+
});
|
|
289
|
+
this._list = list;
|
|
290
|
+
}
|
|
291
|
+
pwd() {
|
|
292
|
+
return this._path.slice(0, -1);
|
|
293
|
+
}
|
|
294
|
+
cd(dir) {
|
|
295
|
+
this._path = lText.urlResolve(this._path, dir);
|
|
296
|
+
if (!this._path.endsWith('/')) {
|
|
297
|
+
this._path += '/';
|
|
298
|
+
}
|
|
299
|
+
return this._path;
|
|
300
|
+
}
|
|
301
|
+
generate(options = {}) {
|
|
302
|
+
const opt = {};
|
|
303
|
+
if (options.type === undefined) {
|
|
304
|
+
opt.type = 'nodebuffer';
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
opt.type = options.type;
|
|
308
|
+
}
|
|
309
|
+
if (options.level === undefined) {
|
|
310
|
+
options.level = 9;
|
|
311
|
+
}
|
|
312
|
+
else if (options.level > 9) {
|
|
313
|
+
options.level = 9;
|
|
314
|
+
}
|
|
315
|
+
if (options.level > 0) {
|
|
316
|
+
opt.compression = 'DEFLATE';
|
|
317
|
+
}
|
|
318
|
+
return this._zip.generateAsync(opt, function (meta) {
|
|
319
|
+
options.onUpdate?.(meta.percent, meta.currentFile);
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
getList() {
|
|
323
|
+
return new Promise((resolve) => {
|
|
324
|
+
const files = {};
|
|
325
|
+
const list = this.readDir('/', {
|
|
326
|
+
'hasChildren': true,
|
|
327
|
+
'hasDir': false
|
|
328
|
+
});
|
|
329
|
+
let loaded = 0;
|
|
330
|
+
for (const file of list) {
|
|
331
|
+
const mim = mime.getData(file.name);
|
|
332
|
+
if (['txt', 'json', 'js', 'css', 'xml', 'html'].includes(mim.extension)) {
|
|
333
|
+
this.getContent(file.path + file.name, 'string').then(function (fb) {
|
|
334
|
+
if (fb) {
|
|
335
|
+
files[file.path + file.name] = fb;
|
|
336
|
+
}
|
|
337
|
+
++loaded;
|
|
338
|
+
if (loaded === list.length) {
|
|
339
|
+
resolve(files);
|
|
340
|
+
}
|
|
341
|
+
}).catch(function () {
|
|
342
|
+
++loaded;
|
|
343
|
+
if (loaded === list.length) {
|
|
344
|
+
resolve(files);
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
this.getContent(file.path + file.name, 'nodebuffer').then(function (fb) {
|
|
350
|
+
if (fb) {
|
|
351
|
+
files[file.path + file.name] = fb;
|
|
352
|
+
}
|
|
353
|
+
++loaded;
|
|
354
|
+
if (loaded === list.length) {
|
|
355
|
+
resolve(files);
|
|
356
|
+
}
|
|
357
|
+
}).catch(function () {
|
|
358
|
+
++loaded;
|
|
359
|
+
if (loaded === list.length) {
|
|
360
|
+
resolve(files);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return files;
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
exports.Zip = Zip;
|
|
370
|
+
async function get(data) {
|
|
371
|
+
const z = (0, jszip_1.default)();
|
|
372
|
+
try {
|
|
373
|
+
if (data) {
|
|
374
|
+
await z.loadAsync(data);
|
|
375
|
+
}
|
|
376
|
+
return new Zip(z);
|
|
377
|
+
}
|
|
378
|
+
catch {
|
|
379
|
+
return null;
|
|
380
|
+
}
|
|
381
|
+
}
|