mol_crypto2_lib 0.0.1
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/.nojekyll +0 -0
- package/README.md +72 -0
- package/manifest.json +10 -0
- package/node.audit.js +2 -0
- package/node.d.ts +674 -0
- package/node.d.ts.map +1 -0
- package/node.deps.json +1 -0
- package/node.js +2805 -0
- package/node.js.map +1 -0
- package/node.meta.tree +28 -0
- package/node.mjs +2806 -0
- package/node.test.js +5272 -0
- package/node.test.js.map +1 -0
- package/package.json +99 -0
- package/test.html +11 -0
- package/web.audit.js +2 -0
- package/web.css +1 -0
- package/web.css.map +1 -0
- package/web.d.ts +272 -0
- package/web.d.ts.map +1 -0
- package/web.deps.json +1 -0
- package/web.js +920 -0
- package/web.js.map +1 -0
- package/web.meta.tree +28 -0
- package/web.mjs +921 -0
- package/web.test.js +1993 -0
- package/web.test.js.map +1 -0
package/node.js
ADDED
|
@@ -0,0 +1,2805 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var exports = void 0;
|
|
4
|
+
|
|
5
|
+
var $node = $node || {}
|
|
6
|
+
void function( module ) { var exports = module.exports = this; function require( id ) { return $node[ id.replace( /^.\// , "../" ) ] };
|
|
7
|
+
;
|
|
8
|
+
"use strict";
|
|
9
|
+
Error.stackTraceLimit = 50;
|
|
10
|
+
var $;
|
|
11
|
+
(function ($) {
|
|
12
|
+
})($ || ($ = {}));
|
|
13
|
+
module.exports = $;
|
|
14
|
+
|
|
15
|
+
;
|
|
16
|
+
|
|
17
|
+
$node[ "../mam.ts" ] = $node[ "../mam.ts" ] = module.exports }.call( {} , {} )
|
|
18
|
+
;
|
|
19
|
+
"use strict"
|
|
20
|
+
|
|
21
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
22
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
23
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
24
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if ((d = decorators[i])) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
25
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var $ = ( typeof module === 'object' ) ? ( module['export'+'s'] = globalThis ) : globalThis
|
|
29
|
+
$.$$ = $
|
|
30
|
+
|
|
31
|
+
;
|
|
32
|
+
"use strict";
|
|
33
|
+
var $;
|
|
34
|
+
(function ($) {
|
|
35
|
+
function $mol_base64_encode(src) {
|
|
36
|
+
return src.toBase64();
|
|
37
|
+
}
|
|
38
|
+
$.$mol_base64_encode = $mol_base64_encode;
|
|
39
|
+
})($ || ($ = {}));
|
|
40
|
+
|
|
41
|
+
;
|
|
42
|
+
"use strict";
|
|
43
|
+
var $;
|
|
44
|
+
(function ($) {
|
|
45
|
+
function $mol_base64_encode_node(str) {
|
|
46
|
+
if (!str)
|
|
47
|
+
return '';
|
|
48
|
+
const buf = Buffer.isBuffer(str) ? str : Buffer.from(str);
|
|
49
|
+
return buf.toString('base64');
|
|
50
|
+
}
|
|
51
|
+
$.$mol_base64_encode_node = $mol_base64_encode_node;
|
|
52
|
+
if (!('toBase64' in Uint8Array.prototype)) {
|
|
53
|
+
$.$mol_base64_encode = $mol_base64_encode_node;
|
|
54
|
+
}
|
|
55
|
+
})($ || ($ = {}));
|
|
56
|
+
|
|
57
|
+
;
|
|
58
|
+
"use strict";
|
|
59
|
+
var $;
|
|
60
|
+
(function ($) {
|
|
61
|
+
function $mol_base64_decode(base64) {
|
|
62
|
+
return Uint8Array.fromBase64(base64);
|
|
63
|
+
}
|
|
64
|
+
$.$mol_base64_decode = $mol_base64_decode;
|
|
65
|
+
})($ || ($ = {}));
|
|
66
|
+
|
|
67
|
+
;
|
|
68
|
+
"use strict";
|
|
69
|
+
var $;
|
|
70
|
+
(function ($) {
|
|
71
|
+
function $mol_base64_decode_node(base64Str) {
|
|
72
|
+
const buffer = Buffer.from(base64Str, 'base64');
|
|
73
|
+
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
74
|
+
}
|
|
75
|
+
$.$mol_base64_decode_node = $mol_base64_decode_node;
|
|
76
|
+
if (!('fromBase64' in Uint8Array)) {
|
|
77
|
+
$.$mol_base64_decode = $mol_base64_decode_node;
|
|
78
|
+
}
|
|
79
|
+
})($ || ($ = {}));
|
|
80
|
+
|
|
81
|
+
;
|
|
82
|
+
"use strict";
|
|
83
|
+
var $;
|
|
84
|
+
(function ($) {
|
|
85
|
+
function $mol_base64_ae_encode(buffer) {
|
|
86
|
+
return $mol_base64_encode(buffer).replace(/\+/g, 'æ').replace(/\//g, 'Æ').replace(/=/g, '');
|
|
87
|
+
}
|
|
88
|
+
$.$mol_base64_ae_encode = $mol_base64_ae_encode;
|
|
89
|
+
function $mol_base64_ae_decode(str) {
|
|
90
|
+
return $mol_base64_decode(str.replace(/æ/g, '+').replace(/Æ/g, '/'));
|
|
91
|
+
}
|
|
92
|
+
$.$mol_base64_ae_decode = $mol_base64_ae_decode;
|
|
93
|
+
})($ || ($ = {}));
|
|
94
|
+
|
|
95
|
+
;
|
|
96
|
+
"use strict";
|
|
97
|
+
var $;
|
|
98
|
+
(function ($) {
|
|
99
|
+
const named = new WeakSet();
|
|
100
|
+
function $mol_func_name(func) {
|
|
101
|
+
let name = func.name;
|
|
102
|
+
if (name?.length > 1)
|
|
103
|
+
return name;
|
|
104
|
+
if (named.has(func))
|
|
105
|
+
return name;
|
|
106
|
+
for (let key in this) {
|
|
107
|
+
try {
|
|
108
|
+
if (this[key] !== func)
|
|
109
|
+
continue;
|
|
110
|
+
name = key;
|
|
111
|
+
Object.defineProperty(func, 'name', { value: name });
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
catch { }
|
|
115
|
+
}
|
|
116
|
+
named.add(func);
|
|
117
|
+
return name;
|
|
118
|
+
}
|
|
119
|
+
$.$mol_func_name = $mol_func_name;
|
|
120
|
+
function $mol_func_name_from(target, source) {
|
|
121
|
+
Object.defineProperty(target, 'name', { value: source.name });
|
|
122
|
+
return target;
|
|
123
|
+
}
|
|
124
|
+
$.$mol_func_name_from = $mol_func_name_from;
|
|
125
|
+
})($ || ($ = {}));
|
|
126
|
+
|
|
127
|
+
;
|
|
128
|
+
"use strict";
|
|
129
|
+
var $;
|
|
130
|
+
(function ($) {
|
|
131
|
+
function $mol_fail(error) {
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
$.$mol_fail = $mol_fail;
|
|
135
|
+
})($ || ($ = {}));
|
|
136
|
+
|
|
137
|
+
;
|
|
138
|
+
"use strict";
|
|
139
|
+
var $;
|
|
140
|
+
(function ($) {
|
|
141
|
+
class $mol_buffer extends DataView {
|
|
142
|
+
[Symbol.toStringTag] = this.constructor.name + '<>';
|
|
143
|
+
static from(array) {
|
|
144
|
+
if (typeof array === 'number')
|
|
145
|
+
array = new Uint8Array(array);
|
|
146
|
+
if (typeof array === 'string')
|
|
147
|
+
array = $mol_base64_ae_decode(array);
|
|
148
|
+
if (!ArrayBuffer.isView(array))
|
|
149
|
+
array = new Uint8Array(array);
|
|
150
|
+
return new this(array.buffer, array.byteOffset, array.byteLength);
|
|
151
|
+
}
|
|
152
|
+
static toString() {
|
|
153
|
+
return $$.$mol_func_name(this);
|
|
154
|
+
}
|
|
155
|
+
getUint48(offset, LE = false) {
|
|
156
|
+
if (offset % 4) {
|
|
157
|
+
return this.getUint16(offset, LE) + this.getUint32(offset + 2, LE) * 2 ** 16;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
return this.getUint32(offset, LE) + this.getUint16(offset + 4, LE) * 2 ** 32;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
setUint48(offset, value, LE = false) {
|
|
164
|
+
if (offset % 4) {
|
|
165
|
+
this.setUint16(offset, value & ((1 << 16) - 1), LE);
|
|
166
|
+
this.setUint32(offset + 2, (value / 2 ** 16) | 0, LE);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
this.setUint32(offset, value | 0, LE);
|
|
170
|
+
this.setUint16(offset + 4, (value / 2 ** 32) | 0, LE);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
int8(offset, next) {
|
|
174
|
+
if (next === undefined)
|
|
175
|
+
return this.getInt8(offset);
|
|
176
|
+
if (next >= -(2 ** 7) && next < 2 ** 7)
|
|
177
|
+
return this.setInt8(offset, next), next;
|
|
178
|
+
$mol_fail(new Error(`Wrong int8 value ${next}`));
|
|
179
|
+
}
|
|
180
|
+
uint8(offset, next) {
|
|
181
|
+
if (next === undefined)
|
|
182
|
+
return this.getUint8(offset);
|
|
183
|
+
if (next >= 0 && next < 2 ** 8)
|
|
184
|
+
return this.setUint8(offset, next), next;
|
|
185
|
+
$mol_fail(new Error(`Wrong uint8 value ${next}`));
|
|
186
|
+
}
|
|
187
|
+
int16(offset, next) {
|
|
188
|
+
if (next === undefined)
|
|
189
|
+
return this.getInt16(offset, true);
|
|
190
|
+
if (next >= -(2 ** 15) && next < 2 ** 15)
|
|
191
|
+
return this.setInt16(offset, next, true), next;
|
|
192
|
+
$mol_fail(new Error(`Wrong int16 value ${next}`));
|
|
193
|
+
}
|
|
194
|
+
uint16(offset, next) {
|
|
195
|
+
if (next === undefined)
|
|
196
|
+
return this.getUint16(offset, true);
|
|
197
|
+
if (next >= 0 && next < 2 ** 16)
|
|
198
|
+
return this.setUint16(offset, next, true), next;
|
|
199
|
+
$mol_fail(new Error(`Wrong uint16 value ${next}`));
|
|
200
|
+
}
|
|
201
|
+
int32(offset, next) {
|
|
202
|
+
if (next === undefined)
|
|
203
|
+
return this.getInt32(offset, true);
|
|
204
|
+
if (next >= -(2 ** 31) && next < 2 ** 31)
|
|
205
|
+
return this.setInt32(offset, next, true), next;
|
|
206
|
+
$mol_fail(new Error(`Wrong int32 value ${next}`));
|
|
207
|
+
}
|
|
208
|
+
uint32(offset, next) {
|
|
209
|
+
if (next === undefined)
|
|
210
|
+
return this.getUint32(offset, true);
|
|
211
|
+
if (next >= 0 && next < 2 ** 32)
|
|
212
|
+
return this.setUint32(offset, next, true), next;
|
|
213
|
+
$mol_fail(new Error(`Wrong uint32 value ${next}`));
|
|
214
|
+
}
|
|
215
|
+
int64(offset, next) {
|
|
216
|
+
if (next === undefined)
|
|
217
|
+
return this.getBigInt64(offset, true);
|
|
218
|
+
if (next >= -(2n ** 63n) && next < 2n ** 63n)
|
|
219
|
+
return this.setBigInt64(offset, next, true), next;
|
|
220
|
+
$mol_fail(new Error(`Wrong int64 value ${next}`));
|
|
221
|
+
}
|
|
222
|
+
uint48(offset, next) {
|
|
223
|
+
if (next === undefined)
|
|
224
|
+
return this.getUint48(offset, true);
|
|
225
|
+
if (next >= 0 && next < 2 ** 48)
|
|
226
|
+
return this.setUint48(offset, next, true), next;
|
|
227
|
+
$mol_fail(new Error(`Wrong uint48 value ${next}`));
|
|
228
|
+
}
|
|
229
|
+
uint64(offset, next) {
|
|
230
|
+
if (next === undefined)
|
|
231
|
+
return this.getBigUint64(offset, true);
|
|
232
|
+
if (next >= 0n && next < 2n ** 64n)
|
|
233
|
+
return this.setBigUint64(offset, next, true), next;
|
|
234
|
+
$mol_fail(new Error(`Wrong uint64 value ${next}`));
|
|
235
|
+
}
|
|
236
|
+
float16(offset, next) {
|
|
237
|
+
if (next !== undefined)
|
|
238
|
+
this.setFloat16(offset, next, true);
|
|
239
|
+
return this.getFloat16(offset, true);
|
|
240
|
+
}
|
|
241
|
+
float32(offset, next) {
|
|
242
|
+
if (next !== undefined)
|
|
243
|
+
this.setFloat32(offset, next, true);
|
|
244
|
+
return this.getFloat32(offset, true);
|
|
245
|
+
}
|
|
246
|
+
float64(offset, next) {
|
|
247
|
+
if (next !== undefined)
|
|
248
|
+
this.setFloat64(offset, next, true);
|
|
249
|
+
return this.getFloat64(offset, true);
|
|
250
|
+
}
|
|
251
|
+
asArray() {
|
|
252
|
+
return new Uint8Array(this.buffer, this.byteOffset, this.byteLength);
|
|
253
|
+
}
|
|
254
|
+
toString() {
|
|
255
|
+
return $mol_base64_ae_encode(this.asArray());
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
$.$mol_buffer = $mol_buffer;
|
|
259
|
+
})($ || ($ = {}));
|
|
260
|
+
|
|
261
|
+
;
|
|
262
|
+
"use strict";
|
|
263
|
+
var $;
|
|
264
|
+
(function ($) {
|
|
265
|
+
function $mol_base64_url_encode(buffer) {
|
|
266
|
+
return buffer.toBase64({ alphabet: 'base64url', omitPadding: true });
|
|
267
|
+
}
|
|
268
|
+
$.$mol_base64_url_encode = $mol_base64_url_encode;
|
|
269
|
+
function $mol_base64_url_decode(str) {
|
|
270
|
+
return Uint8Array.fromBase64(str, { alphabet: 'base64url' });
|
|
271
|
+
}
|
|
272
|
+
$.$mol_base64_url_decode = $mol_base64_url_decode;
|
|
273
|
+
})($ || ($ = {}));
|
|
274
|
+
|
|
275
|
+
;
|
|
276
|
+
"use strict";
|
|
277
|
+
var $;
|
|
278
|
+
(function ($) {
|
|
279
|
+
function $mol_base64_url_encode_node(str) {
|
|
280
|
+
if (!str)
|
|
281
|
+
return '';
|
|
282
|
+
const buf = Buffer.isBuffer(str) ? str : Buffer.from(str);
|
|
283
|
+
return buf.toString('base64url').replace(/=/g, '');
|
|
284
|
+
}
|
|
285
|
+
$.$mol_base64_url_encode_node = $mol_base64_url_encode_node;
|
|
286
|
+
if (!('toBase64' in Uint8Array.prototype)) {
|
|
287
|
+
$.$mol_base64_url_encode = $mol_base64_url_encode_node;
|
|
288
|
+
}
|
|
289
|
+
function $mol_base64_url_decode_node(str) {
|
|
290
|
+
const buffer = Buffer.from(str, 'base64url');
|
|
291
|
+
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
292
|
+
}
|
|
293
|
+
$.$mol_base64_url_decode_node = $mol_base64_url_decode_node;
|
|
294
|
+
if (!('fromBase64' in Uint8Array)) {
|
|
295
|
+
$.$mol_base64_url_decode = $mol_base64_url_decode_node;
|
|
296
|
+
}
|
|
297
|
+
})($ || ($ = {}));
|
|
298
|
+
|
|
299
|
+
;
|
|
300
|
+
"use strict";
|
|
301
|
+
var $;
|
|
302
|
+
(function ($) {
|
|
303
|
+
$.$mol_ambient_ref = Symbol('$mol_ambient_ref');
|
|
304
|
+
function $mol_ambient(overrides) {
|
|
305
|
+
return Object.setPrototypeOf(overrides, this || $);
|
|
306
|
+
}
|
|
307
|
+
$.$mol_ambient = $mol_ambient;
|
|
308
|
+
})($ || ($ = {}));
|
|
309
|
+
|
|
310
|
+
;
|
|
311
|
+
"use strict";
|
|
312
|
+
var $;
|
|
313
|
+
(function ($) {
|
|
314
|
+
const instances = new WeakSet();
|
|
315
|
+
function $mol_delegate(proto, target) {
|
|
316
|
+
const proxy = new Proxy(proto, {
|
|
317
|
+
get: (_, field) => {
|
|
318
|
+
const obj = target();
|
|
319
|
+
let val = Reflect.get(obj, field);
|
|
320
|
+
if (typeof val === 'function') {
|
|
321
|
+
val = val.bind(obj);
|
|
322
|
+
}
|
|
323
|
+
return val;
|
|
324
|
+
},
|
|
325
|
+
has: (_, field) => Reflect.has(target(), field),
|
|
326
|
+
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
327
|
+
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
328
|
+
ownKeys: () => Reflect.ownKeys(target()),
|
|
329
|
+
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
330
|
+
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
331
|
+
isExtensible: () => Reflect.isExtensible(target()),
|
|
332
|
+
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
333
|
+
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
334
|
+
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
335
|
+
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
336
|
+
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
337
|
+
});
|
|
338
|
+
instances.add(proxy);
|
|
339
|
+
return proxy;
|
|
340
|
+
}
|
|
341
|
+
$.$mol_delegate = $mol_delegate;
|
|
342
|
+
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
343
|
+
value: (obj) => instances.has(obj),
|
|
344
|
+
});
|
|
345
|
+
})($ || ($ = {}));
|
|
346
|
+
|
|
347
|
+
;
|
|
348
|
+
"use strict";
|
|
349
|
+
var $;
|
|
350
|
+
(function ($) {
|
|
351
|
+
$.$mol_owning_map = new WeakMap();
|
|
352
|
+
function $mol_owning_allow(having) {
|
|
353
|
+
try {
|
|
354
|
+
if (!having)
|
|
355
|
+
return false;
|
|
356
|
+
if (typeof having !== 'object' && typeof having !== 'function')
|
|
357
|
+
return false;
|
|
358
|
+
if (having instanceof $mol_delegate)
|
|
359
|
+
return false;
|
|
360
|
+
if (typeof having['destructor'] !== 'function')
|
|
361
|
+
return false;
|
|
362
|
+
return true;
|
|
363
|
+
}
|
|
364
|
+
catch {
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
$.$mol_owning_allow = $mol_owning_allow;
|
|
369
|
+
function $mol_owning_get(having, Owner) {
|
|
370
|
+
if (!$mol_owning_allow(having))
|
|
371
|
+
return null;
|
|
372
|
+
while (true) {
|
|
373
|
+
const owner = $.$mol_owning_map.get(having);
|
|
374
|
+
if (!owner)
|
|
375
|
+
return owner;
|
|
376
|
+
if (!Owner)
|
|
377
|
+
return owner;
|
|
378
|
+
if (owner instanceof Owner)
|
|
379
|
+
return owner;
|
|
380
|
+
having = owner;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
$.$mol_owning_get = $mol_owning_get;
|
|
384
|
+
function $mol_owning_check(owner, having) {
|
|
385
|
+
if (!$mol_owning_allow(having))
|
|
386
|
+
return false;
|
|
387
|
+
if ($.$mol_owning_map.get(having) !== owner)
|
|
388
|
+
return false;
|
|
389
|
+
return true;
|
|
390
|
+
}
|
|
391
|
+
$.$mol_owning_check = $mol_owning_check;
|
|
392
|
+
function $mol_owning_catch(owner, having) {
|
|
393
|
+
if (!$mol_owning_allow(having))
|
|
394
|
+
return false;
|
|
395
|
+
if ($.$mol_owning_map.get(having))
|
|
396
|
+
return false;
|
|
397
|
+
$.$mol_owning_map.set(having, owner);
|
|
398
|
+
return true;
|
|
399
|
+
}
|
|
400
|
+
$.$mol_owning_catch = $mol_owning_catch;
|
|
401
|
+
})($ || ($ = {}));
|
|
402
|
+
|
|
403
|
+
;
|
|
404
|
+
"use strict";
|
|
405
|
+
var $;
|
|
406
|
+
(function ($) {
|
|
407
|
+
function $mol_fail_hidden(error) {
|
|
408
|
+
throw error;
|
|
409
|
+
}
|
|
410
|
+
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
411
|
+
})($ || ($ = {}));
|
|
412
|
+
|
|
413
|
+
;
|
|
414
|
+
"use strict";
|
|
415
|
+
|
|
416
|
+
;
|
|
417
|
+
"use strict";
|
|
418
|
+
var $;
|
|
419
|
+
(function ($) {
|
|
420
|
+
$.$mol_key_handle = Symbol.for('$mol_key_handle');
|
|
421
|
+
$.$mol_key_store = new WeakMap();
|
|
422
|
+
})($ || ($ = {}));
|
|
423
|
+
|
|
424
|
+
;
|
|
425
|
+
"use strict";
|
|
426
|
+
var $;
|
|
427
|
+
(function ($) {
|
|
428
|
+
if (!Symbol.dispose)
|
|
429
|
+
Symbol.dispose = Symbol('Symbol.dispose');
|
|
430
|
+
class $mol_object2 {
|
|
431
|
+
static $ = $;
|
|
432
|
+
[Symbol.toStringTag];
|
|
433
|
+
[$mol_ambient_ref] = null;
|
|
434
|
+
get $() {
|
|
435
|
+
if (this[$mol_ambient_ref])
|
|
436
|
+
return this[$mol_ambient_ref];
|
|
437
|
+
const owner = $mol_owning_get(this);
|
|
438
|
+
return this[$mol_ambient_ref] = owner?.$ || this.constructor.$ || $mol_object2.$;
|
|
439
|
+
}
|
|
440
|
+
set $(next) {
|
|
441
|
+
if (this[$mol_ambient_ref])
|
|
442
|
+
$mol_fail_hidden(new Error('Context already defined'));
|
|
443
|
+
this[$mol_ambient_ref] = next;
|
|
444
|
+
}
|
|
445
|
+
static create(init) {
|
|
446
|
+
const obj = new this;
|
|
447
|
+
if (init)
|
|
448
|
+
init(obj);
|
|
449
|
+
return obj;
|
|
450
|
+
}
|
|
451
|
+
static [Symbol.toPrimitive]() {
|
|
452
|
+
return this.toString();
|
|
453
|
+
}
|
|
454
|
+
static toString() {
|
|
455
|
+
return this[Symbol.toStringTag] || this.$.$mol_func_name(this);
|
|
456
|
+
}
|
|
457
|
+
static toJSON() {
|
|
458
|
+
return this.toString();
|
|
459
|
+
}
|
|
460
|
+
static [$mol_key_handle]() {
|
|
461
|
+
return this.toString();
|
|
462
|
+
}
|
|
463
|
+
destructor() { }
|
|
464
|
+
static destructor() { }
|
|
465
|
+
[Symbol.dispose]() {
|
|
466
|
+
this.destructor();
|
|
467
|
+
}
|
|
468
|
+
toString() {
|
|
469
|
+
return this[Symbol.toStringTag] || this.constructor.name + '<>';
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
$.$mol_object2 = $mol_object2;
|
|
473
|
+
})($ || ($ = {}));
|
|
474
|
+
|
|
475
|
+
;
|
|
476
|
+
"use strict";
|
|
477
|
+
var $;
|
|
478
|
+
(function ($) {
|
|
479
|
+
class $mol_wrapper extends $mol_object2 {
|
|
480
|
+
static wrap;
|
|
481
|
+
static run(task) {
|
|
482
|
+
return this.func(task)();
|
|
483
|
+
}
|
|
484
|
+
static func(func) {
|
|
485
|
+
return this.wrap(func);
|
|
486
|
+
}
|
|
487
|
+
static get class() {
|
|
488
|
+
return (Class) => {
|
|
489
|
+
const construct = (target, args) => new Class(...args);
|
|
490
|
+
const handler = {
|
|
491
|
+
construct: this.func(construct)
|
|
492
|
+
};
|
|
493
|
+
handler[Symbol.toStringTag] = Class.name + '#';
|
|
494
|
+
return new Proxy(Class, handler);
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
static get method() {
|
|
498
|
+
return (obj, name, descr = Reflect.getOwnPropertyDescriptor(obj, name)) => {
|
|
499
|
+
descr.value = this.func(descr.value);
|
|
500
|
+
return descr;
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
static get field() {
|
|
504
|
+
return (obj, name, descr = Reflect.getOwnPropertyDescriptor(obj, name)) => {
|
|
505
|
+
descr.get = descr.set = this.func(descr.get);
|
|
506
|
+
return descr;
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
$.$mol_wrapper = $mol_wrapper;
|
|
511
|
+
})($ || ($ = {}));
|
|
512
|
+
|
|
513
|
+
;
|
|
514
|
+
"use strict";
|
|
515
|
+
var $;
|
|
516
|
+
(function ($) {
|
|
517
|
+
class $mol_memo extends $mol_wrapper {
|
|
518
|
+
static wrap(task) {
|
|
519
|
+
const store = new WeakMap();
|
|
520
|
+
const fun = function (next) {
|
|
521
|
+
if (next === undefined && store.has(this))
|
|
522
|
+
return store.get(this);
|
|
523
|
+
const val = task.call(this, next) ?? next;
|
|
524
|
+
store.set(this, val);
|
|
525
|
+
return val;
|
|
526
|
+
};
|
|
527
|
+
Reflect.defineProperty(fun, 'name', { value: task.name + ' ' });
|
|
528
|
+
return fun;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
$.$mol_memo = $mol_memo;
|
|
532
|
+
})($ || ($ = {}));
|
|
533
|
+
|
|
534
|
+
;
|
|
535
|
+
"use strict";
|
|
536
|
+
var $;
|
|
537
|
+
(function ($) {
|
|
538
|
+
class $mol_crypto2_key extends $mol_buffer {
|
|
539
|
+
static size_str = 43;
|
|
540
|
+
static size_bin = 32;
|
|
541
|
+
static from(serial) {
|
|
542
|
+
if (typeof serial === 'string') {
|
|
543
|
+
serial = new Uint8Array(serial.match(/.{43}/g)
|
|
544
|
+
.flatMap(chunk => [...$mol_base64_url_decode(chunk)]));
|
|
545
|
+
}
|
|
546
|
+
return super.from(serial);
|
|
547
|
+
}
|
|
548
|
+
asArray() {
|
|
549
|
+
return new Uint8Array(this.buffer, this.byteOffset, this.constructor.size_bin);
|
|
550
|
+
}
|
|
551
|
+
toString() {
|
|
552
|
+
return $mol_base64_url_encode(this.asArray());
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
__decorate([
|
|
556
|
+
$mol_memo.method
|
|
557
|
+
], $mol_crypto2_key.prototype, "toString", null);
|
|
558
|
+
$.$mol_crypto2_key = $mol_crypto2_key;
|
|
559
|
+
})($ || ($ = {}));
|
|
560
|
+
|
|
561
|
+
;
|
|
562
|
+
"use strict";
|
|
563
|
+
|
|
564
|
+
;
|
|
565
|
+
"use strict";
|
|
566
|
+
var $;
|
|
567
|
+
(function ($) {
|
|
568
|
+
const mod = require('module');
|
|
569
|
+
const internals = mod.builtinModules;
|
|
570
|
+
function $node_internal_check(name) {
|
|
571
|
+
if (name.startsWith('node:'))
|
|
572
|
+
return true;
|
|
573
|
+
return internals.includes(name);
|
|
574
|
+
}
|
|
575
|
+
$.$node_internal_check = $node_internal_check;
|
|
576
|
+
})($ || ($ = {}));
|
|
577
|
+
|
|
578
|
+
;
|
|
579
|
+
"use strict";
|
|
580
|
+
var $;
|
|
581
|
+
(function ($) {
|
|
582
|
+
function $mol_promise_like(val) {
|
|
583
|
+
try {
|
|
584
|
+
return val && typeof val === 'object' && 'then' in val && typeof val.then === 'function';
|
|
585
|
+
}
|
|
586
|
+
catch {
|
|
587
|
+
return false;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
$.$mol_promise_like = $mol_promise_like;
|
|
591
|
+
})($ || ($ = {}));
|
|
592
|
+
|
|
593
|
+
;
|
|
594
|
+
"use strict";
|
|
595
|
+
var $;
|
|
596
|
+
(function ($) {
|
|
597
|
+
const catched = new WeakSet();
|
|
598
|
+
function $mol_fail_catch(error) {
|
|
599
|
+
if (typeof error !== 'object')
|
|
600
|
+
return false;
|
|
601
|
+
if ($mol_promise_like(error))
|
|
602
|
+
$mol_fail_hidden(error);
|
|
603
|
+
if (catched.has(error))
|
|
604
|
+
return false;
|
|
605
|
+
catched.add(error);
|
|
606
|
+
return true;
|
|
607
|
+
}
|
|
608
|
+
$.$mol_fail_catch = $mol_fail_catch;
|
|
609
|
+
})($ || ($ = {}));
|
|
610
|
+
|
|
611
|
+
;
|
|
612
|
+
"use strict";
|
|
613
|
+
var $;
|
|
614
|
+
(function ($) {
|
|
615
|
+
function $mol_try(handler) {
|
|
616
|
+
try {
|
|
617
|
+
return handler();
|
|
618
|
+
}
|
|
619
|
+
catch (error) {
|
|
620
|
+
console.error(error);
|
|
621
|
+
return error;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
$.$mol_try = $mol_try;
|
|
625
|
+
})($ || ($ = {}));
|
|
626
|
+
|
|
627
|
+
;
|
|
628
|
+
"use strict";
|
|
629
|
+
var $;
|
|
630
|
+
(function ($) {
|
|
631
|
+
function $mol_fail_log(error) {
|
|
632
|
+
if ($mol_promise_like(error))
|
|
633
|
+
return false;
|
|
634
|
+
if (!$mol_fail_catch(error))
|
|
635
|
+
return false;
|
|
636
|
+
$mol_try(() => { $mol_fail_hidden(error); });
|
|
637
|
+
return true;
|
|
638
|
+
}
|
|
639
|
+
$.$mol_fail_log = $mol_fail_log;
|
|
640
|
+
})($ || ($ = {}));
|
|
641
|
+
|
|
642
|
+
;
|
|
643
|
+
"use strict";
|
|
644
|
+
var $;
|
|
645
|
+
(function ($) {
|
|
646
|
+
const path = require('path');
|
|
647
|
+
const mod = require('module');
|
|
648
|
+
const localRequire = mod.createRequire(path.join(process.cwd(), 'package.json'));
|
|
649
|
+
function $node_autoinstall(name) {
|
|
650
|
+
try {
|
|
651
|
+
localRequire.resolve(name);
|
|
652
|
+
}
|
|
653
|
+
catch {
|
|
654
|
+
this.$mol_run.spawn({ command: ['npm', 'install', '--omit=dev', name], dir: '.' });
|
|
655
|
+
try {
|
|
656
|
+
this.$mol_run.spawn({ command: ['npm', 'install', '--omit=dev', '@types/' + name], dir: '.' });
|
|
657
|
+
}
|
|
658
|
+
catch (e) {
|
|
659
|
+
if (this.$mol_promise_like(e))
|
|
660
|
+
this.$mol_fail_hidden(e);
|
|
661
|
+
this.$mol_fail_log(e);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
$.$node_autoinstall = $node_autoinstall;
|
|
666
|
+
})($ || ($ = {}));
|
|
667
|
+
|
|
668
|
+
;
|
|
669
|
+
"use strict";
|
|
670
|
+
var $node = new Proxy({ require }, {
|
|
671
|
+
get(target, name, wrapper) {
|
|
672
|
+
if (target[name])
|
|
673
|
+
return target[name];
|
|
674
|
+
if ($.$node_internal_check(name))
|
|
675
|
+
return target.require(name);
|
|
676
|
+
if (name[0] === '.')
|
|
677
|
+
return target.require(name);
|
|
678
|
+
$.$node_autoinstall(name);
|
|
679
|
+
return target.require(name);
|
|
680
|
+
},
|
|
681
|
+
set(target, name, value) {
|
|
682
|
+
target[name] = value;
|
|
683
|
+
return true;
|
|
684
|
+
},
|
|
685
|
+
});
|
|
686
|
+
require = (req => Object.assign(function require(name) {
|
|
687
|
+
return $node[name];
|
|
688
|
+
}, req))(require);
|
|
689
|
+
|
|
690
|
+
;
|
|
691
|
+
"use strict";
|
|
692
|
+
var $;
|
|
693
|
+
(function ($) {
|
|
694
|
+
function cause_serialize(cause) {
|
|
695
|
+
return JSON.stringify(cause, null, ' ')
|
|
696
|
+
.replace(/\(/, '<')
|
|
697
|
+
.replace(/\)/, ' >');
|
|
698
|
+
}
|
|
699
|
+
function frame_normalize(frame) {
|
|
700
|
+
return (typeof frame === 'string' ? frame : cause_serialize(frame))
|
|
701
|
+
.trim()
|
|
702
|
+
.replace(/at /gm, ' at ')
|
|
703
|
+
.replace(/^(?! +at )(.*)/gm, ' at | $1 (#)');
|
|
704
|
+
}
|
|
705
|
+
class $mol_error_mix extends AggregateError {
|
|
706
|
+
cause;
|
|
707
|
+
name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
|
|
708
|
+
constructor(message, cause = {}, ...errors) {
|
|
709
|
+
super(errors, message, { cause });
|
|
710
|
+
this.cause = cause;
|
|
711
|
+
const desc = Object.getOwnPropertyDescriptor(this, 'stack');
|
|
712
|
+
const stack_get = () => desc?.get?.() ?? super.stack ?? desc?.value ?? this.message;
|
|
713
|
+
Object.defineProperty(this, 'stack', {
|
|
714
|
+
get: () => stack_get() + '\n' + [
|
|
715
|
+
this.cause ?? 'no cause',
|
|
716
|
+
...this.errors.flatMap(e => [
|
|
717
|
+
String(e.stack),
|
|
718
|
+
...e instanceof $mol_error_mix || !e.cause ? [] : [e.cause]
|
|
719
|
+
])
|
|
720
|
+
].map(frame_normalize).join('\n')
|
|
721
|
+
});
|
|
722
|
+
Object.defineProperty(this, 'cause', {
|
|
723
|
+
get: () => cause
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
static [Symbol.toPrimitive]() {
|
|
727
|
+
return this.toString();
|
|
728
|
+
}
|
|
729
|
+
static toString() {
|
|
730
|
+
return $$.$mol_func_name(this);
|
|
731
|
+
}
|
|
732
|
+
static make(...params) {
|
|
733
|
+
return new this(...params);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
$.$mol_error_mix = $mol_error_mix;
|
|
737
|
+
})($ || ($ = {}));
|
|
738
|
+
|
|
739
|
+
;
|
|
740
|
+
"use strict";
|
|
741
|
+
var $;
|
|
742
|
+
(function ($_1) {
|
|
743
|
+
let $$;
|
|
744
|
+
(function ($$) {
|
|
745
|
+
let $;
|
|
746
|
+
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
747
|
+
$_1.$mol_object_field = Symbol('$mol_object_field');
|
|
748
|
+
class $mol_object extends $mol_object2 {
|
|
749
|
+
static make(config) {
|
|
750
|
+
return super.create(obj => {
|
|
751
|
+
for (let key in config)
|
|
752
|
+
obj[key] = config[key];
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
$_1.$mol_object = $mol_object;
|
|
757
|
+
})($ || ($ = {}));
|
|
758
|
+
|
|
759
|
+
;
|
|
760
|
+
"use strict";
|
|
761
|
+
var $;
|
|
762
|
+
(function ($) {
|
|
763
|
+
function $mol_env() {
|
|
764
|
+
return {};
|
|
765
|
+
}
|
|
766
|
+
$.$mol_env = $mol_env;
|
|
767
|
+
})($ || ($ = {}));
|
|
768
|
+
|
|
769
|
+
;
|
|
770
|
+
"use strict";
|
|
771
|
+
var $;
|
|
772
|
+
(function ($) {
|
|
773
|
+
$.$mol_env = function $mol_env() {
|
|
774
|
+
return this.process.env;
|
|
775
|
+
};
|
|
776
|
+
})($ || ($ = {}));
|
|
777
|
+
|
|
778
|
+
;
|
|
779
|
+
"use strict";
|
|
780
|
+
var $;
|
|
781
|
+
(function ($) {
|
|
782
|
+
function $mol_guid(length = 8, exists = () => false) {
|
|
783
|
+
for (;;) {
|
|
784
|
+
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
785
|
+
if (exists(id))
|
|
786
|
+
continue;
|
|
787
|
+
return id;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
$.$mol_guid = $mol_guid;
|
|
791
|
+
})($ || ($ = {}));
|
|
792
|
+
|
|
793
|
+
;
|
|
794
|
+
"use strict";
|
|
795
|
+
var $;
|
|
796
|
+
(function ($) {
|
|
797
|
+
let $mol_wire_cursor;
|
|
798
|
+
(function ($mol_wire_cursor) {
|
|
799
|
+
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
|
800
|
+
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
801
|
+
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
802
|
+
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
803
|
+
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
804
|
+
})($ || ($ = {}));
|
|
805
|
+
|
|
806
|
+
;
|
|
807
|
+
"use strict";
|
|
808
|
+
var $;
|
|
809
|
+
(function ($) {
|
|
810
|
+
class $mol_wire_pub extends Object {
|
|
811
|
+
constructor(id = `$mol_wire_pub:${$mol_guid()}`) {
|
|
812
|
+
super();
|
|
813
|
+
this[Symbol.toStringTag] = id;
|
|
814
|
+
}
|
|
815
|
+
[Symbol.toStringTag];
|
|
816
|
+
data = [];
|
|
817
|
+
static get [Symbol.species]() {
|
|
818
|
+
return Array;
|
|
819
|
+
}
|
|
820
|
+
sub_from = 0;
|
|
821
|
+
get sub_list() {
|
|
822
|
+
const res = [];
|
|
823
|
+
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
824
|
+
res.push(this.data[i]);
|
|
825
|
+
}
|
|
826
|
+
return res;
|
|
827
|
+
}
|
|
828
|
+
get sub_empty() {
|
|
829
|
+
return this.sub_from === this.data.length;
|
|
830
|
+
}
|
|
831
|
+
sub_on(sub, pub_pos) {
|
|
832
|
+
const pos = this.data.length;
|
|
833
|
+
this.data.push(sub, pub_pos);
|
|
834
|
+
return pos;
|
|
835
|
+
}
|
|
836
|
+
sub_off(sub_pos) {
|
|
837
|
+
if (!(sub_pos < this.data.length)) {
|
|
838
|
+
$mol_fail(new Error(`Wrong pos ${sub_pos}`));
|
|
839
|
+
}
|
|
840
|
+
const end = this.data.length - 2;
|
|
841
|
+
if (sub_pos !== end) {
|
|
842
|
+
this.peer_move(end, sub_pos);
|
|
843
|
+
}
|
|
844
|
+
this.data.length = end;
|
|
845
|
+
if (end === this.sub_from)
|
|
846
|
+
this.reap();
|
|
847
|
+
}
|
|
848
|
+
reap() { }
|
|
849
|
+
promote() {
|
|
850
|
+
$mol_wire_auto()?.track_next(this);
|
|
851
|
+
}
|
|
852
|
+
fresh() { }
|
|
853
|
+
complete() { }
|
|
854
|
+
get incompleted() {
|
|
855
|
+
return false;
|
|
856
|
+
}
|
|
857
|
+
emit(quant = $mol_wire_cursor.stale) {
|
|
858
|
+
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
859
|
+
;
|
|
860
|
+
this.data[i].absorb(quant, this.data[i + 1]);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
peer_move(from_pos, to_pos) {
|
|
864
|
+
const peer = this.data[from_pos];
|
|
865
|
+
const self_pos = this.data[from_pos + 1];
|
|
866
|
+
this.data[to_pos] = peer;
|
|
867
|
+
this.data[to_pos + 1] = self_pos;
|
|
868
|
+
peer.peer_repos(self_pos, to_pos);
|
|
869
|
+
}
|
|
870
|
+
peer_repos(peer_pos, self_pos) {
|
|
871
|
+
this.data[peer_pos + 1] = self_pos;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
$.$mol_wire_pub = $mol_wire_pub;
|
|
875
|
+
})($ || ($ = {}));
|
|
876
|
+
|
|
877
|
+
;
|
|
878
|
+
"use strict";
|
|
879
|
+
|
|
880
|
+
;
|
|
881
|
+
"use strict";
|
|
882
|
+
var $;
|
|
883
|
+
(function ($) {
|
|
884
|
+
$.$mol_wire_auto_sub = null;
|
|
885
|
+
function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
|
|
886
|
+
return $.$mol_wire_auto_sub = next;
|
|
887
|
+
}
|
|
888
|
+
$.$mol_wire_auto = $mol_wire_auto;
|
|
889
|
+
$.$mol_wire_affected = [];
|
|
890
|
+
})($ || ($ = {}));
|
|
891
|
+
|
|
892
|
+
;
|
|
893
|
+
"use strict";
|
|
894
|
+
var $;
|
|
895
|
+
(function ($) {
|
|
896
|
+
$['devtoolsFormatters'] ||= [];
|
|
897
|
+
function $mol_dev_format_register(config) {
|
|
898
|
+
$['devtoolsFormatters'].push(config);
|
|
899
|
+
}
|
|
900
|
+
$.$mol_dev_format_register = $mol_dev_format_register;
|
|
901
|
+
$.$mol_dev_format_head = Symbol('$mol_dev_format_head');
|
|
902
|
+
$.$mol_dev_format_body = Symbol('$mol_dev_format_body');
|
|
903
|
+
function $mol_dev_format_button(label, click) {
|
|
904
|
+
return $mol_dev_format_auto({
|
|
905
|
+
[$.$mol_dev_format_head]() {
|
|
906
|
+
return $.$mol_dev_format_span({ color: 'cornflowerblue' }, label);
|
|
907
|
+
},
|
|
908
|
+
[$.$mol_dev_format_body]() {
|
|
909
|
+
Promise.resolve().then(click);
|
|
910
|
+
return $.$mol_dev_format_span({});
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
$mol_dev_format_register({
|
|
915
|
+
header: (val, config = false) => {
|
|
916
|
+
if (config)
|
|
917
|
+
return null;
|
|
918
|
+
if (!val)
|
|
919
|
+
return null;
|
|
920
|
+
if ($.$mol_dev_format_head in val) {
|
|
921
|
+
try {
|
|
922
|
+
return val[$.$mol_dev_format_head]();
|
|
923
|
+
}
|
|
924
|
+
catch (error) {
|
|
925
|
+
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
if (typeof val === 'function') {
|
|
929
|
+
return $mol_dev_format_native(val);
|
|
930
|
+
}
|
|
931
|
+
if (val instanceof Error) {
|
|
932
|
+
return $.$mol_dev_format_span({}, $mol_dev_format_native(val), ' ', $mol_dev_format_button('throw', () => $mol_fail_hidden(val)));
|
|
933
|
+
}
|
|
934
|
+
if (val instanceof Promise) {
|
|
935
|
+
return $.$mol_dev_format_shade($mol_dev_format_native(val), ' ', val[Symbol.toStringTag] ?? '');
|
|
936
|
+
}
|
|
937
|
+
if (Symbol.toStringTag in val) {
|
|
938
|
+
return $mol_dev_format_native(val);
|
|
939
|
+
}
|
|
940
|
+
return null;
|
|
941
|
+
},
|
|
942
|
+
hasBody: (val, config = false) => {
|
|
943
|
+
if (config)
|
|
944
|
+
return false;
|
|
945
|
+
if (!val)
|
|
946
|
+
return false;
|
|
947
|
+
if (val[$.$mol_dev_format_body])
|
|
948
|
+
return true;
|
|
949
|
+
return false;
|
|
950
|
+
},
|
|
951
|
+
body: (val, config = false) => {
|
|
952
|
+
if (config)
|
|
953
|
+
return null;
|
|
954
|
+
if (!val)
|
|
955
|
+
return null;
|
|
956
|
+
if ($.$mol_dev_format_body in val) {
|
|
957
|
+
try {
|
|
958
|
+
return val[$.$mol_dev_format_body]();
|
|
959
|
+
}
|
|
960
|
+
catch (error) {
|
|
961
|
+
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
return null;
|
|
965
|
+
},
|
|
966
|
+
});
|
|
967
|
+
function $mol_dev_format_native(obj) {
|
|
968
|
+
if (typeof obj === 'undefined')
|
|
969
|
+
return $.$mol_dev_format_shade('undefined');
|
|
970
|
+
return [
|
|
971
|
+
'object',
|
|
972
|
+
{
|
|
973
|
+
object: obj,
|
|
974
|
+
config: true,
|
|
975
|
+
},
|
|
976
|
+
];
|
|
977
|
+
}
|
|
978
|
+
$.$mol_dev_format_native = $mol_dev_format_native;
|
|
979
|
+
function $mol_dev_format_auto(obj) {
|
|
980
|
+
if (obj == null)
|
|
981
|
+
return $.$mol_dev_format_shade(String(obj));
|
|
982
|
+
return [
|
|
983
|
+
'object',
|
|
984
|
+
{
|
|
985
|
+
object: obj,
|
|
986
|
+
config: false,
|
|
987
|
+
},
|
|
988
|
+
];
|
|
989
|
+
}
|
|
990
|
+
$.$mol_dev_format_auto = $mol_dev_format_auto;
|
|
991
|
+
function $mol_dev_format_element(element, style, ...content) {
|
|
992
|
+
const styles = [];
|
|
993
|
+
for (let key in style)
|
|
994
|
+
styles.push(`${key} : ${style[key]}`);
|
|
995
|
+
return [
|
|
996
|
+
element,
|
|
997
|
+
{
|
|
998
|
+
style: styles.join(' ; '),
|
|
999
|
+
},
|
|
1000
|
+
...content,
|
|
1001
|
+
];
|
|
1002
|
+
}
|
|
1003
|
+
$.$mol_dev_format_element = $mol_dev_format_element;
|
|
1004
|
+
$.$mol_dev_format_span = $mol_dev_format_element.bind(null, 'span');
|
|
1005
|
+
$.$mol_dev_format_div = $mol_dev_format_element.bind(null, 'div');
|
|
1006
|
+
$.$mol_dev_format_ol = $mol_dev_format_element.bind(null, 'ol');
|
|
1007
|
+
$.$mol_dev_format_li = $mol_dev_format_element.bind(null, 'li');
|
|
1008
|
+
$.$mol_dev_format_table = $mol_dev_format_element.bind(null, 'table');
|
|
1009
|
+
$.$mol_dev_format_tr = $mol_dev_format_element.bind(null, 'tr');
|
|
1010
|
+
$.$mol_dev_format_td = $mol_dev_format_element.bind(null, 'td');
|
|
1011
|
+
$.$mol_dev_format_accent = $.$mol_dev_format_span.bind(null, {
|
|
1012
|
+
'color': 'magenta',
|
|
1013
|
+
});
|
|
1014
|
+
$.$mol_dev_format_strong = $.$mol_dev_format_span.bind(null, {
|
|
1015
|
+
'font-weight': 'bold',
|
|
1016
|
+
});
|
|
1017
|
+
$.$mol_dev_format_string = $.$mol_dev_format_span.bind(null, {
|
|
1018
|
+
'color': 'green',
|
|
1019
|
+
});
|
|
1020
|
+
$.$mol_dev_format_shade = $.$mol_dev_format_span.bind(null, {
|
|
1021
|
+
'color': 'gray',
|
|
1022
|
+
});
|
|
1023
|
+
$.$mol_dev_format_indent = $.$mol_dev_format_div.bind(null, {
|
|
1024
|
+
'margin-left': '13px'
|
|
1025
|
+
});
|
|
1026
|
+
class Stack extends Array {
|
|
1027
|
+
toString() {
|
|
1028
|
+
return this.join('\n');
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
class Call extends Object {
|
|
1032
|
+
type;
|
|
1033
|
+
function;
|
|
1034
|
+
method;
|
|
1035
|
+
eval;
|
|
1036
|
+
source;
|
|
1037
|
+
offset;
|
|
1038
|
+
pos;
|
|
1039
|
+
object;
|
|
1040
|
+
flags;
|
|
1041
|
+
[Symbol.toStringTag];
|
|
1042
|
+
constructor(call) {
|
|
1043
|
+
super();
|
|
1044
|
+
this.type = call.getTypeName() ?? '';
|
|
1045
|
+
this.function = call.getFunctionName() ?? '';
|
|
1046
|
+
this.method = call.getMethodName() ?? '';
|
|
1047
|
+
if (this.method === this.function)
|
|
1048
|
+
this.method = '';
|
|
1049
|
+
this.pos = [call.getEnclosingLineNumber() ?? 0, call.getEnclosingColumnNumber() ?? 0];
|
|
1050
|
+
this.eval = call.getEvalOrigin() ?? '';
|
|
1051
|
+
this.source = call.getScriptNameOrSourceURL() ?? '';
|
|
1052
|
+
this.object = call.getThis();
|
|
1053
|
+
this.offset = call.getPosition();
|
|
1054
|
+
const flags = [];
|
|
1055
|
+
if (call.isAsync())
|
|
1056
|
+
flags.push('async');
|
|
1057
|
+
if (call.isConstructor())
|
|
1058
|
+
flags.push('constructor');
|
|
1059
|
+
if (call.isEval())
|
|
1060
|
+
flags.push('eval');
|
|
1061
|
+
if (call.isNative())
|
|
1062
|
+
flags.push('native');
|
|
1063
|
+
if (call.isPromiseAll())
|
|
1064
|
+
flags.push('PromiseAll');
|
|
1065
|
+
if (call.isToplevel())
|
|
1066
|
+
flags.push('top');
|
|
1067
|
+
this.flags = flags;
|
|
1068
|
+
const type = this.type ? this.type + '.' : '';
|
|
1069
|
+
const func = this.function || '<anon>';
|
|
1070
|
+
const method = this.method ? ' [' + this.method + '] ' : '';
|
|
1071
|
+
this[Symbol.toStringTag] = `${type}${func}${method}`;
|
|
1072
|
+
}
|
|
1073
|
+
[Symbol.toPrimitive]() {
|
|
1074
|
+
return this.toString();
|
|
1075
|
+
}
|
|
1076
|
+
toString() {
|
|
1077
|
+
const object = this.object || '';
|
|
1078
|
+
const label = this[Symbol.toStringTag];
|
|
1079
|
+
const source = `${this.source}:${this.pos.join(':')} #${this.offset}`;
|
|
1080
|
+
return `\tat ${object}${label} (${source})`;
|
|
1081
|
+
}
|
|
1082
|
+
[$.$mol_dev_format_head]() {
|
|
1083
|
+
return $.$mol_dev_format_div({}, $mol_dev_format_native(this), $.$mol_dev_format_shade(' '), ...this.object ? [
|
|
1084
|
+
$mol_dev_format_native(this.object),
|
|
1085
|
+
] : [], ...this.method ? [$.$mol_dev_format_shade(' ', ' [', this.method, ']')] : [], $.$mol_dev_format_shade(' ', this.flags.join(', ')));
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
Error.prepareStackTrace ??= (error, stack) => new Stack(...stack.map(call => new Call(call)));
|
|
1089
|
+
})($ || ($ = {}));
|
|
1090
|
+
|
|
1091
|
+
;
|
|
1092
|
+
"use strict";
|
|
1093
|
+
var $;
|
|
1094
|
+
(function ($) {
|
|
1095
|
+
class $mol_wire_pub_sub extends $mol_wire_pub {
|
|
1096
|
+
pub_from = 0;
|
|
1097
|
+
cursor = $mol_wire_cursor.stale;
|
|
1098
|
+
get temp() {
|
|
1099
|
+
return false;
|
|
1100
|
+
}
|
|
1101
|
+
get pub_list() {
|
|
1102
|
+
const res = [];
|
|
1103
|
+
const max = this.cursor >= 0 ? this.cursor : this.sub_from;
|
|
1104
|
+
for (let i = this.pub_from; i < max; i += 2) {
|
|
1105
|
+
if (this.data[i])
|
|
1106
|
+
res.push(this.data[i]);
|
|
1107
|
+
}
|
|
1108
|
+
return res;
|
|
1109
|
+
}
|
|
1110
|
+
track_on() {
|
|
1111
|
+
this.cursor = this.pub_from;
|
|
1112
|
+
const sub = $mol_wire_auto();
|
|
1113
|
+
$mol_wire_auto(this);
|
|
1114
|
+
return sub;
|
|
1115
|
+
}
|
|
1116
|
+
promote() {
|
|
1117
|
+
if (this.cursor >= this.pub_from) {
|
|
1118
|
+
$mol_fail(new Error('Circular subscription'));
|
|
1119
|
+
}
|
|
1120
|
+
super.promote();
|
|
1121
|
+
}
|
|
1122
|
+
track_next(pub) {
|
|
1123
|
+
if (this.cursor < 0)
|
|
1124
|
+
$mol_fail(new Error('Promo to non begun sub'));
|
|
1125
|
+
if (this.cursor < this.sub_from) {
|
|
1126
|
+
const next = this.data[this.cursor];
|
|
1127
|
+
if (pub === undefined)
|
|
1128
|
+
return next ?? null;
|
|
1129
|
+
if (next === pub) {
|
|
1130
|
+
this.cursor += 2;
|
|
1131
|
+
return next;
|
|
1132
|
+
}
|
|
1133
|
+
if (next) {
|
|
1134
|
+
if (this.sub_from < this.data.length) {
|
|
1135
|
+
this.peer_move(this.sub_from, this.data.length);
|
|
1136
|
+
}
|
|
1137
|
+
this.peer_move(this.cursor, this.sub_from);
|
|
1138
|
+
this.sub_from += 2;
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
else {
|
|
1142
|
+
if (pub === undefined)
|
|
1143
|
+
return null;
|
|
1144
|
+
if (this.sub_from < this.data.length) {
|
|
1145
|
+
this.peer_move(this.sub_from, this.data.length);
|
|
1146
|
+
}
|
|
1147
|
+
this.sub_from += 2;
|
|
1148
|
+
}
|
|
1149
|
+
this.data[this.cursor] = pub;
|
|
1150
|
+
this.data[this.cursor + 1] = pub.sub_on(this, this.cursor);
|
|
1151
|
+
this.cursor += 2;
|
|
1152
|
+
return pub;
|
|
1153
|
+
}
|
|
1154
|
+
track_off(sub) {
|
|
1155
|
+
$mol_wire_auto(sub);
|
|
1156
|
+
if (this.cursor < 0) {
|
|
1157
|
+
$mol_fail(new Error('End of non begun sub'));
|
|
1158
|
+
}
|
|
1159
|
+
for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
|
|
1160
|
+
const pub = this.data[cursor];
|
|
1161
|
+
pub.fresh();
|
|
1162
|
+
}
|
|
1163
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
1164
|
+
}
|
|
1165
|
+
pub_off(sub_pos) {
|
|
1166
|
+
this.data[sub_pos] = undefined;
|
|
1167
|
+
this.data[sub_pos + 1] = undefined;
|
|
1168
|
+
}
|
|
1169
|
+
destructor() {
|
|
1170
|
+
for (let cursor = this.data.length - 2; cursor >= this.sub_from; cursor -= 2) {
|
|
1171
|
+
const sub = this.data[cursor];
|
|
1172
|
+
const pos = this.data[cursor + 1];
|
|
1173
|
+
sub.pub_off(pos);
|
|
1174
|
+
}
|
|
1175
|
+
this.data.length = this.sub_from;
|
|
1176
|
+
this.cursor = this.pub_from;
|
|
1177
|
+
this.track_cut();
|
|
1178
|
+
this.cursor = $mol_wire_cursor.stale;
|
|
1179
|
+
}
|
|
1180
|
+
track_cut() {
|
|
1181
|
+
if (this.cursor < this.pub_from) {
|
|
1182
|
+
$mol_fail(new Error('Cut of non begun sub'));
|
|
1183
|
+
}
|
|
1184
|
+
let end = this.data.length;
|
|
1185
|
+
for (let cursor = this.cursor; cursor < this.sub_from; cursor += 2) {
|
|
1186
|
+
const pub = this.data[cursor];
|
|
1187
|
+
pub?.sub_off(this.data[cursor + 1]);
|
|
1188
|
+
end -= 2;
|
|
1189
|
+
if (this.sub_from <= end)
|
|
1190
|
+
this.peer_move(end, cursor);
|
|
1191
|
+
}
|
|
1192
|
+
this.data.length = end;
|
|
1193
|
+
this.sub_from = this.cursor;
|
|
1194
|
+
}
|
|
1195
|
+
complete() { }
|
|
1196
|
+
complete_pubs() {
|
|
1197
|
+
const limit = this.cursor < 0 ? this.sub_from : this.cursor;
|
|
1198
|
+
for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
|
|
1199
|
+
const pub = this.data[cursor];
|
|
1200
|
+
if (pub?.incompleted)
|
|
1201
|
+
return;
|
|
1202
|
+
}
|
|
1203
|
+
for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
|
|
1204
|
+
const pub = this.data[cursor];
|
|
1205
|
+
pub?.complete();
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
absorb(quant = $mol_wire_cursor.stale, pos = -1) {
|
|
1209
|
+
if (this.cursor === $mol_wire_cursor.final)
|
|
1210
|
+
return;
|
|
1211
|
+
if (this.cursor >= quant)
|
|
1212
|
+
return;
|
|
1213
|
+
this.cursor = quant;
|
|
1214
|
+
this.emit($mol_wire_cursor.doubt);
|
|
1215
|
+
}
|
|
1216
|
+
[$mol_dev_format_head]() {
|
|
1217
|
+
return $mol_dev_format_native(this);
|
|
1218
|
+
}
|
|
1219
|
+
get pub_empty() {
|
|
1220
|
+
return this.sub_from === this.pub_from;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
$.$mol_wire_pub_sub = $mol_wire_pub_sub;
|
|
1224
|
+
})($ || ($ = {}));
|
|
1225
|
+
|
|
1226
|
+
;
|
|
1227
|
+
"use strict";
|
|
1228
|
+
var $;
|
|
1229
|
+
(function ($) {
|
|
1230
|
+
class $mol_after_tick extends $mol_object2 {
|
|
1231
|
+
task;
|
|
1232
|
+
static promise = null;
|
|
1233
|
+
cancelled = false;
|
|
1234
|
+
constructor(task) {
|
|
1235
|
+
super();
|
|
1236
|
+
this.task = task;
|
|
1237
|
+
if (!$mol_after_tick.promise)
|
|
1238
|
+
$mol_after_tick.promise = Promise.resolve().then(() => {
|
|
1239
|
+
$mol_after_tick.promise = null;
|
|
1240
|
+
});
|
|
1241
|
+
$mol_after_tick.promise.then(() => {
|
|
1242
|
+
if (this.cancelled)
|
|
1243
|
+
return;
|
|
1244
|
+
task();
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
destructor() {
|
|
1248
|
+
this.cancelled = true;
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
$.$mol_after_tick = $mol_after_tick;
|
|
1252
|
+
})($ || ($ = {}));
|
|
1253
|
+
|
|
1254
|
+
;
|
|
1255
|
+
"use strict";
|
|
1256
|
+
var $;
|
|
1257
|
+
(function ($) {
|
|
1258
|
+
const wrappers = new WeakMap();
|
|
1259
|
+
class $mol_wire_fiber extends $mol_wire_pub_sub {
|
|
1260
|
+
task;
|
|
1261
|
+
host;
|
|
1262
|
+
static warm = true;
|
|
1263
|
+
static planning = new Set();
|
|
1264
|
+
static reaping = new Set();
|
|
1265
|
+
static plan_task = null;
|
|
1266
|
+
static plan() {
|
|
1267
|
+
if (this.plan_task)
|
|
1268
|
+
return;
|
|
1269
|
+
this.plan_task = new $mol_after_tick(() => {
|
|
1270
|
+
try {
|
|
1271
|
+
this.sync();
|
|
1272
|
+
}
|
|
1273
|
+
finally {
|
|
1274
|
+
$mol_wire_fiber.plan_task = null;
|
|
1275
|
+
}
|
|
1276
|
+
});
|
|
1277
|
+
}
|
|
1278
|
+
static sync() {
|
|
1279
|
+
while (this.planning.size) {
|
|
1280
|
+
for (const fiber of this.planning) {
|
|
1281
|
+
this.planning.delete(fiber);
|
|
1282
|
+
if (fiber.cursor >= 0)
|
|
1283
|
+
continue;
|
|
1284
|
+
if (fiber.cursor === $mol_wire_cursor.final)
|
|
1285
|
+
continue;
|
|
1286
|
+
fiber.fresh();
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
while (this.reaping.size) {
|
|
1290
|
+
const fibers = this.reaping;
|
|
1291
|
+
this.reaping = new Set;
|
|
1292
|
+
for (const fiber of fibers) {
|
|
1293
|
+
if (!fiber.sub_empty)
|
|
1294
|
+
continue;
|
|
1295
|
+
fiber.destructor();
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
cache = undefined;
|
|
1300
|
+
get args() {
|
|
1301
|
+
return this.data.slice(0, this.pub_from);
|
|
1302
|
+
}
|
|
1303
|
+
result() {
|
|
1304
|
+
if ($mol_promise_like(this.cache))
|
|
1305
|
+
return;
|
|
1306
|
+
if (this.cache instanceof Error)
|
|
1307
|
+
return;
|
|
1308
|
+
return this.cache;
|
|
1309
|
+
}
|
|
1310
|
+
get incompleted() {
|
|
1311
|
+
return $mol_promise_like(this.cache);
|
|
1312
|
+
}
|
|
1313
|
+
field() {
|
|
1314
|
+
return this.task.name + '()';
|
|
1315
|
+
}
|
|
1316
|
+
constructor(id, task, host, args) {
|
|
1317
|
+
super(id);
|
|
1318
|
+
this.task = task;
|
|
1319
|
+
this.host = host;
|
|
1320
|
+
if (args)
|
|
1321
|
+
this.data.push(...args);
|
|
1322
|
+
this.pub_from = this.sub_from = args?.length ?? 0;
|
|
1323
|
+
}
|
|
1324
|
+
plan() {
|
|
1325
|
+
$mol_wire_fiber.planning.add(this);
|
|
1326
|
+
$mol_wire_fiber.plan();
|
|
1327
|
+
return this;
|
|
1328
|
+
}
|
|
1329
|
+
reap() {
|
|
1330
|
+
$mol_wire_fiber.reaping.add(this);
|
|
1331
|
+
$mol_wire_fiber.plan();
|
|
1332
|
+
}
|
|
1333
|
+
toString() {
|
|
1334
|
+
return this[Symbol.toStringTag];
|
|
1335
|
+
}
|
|
1336
|
+
toJSON() {
|
|
1337
|
+
return this[Symbol.toStringTag];
|
|
1338
|
+
}
|
|
1339
|
+
[$mol_dev_format_head]() {
|
|
1340
|
+
const cursor = {
|
|
1341
|
+
[$mol_wire_cursor.stale]: '🔴',
|
|
1342
|
+
[$mol_wire_cursor.doubt]: '🟡',
|
|
1343
|
+
[$mol_wire_cursor.fresh]: '🟢',
|
|
1344
|
+
[$mol_wire_cursor.final]: '🔵',
|
|
1345
|
+
}[this.cursor] ?? this.cursor.toString();
|
|
1346
|
+
return $mol_dev_format_div({}, $mol_owning_check(this, this.cache)
|
|
1347
|
+
? $mol_dev_format_shade(cursor)
|
|
1348
|
+
: $mol_dev_format_shade(this[Symbol.toStringTag], cursor), $mol_dev_format_auto(this.cache));
|
|
1349
|
+
}
|
|
1350
|
+
[$mol_dev_format_body]() { return null; }
|
|
1351
|
+
get $() {
|
|
1352
|
+
return (this.host ?? this.task)['$'];
|
|
1353
|
+
}
|
|
1354
|
+
emit(quant = $mol_wire_cursor.stale) {
|
|
1355
|
+
if (this.sub_empty)
|
|
1356
|
+
this.plan();
|
|
1357
|
+
else
|
|
1358
|
+
super.emit(quant);
|
|
1359
|
+
}
|
|
1360
|
+
fresh() {
|
|
1361
|
+
if (this.cursor === $mol_wire_cursor.fresh)
|
|
1362
|
+
return;
|
|
1363
|
+
if (this.cursor === $mol_wire_cursor.final)
|
|
1364
|
+
return;
|
|
1365
|
+
check: if (this.cursor === $mol_wire_cursor.doubt) {
|
|
1366
|
+
for (let i = this.pub_from; i < this.sub_from; i += 2) {
|
|
1367
|
+
;
|
|
1368
|
+
this.data[i]?.fresh();
|
|
1369
|
+
if (this.cursor !== $mol_wire_cursor.doubt)
|
|
1370
|
+
break check;
|
|
1371
|
+
}
|
|
1372
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1375
|
+
const bu = this.track_on();
|
|
1376
|
+
let result;
|
|
1377
|
+
try {
|
|
1378
|
+
switch (this.pub_from) {
|
|
1379
|
+
case 0:
|
|
1380
|
+
result = this.task.call(this.host);
|
|
1381
|
+
break;
|
|
1382
|
+
case 1:
|
|
1383
|
+
result = this.task.call(this.host, this.data[0]);
|
|
1384
|
+
break;
|
|
1385
|
+
default:
|
|
1386
|
+
result = this.task.call(this.host, ...this.args);
|
|
1387
|
+
break;
|
|
1388
|
+
}
|
|
1389
|
+
if ($mol_promise_like(result)) {
|
|
1390
|
+
if (wrappers.has(result)) {
|
|
1391
|
+
result = wrappers.get(result).then(a => a);
|
|
1392
|
+
}
|
|
1393
|
+
else {
|
|
1394
|
+
const put = (res) => {
|
|
1395
|
+
if (this.cache === result)
|
|
1396
|
+
this.put(res);
|
|
1397
|
+
return res;
|
|
1398
|
+
};
|
|
1399
|
+
wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
|
|
1400
|
+
wrappers.set(result, result);
|
|
1401
|
+
const error = new Error(`Promise in ${this}`);
|
|
1402
|
+
Object.defineProperty(result, 'stack', { get: () => error.stack });
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
catch (error) {
|
|
1407
|
+
if (error instanceof Error || $mol_promise_like(error)) {
|
|
1408
|
+
result = error;
|
|
1409
|
+
}
|
|
1410
|
+
else {
|
|
1411
|
+
result = new Error(String(error), { cause: error });
|
|
1412
|
+
}
|
|
1413
|
+
if ($mol_promise_like(result)) {
|
|
1414
|
+
if (wrappers.has(result)) {
|
|
1415
|
+
result = wrappers.get(result);
|
|
1416
|
+
}
|
|
1417
|
+
else {
|
|
1418
|
+
const put = (v) => {
|
|
1419
|
+
if (this.cache === result)
|
|
1420
|
+
this.absorb();
|
|
1421
|
+
return v;
|
|
1422
|
+
};
|
|
1423
|
+
wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
|
|
1424
|
+
const error = new Error(`Promise in ${this}`);
|
|
1425
|
+
Object.defineProperty(result, 'stack', { get: () => error.stack });
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
if (!$mol_promise_like(result)) {
|
|
1430
|
+
this.track_cut();
|
|
1431
|
+
}
|
|
1432
|
+
this.track_off(bu);
|
|
1433
|
+
this.put(result);
|
|
1434
|
+
return this;
|
|
1435
|
+
}
|
|
1436
|
+
refresh() {
|
|
1437
|
+
this.cursor = $mol_wire_cursor.stale;
|
|
1438
|
+
this.fresh();
|
|
1439
|
+
}
|
|
1440
|
+
sync() {
|
|
1441
|
+
if (!$mol_wire_fiber.warm) {
|
|
1442
|
+
return this.result();
|
|
1443
|
+
}
|
|
1444
|
+
this.promote();
|
|
1445
|
+
this.fresh();
|
|
1446
|
+
if (this.cache instanceof Error) {
|
|
1447
|
+
return $mol_fail_hidden(this.cache);
|
|
1448
|
+
}
|
|
1449
|
+
if ($mol_promise_like(this.cache)) {
|
|
1450
|
+
return $mol_fail_hidden(this.cache);
|
|
1451
|
+
}
|
|
1452
|
+
return this.cache;
|
|
1453
|
+
}
|
|
1454
|
+
async async_raw() {
|
|
1455
|
+
while (true) {
|
|
1456
|
+
this.fresh();
|
|
1457
|
+
if (this.cache instanceof Error) {
|
|
1458
|
+
$mol_fail_hidden(this.cache);
|
|
1459
|
+
}
|
|
1460
|
+
if (!$mol_promise_like(this.cache))
|
|
1461
|
+
return this.cache;
|
|
1462
|
+
await Promise.race([this.cache, this.step()]);
|
|
1463
|
+
if (!$mol_promise_like(this.cache))
|
|
1464
|
+
return this.cache;
|
|
1465
|
+
if (this.cursor === $mol_wire_cursor.final) {
|
|
1466
|
+
await new Promise(() => { });
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
async() {
|
|
1471
|
+
const promise = this.async_raw();
|
|
1472
|
+
if (!promise.destructor)
|
|
1473
|
+
promise.destructor = () => this.destructor();
|
|
1474
|
+
return promise;
|
|
1475
|
+
}
|
|
1476
|
+
step() {
|
|
1477
|
+
return new Promise(done => {
|
|
1478
|
+
const sub = new $mol_wire_pub_sub;
|
|
1479
|
+
const prev = sub.track_on();
|
|
1480
|
+
sub.track_next(this);
|
|
1481
|
+
sub.track_off(prev);
|
|
1482
|
+
sub.absorb = () => {
|
|
1483
|
+
done(null);
|
|
1484
|
+
setTimeout(() => sub.destructor());
|
|
1485
|
+
};
|
|
1486
|
+
});
|
|
1487
|
+
}
|
|
1488
|
+
destructor() {
|
|
1489
|
+
super.destructor();
|
|
1490
|
+
$mol_wire_fiber.planning.delete(this);
|
|
1491
|
+
if (!$mol_owning_check(this, this.cache))
|
|
1492
|
+
return;
|
|
1493
|
+
try {
|
|
1494
|
+
this.cache.destructor();
|
|
1495
|
+
}
|
|
1496
|
+
catch (result) {
|
|
1497
|
+
if ($mol_promise_like(result)) {
|
|
1498
|
+
const error = new Error(`Promise in ${this}.destructor()`);
|
|
1499
|
+
Object.defineProperty(result, 'stack', { get: () => error.stack });
|
|
1500
|
+
}
|
|
1501
|
+
$mol_fail_hidden(result);
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
$.$mol_wire_fiber = $mol_wire_fiber;
|
|
1506
|
+
})($ || ($ = {}));
|
|
1507
|
+
|
|
1508
|
+
;
|
|
1509
|
+
"use strict";
|
|
1510
|
+
var $;
|
|
1511
|
+
(function ($) {
|
|
1512
|
+
$.$mol_compare_deep_cache = new WeakMap();
|
|
1513
|
+
function $mol_compare_deep(left, right) {
|
|
1514
|
+
if (Object.is(left, right))
|
|
1515
|
+
return true;
|
|
1516
|
+
if (left === null)
|
|
1517
|
+
return false;
|
|
1518
|
+
if (right === null)
|
|
1519
|
+
return false;
|
|
1520
|
+
if (typeof left !== 'object')
|
|
1521
|
+
return false;
|
|
1522
|
+
if (typeof right !== 'object')
|
|
1523
|
+
return false;
|
|
1524
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
|
1525
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
|
1526
|
+
if (left_proto !== right_proto)
|
|
1527
|
+
return false;
|
|
1528
|
+
if (left instanceof Boolean)
|
|
1529
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1530
|
+
if (left instanceof Number)
|
|
1531
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1532
|
+
if (left instanceof String)
|
|
1533
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1534
|
+
if (left instanceof Date)
|
|
1535
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1536
|
+
if (left instanceof RegExp)
|
|
1537
|
+
return left.source === right.source && left.flags === right.flags;
|
|
1538
|
+
if (left instanceof Error)
|
|
1539
|
+
return left.message === right.message && $mol_compare_deep(left.stack, right.stack);
|
|
1540
|
+
let left_cache = $.$mol_compare_deep_cache.get(left);
|
|
1541
|
+
if (left_cache) {
|
|
1542
|
+
const right_cache = left_cache.get(right);
|
|
1543
|
+
if (typeof right_cache === 'boolean')
|
|
1544
|
+
return right_cache;
|
|
1545
|
+
}
|
|
1546
|
+
else {
|
|
1547
|
+
left_cache = new WeakMap();
|
|
1548
|
+
$.$mol_compare_deep_cache.set(left, left_cache);
|
|
1549
|
+
}
|
|
1550
|
+
left_cache.set(right, true);
|
|
1551
|
+
let result;
|
|
1552
|
+
try {
|
|
1553
|
+
if (!left_proto)
|
|
1554
|
+
result = compare_pojo(left, right);
|
|
1555
|
+
else if (!Reflect.getPrototypeOf(left_proto))
|
|
1556
|
+
result = compare_pojo(left, right);
|
|
1557
|
+
else if (Symbol.toPrimitive in left)
|
|
1558
|
+
result = compare_primitive(left, right);
|
|
1559
|
+
else if (Array.isArray(left))
|
|
1560
|
+
result = compare_array(left, right);
|
|
1561
|
+
else if (left instanceof Set)
|
|
1562
|
+
result = compare_set(left, right);
|
|
1563
|
+
else if (left instanceof Map)
|
|
1564
|
+
result = compare_map(left, right);
|
|
1565
|
+
else if (ArrayBuffer.isView(left))
|
|
1566
|
+
result = compare_buffer(left, right);
|
|
1567
|
+
else if (Symbol.iterator in left)
|
|
1568
|
+
result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
|
|
1569
|
+
else
|
|
1570
|
+
result = false;
|
|
1571
|
+
}
|
|
1572
|
+
finally {
|
|
1573
|
+
left_cache.set(right, result);
|
|
1574
|
+
}
|
|
1575
|
+
return result;
|
|
1576
|
+
}
|
|
1577
|
+
$.$mol_compare_deep = $mol_compare_deep;
|
|
1578
|
+
function compare_array(left, right) {
|
|
1579
|
+
const len = left.length;
|
|
1580
|
+
if (len !== right.length)
|
|
1581
|
+
return false;
|
|
1582
|
+
for (let i = 0; i < len; ++i) {
|
|
1583
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
|
1584
|
+
return false;
|
|
1585
|
+
}
|
|
1586
|
+
return true;
|
|
1587
|
+
}
|
|
1588
|
+
function compare_buffer(left, right) {
|
|
1589
|
+
const len = left.byteLength;
|
|
1590
|
+
if (len !== right.byteLength)
|
|
1591
|
+
return false;
|
|
1592
|
+
if (left instanceof DataView)
|
|
1593
|
+
return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, right.byteOffset, right.byteLength));
|
|
1594
|
+
for (let i = 0; i < len; ++i) {
|
|
1595
|
+
if (left[i] !== right[i])
|
|
1596
|
+
return false;
|
|
1597
|
+
}
|
|
1598
|
+
return true;
|
|
1599
|
+
}
|
|
1600
|
+
function compare_iterator(left, right) {
|
|
1601
|
+
while (true) {
|
|
1602
|
+
const left_next = left.next();
|
|
1603
|
+
const right_next = right.next();
|
|
1604
|
+
if (left_next.done !== right_next.done)
|
|
1605
|
+
return false;
|
|
1606
|
+
if (left_next.done)
|
|
1607
|
+
break;
|
|
1608
|
+
if (!$mol_compare_deep(left_next.value, right_next.value))
|
|
1609
|
+
return false;
|
|
1610
|
+
}
|
|
1611
|
+
return true;
|
|
1612
|
+
}
|
|
1613
|
+
function compare_set(left, right) {
|
|
1614
|
+
if (left.size !== right.size)
|
|
1615
|
+
return false;
|
|
1616
|
+
return compare_iterator(left.values(), right.values());
|
|
1617
|
+
}
|
|
1618
|
+
function compare_map(left, right) {
|
|
1619
|
+
if (left.size !== right.size)
|
|
1620
|
+
return false;
|
|
1621
|
+
return compare_iterator(left.keys(), right.keys())
|
|
1622
|
+
&& compare_iterator(left.values(), right.values());
|
|
1623
|
+
}
|
|
1624
|
+
function compare_pojo(left, right) {
|
|
1625
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
|
1626
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
|
1627
|
+
if (!compare_array(left_keys, right_keys))
|
|
1628
|
+
return false;
|
|
1629
|
+
for (let key of left_keys) {
|
|
1630
|
+
if (!$mol_compare_deep(left[key], right[key]))
|
|
1631
|
+
return false;
|
|
1632
|
+
}
|
|
1633
|
+
const left_syms = Object.getOwnPropertySymbols(left);
|
|
1634
|
+
const right_syms = Object.getOwnPropertySymbols(right);
|
|
1635
|
+
if (!compare_array(left_syms, right_syms))
|
|
1636
|
+
return false;
|
|
1637
|
+
for (let key of left_syms) {
|
|
1638
|
+
if (!$mol_compare_deep(left[key], right[key]))
|
|
1639
|
+
return false;
|
|
1640
|
+
}
|
|
1641
|
+
return true;
|
|
1642
|
+
}
|
|
1643
|
+
function compare_primitive(left, right) {
|
|
1644
|
+
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
1645
|
+
}
|
|
1646
|
+
})($ || ($ = {}));
|
|
1647
|
+
|
|
1648
|
+
;
|
|
1649
|
+
"use strict";
|
|
1650
|
+
var $;
|
|
1651
|
+
(function ($) {
|
|
1652
|
+
function $mol_log3_area_lazy(event) {
|
|
1653
|
+
const self = this.$;
|
|
1654
|
+
const stack = self.$mol_log3_stack;
|
|
1655
|
+
const deep = stack.length;
|
|
1656
|
+
let logged = false;
|
|
1657
|
+
stack.push(() => {
|
|
1658
|
+
logged = true;
|
|
1659
|
+
self.$mol_log3_area.call(self, event);
|
|
1660
|
+
});
|
|
1661
|
+
return () => {
|
|
1662
|
+
if (logged)
|
|
1663
|
+
self.console.groupEnd();
|
|
1664
|
+
if (stack.length > deep)
|
|
1665
|
+
stack.length = deep;
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
1669
|
+
$.$mol_log3_stack = [];
|
|
1670
|
+
})($ || ($ = {}));
|
|
1671
|
+
|
|
1672
|
+
;
|
|
1673
|
+
"use strict";
|
|
1674
|
+
var $;
|
|
1675
|
+
(function ($) {
|
|
1676
|
+
class $mol_span extends $mol_object2 {
|
|
1677
|
+
uri;
|
|
1678
|
+
source;
|
|
1679
|
+
row;
|
|
1680
|
+
col;
|
|
1681
|
+
length;
|
|
1682
|
+
constructor(uri, source, row, col, length) {
|
|
1683
|
+
super();
|
|
1684
|
+
this.uri = uri;
|
|
1685
|
+
this.source = source;
|
|
1686
|
+
this.row = row;
|
|
1687
|
+
this.col = col;
|
|
1688
|
+
this.length = length;
|
|
1689
|
+
this[Symbol.toStringTag] = this.uri + ('#' + this.row + ':' + this.col + '/' + this.length);
|
|
1690
|
+
}
|
|
1691
|
+
static unknown = $mol_span.begin('?');
|
|
1692
|
+
static begin(uri, source = '') {
|
|
1693
|
+
return new $mol_span(uri, source, 1, 1, 0);
|
|
1694
|
+
}
|
|
1695
|
+
static end(uri, source) {
|
|
1696
|
+
return new $mol_span(uri, source, 1, source.length + 1, 0);
|
|
1697
|
+
}
|
|
1698
|
+
static entire(uri, source) {
|
|
1699
|
+
return new $mol_span(uri, source, 1, 1, source.length);
|
|
1700
|
+
}
|
|
1701
|
+
toString() {
|
|
1702
|
+
return this[Symbol.toStringTag];
|
|
1703
|
+
}
|
|
1704
|
+
toJSON() {
|
|
1705
|
+
return {
|
|
1706
|
+
uri: this.uri,
|
|
1707
|
+
row: this.row,
|
|
1708
|
+
col: this.col,
|
|
1709
|
+
length: this.length
|
|
1710
|
+
};
|
|
1711
|
+
}
|
|
1712
|
+
error(message, Class = Error) {
|
|
1713
|
+
return new Class(`${message} (${this})`);
|
|
1714
|
+
}
|
|
1715
|
+
span(row, col, length) {
|
|
1716
|
+
return new $mol_span(this.uri, this.source, row, col, length);
|
|
1717
|
+
}
|
|
1718
|
+
after(length = 0) {
|
|
1719
|
+
return new $mol_span(this.uri, this.source, this.row, this.col + this.length, length);
|
|
1720
|
+
}
|
|
1721
|
+
slice(begin, end = -1) {
|
|
1722
|
+
let len = this.length;
|
|
1723
|
+
if (begin < 0)
|
|
1724
|
+
begin += len;
|
|
1725
|
+
if (end < 0)
|
|
1726
|
+
end += len;
|
|
1727
|
+
if (begin < 0 || begin > len)
|
|
1728
|
+
this.$.$mol_fail(this.error(`Begin value '${begin}' out of range`, RangeError));
|
|
1729
|
+
if (end < 0 || end > len)
|
|
1730
|
+
this.$.$mol_fail(this.error(`End value '${end}' out of range`, RangeError));
|
|
1731
|
+
if (end < begin)
|
|
1732
|
+
this.$.$mol_fail(this.error(`End value '${end}' can't be less than begin value`, RangeError));
|
|
1733
|
+
return this.span(this.row, this.col + begin, end - begin);
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
$.$mol_span = $mol_span;
|
|
1737
|
+
})($ || ($ = {}));
|
|
1738
|
+
|
|
1739
|
+
;
|
|
1740
|
+
"use strict";
|
|
1741
|
+
var $;
|
|
1742
|
+
(function ($) {
|
|
1743
|
+
function $mol_tree2_to_string(tree) {
|
|
1744
|
+
let output = [];
|
|
1745
|
+
function dump(tree, prefix = '') {
|
|
1746
|
+
if (tree.type.length) {
|
|
1747
|
+
if (!prefix.length) {
|
|
1748
|
+
prefix = "\t";
|
|
1749
|
+
}
|
|
1750
|
+
output.push(tree.type);
|
|
1751
|
+
if (tree.kids.length == 1) {
|
|
1752
|
+
output.push(' ');
|
|
1753
|
+
dump(tree.kids[0], prefix);
|
|
1754
|
+
return;
|
|
1755
|
+
}
|
|
1756
|
+
output.push("\n");
|
|
1757
|
+
}
|
|
1758
|
+
else if (tree.value.length || prefix.length) {
|
|
1759
|
+
output.push("\\" + tree.value + "\n");
|
|
1760
|
+
}
|
|
1761
|
+
for (const kid of tree.kids) {
|
|
1762
|
+
output.push(prefix);
|
|
1763
|
+
dump(kid, prefix + "\t");
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
dump(tree);
|
|
1767
|
+
return output.join('');
|
|
1768
|
+
}
|
|
1769
|
+
$.$mol_tree2_to_string = $mol_tree2_to_string;
|
|
1770
|
+
})($ || ($ = {}));
|
|
1771
|
+
|
|
1772
|
+
;
|
|
1773
|
+
"use strict";
|
|
1774
|
+
var $;
|
|
1775
|
+
(function ($) {
|
|
1776
|
+
function $mol_maybe(value) {
|
|
1777
|
+
return (value == null) ? [] : [value];
|
|
1778
|
+
}
|
|
1779
|
+
$.$mol_maybe = $mol_maybe;
|
|
1780
|
+
})($ || ($ = {}));
|
|
1781
|
+
|
|
1782
|
+
;
|
|
1783
|
+
"use strict";
|
|
1784
|
+
var $;
|
|
1785
|
+
(function ($) {
|
|
1786
|
+
class $mol_tree2 extends Object {
|
|
1787
|
+
type;
|
|
1788
|
+
value;
|
|
1789
|
+
kids;
|
|
1790
|
+
span;
|
|
1791
|
+
constructor(type, value, kids, span) {
|
|
1792
|
+
super();
|
|
1793
|
+
this.type = type;
|
|
1794
|
+
this.value = value;
|
|
1795
|
+
this.kids = kids;
|
|
1796
|
+
this.span = span;
|
|
1797
|
+
this[Symbol.toStringTag] = type || '\\' + value;
|
|
1798
|
+
}
|
|
1799
|
+
static list(kids, span = $mol_span.unknown) {
|
|
1800
|
+
return new $mol_tree2('', '', kids, span);
|
|
1801
|
+
}
|
|
1802
|
+
list(kids) {
|
|
1803
|
+
return $mol_tree2.list(kids, this.span);
|
|
1804
|
+
}
|
|
1805
|
+
static data(value, kids = [], span = $mol_span.unknown) {
|
|
1806
|
+
const chunks = value.split('\n');
|
|
1807
|
+
if (chunks.length > 1) {
|
|
1808
|
+
let kid_span = span.span(span.row, span.col, 0);
|
|
1809
|
+
const data = chunks.map(chunk => {
|
|
1810
|
+
kid_span = kid_span.after(chunk.length);
|
|
1811
|
+
return new $mol_tree2('', chunk, [], kid_span);
|
|
1812
|
+
});
|
|
1813
|
+
kids = [...data, ...kids];
|
|
1814
|
+
value = '';
|
|
1815
|
+
}
|
|
1816
|
+
return new $mol_tree2('', value, kids, span);
|
|
1817
|
+
}
|
|
1818
|
+
data(value, kids = []) {
|
|
1819
|
+
return $mol_tree2.data(value, kids, this.span);
|
|
1820
|
+
}
|
|
1821
|
+
static struct(type, kids = [], span = $mol_span.unknown) {
|
|
1822
|
+
if (/[ \n\t\\]/.test(type)) {
|
|
1823
|
+
$$.$mol_fail(span.error(`Wrong type ${JSON.stringify(type)}`));
|
|
1824
|
+
}
|
|
1825
|
+
return new $mol_tree2(type, '', kids, span);
|
|
1826
|
+
}
|
|
1827
|
+
struct(type, kids = []) {
|
|
1828
|
+
return $mol_tree2.struct(type, kids, this.span);
|
|
1829
|
+
}
|
|
1830
|
+
clone(kids, span = this.span) {
|
|
1831
|
+
return new $mol_tree2(this.type, this.value, kids, span);
|
|
1832
|
+
}
|
|
1833
|
+
text() {
|
|
1834
|
+
var values = [];
|
|
1835
|
+
for (var kid of this.kids) {
|
|
1836
|
+
if (kid.type)
|
|
1837
|
+
continue;
|
|
1838
|
+
values.push(kid.value);
|
|
1839
|
+
}
|
|
1840
|
+
return this.value + values.join('\n');
|
|
1841
|
+
}
|
|
1842
|
+
static fromString(str, uri = 'unknown') {
|
|
1843
|
+
return $$.$mol_tree2_from_string(str, uri);
|
|
1844
|
+
}
|
|
1845
|
+
toString() {
|
|
1846
|
+
return $$.$mol_tree2_to_string(this);
|
|
1847
|
+
}
|
|
1848
|
+
insert(value, ...path) {
|
|
1849
|
+
return this.update($mol_maybe(value), ...path)[0];
|
|
1850
|
+
}
|
|
1851
|
+
update(value, ...path) {
|
|
1852
|
+
if (path.length === 0)
|
|
1853
|
+
return value;
|
|
1854
|
+
const type = path[0];
|
|
1855
|
+
if (typeof type === 'string') {
|
|
1856
|
+
let replaced = false;
|
|
1857
|
+
const sub = this.kids.flatMap((item, index) => {
|
|
1858
|
+
if (item.type !== type)
|
|
1859
|
+
return item;
|
|
1860
|
+
replaced = true;
|
|
1861
|
+
return item.update(value, ...path.slice(1));
|
|
1862
|
+
}).filter(Boolean);
|
|
1863
|
+
if (!replaced && value) {
|
|
1864
|
+
sub.push(...this.struct(type, []).update(value, ...path.slice(1)));
|
|
1865
|
+
}
|
|
1866
|
+
return [this.clone(sub)];
|
|
1867
|
+
}
|
|
1868
|
+
else if (typeof type === 'number') {
|
|
1869
|
+
const ins = (this.kids[type] || this.list([]))
|
|
1870
|
+
.update(value, ...path.slice(1));
|
|
1871
|
+
return [this.clone([
|
|
1872
|
+
...this.kids.slice(0, type),
|
|
1873
|
+
...ins,
|
|
1874
|
+
...this.kids.slice(type + 1),
|
|
1875
|
+
])];
|
|
1876
|
+
}
|
|
1877
|
+
else {
|
|
1878
|
+
const kids = ((this.kids.length === 0) ? [this.list([])] : this.kids)
|
|
1879
|
+
.flatMap(item => item.update(value, ...path.slice(1)));
|
|
1880
|
+
return [this.clone(kids)];
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
select(...path) {
|
|
1884
|
+
let next = [this];
|
|
1885
|
+
for (const type of path) {
|
|
1886
|
+
if (!next.length)
|
|
1887
|
+
break;
|
|
1888
|
+
const prev = next;
|
|
1889
|
+
next = [];
|
|
1890
|
+
for (var item of prev) {
|
|
1891
|
+
switch (typeof (type)) {
|
|
1892
|
+
case 'string':
|
|
1893
|
+
for (var child of item.kids) {
|
|
1894
|
+
if (child.type == type) {
|
|
1895
|
+
next.push(child);
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
break;
|
|
1899
|
+
case 'number':
|
|
1900
|
+
if (type < item.kids.length)
|
|
1901
|
+
next.push(item.kids[type]);
|
|
1902
|
+
break;
|
|
1903
|
+
default: next.push(...item.kids);
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
return this.list(next);
|
|
1908
|
+
}
|
|
1909
|
+
filter(path, value) {
|
|
1910
|
+
const sub = this.kids.filter(item => {
|
|
1911
|
+
var found = item.select(...path);
|
|
1912
|
+
if (value === undefined) {
|
|
1913
|
+
return Boolean(found.kids.length);
|
|
1914
|
+
}
|
|
1915
|
+
else {
|
|
1916
|
+
return found.kids.some(child => child.value == value);
|
|
1917
|
+
}
|
|
1918
|
+
});
|
|
1919
|
+
return this.clone(sub);
|
|
1920
|
+
}
|
|
1921
|
+
hack_self(belt, context = {}) {
|
|
1922
|
+
let handle = belt[this.type] || belt[''];
|
|
1923
|
+
if (!handle || handle === Object.prototype[this.type]) {
|
|
1924
|
+
handle = (input, belt, context) => [
|
|
1925
|
+
input.clone(input.hack(belt, context), context.span)
|
|
1926
|
+
];
|
|
1927
|
+
}
|
|
1928
|
+
try {
|
|
1929
|
+
return handle(this, belt, context);
|
|
1930
|
+
}
|
|
1931
|
+
catch (error) {
|
|
1932
|
+
error.message += `\n${this.clone([])}${this.span}`;
|
|
1933
|
+
$mol_fail_hidden(error);
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
hack(belt, context = {}) {
|
|
1937
|
+
return [].concat(...this.kids.map(child => child.hack_self(belt, context)));
|
|
1938
|
+
}
|
|
1939
|
+
error(message, Class = Error) {
|
|
1940
|
+
return this.span.error(`${message}\n${this.clone([])}`, Class);
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
$.$mol_tree2 = $mol_tree2;
|
|
1944
|
+
class $mol_tree2_empty extends $mol_tree2 {
|
|
1945
|
+
constructor() {
|
|
1946
|
+
super('', '', [], $mol_span.unknown);
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
$.$mol_tree2_empty = $mol_tree2_empty;
|
|
1950
|
+
})($ || ($ = {}));
|
|
1951
|
+
|
|
1952
|
+
;
|
|
1953
|
+
"use strict";
|
|
1954
|
+
var $;
|
|
1955
|
+
(function ($) {
|
|
1956
|
+
class $mol_error_syntax extends SyntaxError {
|
|
1957
|
+
reason;
|
|
1958
|
+
line;
|
|
1959
|
+
span;
|
|
1960
|
+
constructor(reason, line, span) {
|
|
1961
|
+
super(`${reason}\n${span}\n${line.substring(0, span.col - 1).replace(/\S/g, ' ')}${''.padEnd(span.length, '!')}\n${line}`);
|
|
1962
|
+
this.reason = reason;
|
|
1963
|
+
this.line = line;
|
|
1964
|
+
this.span = span;
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
$.$mol_error_syntax = $mol_error_syntax;
|
|
1968
|
+
})($ || ($ = {}));
|
|
1969
|
+
|
|
1970
|
+
;
|
|
1971
|
+
"use strict";
|
|
1972
|
+
var $;
|
|
1973
|
+
(function ($) {
|
|
1974
|
+
function $mol_tree2_from_string(str, uri = '?') {
|
|
1975
|
+
const span = $mol_span.entire(uri, str);
|
|
1976
|
+
var root = $mol_tree2.list([], span);
|
|
1977
|
+
var stack = [root];
|
|
1978
|
+
var pos = 0, row = 0, min_indent = 0;
|
|
1979
|
+
while (str.length > pos) {
|
|
1980
|
+
var indent = 0;
|
|
1981
|
+
var line_start = pos;
|
|
1982
|
+
row++;
|
|
1983
|
+
while (str.length > pos && str[pos] == '\t') {
|
|
1984
|
+
indent++;
|
|
1985
|
+
pos++;
|
|
1986
|
+
}
|
|
1987
|
+
if (!root.kids.length) {
|
|
1988
|
+
min_indent = indent;
|
|
1989
|
+
}
|
|
1990
|
+
indent -= min_indent;
|
|
1991
|
+
if (indent < 0 || indent >= stack.length) {
|
|
1992
|
+
const sp = span.span(row, 1, pos - line_start);
|
|
1993
|
+
while (str.length > pos && str[pos] != '\n') {
|
|
1994
|
+
pos++;
|
|
1995
|
+
}
|
|
1996
|
+
if (indent < 0) {
|
|
1997
|
+
if (str.length > pos) {
|
|
1998
|
+
this.$mol_fail(new this.$mol_error_syntax(`Too few tabs`, str.substring(line_start, pos), sp));
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
else {
|
|
2002
|
+
this.$mol_fail(new this.$mol_error_syntax(`Too many tabs`, str.substring(line_start, pos), sp));
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
stack.length = indent + 1;
|
|
2006
|
+
var parent = stack[indent];
|
|
2007
|
+
while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') {
|
|
2008
|
+
var error_start = pos;
|
|
2009
|
+
while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) {
|
|
2010
|
+
pos++;
|
|
2011
|
+
}
|
|
2012
|
+
if (pos > error_start) {
|
|
2013
|
+
let line_end = str.indexOf('\n', pos);
|
|
2014
|
+
if (line_end === -1)
|
|
2015
|
+
line_end = str.length;
|
|
2016
|
+
const sp = span.span(row, error_start - line_start + 1, pos - error_start);
|
|
2017
|
+
this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
|
|
2018
|
+
}
|
|
2019
|
+
var type_start = pos;
|
|
2020
|
+
while (str.length > pos &&
|
|
2021
|
+
str[pos] != '\\' &&
|
|
2022
|
+
str[pos] != ' ' &&
|
|
2023
|
+
str[pos] != '\t' &&
|
|
2024
|
+
str[pos] != '\n') {
|
|
2025
|
+
pos++;
|
|
2026
|
+
}
|
|
2027
|
+
if (pos > type_start) {
|
|
2028
|
+
let next = new $mol_tree2(str.slice(type_start, pos), '', [], span.span(row, type_start - line_start + 1, pos - type_start));
|
|
2029
|
+
const parent_kids = parent.kids;
|
|
2030
|
+
parent_kids.push(next);
|
|
2031
|
+
parent = next;
|
|
2032
|
+
}
|
|
2033
|
+
if (str.length > pos && str[pos] == ' ') {
|
|
2034
|
+
pos++;
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
if (str.length > pos && str[pos] == '\\') {
|
|
2038
|
+
var data_start = pos;
|
|
2039
|
+
while (str.length > pos && str[pos] != '\n') {
|
|
2040
|
+
pos++;
|
|
2041
|
+
}
|
|
2042
|
+
let next = new $mol_tree2('', str.slice(data_start + 1, pos), [], span.span(row, data_start - line_start + 2, pos - data_start - 1));
|
|
2043
|
+
const parent_kids = parent.kids;
|
|
2044
|
+
parent_kids.push(next);
|
|
2045
|
+
parent = next;
|
|
2046
|
+
}
|
|
2047
|
+
if (str.length === pos && stack.length > 0) {
|
|
2048
|
+
const sp = span.span(row, pos - line_start + 1, 1);
|
|
2049
|
+
this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
|
|
2050
|
+
}
|
|
2051
|
+
stack.push(parent);
|
|
2052
|
+
pos++;
|
|
2053
|
+
}
|
|
2054
|
+
return root;
|
|
2055
|
+
}
|
|
2056
|
+
$.$mol_tree2_from_string = $mol_tree2_from_string;
|
|
2057
|
+
})($ || ($ = {}));
|
|
2058
|
+
|
|
2059
|
+
;
|
|
2060
|
+
"use strict";
|
|
2061
|
+
var $;
|
|
2062
|
+
(function ($) {
|
|
2063
|
+
function $mol_array_chunks(array, rule) {
|
|
2064
|
+
const br = typeof rule === 'number' ? (_, i) => i % rule === 0 : rule;
|
|
2065
|
+
let chunk = [];
|
|
2066
|
+
const chunks = [];
|
|
2067
|
+
for (let i = 0; i < array.length; ++i) {
|
|
2068
|
+
const item = array[i];
|
|
2069
|
+
if (br(item, i)) {
|
|
2070
|
+
if (chunk.length)
|
|
2071
|
+
chunks.push(chunk);
|
|
2072
|
+
chunk = [];
|
|
2073
|
+
}
|
|
2074
|
+
chunk.push(item);
|
|
2075
|
+
}
|
|
2076
|
+
if (chunk.length)
|
|
2077
|
+
chunks.push(chunk);
|
|
2078
|
+
return chunks;
|
|
2079
|
+
}
|
|
2080
|
+
$.$mol_array_chunks = $mol_array_chunks;
|
|
2081
|
+
})($ || ($ = {}));
|
|
2082
|
+
|
|
2083
|
+
;
|
|
2084
|
+
"use strict";
|
|
2085
|
+
var $;
|
|
2086
|
+
(function ($) {
|
|
2087
|
+
function $mol_tree2_from_json(json, span = $mol_span.unknown) {
|
|
2088
|
+
if (typeof json === 'boolean' || typeof json === 'number' || json === null) {
|
|
2089
|
+
return new $mol_tree2(String(json), '', [], span);
|
|
2090
|
+
}
|
|
2091
|
+
if (typeof json === 'string') {
|
|
2092
|
+
return $mol_tree2.data(json, [], span);
|
|
2093
|
+
}
|
|
2094
|
+
if (typeof json.toJSON === 'function') {
|
|
2095
|
+
return $mol_tree2_from_json(json.toJSON());
|
|
2096
|
+
}
|
|
2097
|
+
if (Array.isArray(json)) {
|
|
2098
|
+
const sub = json.map(json => $mol_tree2_from_json(json, span));
|
|
2099
|
+
return new $mol_tree2('/', '', sub, span);
|
|
2100
|
+
}
|
|
2101
|
+
if (ArrayBuffer.isView(json)) {
|
|
2102
|
+
const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
|
|
2103
|
+
const codes = [...buf].map(b => b.toString(16).toUpperCase().padStart(2, '0'));
|
|
2104
|
+
const str = $mol_array_chunks(codes, 8).map(c => c.join(' ')).join('\n');
|
|
2105
|
+
return $mol_tree2.data(str, [], span);
|
|
2106
|
+
}
|
|
2107
|
+
if (json instanceof Date) {
|
|
2108
|
+
return new $mol_tree2('', json.toISOString(), [], span);
|
|
2109
|
+
}
|
|
2110
|
+
if (json.toString !== Object.prototype.toString) {
|
|
2111
|
+
return $mol_tree2.data(json.toString(), [], span);
|
|
2112
|
+
}
|
|
2113
|
+
if (json instanceof Error) {
|
|
2114
|
+
const { name, message, stack } = json;
|
|
2115
|
+
json = { ...json, name, message, stack };
|
|
2116
|
+
}
|
|
2117
|
+
const sub = [];
|
|
2118
|
+
for (var key in json) {
|
|
2119
|
+
const val = json[key];
|
|
2120
|
+
if (val === undefined)
|
|
2121
|
+
continue;
|
|
2122
|
+
const subsub = $mol_tree2_from_json(val, span);
|
|
2123
|
+
if (/^[^\n\t\\ ]+$/.test(key)) {
|
|
2124
|
+
sub.push(new $mol_tree2(key, '', [subsub], span));
|
|
2125
|
+
}
|
|
2126
|
+
else {
|
|
2127
|
+
sub.push($mol_tree2.data(key, [subsub], span));
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
return new $mol_tree2('*', '', sub, span);
|
|
2131
|
+
}
|
|
2132
|
+
$.$mol_tree2_from_json = $mol_tree2_from_json;
|
|
2133
|
+
})($ || ($ = {}));
|
|
2134
|
+
|
|
2135
|
+
;
|
|
2136
|
+
"use strict";
|
|
2137
|
+
var $;
|
|
2138
|
+
(function ($) {
|
|
2139
|
+
class $mol_term_color {
|
|
2140
|
+
static reset = this.ansi(0, 0);
|
|
2141
|
+
static bold = this.ansi(1, 22);
|
|
2142
|
+
static italic = this.ansi(3, 23);
|
|
2143
|
+
static underline = this.ansi(4, 24);
|
|
2144
|
+
static inverse = this.ansi(7, 27);
|
|
2145
|
+
static hidden = this.ansi(8, 28);
|
|
2146
|
+
static strike = this.ansi(9, 29);
|
|
2147
|
+
static gray = this.ansi(90, 39);
|
|
2148
|
+
static red = this.ansi(91, 39);
|
|
2149
|
+
static green = this.ansi(92, 39);
|
|
2150
|
+
static yellow = this.ansi(93, 39);
|
|
2151
|
+
static blue = this.ansi(94, 39);
|
|
2152
|
+
static magenta = this.ansi(95, 39);
|
|
2153
|
+
static cyan = this.ansi(96, 39);
|
|
2154
|
+
static Gray = (str) => this.inverse(this.gray(str));
|
|
2155
|
+
static Red = (str) => this.inverse(this.red(str));
|
|
2156
|
+
static Green = (str) => this.inverse(this.green(str));
|
|
2157
|
+
static Yellow = (str) => this.inverse(this.yellow(str));
|
|
2158
|
+
static Blue = (str) => this.inverse(this.blue(str));
|
|
2159
|
+
static Magenta = (str) => this.inverse(this.magenta(str));
|
|
2160
|
+
static Cyan = (str) => this.inverse(this.cyan(str));
|
|
2161
|
+
static ansi(open, close) {
|
|
2162
|
+
if (typeof process === 'undefined')
|
|
2163
|
+
return String;
|
|
2164
|
+
if (!process.stdout.isTTY)
|
|
2165
|
+
return String;
|
|
2166
|
+
const prefix = `\x1b[${open}m`;
|
|
2167
|
+
const postfix = `\x1b[${close}m`;
|
|
2168
|
+
const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
|
|
2169
|
+
return function colorer(str) {
|
|
2170
|
+
str = String(str);
|
|
2171
|
+
if (str === '')
|
|
2172
|
+
return str;
|
|
2173
|
+
const suffix = str.replace(suffix_regexp, prefix);
|
|
2174
|
+
return prefix + suffix + postfix;
|
|
2175
|
+
};
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
$.$mol_term_color = $mol_term_color;
|
|
2179
|
+
})($ || ($ = {}));
|
|
2180
|
+
|
|
2181
|
+
;
|
|
2182
|
+
"use strict";
|
|
2183
|
+
var $;
|
|
2184
|
+
(function ($) {
|
|
2185
|
+
function $mol_log3_node_make(level, output, type, color) {
|
|
2186
|
+
return function $mol_log3_logger(event) {
|
|
2187
|
+
if (!event.time)
|
|
2188
|
+
event = { ...event, time: new Date().toISOString() };
|
|
2189
|
+
let tree = this.$mol_tree2_from_json(event);
|
|
2190
|
+
tree = tree.struct(type, tree.kids);
|
|
2191
|
+
let str = color(tree.toString());
|
|
2192
|
+
this.console[level](str);
|
|
2193
|
+
const self = this;
|
|
2194
|
+
return () => self.console.groupEnd();
|
|
2195
|
+
};
|
|
2196
|
+
}
|
|
2197
|
+
$.$mol_log3_node_make = $mol_log3_node_make;
|
|
2198
|
+
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
|
|
2199
|
+
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
|
|
2200
|
+
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
|
|
2201
|
+
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
|
|
2202
|
+
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
|
|
2203
|
+
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
|
2204
|
+
})($ || ($ = {}));
|
|
2205
|
+
|
|
2206
|
+
;
|
|
2207
|
+
"use strict";
|
|
2208
|
+
var $;
|
|
2209
|
+
(function ($) {
|
|
2210
|
+
class $mol_wire_task extends $mol_wire_fiber {
|
|
2211
|
+
static getter(task) {
|
|
2212
|
+
return function $mol_wire_task_get(host, args) {
|
|
2213
|
+
const sub = $mol_wire_auto();
|
|
2214
|
+
const existen = sub?.track_next();
|
|
2215
|
+
let cause = '';
|
|
2216
|
+
reuse: if (existen) {
|
|
2217
|
+
if (!existen.temp)
|
|
2218
|
+
break reuse;
|
|
2219
|
+
if (existen.task !== task) {
|
|
2220
|
+
cause = 'task';
|
|
2221
|
+
break reuse;
|
|
2222
|
+
}
|
|
2223
|
+
if (existen.host !== host) {
|
|
2224
|
+
cause = 'host';
|
|
2225
|
+
break reuse;
|
|
2226
|
+
}
|
|
2227
|
+
if (!$mol_compare_deep(existen.args, args)) {
|
|
2228
|
+
cause = 'args';
|
|
2229
|
+
break reuse;
|
|
2230
|
+
}
|
|
2231
|
+
return existen;
|
|
2232
|
+
}
|
|
2233
|
+
const key = (host?.[Symbol.toStringTag] ?? host) + ('.' + task.name + '<#>');
|
|
2234
|
+
const next = new $mol_wire_task(key, task, host, args);
|
|
2235
|
+
if (existen?.temp) {
|
|
2236
|
+
$$.$mol_log3_warn({
|
|
2237
|
+
place: '$mol_wire_task',
|
|
2238
|
+
message: `Different ${cause} on restart`,
|
|
2239
|
+
sub,
|
|
2240
|
+
prev: existen,
|
|
2241
|
+
next,
|
|
2242
|
+
hint: 'Maybe required additional memoization',
|
|
2243
|
+
});
|
|
2244
|
+
}
|
|
2245
|
+
return next;
|
|
2246
|
+
};
|
|
2247
|
+
}
|
|
2248
|
+
get temp() {
|
|
2249
|
+
return true;
|
|
2250
|
+
}
|
|
2251
|
+
complete() {
|
|
2252
|
+
if ($mol_promise_like(this.cache))
|
|
2253
|
+
return;
|
|
2254
|
+
this.destructor();
|
|
2255
|
+
}
|
|
2256
|
+
put(next) {
|
|
2257
|
+
const prev = this.cache;
|
|
2258
|
+
this.cache = next;
|
|
2259
|
+
if ($mol_promise_like(next)) {
|
|
2260
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
2261
|
+
if (next !== prev)
|
|
2262
|
+
this.emit();
|
|
2263
|
+
if ($mol_owning_catch(this, next)) {
|
|
2264
|
+
try {
|
|
2265
|
+
next[Symbol.toStringTag] = this[Symbol.toStringTag];
|
|
2266
|
+
}
|
|
2267
|
+
catch {
|
|
2268
|
+
Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
return next;
|
|
2272
|
+
}
|
|
2273
|
+
this.cursor = $mol_wire_cursor.final;
|
|
2274
|
+
if (this.sub_empty)
|
|
2275
|
+
this.destructor();
|
|
2276
|
+
else if (next !== prev)
|
|
2277
|
+
this.emit();
|
|
2278
|
+
return next;
|
|
2279
|
+
}
|
|
2280
|
+
destructor() {
|
|
2281
|
+
super.destructor();
|
|
2282
|
+
this.cursor = $mol_wire_cursor.final;
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
$.$mol_wire_task = $mol_wire_task;
|
|
2286
|
+
})($ || ($ = {}));
|
|
2287
|
+
|
|
2288
|
+
;
|
|
2289
|
+
"use strict";
|
|
2290
|
+
var $;
|
|
2291
|
+
(function ($) {
|
|
2292
|
+
const factories = new WeakMap();
|
|
2293
|
+
function factory(val) {
|
|
2294
|
+
let make = factories.get(val);
|
|
2295
|
+
if (make)
|
|
2296
|
+
return make;
|
|
2297
|
+
make = $mol_func_name_from((...args) => new val(...args), val);
|
|
2298
|
+
factories.set(val, make);
|
|
2299
|
+
return make;
|
|
2300
|
+
}
|
|
2301
|
+
const getters = new WeakMap();
|
|
2302
|
+
function get_prop(host, field) {
|
|
2303
|
+
let props = getters.get(host);
|
|
2304
|
+
let get_val = props?.[field];
|
|
2305
|
+
if (get_val)
|
|
2306
|
+
return get_val;
|
|
2307
|
+
get_val = (next) => {
|
|
2308
|
+
if (next !== undefined)
|
|
2309
|
+
host[field] = next;
|
|
2310
|
+
return host[field];
|
|
2311
|
+
};
|
|
2312
|
+
Object.defineProperty(get_val, 'name', { value: field });
|
|
2313
|
+
if (!props) {
|
|
2314
|
+
props = {};
|
|
2315
|
+
getters.set(host, props);
|
|
2316
|
+
}
|
|
2317
|
+
props[field] = get_val;
|
|
2318
|
+
return get_val;
|
|
2319
|
+
}
|
|
2320
|
+
function $mol_wire_sync(obj) {
|
|
2321
|
+
return new Proxy(obj, {
|
|
2322
|
+
get(obj, field) {
|
|
2323
|
+
let val = obj[field];
|
|
2324
|
+
const temp = $mol_wire_task.getter(typeof val === 'function' ? val : get_prop(obj, field));
|
|
2325
|
+
if (typeof val !== 'function')
|
|
2326
|
+
return temp(obj, []).sync();
|
|
2327
|
+
return function $mol_wire_sync(...args) {
|
|
2328
|
+
const fiber = temp(obj, args);
|
|
2329
|
+
return fiber.sync();
|
|
2330
|
+
};
|
|
2331
|
+
},
|
|
2332
|
+
set(obj, field, next) {
|
|
2333
|
+
const temp = $mol_wire_task.getter(get_prop(obj, field));
|
|
2334
|
+
temp(obj, [next]).sync();
|
|
2335
|
+
return true;
|
|
2336
|
+
},
|
|
2337
|
+
construct(obj, args) {
|
|
2338
|
+
const temp = $mol_wire_task.getter(factory(obj));
|
|
2339
|
+
return temp(obj, args).sync();
|
|
2340
|
+
},
|
|
2341
|
+
apply(obj, self, args) {
|
|
2342
|
+
const temp = $mol_wire_task.getter(obj);
|
|
2343
|
+
return temp(self, args).sync();
|
|
2344
|
+
},
|
|
2345
|
+
});
|
|
2346
|
+
}
|
|
2347
|
+
$.$mol_wire_sync = $mol_wire_sync;
|
|
2348
|
+
})($ || ($ = {}));
|
|
2349
|
+
|
|
2350
|
+
;
|
|
2351
|
+
"use strict";
|
|
2352
|
+
var $;
|
|
2353
|
+
(function ($) {
|
|
2354
|
+
class $mol_run_error extends $mol_error_mix {
|
|
2355
|
+
}
|
|
2356
|
+
$.$mol_run_error = $mol_run_error;
|
|
2357
|
+
$.$mol_run_spawn = (...args) => $node['child_process'].spawn(...args);
|
|
2358
|
+
$.$mol_run_spawn_sync = (...args) => $node['child_process'].spawnSync(...args);
|
|
2359
|
+
class $mol_run extends $mol_object {
|
|
2360
|
+
static async_enabled() {
|
|
2361
|
+
return Boolean(this.$.$mol_env()['MOL_RUN_ASYNC']);
|
|
2362
|
+
}
|
|
2363
|
+
static spawn(options) {
|
|
2364
|
+
const sync = !this.async_enabled() || !Boolean($mol_wire_auto());
|
|
2365
|
+
const env = options.env ?? this.$.$mol_env();
|
|
2366
|
+
return $mol_wire_sync(this).spawn_async({ ...options, sync, env });
|
|
2367
|
+
}
|
|
2368
|
+
static spawn_async({ dir, sync, timeout, command, env }) {
|
|
2369
|
+
const args_raw = typeof command === 'string' ? command.split(' ') : command;
|
|
2370
|
+
const [app, ...args] = args_raw;
|
|
2371
|
+
const opts = { shell: true, cwd: dir, env };
|
|
2372
|
+
const log_object = {
|
|
2373
|
+
place: `${this}.spawn()`,
|
|
2374
|
+
message: 'Run',
|
|
2375
|
+
command: args_raw.join(' '),
|
|
2376
|
+
dir: $node.path.relative('', dir),
|
|
2377
|
+
};
|
|
2378
|
+
if (sync) {
|
|
2379
|
+
this.$.$mol_log3_come({
|
|
2380
|
+
hint: 'Run inside fiber',
|
|
2381
|
+
...log_object
|
|
2382
|
+
});
|
|
2383
|
+
let error;
|
|
2384
|
+
let res;
|
|
2385
|
+
try {
|
|
2386
|
+
res = this.$.$mol_run_spawn_sync(app, args, opts);
|
|
2387
|
+
error = res.error;
|
|
2388
|
+
}
|
|
2389
|
+
catch (err) {
|
|
2390
|
+
error = err;
|
|
2391
|
+
}
|
|
2392
|
+
if (!res || error || res.status) {
|
|
2393
|
+
throw new $mol_run_error(this.error_message(res), { ...log_object, status: res?.status, signal: res?.signal }, ...(error ? [error] : []));
|
|
2394
|
+
}
|
|
2395
|
+
return res;
|
|
2396
|
+
}
|
|
2397
|
+
let sub;
|
|
2398
|
+
try {
|
|
2399
|
+
sub = this.$.$mol_run_spawn(app, args, {
|
|
2400
|
+
...opts,
|
|
2401
|
+
stdio: ['pipe', 'inherit', 'inherit'],
|
|
2402
|
+
});
|
|
2403
|
+
}
|
|
2404
|
+
catch (error) {
|
|
2405
|
+
throw new $mol_run_error(this.error_message(undefined), log_object, error);
|
|
2406
|
+
}
|
|
2407
|
+
const pid = sub.pid ?? 0;
|
|
2408
|
+
this.$.$mol_log3_come({
|
|
2409
|
+
...log_object,
|
|
2410
|
+
pid,
|
|
2411
|
+
});
|
|
2412
|
+
let timeout_kill = false;
|
|
2413
|
+
let timer;
|
|
2414
|
+
const std_data = [];
|
|
2415
|
+
const error_data = [];
|
|
2416
|
+
const add = (std_chunk, error_chunk) => {
|
|
2417
|
+
if (std_chunk)
|
|
2418
|
+
std_data.push(std_chunk);
|
|
2419
|
+
if (error_chunk)
|
|
2420
|
+
error_data.push(error_chunk);
|
|
2421
|
+
if (!timeout)
|
|
2422
|
+
return;
|
|
2423
|
+
clearTimeout(timer);
|
|
2424
|
+
timer = setTimeout(() => {
|
|
2425
|
+
const signal = timeout_kill ? 'SIGKILL' : 'SIGTERM';
|
|
2426
|
+
timeout_kill = true;
|
|
2427
|
+
add();
|
|
2428
|
+
sub.kill(signal);
|
|
2429
|
+
}, timeout);
|
|
2430
|
+
};
|
|
2431
|
+
add();
|
|
2432
|
+
sub.stdout?.on('data', data => add(data));
|
|
2433
|
+
sub.stderr?.on('data', data => add(undefined, data));
|
|
2434
|
+
const result_promise = new Promise((done, fail) => {
|
|
2435
|
+
const close = (error, status = null, signal = null) => {
|
|
2436
|
+
if (!timer && timeout)
|
|
2437
|
+
return;
|
|
2438
|
+
clearTimeout(timer);
|
|
2439
|
+
timer = undefined;
|
|
2440
|
+
const res = {
|
|
2441
|
+
pid,
|
|
2442
|
+
signal,
|
|
2443
|
+
get stdout() { return Buffer.concat(std_data); },
|
|
2444
|
+
get stderr() { return Buffer.concat(error_data); }
|
|
2445
|
+
};
|
|
2446
|
+
if (error || status || timeout_kill)
|
|
2447
|
+
return fail(new $mol_run_error(this.error_message(res) + (timeout_kill ? ', timeout' : ''), { ...log_object, pid, status, signal, timeout_kill }, ...error ? [error] : []));
|
|
2448
|
+
this.$.$mol_log3_done({
|
|
2449
|
+
...log_object,
|
|
2450
|
+
pid,
|
|
2451
|
+
});
|
|
2452
|
+
done(res);
|
|
2453
|
+
};
|
|
2454
|
+
sub.on('disconnect', () => close(new Error('Disconnected')));
|
|
2455
|
+
sub.on('error', err => close(err));
|
|
2456
|
+
sub.on('exit', (status, signal) => close(null, status, signal));
|
|
2457
|
+
});
|
|
2458
|
+
return Object.assign(result_promise, { destructor: () => {
|
|
2459
|
+
clearTimeout(timer);
|
|
2460
|
+
sub.kill('SIGKILL');
|
|
2461
|
+
} });
|
|
2462
|
+
}
|
|
2463
|
+
static error_message(res) {
|
|
2464
|
+
return res?.stderr.toString() || res?.stdout.toString() || 'Run error';
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2467
|
+
$.$mol_run = $mol_run;
|
|
2468
|
+
})($ || ($ = {}));
|
|
2469
|
+
|
|
2470
|
+
;
|
|
2471
|
+
"use strict";
|
|
2472
|
+
var $;
|
|
2473
|
+
(function ($) {
|
|
2474
|
+
$.$mol_crypto_native = $node.crypto.webcrypto;
|
|
2475
|
+
})($ || ($ = {}));
|
|
2476
|
+
|
|
2477
|
+
;
|
|
2478
|
+
"use strict";
|
|
2479
|
+
var $;
|
|
2480
|
+
(function ($) {
|
|
2481
|
+
function $mol_crypto_restack(error) {
|
|
2482
|
+
error = new Error(error instanceof Error ? error.message : String(error), { cause: error });
|
|
2483
|
+
$mol_fail_hidden(error);
|
|
2484
|
+
}
|
|
2485
|
+
$.$mol_crypto_restack = $mol_crypto_restack;
|
|
2486
|
+
})($ || ($ = {}));
|
|
2487
|
+
|
|
2488
|
+
;
|
|
2489
|
+
"use strict";
|
|
2490
|
+
var $;
|
|
2491
|
+
(function ($) {
|
|
2492
|
+
class $mol_crypto2_auditor extends $mol_crypto2_key {
|
|
2493
|
+
async native() {
|
|
2494
|
+
return $mol_crypto_native.subtle.importKey('jwk', {
|
|
2495
|
+
crv: "Ed25519",
|
|
2496
|
+
ext: true,
|
|
2497
|
+
key_ops: ['verify'],
|
|
2498
|
+
kty: "OKP",
|
|
2499
|
+
x: this.toString(),
|
|
2500
|
+
}, "Ed25519", Boolean('extractable'), ['verify']).catch($mol_crypto_restack);
|
|
2501
|
+
}
|
|
2502
|
+
async verify(data, sign) {
|
|
2503
|
+
return await $mol_crypto_native.subtle.verify("Ed25519", await this.native(), sign, data).catch($mol_crypto_restack);
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
__decorate([
|
|
2507
|
+
$mol_memo.method
|
|
2508
|
+
], $mol_crypto2_auditor.prototype, "native", null);
|
|
2509
|
+
$.$mol_crypto2_auditor = $mol_crypto2_auditor;
|
|
2510
|
+
})($ || ($ = {}));
|
|
2511
|
+
|
|
2512
|
+
;
|
|
2513
|
+
"use strict";
|
|
2514
|
+
var $;
|
|
2515
|
+
(function ($) {
|
|
2516
|
+
class $mol_crypto2_signer extends $mol_crypto2_auditor {
|
|
2517
|
+
static size_sign = 64;
|
|
2518
|
+
static async generate() {
|
|
2519
|
+
const pair = await $mol_crypto_native.subtle.generateKey("Ed25519", Boolean('extractable'), ['sign', 'verify']).catch($mol_crypto_restack);
|
|
2520
|
+
const { x, d } = await $mol_crypto_native.subtle.exportKey('jwk', pair.privateKey).catch($mol_crypto_restack);
|
|
2521
|
+
return this.from(x + d);
|
|
2522
|
+
}
|
|
2523
|
+
async nativePrivate() {
|
|
2524
|
+
return await $mol_crypto_native.subtle.importKey('jwk', {
|
|
2525
|
+
crv: "Ed25519",
|
|
2526
|
+
ext: true,
|
|
2527
|
+
key_ops: ['sign'],
|
|
2528
|
+
kty: "OKP",
|
|
2529
|
+
x: this.toString(),
|
|
2530
|
+
d: this.toStringPrivate(),
|
|
2531
|
+
}, "Ed25519", Boolean('extractable'), ['sign']).catch($mol_crypto_restack);
|
|
2532
|
+
}
|
|
2533
|
+
asArrayPrivate() {
|
|
2534
|
+
return new Uint8Array(this.buffer, this.byteOffset + 32, 32);
|
|
2535
|
+
}
|
|
2536
|
+
toStringPrivate() {
|
|
2537
|
+
return $mol_base64_url_encode(this.asArrayPrivate());
|
|
2538
|
+
}
|
|
2539
|
+
auditor() {
|
|
2540
|
+
return $mol_crypto2_auditor.from(this.asArray());
|
|
2541
|
+
}
|
|
2542
|
+
async sign(data) {
|
|
2543
|
+
return new Uint8Array(await $mol_crypto_native.subtle.sign("Ed25519", await this.nativePrivate(), data).catch($mol_crypto_restack));
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
__decorate([
|
|
2547
|
+
$mol_memo.method
|
|
2548
|
+
], $mol_crypto2_signer.prototype, "nativePrivate", null);
|
|
2549
|
+
__decorate([
|
|
2550
|
+
$mol_memo.method
|
|
2551
|
+
], $mol_crypto2_signer.prototype, "toStringPrivate", null);
|
|
2552
|
+
__decorate([
|
|
2553
|
+
$mol_memo.method
|
|
2554
|
+
], $mol_crypto2_signer.prototype, "auditor", null);
|
|
2555
|
+
$.$mol_crypto2_signer = $mol_crypto2_signer;
|
|
2556
|
+
})($ || ($ = {}));
|
|
2557
|
+
|
|
2558
|
+
;
|
|
2559
|
+
"use strict";
|
|
2560
|
+
var $;
|
|
2561
|
+
(function ($) {
|
|
2562
|
+
class $mol_crypto2_socket extends $mol_crypto2_key {
|
|
2563
|
+
async native() {
|
|
2564
|
+
return await $mol_crypto_native.subtle.importKey('jwk', {
|
|
2565
|
+
crv: 'X25519',
|
|
2566
|
+
ext: true,
|
|
2567
|
+
kty: 'OKP',
|
|
2568
|
+
key_ops: [],
|
|
2569
|
+
x: this.toString(),
|
|
2570
|
+
}, "X25519", true, []).catch($mol_crypto_restack);
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
__decorate([
|
|
2574
|
+
$mol_memo.method
|
|
2575
|
+
], $mol_crypto2_socket.prototype, "native", null);
|
|
2576
|
+
$.$mol_crypto2_socket = $mol_crypto2_socket;
|
|
2577
|
+
})($ || ($ = {}));
|
|
2578
|
+
|
|
2579
|
+
;
|
|
2580
|
+
"use strict";
|
|
2581
|
+
var $;
|
|
2582
|
+
(function ($) {
|
|
2583
|
+
function $mol_crypto_salt() {
|
|
2584
|
+
return $mol_crypto_native.getRandomValues(new Uint8Array(16));
|
|
2585
|
+
}
|
|
2586
|
+
$.$mol_crypto_salt = $mol_crypto_salt;
|
|
2587
|
+
$.$mol_crypto_salt_once = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6]);
|
|
2588
|
+
})($ || ($ = {}));
|
|
2589
|
+
|
|
2590
|
+
;
|
|
2591
|
+
"use strict";
|
|
2592
|
+
var $;
|
|
2593
|
+
(function ($) {
|
|
2594
|
+
class $mol_crypto_sacred extends $mol_buffer {
|
|
2595
|
+
static size = 16;
|
|
2596
|
+
static make() {
|
|
2597
|
+
return this.from($mol_crypto_salt());
|
|
2598
|
+
}
|
|
2599
|
+
static from(serial) {
|
|
2600
|
+
if (typeof serial === 'string') {
|
|
2601
|
+
serial = new Uint8Array([
|
|
2602
|
+
...$mol_base64_url_decode(serial),
|
|
2603
|
+
]);
|
|
2604
|
+
}
|
|
2605
|
+
if (!(serial instanceof Uint8Array)) {
|
|
2606
|
+
serial = new Uint8Array(serial.buffer, serial.byteOffset, serial.byteLength);
|
|
2607
|
+
}
|
|
2608
|
+
;
|
|
2609
|
+
serial[0] = 0xFF;
|
|
2610
|
+
const sacred = super.from(serial);
|
|
2611
|
+
return sacred;
|
|
2612
|
+
}
|
|
2613
|
+
static async from_native(native) {
|
|
2614
|
+
const buf = await $mol_crypto_native.subtle.exportKey('raw', native).catch($mol_crypto_restack);
|
|
2615
|
+
const sacred = this.from(new Uint8Array(buf));
|
|
2616
|
+
sacred._native = native;
|
|
2617
|
+
return sacred;
|
|
2618
|
+
}
|
|
2619
|
+
constructor(buffer, byteOffset, byteLength) {
|
|
2620
|
+
super(buffer, byteOffset, byteLength);
|
|
2621
|
+
if (this.getUint8(0) !== 0xFF)
|
|
2622
|
+
$mol_fail(new Error('Buffer should starts with 0xFF byte'));
|
|
2623
|
+
}
|
|
2624
|
+
toString() {
|
|
2625
|
+
return $mol_base64_url_encode(this.asArray());
|
|
2626
|
+
}
|
|
2627
|
+
_native;
|
|
2628
|
+
async native() {
|
|
2629
|
+
return this._native ?? (this._native = await $mol_crypto_native.subtle.importKey('raw', this, {
|
|
2630
|
+
name: 'AES-CBC',
|
|
2631
|
+
length: 128,
|
|
2632
|
+
}, true, ['encrypt', 'decrypt']).catch($mol_crypto_restack));
|
|
2633
|
+
}
|
|
2634
|
+
async encrypt(open, salt) {
|
|
2635
|
+
return new Uint8Array(await $mol_crypto_native.subtle.encrypt({
|
|
2636
|
+
name: 'AES-CBC',
|
|
2637
|
+
length: 128,
|
|
2638
|
+
tagLength: 32,
|
|
2639
|
+
iv: salt,
|
|
2640
|
+
}, await this.native(), open).catch($mol_crypto_restack));
|
|
2641
|
+
}
|
|
2642
|
+
async decrypt(closed, salt) {
|
|
2643
|
+
return new Uint8Array(await $mol_crypto_native.subtle.decrypt({
|
|
2644
|
+
name: 'AES-CBC',
|
|
2645
|
+
length: 128,
|
|
2646
|
+
tagLength: 32,
|
|
2647
|
+
iv: salt,
|
|
2648
|
+
}, await this.native(), closed).catch($mol_crypto_restack));
|
|
2649
|
+
}
|
|
2650
|
+
async close(opened, salt) {
|
|
2651
|
+
if (opened.getUint8(0) !== 0xFF)
|
|
2652
|
+
throw new Error('Closable buffer should starts with 0xFF');
|
|
2653
|
+
const trimed = new Uint8Array(opened.buffer, opened.byteOffset + 1, opened.byteLength - 1);
|
|
2654
|
+
return this.encrypt(trimed, salt);
|
|
2655
|
+
}
|
|
2656
|
+
async open(closed, salt) {
|
|
2657
|
+
const trimed = await this.decrypt(closed, salt);
|
|
2658
|
+
if (trimed.byteLength !== closed.byteLength - 1)
|
|
2659
|
+
throw new Error('Length of opened buffer should be ' + (closed.byteLength - 1));
|
|
2660
|
+
const opened = new Uint8Array(closed.byteLength);
|
|
2661
|
+
opened[0] = 0xFF;
|
|
2662
|
+
opened.set(trimed, 1);
|
|
2663
|
+
return opened;
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
__decorate([
|
|
2667
|
+
$mol_memo.method
|
|
2668
|
+
], $mol_crypto_sacred.prototype, "toString", null);
|
|
2669
|
+
$.$mol_crypto_sacred = $mol_crypto_sacred;
|
|
2670
|
+
})($ || ($ = {}));
|
|
2671
|
+
|
|
2672
|
+
;
|
|
2673
|
+
"use strict";
|
|
2674
|
+
var $;
|
|
2675
|
+
(function ($) {
|
|
2676
|
+
class $mol_crypto2_cipher extends $mol_crypto2_socket {
|
|
2677
|
+
static size_secret = 16;
|
|
2678
|
+
static async generate() {
|
|
2679
|
+
const pair = await $mol_crypto_native.subtle.generateKey("X25519", Boolean('extractable'), ['deriveKey']).catch($mol_crypto_restack);
|
|
2680
|
+
const { x, d } = await $mol_crypto_native.subtle.exportKey('jwk', pair.privateKey).catch($mol_crypto_restack);
|
|
2681
|
+
return this.from(x + d);
|
|
2682
|
+
}
|
|
2683
|
+
async nativePrivate() {
|
|
2684
|
+
return $mol_crypto_native.subtle.importKey('jwk', {
|
|
2685
|
+
crv: 'X25519',
|
|
2686
|
+
ext: true,
|
|
2687
|
+
kty: 'OKP',
|
|
2688
|
+
key_ops: ['deriveKey', 'deriveBits'],
|
|
2689
|
+
x: this.toString(),
|
|
2690
|
+
d: this.toStringPrivate(),
|
|
2691
|
+
}, "X25519", Boolean('extractable'), ['deriveKey', 'deriveBits']).catch($mol_crypto_restack);
|
|
2692
|
+
}
|
|
2693
|
+
asArrayPrivate() {
|
|
2694
|
+
return new Uint8Array(this.buffer, this.byteOffset + 32, 32);
|
|
2695
|
+
}
|
|
2696
|
+
toStringPrivate() {
|
|
2697
|
+
return $mol_base64_url_encode(this.asArrayPrivate());
|
|
2698
|
+
}
|
|
2699
|
+
socket() {
|
|
2700
|
+
return $mol_crypto2_socket.from(this.asArray());
|
|
2701
|
+
}
|
|
2702
|
+
async secret(pub) {
|
|
2703
|
+
return $mol_crypto_sacred.from(new Uint8Array(await $mol_crypto_native.subtle.deriveBits({
|
|
2704
|
+
name: "X25519",
|
|
2705
|
+
public: await pub.native(),
|
|
2706
|
+
}, await this.nativePrivate(), $mol_crypto_sacred.size * 8).catch($mol_crypto_restack)));
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
__decorate([
|
|
2710
|
+
$mol_memo.method
|
|
2711
|
+
], $mol_crypto2_cipher.prototype, "nativePrivate", null);
|
|
2712
|
+
__decorate([
|
|
2713
|
+
$mol_memo.method
|
|
2714
|
+
], $mol_crypto2_cipher.prototype, "toStringPrivate", null);
|
|
2715
|
+
__decorate([
|
|
2716
|
+
$mol_memo.method
|
|
2717
|
+
], $mol_crypto2_cipher.prototype, "socket", null);
|
|
2718
|
+
$.$mol_crypto2_cipher = $mol_crypto2_cipher;
|
|
2719
|
+
})($ || ($ = {}));
|
|
2720
|
+
|
|
2721
|
+
;
|
|
2722
|
+
"use strict";
|
|
2723
|
+
var $;
|
|
2724
|
+
(function ($) {
|
|
2725
|
+
class $mol_crypto2_public extends $mol_crypto2_key {
|
|
2726
|
+
static size_str = 86;
|
|
2727
|
+
static size_bin = 64;
|
|
2728
|
+
auditor() {
|
|
2729
|
+
return $mol_crypto2_auditor.from(this.asArray().subarray(0, 32));
|
|
2730
|
+
}
|
|
2731
|
+
socket() {
|
|
2732
|
+
return $mol_crypto2_socket.from(this.asArray().subarray(32, 64));
|
|
2733
|
+
}
|
|
2734
|
+
toString() {
|
|
2735
|
+
return this.auditor().toString() + this.socket().toString();
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
__decorate([
|
|
2739
|
+
$mol_memo.method
|
|
2740
|
+
], $mol_crypto2_public.prototype, "auditor", null);
|
|
2741
|
+
__decorate([
|
|
2742
|
+
$mol_memo.method
|
|
2743
|
+
], $mol_crypto2_public.prototype, "socket", null);
|
|
2744
|
+
__decorate([
|
|
2745
|
+
$mol_memo.method
|
|
2746
|
+
], $mol_crypto2_public.prototype, "toString", null);
|
|
2747
|
+
$.$mol_crypto2_public = $mol_crypto2_public;
|
|
2748
|
+
})($ || ($ = {}));
|
|
2749
|
+
|
|
2750
|
+
;
|
|
2751
|
+
"use strict";
|
|
2752
|
+
var $;
|
|
2753
|
+
(function ($) {
|
|
2754
|
+
class $mol_crypto2_private extends $mol_crypto2_public {
|
|
2755
|
+
static async generate() {
|
|
2756
|
+
const [signer, cipher] = await Promise.all([
|
|
2757
|
+
$mol_crypto2_signer.generate(),
|
|
2758
|
+
$mol_crypto2_cipher.generate(),
|
|
2759
|
+
]);
|
|
2760
|
+
const key = $mol_crypto2_private.from($mol_crypto2_public.size_bin + $mol_crypto2_private.size_bin);
|
|
2761
|
+
key.asArray().set(signer.asArray(), 0);
|
|
2762
|
+
key.asArray().set(cipher.asArray(), 32);
|
|
2763
|
+
key.asArrayPrivate().set(signer.asArrayPrivate(), 0);
|
|
2764
|
+
key.asArrayPrivate().set(cipher.asArrayPrivate(), 32);
|
|
2765
|
+
return key;
|
|
2766
|
+
}
|
|
2767
|
+
signer() {
|
|
2768
|
+
const signer = $mol_crypto2_signer.from($mol_crypto2_auditor.size_bin + $mol_crypto2_signer.size_bin);
|
|
2769
|
+
signer.asArray().set(this.asArray().subarray(0, 32));
|
|
2770
|
+
signer.asArrayPrivate().set(this.asArrayPrivate().subarray(0, 32));
|
|
2771
|
+
return signer;
|
|
2772
|
+
}
|
|
2773
|
+
cipher() {
|
|
2774
|
+
const cipher = $mol_crypto2_cipher.from($mol_crypto2_socket.size_bin + $mol_crypto2_cipher.size_bin);
|
|
2775
|
+
cipher.asArray().set(this.asArray().subarray(32, 64));
|
|
2776
|
+
cipher.asArrayPrivate().set(this.asArrayPrivate().subarray(32, 64));
|
|
2777
|
+
return cipher;
|
|
2778
|
+
}
|
|
2779
|
+
public() {
|
|
2780
|
+
return $mol_crypto2_public.from(this.asArray());
|
|
2781
|
+
}
|
|
2782
|
+
asArrayPrivate() {
|
|
2783
|
+
return new Uint8Array(this.buffer, this.byteOffset + 64, 64);
|
|
2784
|
+
}
|
|
2785
|
+
toStringPrivate() {
|
|
2786
|
+
return this.signer().toStringPrivate() + this.cipher().toStringPrivate();
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
__decorate([
|
|
2790
|
+
$mol_memo.method
|
|
2791
|
+
], $mol_crypto2_private.prototype, "signer", null);
|
|
2792
|
+
__decorate([
|
|
2793
|
+
$mol_memo.method
|
|
2794
|
+
], $mol_crypto2_private.prototype, "cipher", null);
|
|
2795
|
+
__decorate([
|
|
2796
|
+
$mol_memo.method
|
|
2797
|
+
], $mol_crypto2_private.prototype, "public", null);
|
|
2798
|
+
__decorate([
|
|
2799
|
+
$mol_memo.method
|
|
2800
|
+
], $mol_crypto2_private.prototype, "toStringPrivate", null);
|
|
2801
|
+
$.$mol_crypto2_private = $mol_crypto2_private;
|
|
2802
|
+
})($ || ($ = {}));
|
|
2803
|
+
|
|
2804
|
+
|
|
2805
|
+
//# sourceMappingURL=node.js.map
|