mol_crypto_lib 0.0.414 → 0.0.415
Sign up to get free protection for your applications and to get access to all the features.
- package/node.d.ts +164 -0
- package/node.deps.json +1 -1
- package/node.esm.js +712 -20
- package/node.esm.js.map +1 -1
- package/node.js +712 -20
- package/node.js.map +1 -1
- package/node.test.js +1614 -1643
- package/node.test.js.map +1 -1
- package/package.json +18 -1
- package/web.d.ts +4 -0
- package/web.deps.json +1 -1
- package/web.esm.js +27 -20
- package/web.esm.js.map +1 -1
- package/web.js +27 -20
- package/web.js.map +1 -1
- package/web.test.js +3 -7
- package/web.test.js.map +1 -1
package/node.js
CHANGED
@@ -29,6 +29,698 @@ module.exports = $;
|
|
29
29
|
$node[ "../mam.ts" ] = $node[ "../mam.ts" ] = module.exports }.call( {} , {} )
|
30
30
|
;
|
31
31
|
"use strict";
|
32
|
+
//node/node.ts
|
33
|
+
;
|
34
|
+
"use strict";
|
35
|
+
var $node = new Proxy({ require }, {
|
36
|
+
get(target, name, wrapper) {
|
37
|
+
if (target[name])
|
38
|
+
return target[name];
|
39
|
+
const mod = target.require('module');
|
40
|
+
if (mod.builtinModules.indexOf(name) >= 0)
|
41
|
+
return target.require(name);
|
42
|
+
if (name[0] === '.')
|
43
|
+
return target.require(name);
|
44
|
+
const path = target.require('path');
|
45
|
+
const fs = target.require('fs');
|
46
|
+
let dir = path.resolve('.');
|
47
|
+
const suffix = `./node_modules/${name}`;
|
48
|
+
const $$ = $;
|
49
|
+
while (!fs.existsSync(path.join(dir, suffix))) {
|
50
|
+
const parent = path.resolve(dir, '..');
|
51
|
+
if (parent === dir) {
|
52
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
53
|
+
try {
|
54
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
55
|
+
}
|
56
|
+
catch { }
|
57
|
+
break;
|
58
|
+
}
|
59
|
+
else {
|
60
|
+
dir = parent;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
return target.require(name);
|
64
|
+
},
|
65
|
+
set(target, name, value) {
|
66
|
+
target[name] = value;
|
67
|
+
return true;
|
68
|
+
},
|
69
|
+
});
|
70
|
+
require = (req => Object.assign(function require(name) {
|
71
|
+
return $node[name];
|
72
|
+
}, req))(require);
|
73
|
+
//node/node.node.ts
|
74
|
+
;
|
75
|
+
"use strict";
|
76
|
+
var $;
|
77
|
+
(function ($) {
|
78
|
+
function $mol_log3_area_lazy(event) {
|
79
|
+
const self = this;
|
80
|
+
const stack = self.$mol_log3_stack;
|
81
|
+
const deep = stack.length;
|
82
|
+
let logged = false;
|
83
|
+
stack.push(() => {
|
84
|
+
logged = true;
|
85
|
+
self.$mol_log3_area.call(self, event);
|
86
|
+
});
|
87
|
+
return () => {
|
88
|
+
if (logged)
|
89
|
+
self.console.groupEnd();
|
90
|
+
if (stack.length > deep)
|
91
|
+
stack.length = deep;
|
92
|
+
};
|
93
|
+
}
|
94
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
95
|
+
$.$mol_log3_stack = [];
|
96
|
+
})($ || ($ = {}));
|
97
|
+
//mol/log3/log3.ts
|
98
|
+
;
|
99
|
+
"use strict";
|
100
|
+
var $;
|
101
|
+
(function ($) {
|
102
|
+
$.$mol_ambient_ref = Symbol('$mol_ambient_ref');
|
103
|
+
function $mol_ambient(overrides) {
|
104
|
+
return Object.setPrototypeOf(overrides, this || $);
|
105
|
+
}
|
106
|
+
$.$mol_ambient = $mol_ambient;
|
107
|
+
})($ || ($ = {}));
|
108
|
+
//mol/ambient/ambient.ts
|
109
|
+
;
|
110
|
+
"use strict";
|
111
|
+
var $;
|
112
|
+
(function ($) {
|
113
|
+
const instances = new WeakSet();
|
114
|
+
function $mol_delegate(proto, target) {
|
115
|
+
const proxy = new Proxy(proto, {
|
116
|
+
get: (_, field) => {
|
117
|
+
const obj = target();
|
118
|
+
let val = Reflect.get(obj, field);
|
119
|
+
if (typeof val === 'function') {
|
120
|
+
val = val.bind(obj);
|
121
|
+
}
|
122
|
+
return val;
|
123
|
+
},
|
124
|
+
has: (_, field) => Reflect.has(target(), field),
|
125
|
+
set: (_, field, value) => Reflect.set(target(), field, value),
|
126
|
+
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
127
|
+
ownKeys: () => Reflect.ownKeys(target()),
|
128
|
+
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
129
|
+
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
130
|
+
isExtensible: () => Reflect.isExtensible(target()),
|
131
|
+
preventExtensions: () => Reflect.preventExtensions(target()),
|
132
|
+
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
133
|
+
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
134
|
+
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
135
|
+
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
136
|
+
});
|
137
|
+
instances.add(proxy);
|
138
|
+
return proxy;
|
139
|
+
}
|
140
|
+
$.$mol_delegate = $mol_delegate;
|
141
|
+
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
142
|
+
value: (obj) => instances.has(obj),
|
143
|
+
});
|
144
|
+
})($ || ($ = {}));
|
145
|
+
//mol/delegate/delegate.ts
|
146
|
+
;
|
147
|
+
"use strict";
|
148
|
+
var $;
|
149
|
+
(function ($) {
|
150
|
+
$.$mol_owning_map = new WeakMap();
|
151
|
+
function $mol_owning_allow(having) {
|
152
|
+
try {
|
153
|
+
if (!having)
|
154
|
+
return false;
|
155
|
+
if (typeof having !== 'object')
|
156
|
+
return false;
|
157
|
+
if (having instanceof $mol_delegate)
|
158
|
+
return false;
|
159
|
+
if (typeof having['destructor'] !== 'function')
|
160
|
+
return false;
|
161
|
+
return true;
|
162
|
+
}
|
163
|
+
catch {
|
164
|
+
return false;
|
165
|
+
}
|
166
|
+
}
|
167
|
+
$.$mol_owning_allow = $mol_owning_allow;
|
168
|
+
function $mol_owning_get(having, Owner) {
|
169
|
+
if (!$mol_owning_allow(having))
|
170
|
+
return null;
|
171
|
+
while (true) {
|
172
|
+
const owner = $.$mol_owning_map.get(having);
|
173
|
+
if (!owner)
|
174
|
+
return owner;
|
175
|
+
if (!Owner)
|
176
|
+
return owner;
|
177
|
+
if (owner instanceof Owner)
|
178
|
+
return owner;
|
179
|
+
having = owner;
|
180
|
+
}
|
181
|
+
}
|
182
|
+
$.$mol_owning_get = $mol_owning_get;
|
183
|
+
function $mol_owning_check(owner, having) {
|
184
|
+
if (!$mol_owning_allow(having))
|
185
|
+
return false;
|
186
|
+
if ($.$mol_owning_map.get(having) !== owner)
|
187
|
+
return false;
|
188
|
+
return true;
|
189
|
+
}
|
190
|
+
$.$mol_owning_check = $mol_owning_check;
|
191
|
+
function $mol_owning_catch(owner, having) {
|
192
|
+
if (!$mol_owning_allow(having))
|
193
|
+
return false;
|
194
|
+
if ($.$mol_owning_map.get(having))
|
195
|
+
return false;
|
196
|
+
$.$mol_owning_map.set(having, owner);
|
197
|
+
return true;
|
198
|
+
}
|
199
|
+
$.$mol_owning_catch = $mol_owning_catch;
|
200
|
+
})($ || ($ = {}));
|
201
|
+
//mol/owning/owning.ts
|
202
|
+
;
|
203
|
+
"use strict";
|
204
|
+
var $;
|
205
|
+
(function ($) {
|
206
|
+
function $mol_fail(error) {
|
207
|
+
throw error;
|
208
|
+
}
|
209
|
+
$.$mol_fail = $mol_fail;
|
210
|
+
})($ || ($ = {}));
|
211
|
+
//mol/fail/fail.ts
|
212
|
+
;
|
213
|
+
"use strict";
|
214
|
+
var $;
|
215
|
+
(function ($) {
|
216
|
+
function $mol_fail_hidden(error) {
|
217
|
+
throw error;
|
218
|
+
}
|
219
|
+
$.$mol_fail_hidden = $mol_fail_hidden;
|
220
|
+
})($ || ($ = {}));
|
221
|
+
//mol/fail/hidden/hidden.ts
|
222
|
+
;
|
223
|
+
"use strict";
|
224
|
+
//mol/type/writable/writable.ts
|
225
|
+
;
|
226
|
+
"use strict";
|
227
|
+
var $;
|
228
|
+
(function ($) {
|
229
|
+
class $mol_object2 {
|
230
|
+
static $ = $;
|
231
|
+
[$mol_ambient_ref] = null;
|
232
|
+
get $() {
|
233
|
+
if (this[$mol_ambient_ref])
|
234
|
+
return this[$mol_ambient_ref];
|
235
|
+
const owner = $mol_owning_get(this);
|
236
|
+
return this[$mol_ambient_ref] = owner?.$ || $mol_object2.$;
|
237
|
+
}
|
238
|
+
set $(next) {
|
239
|
+
if (this[$mol_ambient_ref])
|
240
|
+
$mol_fail_hidden(new Error('Context already defined'));
|
241
|
+
this[$mol_ambient_ref] = next;
|
242
|
+
}
|
243
|
+
static create(init) {
|
244
|
+
const obj = new this;
|
245
|
+
if (init)
|
246
|
+
init(obj);
|
247
|
+
return obj;
|
248
|
+
}
|
249
|
+
static [Symbol.toPrimitive]() {
|
250
|
+
return this.toString();
|
251
|
+
}
|
252
|
+
static toString() {
|
253
|
+
if (Symbol.toStringTag in this)
|
254
|
+
return this[Symbol.toStringTag];
|
255
|
+
return this.name;
|
256
|
+
}
|
257
|
+
destructor() { }
|
258
|
+
toString() {
|
259
|
+
return this[Symbol.toStringTag] || this.constructor.name + '()';
|
260
|
+
}
|
261
|
+
toJSON() {
|
262
|
+
return this.toString();
|
263
|
+
}
|
264
|
+
}
|
265
|
+
$.$mol_object2 = $mol_object2;
|
266
|
+
})($ || ($ = {}));
|
267
|
+
//mol/object2/object2.ts
|
268
|
+
;
|
269
|
+
"use strict";
|
270
|
+
var $;
|
271
|
+
(function ($) {
|
272
|
+
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
273
|
+
class $mol_tree extends $mol_object2 {
|
274
|
+
type;
|
275
|
+
data;
|
276
|
+
sub;
|
277
|
+
baseUri;
|
278
|
+
row;
|
279
|
+
col;
|
280
|
+
length;
|
281
|
+
constructor(config = {}) {
|
282
|
+
super();
|
283
|
+
this.type = config.type || '';
|
284
|
+
if (config.value !== undefined) {
|
285
|
+
var sub = $mol_tree.values(config.value);
|
286
|
+
if (config.type || sub.length > 1) {
|
287
|
+
this.sub = [...sub, ...(config.sub || [])];
|
288
|
+
this.data = config.data || '';
|
289
|
+
}
|
290
|
+
else {
|
291
|
+
this.data = sub[0].data;
|
292
|
+
this.sub = config.sub || [];
|
293
|
+
}
|
294
|
+
}
|
295
|
+
else {
|
296
|
+
this.data = config.data || '';
|
297
|
+
this.sub = config.sub || [];
|
298
|
+
}
|
299
|
+
this.baseUri = config.baseUri || '';
|
300
|
+
this.row = config.row || 0;
|
301
|
+
this.col = config.col || 0;
|
302
|
+
this.length = config.length || 0;
|
303
|
+
}
|
304
|
+
static values(str, baseUri) {
|
305
|
+
return str.split('\n').map((data, index) => new $mol_tree({
|
306
|
+
data: data,
|
307
|
+
baseUri: baseUri,
|
308
|
+
row: index + 1,
|
309
|
+
length: data.length,
|
310
|
+
}));
|
311
|
+
}
|
312
|
+
clone(config = {}) {
|
313
|
+
return new $mol_tree({
|
314
|
+
type: ('type' in config) ? config.type : this.type,
|
315
|
+
data: ('data' in config) ? config.data : this.data,
|
316
|
+
sub: ('sub' in config) ? config.sub : this.sub,
|
317
|
+
baseUri: ('baseUri' in config) ? config.baseUri : this.baseUri,
|
318
|
+
row: ('row' in config) ? config.row : this.row,
|
319
|
+
col: ('col' in config) ? config.col : this.col,
|
320
|
+
length: ('length' in config) ? config.length : this.length,
|
321
|
+
value: config.value
|
322
|
+
});
|
323
|
+
}
|
324
|
+
make(config) {
|
325
|
+
return new $mol_tree({
|
326
|
+
baseUri: this.baseUri,
|
327
|
+
row: this.row,
|
328
|
+
col: this.col,
|
329
|
+
length: this.length,
|
330
|
+
...config,
|
331
|
+
});
|
332
|
+
}
|
333
|
+
make_data(value, sub) {
|
334
|
+
return this.make({ value, sub });
|
335
|
+
}
|
336
|
+
make_struct(type, sub) {
|
337
|
+
return this.make({ type, sub });
|
338
|
+
}
|
339
|
+
static fromString(str, baseUri) {
|
340
|
+
var root = new $mol_tree({ baseUri: baseUri });
|
341
|
+
var stack = [root];
|
342
|
+
var row = 0;
|
343
|
+
var prefix = str.replace(/^\n?(\t*)[\s\S]*/, '$1');
|
344
|
+
var lines = str.replace(new RegExp('^\\t{0,' + prefix.length + '}', 'mg'), '').split('\n');
|
345
|
+
lines.forEach(line => {
|
346
|
+
++row;
|
347
|
+
var chunks = /^(\t*)((?:[^\n\t\\ ]+ *)*)(\\[^\n]*)?(.*?)(?:$|\n)/m.exec(line);
|
348
|
+
if (!chunks || chunks[4])
|
349
|
+
return this.$.$mol_fail(new Error(`Syntax error at ${baseUri}:${row}\n${line}`));
|
350
|
+
var indent = chunks[1];
|
351
|
+
var path = chunks[2];
|
352
|
+
var data = chunks[3];
|
353
|
+
var deep = indent.length;
|
354
|
+
var types = path ? path.replace(/ $/, '').split(/ +/) : [];
|
355
|
+
if (stack.length <= deep)
|
356
|
+
return this.$.$mol_fail(new Error(`Too many tabs at ${baseUri}:${row}\n${line}`));
|
357
|
+
stack.length = deep + 1;
|
358
|
+
var parent = stack[deep];
|
359
|
+
let col = deep;
|
360
|
+
types.forEach(type => {
|
361
|
+
if (!type)
|
362
|
+
return this.$.$mol_fail(new Error(`Unexpected space symbol ${baseUri}:${row}\n${line}`));
|
363
|
+
var next = new $mol_tree({ type, baseUri, row, col, length: type.length });
|
364
|
+
const parent_sub = parent.sub;
|
365
|
+
parent_sub.push(next);
|
366
|
+
parent = next;
|
367
|
+
col += type.length + 1;
|
368
|
+
});
|
369
|
+
if (data) {
|
370
|
+
var next = new $mol_tree({ data: data.substring(1), baseUri, row, col, length: data.length });
|
371
|
+
const parent_sub = parent.sub;
|
372
|
+
parent_sub.push(next);
|
373
|
+
parent = next;
|
374
|
+
}
|
375
|
+
stack.push(parent);
|
376
|
+
});
|
377
|
+
return root;
|
378
|
+
}
|
379
|
+
static fromJSON(json, baseUri = '') {
|
380
|
+
switch (true) {
|
381
|
+
case typeof json === 'boolean':
|
382
|
+
case typeof json === 'number':
|
383
|
+
case json === null:
|
384
|
+
return new $mol_tree({
|
385
|
+
type: String(json),
|
386
|
+
baseUri: baseUri
|
387
|
+
});
|
388
|
+
case typeof json === 'string':
|
389
|
+
return new $mol_tree({
|
390
|
+
value: json,
|
391
|
+
baseUri: baseUri
|
392
|
+
});
|
393
|
+
case Array.isArray(json):
|
394
|
+
return new $mol_tree({
|
395
|
+
type: "/",
|
396
|
+
sub: json.map(json => $mol_tree.fromJSON(json, baseUri))
|
397
|
+
});
|
398
|
+
case json instanceof Date:
|
399
|
+
return new $mol_tree({
|
400
|
+
value: json.toISOString(),
|
401
|
+
baseUri: baseUri
|
402
|
+
});
|
403
|
+
default:
|
404
|
+
if (typeof json[$.$mol_tree_convert] === 'function') {
|
405
|
+
return json[$.$mol_tree_convert]();
|
406
|
+
}
|
407
|
+
if (typeof json.toJSON === 'function') {
|
408
|
+
return $mol_tree.fromJSON(json.toJSON());
|
409
|
+
}
|
410
|
+
if (json instanceof Error) {
|
411
|
+
const { name, message, stack } = json;
|
412
|
+
json = { ...json, name, message, stack };
|
413
|
+
}
|
414
|
+
var sub = [];
|
415
|
+
for (var key in json) {
|
416
|
+
if (json[key] === undefined)
|
417
|
+
continue;
|
418
|
+
const subsub = $mol_tree.fromJSON(json[key], baseUri);
|
419
|
+
if (/^[^\n\t\\ ]+$/.test(key)) {
|
420
|
+
var child = new $mol_tree({
|
421
|
+
type: key,
|
422
|
+
baseUri: baseUri,
|
423
|
+
sub: [subsub],
|
424
|
+
});
|
425
|
+
}
|
426
|
+
else {
|
427
|
+
var child = new $mol_tree({
|
428
|
+
value: key,
|
429
|
+
baseUri: baseUri,
|
430
|
+
sub: [subsub],
|
431
|
+
});
|
432
|
+
}
|
433
|
+
sub.push(child);
|
434
|
+
}
|
435
|
+
return new $mol_tree({
|
436
|
+
type: "*",
|
437
|
+
sub: sub,
|
438
|
+
baseUri: baseUri
|
439
|
+
});
|
440
|
+
}
|
441
|
+
}
|
442
|
+
get uri() {
|
443
|
+
return this.baseUri + '#' + this.row + ':' + this.col;
|
444
|
+
}
|
445
|
+
toString(prefix = '') {
|
446
|
+
var output = '';
|
447
|
+
if (this.type.length) {
|
448
|
+
if (!prefix.length) {
|
449
|
+
prefix = "\t";
|
450
|
+
}
|
451
|
+
output += this.type;
|
452
|
+
if (this.sub.length == 1) {
|
453
|
+
return output + ' ' + this.sub[0].toString(prefix);
|
454
|
+
}
|
455
|
+
output += "\n";
|
456
|
+
}
|
457
|
+
else if (this.data.length || prefix.length) {
|
458
|
+
output += "\\" + this.data + "\n";
|
459
|
+
}
|
460
|
+
for (var child of this.sub) {
|
461
|
+
output += prefix;
|
462
|
+
output += child.toString(prefix + "\t");
|
463
|
+
}
|
464
|
+
return output;
|
465
|
+
}
|
466
|
+
toJSON() {
|
467
|
+
if (!this.type)
|
468
|
+
return this.value;
|
469
|
+
if (this.type === 'true')
|
470
|
+
return true;
|
471
|
+
if (this.type === 'false')
|
472
|
+
return false;
|
473
|
+
if (this.type === 'null')
|
474
|
+
return null;
|
475
|
+
if (this.type === '*') {
|
476
|
+
var obj = {};
|
477
|
+
for (var child of this.sub) {
|
478
|
+
if (child.type === '-')
|
479
|
+
continue;
|
480
|
+
var key = child.type || child.clone({ sub: child.sub.slice(0, child.sub.length - 1) }).value;
|
481
|
+
var val = child.sub[child.sub.length - 1].toJSON();
|
482
|
+
if (val !== undefined)
|
483
|
+
obj[key] = val;
|
484
|
+
}
|
485
|
+
return obj;
|
486
|
+
}
|
487
|
+
if (this.type === '/') {
|
488
|
+
var res = [];
|
489
|
+
this.sub.forEach(child => {
|
490
|
+
if (child.type === '-')
|
491
|
+
return;
|
492
|
+
var val = child.toJSON();
|
493
|
+
if (val !== undefined)
|
494
|
+
res.push(val);
|
495
|
+
});
|
496
|
+
return res;
|
497
|
+
}
|
498
|
+
if (this.type === 'time') {
|
499
|
+
return new Date(this.value);
|
500
|
+
}
|
501
|
+
const numb = Number(this.type);
|
502
|
+
if (!Number.isNaN(numb) || this.type === 'NaN')
|
503
|
+
return numb;
|
504
|
+
throw new Error(`Unknown type (${this.type}) at ${this.uri}`);
|
505
|
+
}
|
506
|
+
get value() {
|
507
|
+
var values = [];
|
508
|
+
for (var child of this.sub) {
|
509
|
+
if (child.type)
|
510
|
+
continue;
|
511
|
+
values.push(child.value);
|
512
|
+
}
|
513
|
+
return this.data + values.join("\n");
|
514
|
+
}
|
515
|
+
insert(value, ...path) {
|
516
|
+
if (path.length === 0)
|
517
|
+
return value;
|
518
|
+
const type = path[0];
|
519
|
+
if (typeof type === 'string') {
|
520
|
+
let replaced = false;
|
521
|
+
const sub = this.sub.map((item, index) => {
|
522
|
+
if (item.type !== type)
|
523
|
+
return item;
|
524
|
+
replaced = true;
|
525
|
+
return item.insert(value, ...path.slice(1));
|
526
|
+
});
|
527
|
+
if (!replaced)
|
528
|
+
sub.push(new $mol_tree({ type }).insert(value, ...path.slice(1)));
|
529
|
+
return this.clone({ sub });
|
530
|
+
}
|
531
|
+
else if (typeof type === 'number') {
|
532
|
+
const sub = this.sub.slice();
|
533
|
+
sub[type] = (sub[type] || new $mol_tree).insert(value, ...path.slice(1));
|
534
|
+
return this.clone({ sub });
|
535
|
+
}
|
536
|
+
else {
|
537
|
+
return this.clone({ sub: ((this.sub.length === 0) ? [new $mol_tree()] : this.sub).map(item => item.insert(value, ...path.slice(1))) });
|
538
|
+
}
|
539
|
+
}
|
540
|
+
select(...path) {
|
541
|
+
var next = [this];
|
542
|
+
for (var type of path) {
|
543
|
+
if (!next.length)
|
544
|
+
break;
|
545
|
+
var prev = next;
|
546
|
+
next = [];
|
547
|
+
for (var item of prev) {
|
548
|
+
switch (typeof (type)) {
|
549
|
+
case 'string':
|
550
|
+
for (var child of item.sub) {
|
551
|
+
if (!type || (child.type == type)) {
|
552
|
+
next.push(child);
|
553
|
+
}
|
554
|
+
}
|
555
|
+
break;
|
556
|
+
case 'number':
|
557
|
+
if (type < item.sub.length)
|
558
|
+
next.push(item.sub[type]);
|
559
|
+
break;
|
560
|
+
default: next.push(...item.sub);
|
561
|
+
}
|
562
|
+
}
|
563
|
+
}
|
564
|
+
return new $mol_tree({ sub: next });
|
565
|
+
}
|
566
|
+
filter(path, value) {
|
567
|
+
var sub = this.sub.filter(function (item) {
|
568
|
+
var found = item.select(...path);
|
569
|
+
if (value == null) {
|
570
|
+
return Boolean(found.sub.length);
|
571
|
+
}
|
572
|
+
else {
|
573
|
+
return found.sub.some(child => child.value == value);
|
574
|
+
}
|
575
|
+
});
|
576
|
+
return new $mol_tree({ sub: sub });
|
577
|
+
}
|
578
|
+
transform(visit, stack = []) {
|
579
|
+
const sub_stack = [this, ...stack];
|
580
|
+
return visit(sub_stack, () => this.sub.map(node => node.transform(visit, sub_stack)).filter(n => n));
|
581
|
+
}
|
582
|
+
hack(context) {
|
583
|
+
const sub = [].concat(...this.sub.map(child => {
|
584
|
+
const handle = context[child.type] || context[''];
|
585
|
+
if (!handle)
|
586
|
+
$mol_fail(child.error('Handler not defined'));
|
587
|
+
return handle(child, context);
|
588
|
+
}));
|
589
|
+
return this.clone({ sub });
|
590
|
+
}
|
591
|
+
error(message) {
|
592
|
+
return new Error(`${message}:\n${this} ${this.baseUri}:${this.row}:${this.col}`);
|
593
|
+
}
|
594
|
+
}
|
595
|
+
$.$mol_tree = $mol_tree;
|
596
|
+
})($ || ($ = {}));
|
597
|
+
//mol/tree/tree.ts
|
598
|
+
;
|
599
|
+
"use strict";
|
600
|
+
var $;
|
601
|
+
(function ($) {
|
602
|
+
class $mol_term_color {
|
603
|
+
static reset = this.ansi(0, 0);
|
604
|
+
static bold = this.ansi(1, 22);
|
605
|
+
static italic = this.ansi(3, 23);
|
606
|
+
static underline = this.ansi(4, 24);
|
607
|
+
static inverse = this.ansi(7, 27);
|
608
|
+
static hidden = this.ansi(8, 28);
|
609
|
+
static strike = this.ansi(9, 29);
|
610
|
+
static gray = this.ansi(90, 39);
|
611
|
+
static red = this.ansi(91, 39);
|
612
|
+
static green = this.ansi(92, 39);
|
613
|
+
static yellow = this.ansi(93, 39);
|
614
|
+
static blue = this.ansi(94, 39);
|
615
|
+
static magenta = this.ansi(95, 39);
|
616
|
+
static cyan = this.ansi(96, 39);
|
617
|
+
static white = this.ansi(97, 39);
|
618
|
+
static Red = (str) => this.inverse(this.red(str));
|
619
|
+
static Green = (str) => this.inverse(this.green(str));
|
620
|
+
static Yellow = (str) => this.inverse(this.yellow(str));
|
621
|
+
static Blue = (str) => this.inverse(this.blue(str));
|
622
|
+
static Magenta = (str) => this.inverse(this.magenta(str));
|
623
|
+
static Cyan = (str) => this.inverse(this.cyan(str));
|
624
|
+
static White = (str) => this.inverse(this.white(str));
|
625
|
+
static ansi(open, close) {
|
626
|
+
if (typeof process === 'undefined')
|
627
|
+
return String;
|
628
|
+
if (!process.stdout.isTTY)
|
629
|
+
return String;
|
630
|
+
const prefix = `\x1b[${open}m`;
|
631
|
+
const postfix = `\x1b[${close}m`;
|
632
|
+
const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
|
633
|
+
return function colorer(str) {
|
634
|
+
str = String(str);
|
635
|
+
if (str === '')
|
636
|
+
return str;
|
637
|
+
const suffix = str.replace(suffix_regexp, prefix);
|
638
|
+
return prefix + suffix + postfix;
|
639
|
+
};
|
640
|
+
}
|
641
|
+
}
|
642
|
+
$.$mol_term_color = $mol_term_color;
|
643
|
+
})($ || ($ = {}));
|
644
|
+
//mol/term/color/color.ts
|
645
|
+
;
|
646
|
+
"use strict";
|
647
|
+
var $;
|
648
|
+
(function ($) {
|
649
|
+
function $mol_log3_node_make(level, output, type, color) {
|
650
|
+
return function $mol_log3_logger(event) {
|
651
|
+
if (!event.time)
|
652
|
+
event = { time: new Date().toISOString(), ...event };
|
653
|
+
const tree = this.$mol_tree.fromJSON(event).clone({ type });
|
654
|
+
let str = color(tree.toString());
|
655
|
+
this.console[level](str);
|
656
|
+
const self = this;
|
657
|
+
return () => self.console.groupEnd();
|
658
|
+
};
|
659
|
+
}
|
660
|
+
$.$mol_log3_node_make = $mol_log3_node_make;
|
661
|
+
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
|
662
|
+
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
|
663
|
+
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
|
664
|
+
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
|
665
|
+
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
|
666
|
+
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
667
|
+
})($ || ($ = {}));
|
668
|
+
//mol/log3/log3.node.ts
|
669
|
+
;
|
670
|
+
"use strict";
|
671
|
+
var $;
|
672
|
+
(function ($) {
|
673
|
+
function $mol_env() {
|
674
|
+
return {};
|
675
|
+
}
|
676
|
+
$.$mol_env = $mol_env;
|
677
|
+
})($ || ($ = {}));
|
678
|
+
//mol/env/env.ts
|
679
|
+
;
|
680
|
+
"use strict";
|
681
|
+
var $;
|
682
|
+
(function ($) {
|
683
|
+
$.$mol_env = function $mol_env() {
|
684
|
+
return this.process.env;
|
685
|
+
};
|
686
|
+
})($ || ($ = {}));
|
687
|
+
//mol/env/env.node.ts
|
688
|
+
;
|
689
|
+
"use strict";
|
690
|
+
var $;
|
691
|
+
(function ($) {
|
692
|
+
function $mol_exec(dir, command, ...args) {
|
693
|
+
let [app, ...args0] = command.split(' ');
|
694
|
+
args = [...args0, ...args];
|
695
|
+
this.$mol_log3_come({
|
696
|
+
place: '$mol_exec',
|
697
|
+
dir: $node.path.relative('', dir),
|
698
|
+
message: 'Run',
|
699
|
+
command: `${app} ${args.join(' ')}`,
|
700
|
+
});
|
701
|
+
var res = $node['child_process'].spawnSync(app, args, {
|
702
|
+
cwd: $node.path.resolve(dir),
|
703
|
+
shell: true,
|
704
|
+
env: this.$mol_env(),
|
705
|
+
});
|
706
|
+
if (res.status || res.error)
|
707
|
+
return $mol_fail(res.error || new Error(res.stderr.toString()));
|
708
|
+
if (!res.stdout)
|
709
|
+
res.stdout = Buffer.from([]);
|
710
|
+
return res;
|
711
|
+
}
|
712
|
+
$.$mol_exec = $mol_exec;
|
713
|
+
})($ || ($ = {}));
|
714
|
+
//mol/exec/exec.node.ts
|
715
|
+
;
|
716
|
+
"use strict";
|
717
|
+
var $;
|
718
|
+
(function ($) {
|
719
|
+
$.$mol_crypto_native = $node.crypto.webcrypto;
|
720
|
+
})($ || ($ = {}));
|
721
|
+
//mol/crypto/native/native.node.ts
|
722
|
+
;
|
723
|
+
"use strict";
|
32
724
|
var $;
|
33
725
|
(function ($) {
|
34
726
|
const algorithm = {
|
@@ -45,22 +737,22 @@ var $;
|
|
45
737
|
this.native = native;
|
46
738
|
}
|
47
739
|
static async generate() {
|
48
|
-
return new this(await
|
740
|
+
return new this(await $mol_crypto_native.subtle.generateKey(algorithm, true, ['encrypt', 'decrypt']));
|
49
741
|
}
|
50
742
|
static async from(serial) {
|
51
|
-
return new this(await
|
743
|
+
return new this(await $mol_crypto_native.subtle.importKey('raw', serial, algorithm, true, ['encrypt', 'decrypt']));
|
52
744
|
}
|
53
745
|
async serial() {
|
54
|
-
return await
|
746
|
+
return await $mol_crypto_native.subtle.exportKey('raw', this.native);
|
55
747
|
}
|
56
748
|
async encrypt(open, salt) {
|
57
|
-
return await
|
749
|
+
return await $mol_crypto_native.subtle.encrypt({
|
58
750
|
...algorithm,
|
59
751
|
iv: salt,
|
60
752
|
}, this.native, open);
|
61
753
|
}
|
62
754
|
async decrypt(closed, salt) {
|
63
|
-
return await
|
755
|
+
return await $mol_crypto_native.subtle.decrypt({
|
64
756
|
...algorithm,
|
65
757
|
iv: salt,
|
66
758
|
}, this.native, closed);
|
@@ -80,7 +772,7 @@ var $;
|
|
80
772
|
hash: 'SHA-1',
|
81
773
|
};
|
82
774
|
async function $mol_crypto_cipher_pair() {
|
83
|
-
const pair = await
|
775
|
+
const pair = await $mol_crypto_native.subtle.generateKey(algorithm, true, ['encrypt', 'decrypt']);
|
84
776
|
return {
|
85
777
|
public: new $mol_crypto_cipher_public(pair.publicKey),
|
86
778
|
private: new $mol_crypto_cipher_private(pair.privateKey),
|
@@ -95,13 +787,13 @@ var $;
|
|
95
787
|
this.native = native;
|
96
788
|
}
|
97
789
|
static async from(serial) {
|
98
|
-
return new this(await
|
790
|
+
return new this(await $mol_crypto_native.subtle.importKey('spki', serial, algorithm, true, ['encrypt']));
|
99
791
|
}
|
100
792
|
async serial() {
|
101
|
-
return await
|
793
|
+
return await $mol_crypto_native.subtle.exportKey('spki', this.native);
|
102
794
|
}
|
103
795
|
async encrypt(data) {
|
104
|
-
return await
|
796
|
+
return await $mol_crypto_native.subtle.encrypt(algorithm, this.native, data);
|
105
797
|
}
|
106
798
|
}
|
107
799
|
$.$mol_crypto_cipher_public = $mol_crypto_cipher_public;
|
@@ -112,13 +804,13 @@ var $;
|
|
112
804
|
this.native = native;
|
113
805
|
}
|
114
806
|
static async from(serial) {
|
115
|
-
return new this(await
|
807
|
+
return new this(await $mol_crypto_native.subtle.importKey('pkcs8', serial, algorithm, true, ['decrypt']));
|
116
808
|
}
|
117
809
|
async serial() {
|
118
|
-
return await
|
810
|
+
return await $mol_crypto_native.subtle.exportKey('pkcs8', this.native);
|
119
811
|
}
|
120
812
|
async decrypt(data) {
|
121
|
-
return await
|
813
|
+
return await $mol_crypto_native.subtle.decrypt(algorithm, this.native, data);
|
122
814
|
}
|
123
815
|
}
|
124
816
|
$.$mol_crypto_cipher_private = $mol_crypto_cipher_private;
|
@@ -137,7 +829,7 @@ var $;
|
|
137
829
|
saltLength: 8,
|
138
830
|
};
|
139
831
|
async function $mol_crypto_auditor_pair() {
|
140
|
-
const pair = await
|
832
|
+
const pair = await $mol_crypto_native.subtle.generateKey(algorithm, true, ['sign', 'verify']);
|
141
833
|
return {
|
142
834
|
public: new $mol_crypto_auditor_public(pair.publicKey),
|
143
835
|
private: new $mol_crypto_auditor_private(pair.privateKey),
|
@@ -152,13 +844,13 @@ var $;
|
|
152
844
|
this.native = native;
|
153
845
|
}
|
154
846
|
static async from(serial) {
|
155
|
-
return new this(await
|
847
|
+
return new this(await $mol_crypto_native.subtle.importKey('spki', serial, algorithm, true, ['verify']));
|
156
848
|
}
|
157
849
|
async serial() {
|
158
|
-
return await
|
850
|
+
return await $mol_crypto_native.subtle.exportKey('spki', this.native);
|
159
851
|
}
|
160
852
|
async verify(data, sign) {
|
161
|
-
return await
|
853
|
+
return await $mol_crypto_native.subtle.verify(algorithm, this.native, sign, data);
|
162
854
|
}
|
163
855
|
}
|
164
856
|
$.$mol_crypto_auditor_public = $mol_crypto_auditor_public;
|
@@ -170,13 +862,13 @@ var $;
|
|
170
862
|
this.native = native;
|
171
863
|
}
|
172
864
|
static async from(serial) {
|
173
|
-
return new this(await
|
865
|
+
return new this(await $mol_crypto_native.subtle.importKey('pkcs8', serial, algorithm, true, ['sign']));
|
174
866
|
}
|
175
867
|
async serial() {
|
176
|
-
return await
|
868
|
+
return await $mol_crypto_native.subtle.exportKey('pkcs8', this.native);
|
177
869
|
}
|
178
870
|
async sign(data) {
|
179
|
-
return await
|
871
|
+
return await $mol_crypto_native.subtle.sign(algorithm, this.native, data);
|
180
872
|
}
|
181
873
|
}
|
182
874
|
$.$mol_crypto_auditor_private = $mol_crypto_auditor_private;
|
@@ -260,7 +952,7 @@ var $;
|
|
260
952
|
var $;
|
261
953
|
(function ($) {
|
262
954
|
function $mol_crypto_salt() {
|
263
|
-
return
|
955
|
+
return $mol_crypto_native.getRandomValues(new Uint8Array(12));
|
264
956
|
}
|
265
957
|
$.$mol_crypto_salt = $mol_crypto_salt;
|
266
958
|
})($ || ($ = {}));
|