mol_crypto_lib 0.0.414 → 0.0.415
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/node.d.ts +164 -0
- package/node.deps.json +1 -1
- package/node.esm.js +712 -20
- package/node.esm.js.map +1 -1
- package/node.js +712 -20
- package/node.js.map +1 -1
- package/node.test.js +1614 -1643
- package/node.test.js.map +1 -1
- package/package.json +18 -1
- package/web.d.ts +4 -0
- package/web.deps.json +1 -1
- package/web.esm.js +27 -20
- package/web.esm.js.map +1 -1
- package/web.js +27 -20
- package/web.js.map +1 -1
- package/web.test.js +3 -7
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
@@ -21,242 +21,176 @@ module.exports = $;
|
|
21
21
|
//mam.ts
|
22
22
|
;
|
23
23
|
"use strict";
|
24
|
+
//node/node.ts
|
25
|
+
;
|
26
|
+
"use strict";
|
27
|
+
var $node = new Proxy({ require }, {
|
28
|
+
get(target, name, wrapper) {
|
29
|
+
if (target[name])
|
30
|
+
return target[name];
|
31
|
+
const mod = target.require('module');
|
32
|
+
if (mod.builtinModules.indexOf(name) >= 0)
|
33
|
+
return target.require(name);
|
34
|
+
if (name[0] === '.')
|
35
|
+
return target.require(name);
|
36
|
+
const path = target.require('path');
|
37
|
+
const fs = target.require('fs');
|
38
|
+
let dir = path.resolve('.');
|
39
|
+
const suffix = `./node_modules/${name}`;
|
40
|
+
const $$ = $;
|
41
|
+
while (!fs.existsSync(path.join(dir, suffix))) {
|
42
|
+
const parent = path.resolve(dir, '..');
|
43
|
+
if (parent === dir) {
|
44
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
45
|
+
try {
|
46
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
47
|
+
}
|
48
|
+
catch { }
|
49
|
+
break;
|
50
|
+
}
|
51
|
+
else {
|
52
|
+
dir = parent;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
return target.require(name);
|
56
|
+
},
|
57
|
+
set(target, name, value) {
|
58
|
+
target[name] = value;
|
59
|
+
return true;
|
60
|
+
},
|
61
|
+
});
|
62
|
+
require = (req => Object.assign(function require(name) {
|
63
|
+
return $node[name];
|
64
|
+
}, req))(require);
|
65
|
+
//node/node.node.ts
|
66
|
+
;
|
67
|
+
"use strict";
|
24
68
|
var $;
|
25
69
|
(function ($) {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
}
|
42
|
-
static async from(serial) {
|
43
|
-
return new this(await crypto.subtle.importKey('raw', serial, algorithm, true, ['encrypt', 'decrypt']));
|
44
|
-
}
|
45
|
-
async serial() {
|
46
|
-
return await crypto.subtle.exportKey('raw', this.native);
|
47
|
-
}
|
48
|
-
async encrypt(open, salt) {
|
49
|
-
return await crypto.subtle.encrypt({
|
50
|
-
...algorithm,
|
51
|
-
iv: salt,
|
52
|
-
}, this.native, open);
|
53
|
-
}
|
54
|
-
async decrypt(closed, salt) {
|
55
|
-
return await crypto.subtle.decrypt({
|
56
|
-
...algorithm,
|
57
|
-
iv: salt,
|
58
|
-
}, this.native, closed);
|
59
|
-
}
|
70
|
+
function $mol_log3_area_lazy(event) {
|
71
|
+
const self = this;
|
72
|
+
const stack = self.$mol_log3_stack;
|
73
|
+
const deep = stack.length;
|
74
|
+
let logged = false;
|
75
|
+
stack.push(() => {
|
76
|
+
logged = true;
|
77
|
+
self.$mol_log3_area.call(self, event);
|
78
|
+
});
|
79
|
+
return () => {
|
80
|
+
if (logged)
|
81
|
+
self.console.groupEnd();
|
82
|
+
if (stack.length > deep)
|
83
|
+
stack.length = deep;
|
84
|
+
};
|
60
85
|
}
|
61
|
-
$.$
|
86
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
87
|
+
$.$mol_log3_stack = [];
|
62
88
|
})($ || ($ = {}));
|
63
|
-
//mol/
|
89
|
+
//mol/log3/log3.ts
|
64
90
|
;
|
65
91
|
"use strict";
|
66
92
|
var $;
|
67
93
|
(function ($) {
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
publicExponent: new Uint8Array([1, 0, 1]),
|
72
|
-
hash: 'SHA-1',
|
73
|
-
};
|
74
|
-
async function $mol_crypto_cipher_pair() {
|
75
|
-
const pair = await $.crypto.subtle.generateKey(algorithm, true, ['encrypt', 'decrypt']);
|
76
|
-
return {
|
77
|
-
public: new $mol_crypto_cipher_public(pair.publicKey),
|
78
|
-
private: new $mol_crypto_cipher_private(pair.privateKey),
|
79
|
-
};
|
80
|
-
}
|
81
|
-
$.$mol_crypto_cipher_pair = $mol_crypto_cipher_pair;
|
82
|
-
class $mol_crypto_cipher_public extends Object {
|
83
|
-
native;
|
84
|
-
static size = 162;
|
85
|
-
constructor(native) {
|
86
|
-
super();
|
87
|
-
this.native = native;
|
88
|
-
}
|
89
|
-
static async from(serial) {
|
90
|
-
return new this(await crypto.subtle.importKey('spki', serial, algorithm, true, ['encrypt']));
|
91
|
-
}
|
92
|
-
async serial() {
|
93
|
-
return await crypto.subtle.exportKey('spki', this.native);
|
94
|
-
}
|
95
|
-
async encrypt(data) {
|
96
|
-
return await crypto.subtle.encrypt(algorithm, this.native, data);
|
97
|
-
}
|
98
|
-
}
|
99
|
-
$.$mol_crypto_cipher_public = $mol_crypto_cipher_public;
|
100
|
-
class $mol_crypto_cipher_private extends Object {
|
101
|
-
native;
|
102
|
-
constructor(native) {
|
103
|
-
super();
|
104
|
-
this.native = native;
|
105
|
-
}
|
106
|
-
static async from(serial) {
|
107
|
-
return new this(await crypto.subtle.importKey('pkcs8', serial, algorithm, true, ['decrypt']));
|
108
|
-
}
|
109
|
-
async serial() {
|
110
|
-
return await crypto.subtle.exportKey('pkcs8', this.native);
|
111
|
-
}
|
112
|
-
async decrypt(data) {
|
113
|
-
return await crypto.subtle.decrypt(algorithm, this.native, data);
|
114
|
-
}
|
94
|
+
$.$mol_ambient_ref = Symbol('$mol_ambient_ref');
|
95
|
+
function $mol_ambient(overrides) {
|
96
|
+
return Object.setPrototypeOf(overrides, this || $);
|
115
97
|
}
|
116
|
-
$.$
|
117
|
-
$.$mol_crypto_cipher_ecrypted_size = 128;
|
98
|
+
$.$mol_ambient = $mol_ambient;
|
118
99
|
})($ || ($ = {}));
|
119
|
-
//mol/
|
100
|
+
//mol/ambient/ambient.ts
|
120
101
|
;
|
121
102
|
"use strict";
|
122
103
|
var $;
|
123
104
|
(function ($) {
|
124
|
-
const
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
return await crypto.subtle.exportKey('spki', this.native);
|
151
|
-
}
|
152
|
-
async verify(data, sign) {
|
153
|
-
return await crypto.subtle.verify(algorithm, this.native, sign, data);
|
154
|
-
}
|
155
|
-
}
|
156
|
-
$.$mol_crypto_auditor_public = $mol_crypto_auditor_public;
|
157
|
-
class $mol_crypto_auditor_private extends Object {
|
158
|
-
native;
|
159
|
-
static size = 200;
|
160
|
-
constructor(native) {
|
161
|
-
super();
|
162
|
-
this.native = native;
|
163
|
-
}
|
164
|
-
static async from(serial) {
|
165
|
-
return new this(await crypto.subtle.importKey('pkcs8', serial, algorithm, true, ['sign']));
|
166
|
-
}
|
167
|
-
async serial() {
|
168
|
-
return await crypto.subtle.exportKey('pkcs8', this.native);
|
169
|
-
}
|
170
|
-
async sign(data) {
|
171
|
-
return await crypto.subtle.sign(algorithm, this.native, data);
|
172
|
-
}
|
105
|
+
const instances = new WeakSet();
|
106
|
+
function $mol_delegate(proto, target) {
|
107
|
+
const proxy = new Proxy(proto, {
|
108
|
+
get: (_, field) => {
|
109
|
+
const obj = target();
|
110
|
+
let val = Reflect.get(obj, field);
|
111
|
+
if (typeof val === 'function') {
|
112
|
+
val = val.bind(obj);
|
113
|
+
}
|
114
|
+
return val;
|
115
|
+
},
|
116
|
+
has: (_, field) => Reflect.has(target(), field),
|
117
|
+
set: (_, field, value) => Reflect.set(target(), field, value),
|
118
|
+
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
119
|
+
ownKeys: () => Reflect.ownKeys(target()),
|
120
|
+
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
121
|
+
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
122
|
+
isExtensible: () => Reflect.isExtensible(target()),
|
123
|
+
preventExtensions: () => Reflect.preventExtensions(target()),
|
124
|
+
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
125
|
+
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
126
|
+
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
127
|
+
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
128
|
+
});
|
129
|
+
instances.add(proxy);
|
130
|
+
return proxy;
|
173
131
|
}
|
174
|
-
$.$
|
175
|
-
|
132
|
+
$.$mol_delegate = $mol_delegate;
|
133
|
+
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
134
|
+
value: (obj) => instances.has(obj),
|
135
|
+
});
|
176
136
|
})($ || ($ = {}));
|
177
|
-
//mol/
|
137
|
+
//mol/delegate/delegate.ts
|
178
138
|
;
|
179
139
|
"use strict";
|
180
140
|
var $;
|
181
141
|
(function ($) {
|
182
|
-
|
183
|
-
function $
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
142
|
+
$.$mol_owning_map = new WeakMap();
|
143
|
+
function $mol_owning_allow(having) {
|
144
|
+
try {
|
145
|
+
if (!having)
|
146
|
+
return false;
|
147
|
+
if (typeof having !== 'object')
|
148
|
+
return false;
|
149
|
+
if (having instanceof $mol_delegate)
|
150
|
+
return false;
|
151
|
+
if (typeof having['destructor'] !== 'function')
|
152
|
+
return false;
|
153
|
+
return true;
|
193
154
|
}
|
194
|
-
|
195
|
-
|
196
|
-
let h0 = hash[0];
|
197
|
-
let h1 = hash[1];
|
198
|
-
let h2 = hash[2];
|
199
|
-
let h3 = hash[3];
|
200
|
-
let h4 = hash[4];
|
201
|
-
for (let j = 0; j < 80; ++j) {
|
202
|
-
let turn;
|
203
|
-
if (j < 16) {
|
204
|
-
const k = i + j;
|
205
|
-
if (k === klens) {
|
206
|
-
sponge[j] = bits;
|
207
|
-
}
|
208
|
-
else {
|
209
|
-
let word = k === words.length ? tail :
|
210
|
-
k > words.length ? 0 :
|
211
|
-
words[k];
|
212
|
-
word = word << 24 | word << 8 & 0xFF0000 | word >>> 8 & 0xFF00 | word >>> 24 & 0xFF;
|
213
|
-
if (k === kbits)
|
214
|
-
word |= kword;
|
215
|
-
sponge[j] = word;
|
216
|
-
}
|
217
|
-
turn = (h1 & h2 | ~h1 & h3) + 1518500249;
|
218
|
-
}
|
219
|
-
else {
|
220
|
-
const shuffle = sponge[j - 3] ^ sponge[j - 8] ^ sponge[j - 14] ^ sponge[j - 16];
|
221
|
-
sponge[j] = shuffle << 1 | shuffle >>> 31;
|
222
|
-
turn =
|
223
|
-
j < 20 ? (h1 & h2 | ~h1 & h3) + 1518500249 :
|
224
|
-
j < 40 ? (h1 ^ h2 ^ h3) + 1859775393 :
|
225
|
-
j < 60 ? (h1 & h2 | h1 & h3 | h2 & h3) - 1894007588 :
|
226
|
-
(h1 ^ h2 ^ h3) - 899497514;
|
227
|
-
}
|
228
|
-
const next = turn + h4 + (sponge[j] >>> 0) + ((h0 << 5) | (h0 >>> 27));
|
229
|
-
h4 = h3;
|
230
|
-
h3 = h2;
|
231
|
-
h2 = (h1 << 30) | (h1 >>> 2);
|
232
|
-
h1 = h0;
|
233
|
-
h0 = next;
|
234
|
-
}
|
235
|
-
hash[0] += h0;
|
236
|
-
hash[1] += h1;
|
237
|
-
hash[2] += h2;
|
238
|
-
hash[3] += h3;
|
239
|
-
hash[4] += h4;
|
155
|
+
catch {
|
156
|
+
return false;
|
240
157
|
}
|
241
|
-
|
242
|
-
|
243
|
-
|
158
|
+
}
|
159
|
+
$.$mol_owning_allow = $mol_owning_allow;
|
160
|
+
function $mol_owning_get(having, Owner) {
|
161
|
+
if (!$mol_owning_allow(having))
|
162
|
+
return null;
|
163
|
+
while (true) {
|
164
|
+
const owner = $.$mol_owning_map.get(having);
|
165
|
+
if (!owner)
|
166
|
+
return owner;
|
167
|
+
if (!Owner)
|
168
|
+
return owner;
|
169
|
+
if (owner instanceof Owner)
|
170
|
+
return owner;
|
171
|
+
having = owner;
|
244
172
|
}
|
245
|
-
return new Uint8Array(hash.buffer);
|
246
173
|
}
|
247
|
-
$.$
|
248
|
-
|
249
|
-
|
250
|
-
;
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
function $mol_crypto_salt() {
|
255
|
-
return crypto.getRandomValues(new Uint8Array(8));
|
174
|
+
$.$mol_owning_get = $mol_owning_get;
|
175
|
+
function $mol_owning_check(owner, having) {
|
176
|
+
if (!$mol_owning_allow(having))
|
177
|
+
return false;
|
178
|
+
if ($.$mol_owning_map.get(having) !== owner)
|
179
|
+
return false;
|
180
|
+
return true;
|
256
181
|
}
|
257
|
-
$.$
|
182
|
+
$.$mol_owning_check = $mol_owning_check;
|
183
|
+
function $mol_owning_catch(owner, having) {
|
184
|
+
if (!$mol_owning_allow(having))
|
185
|
+
return false;
|
186
|
+
if ($.$mol_owning_map.get(having))
|
187
|
+
return false;
|
188
|
+
$.$mol_owning_map.set(having, owner);
|
189
|
+
return true;
|
190
|
+
}
|
191
|
+
$.$mol_owning_catch = $mol_owning_catch;
|
258
192
|
})($ || ($ = {}));
|
259
|
-
//mol/
|
193
|
+
//mol/owning/owning.ts
|
260
194
|
;
|
261
195
|
"use strict";
|
262
196
|
var $;
|
@@ -279,1566 +213,1635 @@ var $;
|
|
279
213
|
//mol/fail/hidden/hidden.ts
|
280
214
|
;
|
281
215
|
"use strict";
|
282
|
-
|
283
|
-
(function ($) {
|
284
|
-
function $mol_test_complete() {
|
285
|
-
process.exit(0);
|
286
|
-
}
|
287
|
-
$.$mol_test_complete = $mol_test_complete;
|
288
|
-
})($ || ($ = {}));
|
289
|
-
//mol/test/test.node.test.ts
|
216
|
+
//mol/type/writable/writable.ts
|
290
217
|
;
|
291
218
|
"use strict";
|
292
219
|
var $;
|
293
|
-
(function ($
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
$
|
220
|
+
(function ($) {
|
221
|
+
class $mol_object2 {
|
222
|
+
static $ = $;
|
223
|
+
[$mol_ambient_ref] = null;
|
224
|
+
get $() {
|
225
|
+
if (this[$mol_ambient_ref])
|
226
|
+
return this[$mol_ambient_ref];
|
227
|
+
const owner = $mol_owning_get(this);
|
228
|
+
return this[$mol_ambient_ref] = owner?.$ || $mol_object2.$;
|
299
229
|
}
|
300
|
-
$
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
$_1.$mol_test_all = [];
|
305
|
-
async function $mol_test_run() {
|
306
|
-
for (var test of $_1.$mol_test_all) {
|
307
|
-
let context = Object.create($$);
|
308
|
-
for (let mock of $_1.$mol_test_mocks)
|
309
|
-
await mock(context);
|
310
|
-
const res = test(context);
|
311
|
-
if (res instanceof Promise) {
|
312
|
-
await new Promise((done, fail) => {
|
313
|
-
res.then(done, fail);
|
314
|
-
setTimeout(() => fail(new Error('Test timeout: ' + test.name)), 1000);
|
315
|
-
});
|
316
|
-
}
|
230
|
+
set $(next) {
|
231
|
+
if (this[$mol_ambient_ref])
|
232
|
+
$mol_fail_hidden(new Error('Context already defined'));
|
233
|
+
this[$mol_ambient_ref] = next;
|
317
234
|
}
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
}
|
324
|
-
$_1.$mol_test_run = $mol_test_run;
|
325
|
-
let scheduled = false;
|
326
|
-
function $mol_test_schedule() {
|
327
|
-
if (scheduled)
|
328
|
-
return;
|
329
|
-
scheduled = true;
|
330
|
-
setTimeout(async () => {
|
331
|
-
scheduled = false;
|
332
|
-
try {
|
333
|
-
await $mol_test_run();
|
334
|
-
}
|
335
|
-
finally {
|
336
|
-
$$.$mol_test_complete();
|
337
|
-
}
|
338
|
-
}, 0);
|
339
|
-
}
|
340
|
-
$_1.$mol_test_schedule = $mol_test_schedule;
|
341
|
-
$_1.$mol_test_mocks.push(context => {
|
342
|
-
let seed = 0;
|
343
|
-
context.Math = Object.create(Math);
|
344
|
-
context.Math.random = () => Math.sin(seed++);
|
345
|
-
const forbidden = ['XMLHttpRequest', 'fetch'];
|
346
|
-
for (let api of forbidden) {
|
347
|
-
context[api] = new Proxy(function () { }, {
|
348
|
-
get() {
|
349
|
-
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
350
|
-
},
|
351
|
-
apply() {
|
352
|
-
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
353
|
-
},
|
354
|
-
});
|
235
|
+
static create(init) {
|
236
|
+
const obj = new this;
|
237
|
+
if (init)
|
238
|
+
init(obj);
|
239
|
+
return obj;
|
355
240
|
}
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
}
|
374
|
-
catch (error) {
|
375
|
-
console.assert(error.message === 'fetch is forbidden in tests');
|
376
|
-
}
|
377
|
-
},
|
378
|
-
});
|
241
|
+
static [Symbol.toPrimitive]() {
|
242
|
+
return this.toString();
|
243
|
+
}
|
244
|
+
static toString() {
|
245
|
+
if (Symbol.toStringTag in this)
|
246
|
+
return this[Symbol.toStringTag];
|
247
|
+
return this.name;
|
248
|
+
}
|
249
|
+
destructor() { }
|
250
|
+
toString() {
|
251
|
+
return this[Symbol.toStringTag] || this.constructor.name + '()';
|
252
|
+
}
|
253
|
+
toJSON() {
|
254
|
+
return this.toString();
|
255
|
+
}
|
256
|
+
}
|
257
|
+
$.$mol_object2 = $mol_object2;
|
379
258
|
})($ || ($ = {}));
|
380
|
-
//mol/
|
259
|
+
//mol/object2/object2.ts
|
381
260
|
;
|
382
261
|
"use strict";
|
383
262
|
var $;
|
384
263
|
(function ($) {
|
385
|
-
|
386
|
-
|
387
|
-
;
|
388
|
-
|
389
|
-
|
390
|
-
;
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
while (!fs.existsSync(path.join(dir, suffix))) {
|
407
|
-
const parent = path.resolve(dir, '..');
|
408
|
-
if (parent === dir) {
|
409
|
-
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
410
|
-
try {
|
411
|
-
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
264
|
+
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
265
|
+
class $mol_tree extends $mol_object2 {
|
266
|
+
type;
|
267
|
+
data;
|
268
|
+
sub;
|
269
|
+
baseUri;
|
270
|
+
row;
|
271
|
+
col;
|
272
|
+
length;
|
273
|
+
constructor(config = {}) {
|
274
|
+
super();
|
275
|
+
this.type = config.type || '';
|
276
|
+
if (config.value !== undefined) {
|
277
|
+
var sub = $mol_tree.values(config.value);
|
278
|
+
if (config.type || sub.length > 1) {
|
279
|
+
this.sub = [...sub, ...(config.sub || [])];
|
280
|
+
this.data = config.data || '';
|
281
|
+
}
|
282
|
+
else {
|
283
|
+
this.data = sub[0].data;
|
284
|
+
this.sub = config.sub || [];
|
412
285
|
}
|
413
|
-
catch { }
|
414
|
-
break;
|
415
286
|
}
|
416
287
|
else {
|
417
|
-
|
418
|
-
|
288
|
+
this.data = config.data || '';
|
289
|
+
this.sub = config.sub || [];
|
290
|
+
}
|
291
|
+
this.baseUri = config.baseUri || '';
|
292
|
+
this.row = config.row || 0;
|
293
|
+
this.col = config.col || 0;
|
294
|
+
this.length = config.length || 0;
|
419
295
|
}
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
});
|
427
|
-
require = (req => Object.assign(function require(name) {
|
428
|
-
return $node[name];
|
429
|
-
}, req))(require);
|
430
|
-
//node/node.node.ts
|
431
|
-
;
|
432
|
-
"use strict";
|
433
|
-
var $;
|
434
|
-
(function ($) {
|
435
|
-
function $mol_log3_area_lazy(event) {
|
436
|
-
const self = this;
|
437
|
-
const stack = self.$mol_log3_stack;
|
438
|
-
const deep = stack.length;
|
439
|
-
let logged = false;
|
440
|
-
stack.push(() => {
|
441
|
-
logged = true;
|
442
|
-
self.$mol_log3_area.call(self, event);
|
443
|
-
});
|
444
|
-
return () => {
|
445
|
-
if (logged)
|
446
|
-
self.console.groupEnd();
|
447
|
-
if (stack.length > deep)
|
448
|
-
stack.length = deep;
|
449
|
-
};
|
450
|
-
}
|
451
|
-
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
452
|
-
$.$mol_log3_stack = [];
|
453
|
-
})($ || ($ = {}));
|
454
|
-
//mol/log3/log3.ts
|
455
|
-
;
|
456
|
-
"use strict";
|
457
|
-
var $;
|
458
|
-
(function ($) {
|
459
|
-
class $mol_term_color {
|
460
|
-
static reset = this.ansi(0, 0);
|
461
|
-
static bold = this.ansi(1, 22);
|
462
|
-
static italic = this.ansi(3, 23);
|
463
|
-
static underline = this.ansi(4, 24);
|
464
|
-
static inverse = this.ansi(7, 27);
|
465
|
-
static hidden = this.ansi(8, 28);
|
466
|
-
static strike = this.ansi(9, 29);
|
467
|
-
static gray = this.ansi(90, 39);
|
468
|
-
static red = this.ansi(91, 39);
|
469
|
-
static green = this.ansi(92, 39);
|
470
|
-
static yellow = this.ansi(93, 39);
|
471
|
-
static blue = this.ansi(94, 39);
|
472
|
-
static magenta = this.ansi(95, 39);
|
473
|
-
static cyan = this.ansi(96, 39);
|
474
|
-
static white = this.ansi(97, 39);
|
475
|
-
static Red = (str) => this.inverse(this.red(str));
|
476
|
-
static Green = (str) => this.inverse(this.green(str));
|
477
|
-
static Yellow = (str) => this.inverse(this.yellow(str));
|
478
|
-
static Blue = (str) => this.inverse(this.blue(str));
|
479
|
-
static Magenta = (str) => this.inverse(this.magenta(str));
|
480
|
-
static Cyan = (str) => this.inverse(this.cyan(str));
|
481
|
-
static White = (str) => this.inverse(this.white(str));
|
482
|
-
static ansi(open, close) {
|
483
|
-
if (typeof process === 'undefined')
|
484
|
-
return String;
|
485
|
-
if (!process.stdout.isTTY)
|
486
|
-
return String;
|
487
|
-
const prefix = `\x1b[${open}m`;
|
488
|
-
const postfix = `\x1b[${close}m`;
|
489
|
-
const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
|
490
|
-
return function colorer(str) {
|
491
|
-
str = String(str);
|
492
|
-
if (str === '')
|
493
|
-
return str;
|
494
|
-
const suffix = str.replace(suffix_regexp, prefix);
|
495
|
-
return prefix + suffix + postfix;
|
496
|
-
};
|
296
|
+
static values(str, baseUri) {
|
297
|
+
return str.split('\n').map((data, index) => new $mol_tree({
|
298
|
+
data: data,
|
299
|
+
baseUri: baseUri,
|
300
|
+
row: index + 1,
|
301
|
+
length: data.length,
|
302
|
+
}));
|
497
303
|
}
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
(
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
}
|
525
|
-
|
526
|
-
;
|
527
|
-
|
528
|
-
var
|
529
|
-
(
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
;
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
;
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
;
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
//mol/dom/context/context.node.ts
|
593
|
-
;
|
594
|
-
"use strict";
|
595
|
-
var $;
|
596
|
-
(function ($) {
|
597
|
-
function $mol_dom_render_children(el, childNodes) {
|
598
|
-
const node_set = new Set(childNodes);
|
599
|
-
let nextNode = el.firstChild;
|
600
|
-
for (let view of childNodes) {
|
601
|
-
if (view == null)
|
602
|
-
continue;
|
603
|
-
if (view instanceof $mol_dom_context.Node) {
|
604
|
-
while (true) {
|
605
|
-
if (!nextNode) {
|
606
|
-
el.appendChild(view);
|
607
|
-
break;
|
304
|
+
clone(config = {}) {
|
305
|
+
return new $mol_tree({
|
306
|
+
type: ('type' in config) ? config.type : this.type,
|
307
|
+
data: ('data' in config) ? config.data : this.data,
|
308
|
+
sub: ('sub' in config) ? config.sub : this.sub,
|
309
|
+
baseUri: ('baseUri' in config) ? config.baseUri : this.baseUri,
|
310
|
+
row: ('row' in config) ? config.row : this.row,
|
311
|
+
col: ('col' in config) ? config.col : this.col,
|
312
|
+
length: ('length' in config) ? config.length : this.length,
|
313
|
+
value: config.value
|
314
|
+
});
|
315
|
+
}
|
316
|
+
make(config) {
|
317
|
+
return new $mol_tree({
|
318
|
+
baseUri: this.baseUri,
|
319
|
+
row: this.row,
|
320
|
+
col: this.col,
|
321
|
+
length: this.length,
|
322
|
+
...config,
|
323
|
+
});
|
324
|
+
}
|
325
|
+
make_data(value, sub) {
|
326
|
+
return this.make({ value, sub });
|
327
|
+
}
|
328
|
+
make_struct(type, sub) {
|
329
|
+
return this.make({ type, sub });
|
330
|
+
}
|
331
|
+
static fromString(str, baseUri) {
|
332
|
+
var root = new $mol_tree({ baseUri: baseUri });
|
333
|
+
var stack = [root];
|
334
|
+
var row = 0;
|
335
|
+
var prefix = str.replace(/^\n?(\t*)[\s\S]*/, '$1');
|
336
|
+
var lines = str.replace(new RegExp('^\\t{0,' + prefix.length + '}', 'mg'), '').split('\n');
|
337
|
+
lines.forEach(line => {
|
338
|
+
++row;
|
339
|
+
var chunks = /^(\t*)((?:[^\n\t\\ ]+ *)*)(\\[^\n]*)?(.*?)(?:$|\n)/m.exec(line);
|
340
|
+
if (!chunks || chunks[4])
|
341
|
+
return this.$.$mol_fail(new Error(`Syntax error at ${baseUri}:${row}\n${line}`));
|
342
|
+
var indent = chunks[1];
|
343
|
+
var path = chunks[2];
|
344
|
+
var data = chunks[3];
|
345
|
+
var deep = indent.length;
|
346
|
+
var types = path ? path.replace(/ $/, '').split(/ +/) : [];
|
347
|
+
if (stack.length <= deep)
|
348
|
+
return this.$.$mol_fail(new Error(`Too many tabs at ${baseUri}:${row}\n${line}`));
|
349
|
+
stack.length = deep + 1;
|
350
|
+
var parent = stack[deep];
|
351
|
+
let col = deep;
|
352
|
+
types.forEach(type => {
|
353
|
+
if (!type)
|
354
|
+
return this.$.$mol_fail(new Error(`Unexpected space symbol ${baseUri}:${row}\n${line}`));
|
355
|
+
var next = new $mol_tree({ type, baseUri, row, col, length: type.length });
|
356
|
+
const parent_sub = parent.sub;
|
357
|
+
parent_sub.push(next);
|
358
|
+
parent = next;
|
359
|
+
col += type.length + 1;
|
360
|
+
});
|
361
|
+
if (data) {
|
362
|
+
var next = new $mol_tree({ data: data.substring(1), baseUri, row, col, length: data.length });
|
363
|
+
const parent_sub = parent.sub;
|
364
|
+
parent_sub.push(next);
|
365
|
+
parent = next;
|
366
|
+
}
|
367
|
+
stack.push(parent);
|
368
|
+
});
|
369
|
+
return root;
|
370
|
+
}
|
371
|
+
static fromJSON(json, baseUri = '') {
|
372
|
+
switch (true) {
|
373
|
+
case typeof json === 'boolean':
|
374
|
+
case typeof json === 'number':
|
375
|
+
case json === null:
|
376
|
+
return new $mol_tree({
|
377
|
+
type: String(json),
|
378
|
+
baseUri: baseUri
|
379
|
+
});
|
380
|
+
case typeof json === 'string':
|
381
|
+
return new $mol_tree({
|
382
|
+
value: json,
|
383
|
+
baseUri: baseUri
|
384
|
+
});
|
385
|
+
case Array.isArray(json):
|
386
|
+
return new $mol_tree({
|
387
|
+
type: "/",
|
388
|
+
sub: json.map(json => $mol_tree.fromJSON(json, baseUri))
|
389
|
+
});
|
390
|
+
case json instanceof Date:
|
391
|
+
return new $mol_tree({
|
392
|
+
value: json.toISOString(),
|
393
|
+
baseUri: baseUri
|
394
|
+
});
|
395
|
+
default:
|
396
|
+
if (typeof json[$.$mol_tree_convert] === 'function') {
|
397
|
+
return json[$.$mol_tree_convert]();
|
608
398
|
}
|
609
|
-
if (
|
610
|
-
|
611
|
-
break;
|
399
|
+
if (typeof json.toJSON === 'function') {
|
400
|
+
return $mol_tree.fromJSON(json.toJSON());
|
612
401
|
}
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
402
|
+
if (json instanceof Error) {
|
403
|
+
const { name, message, stack } = json;
|
404
|
+
json = { ...json, name, message, stack };
|
405
|
+
}
|
406
|
+
var sub = [];
|
407
|
+
for (var key in json) {
|
408
|
+
if (json[key] === undefined)
|
409
|
+
continue;
|
410
|
+
const subsub = $mol_tree.fromJSON(json[key], baseUri);
|
411
|
+
if (/^[^\n\t\\ ]+$/.test(key)) {
|
412
|
+
var child = new $mol_tree({
|
413
|
+
type: key,
|
414
|
+
baseUri: baseUri,
|
415
|
+
sub: [subsub],
|
416
|
+
});
|
617
417
|
}
|
618
418
|
else {
|
619
|
-
|
620
|
-
|
621
|
-
|
419
|
+
var child = new $mol_tree({
|
420
|
+
value: key,
|
421
|
+
baseUri: baseUri,
|
422
|
+
sub: [subsub],
|
423
|
+
});
|
622
424
|
}
|
425
|
+
sub.push(child);
|
623
426
|
}
|
624
|
-
|
427
|
+
return new $mol_tree({
|
428
|
+
type: "*",
|
429
|
+
sub: sub,
|
430
|
+
baseUri: baseUri
|
431
|
+
});
|
625
432
|
}
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
433
|
+
}
|
434
|
+
get uri() {
|
435
|
+
return this.baseUri + '#' + this.row + ':' + this.col;
|
436
|
+
}
|
437
|
+
toString(prefix = '') {
|
438
|
+
var output = '';
|
439
|
+
if (this.type.length) {
|
440
|
+
if (!prefix.length) {
|
441
|
+
prefix = "\t";
|
632
442
|
}
|
633
|
-
|
634
|
-
|
635
|
-
|
443
|
+
output += this.type;
|
444
|
+
if (this.sub.length == 1) {
|
445
|
+
return output + ' ' + this.sub[0].toString(prefix);
|
446
|
+
}
|
447
|
+
output += "\n";
|
448
|
+
}
|
449
|
+
else if (this.data.length || prefix.length) {
|
450
|
+
output += "\\" + this.data + "\n";
|
451
|
+
}
|
452
|
+
for (var child of this.sub) {
|
453
|
+
output += prefix;
|
454
|
+
output += child.toString(prefix + "\t");
|
455
|
+
}
|
456
|
+
return output;
|
457
|
+
}
|
458
|
+
toJSON() {
|
459
|
+
if (!this.type)
|
460
|
+
return this.value;
|
461
|
+
if (this.type === 'true')
|
462
|
+
return true;
|
463
|
+
if (this.type === 'false')
|
464
|
+
return false;
|
465
|
+
if (this.type === 'null')
|
466
|
+
return null;
|
467
|
+
if (this.type === '*') {
|
468
|
+
var obj = {};
|
469
|
+
for (var child of this.sub) {
|
470
|
+
if (child.type === '-')
|
471
|
+
continue;
|
472
|
+
var key = child.type || child.clone({ sub: child.sub.slice(0, child.sub.length - 1) }).value;
|
473
|
+
var val = child.sub[child.sub.length - 1].toJSON();
|
474
|
+
if (val !== undefined)
|
475
|
+
obj[key] = val;
|
636
476
|
}
|
477
|
+
return obj;
|
637
478
|
}
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
})
|
647
|
-
|
648
|
-
;
|
649
|
-
"use strict";
|
650
|
-
//mol/type/error/error.ts
|
651
|
-
;
|
652
|
-
"use strict";
|
653
|
-
//mol/type/assert/assert.test.ts
|
654
|
-
;
|
655
|
-
"use strict";
|
656
|
-
//mol/type/assert/assert.ts
|
657
|
-
;
|
658
|
-
"use strict";
|
659
|
-
//mol/type/equals/equals.test.ts
|
660
|
-
;
|
661
|
-
"use strict";
|
662
|
-
//mol/type/equals/equals.ts
|
663
|
-
;
|
664
|
-
"use strict";
|
665
|
-
//mol/type/partial/deep/deep.test.ts
|
666
|
-
;
|
667
|
-
"use strict";
|
668
|
-
//mol/type/partial/deep/deep.ts
|
669
|
-
;
|
670
|
-
"use strict";
|
671
|
-
var $;
|
672
|
-
(function ($) {
|
673
|
-
$mol_test({
|
674
|
-
'Make empty div'() {
|
675
|
-
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
676
|
-
},
|
677
|
-
'Define native field'() {
|
678
|
-
const dom = $mol_jsx("input", { value: '123' });
|
679
|
-
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
680
|
-
$mol_assert_equal(dom.value, '123');
|
681
|
-
},
|
682
|
-
'Define classes'() {
|
683
|
-
const dom = $mol_jsx("div", { class: 'foo bar' });
|
684
|
-
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
685
|
-
},
|
686
|
-
'Define styles'() {
|
687
|
-
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
688
|
-
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
689
|
-
},
|
690
|
-
'Define dataset'() {
|
691
|
-
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
692
|
-
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
693
|
-
},
|
694
|
-
'Define attributes'() {
|
695
|
-
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
696
|
-
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
697
|
-
},
|
698
|
-
'Define child nodes'() {
|
699
|
-
const dom = $mol_jsx("div", null,
|
700
|
-
"hello",
|
701
|
-
$mol_jsx("strong", null, "world"),
|
702
|
-
"!");
|
703
|
-
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
704
|
-
},
|
705
|
-
'Function as component'() {
|
706
|
-
const Button = (props, target) => {
|
707
|
-
return $mol_jsx("button", { title: props.hint }, target());
|
708
|
-
};
|
709
|
-
const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
|
710
|
-
$mol_assert_equal(dom.outerHTML, '<button id="foo" title="click me" class="Button">hey!</button>');
|
711
|
-
},
|
712
|
-
'Nested guid generation'() {
|
713
|
-
const Foo = () => {
|
714
|
-
return $mol_jsx("div", null,
|
715
|
-
$mol_jsx(Bar, { id: "bar" },
|
716
|
-
$mol_jsx("img", { id: "icon" })));
|
717
|
-
};
|
718
|
-
const Bar = (props, icon) => {
|
719
|
-
return $mol_jsx("span", null,
|
720
|
-
icon,
|
721
|
-
$mol_jsx("i", { id: "label" }));
|
722
|
-
};
|
723
|
-
const dom = $mol_jsx(Foo, { id: "foo" });
|
724
|
-
$mol_assert_equal(dom.outerHTML, '<div id="foo" class="Foo"><span id="foo/bar" class="Foo_bar Bar"><img id="foo/icon" class="Foo_icon"><i id="foo/bar/label" class="Foo_bar_label Bar_label"></i></span></div>');
|
725
|
-
},
|
726
|
-
'Fail on non unique ids'() {
|
727
|
-
const App = () => {
|
728
|
-
return $mol_jsx("div", null,
|
729
|
-
$mol_jsx("span", { id: "bar" }),
|
730
|
-
$mol_jsx("span", { id: "bar" }));
|
731
|
-
};
|
732
|
-
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
733
|
-
},
|
734
|
-
'Owner based guid generationn'() {
|
735
|
-
const Foo = () => {
|
736
|
-
return $mol_jsx("div", null,
|
737
|
-
$mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
738
|
-
};
|
739
|
-
const Bar = (props) => {
|
740
|
-
return $mol_jsx("span", null, props.icon());
|
741
|
-
};
|
742
|
-
const dom = $mol_jsx(Foo, { id: "app" });
|
743
|
-
$mol_assert_equal(dom.outerHTML, '<div id="app" class="Foo"><span id="app/middle" class="Foo_middle Bar"><img id="app/icon" class="Foo_icon"></span></div>');
|
744
|
-
},
|
745
|
-
'Fail on same ids from different caller'() {
|
746
|
-
const Foo = () => {
|
747
|
-
return $mol_jsx("div", null,
|
748
|
-
$mol_jsx("img", { id: "icon" }),
|
749
|
-
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
750
|
-
};
|
751
|
-
const Bar = (props) => {
|
752
|
-
return $mol_jsx("span", null, props.icon());
|
753
|
-
};
|
754
|
-
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
755
|
-
},
|
756
|
-
});
|
757
|
-
})($ || ($ = {}));
|
758
|
-
//mol/jsx/jsx.test.tsx
|
759
|
-
;
|
760
|
-
"use strict";
|
761
|
-
var $;
|
762
|
-
(function ($) {
|
763
|
-
$.$mol_jsx_prefix = '';
|
764
|
-
$.$mol_jsx_crumbs = '';
|
765
|
-
$.$mol_jsx_booked = null;
|
766
|
-
$.$mol_jsx_document = {
|
767
|
-
getElementById: () => null,
|
768
|
-
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
769
|
-
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
770
|
-
};
|
771
|
-
$.$mol_jsx_frag = '';
|
772
|
-
function $mol_jsx(Elem, props, ...childNodes) {
|
773
|
-
const id = props && props.id || '';
|
774
|
-
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
775
|
-
const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
|
776
|
-
if (Elem && $.$mol_jsx_booked) {
|
777
|
-
if ($.$mol_jsx_booked.has(id)) {
|
778
|
-
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
|
479
|
+
if (this.type === '/') {
|
480
|
+
var res = [];
|
481
|
+
this.sub.forEach(child => {
|
482
|
+
if (child.type === '-')
|
483
|
+
return;
|
484
|
+
var val = child.toJSON();
|
485
|
+
if (val !== undefined)
|
486
|
+
res.push(val);
|
487
|
+
});
|
488
|
+
return res;
|
779
489
|
}
|
780
|
-
|
781
|
-
|
490
|
+
if (this.type === 'time') {
|
491
|
+
return new Date(this.value);
|
782
492
|
}
|
493
|
+
const numb = Number(this.type);
|
494
|
+
if (!Number.isNaN(numb) || this.type === 'NaN')
|
495
|
+
return numb;
|
496
|
+
throw new Error(`Unknown type (${this.type}) at ${this.uri}`);
|
783
497
|
}
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
const crumbs_ext = $.$mol_jsx_crumbs;
|
789
|
-
for (const field in props) {
|
790
|
-
const func = props[field];
|
791
|
-
if (typeof func !== 'function')
|
498
|
+
get value() {
|
499
|
+
var values = [];
|
500
|
+
for (var child of this.sub) {
|
501
|
+
if (child.type)
|
792
502
|
continue;
|
793
|
-
|
794
|
-
const prefix = $.$mol_jsx_prefix;
|
795
|
-
const booked = $.$mol_jsx_booked;
|
796
|
-
const crumbs = $.$mol_jsx_crumbs;
|
797
|
-
try {
|
798
|
-
$.$mol_jsx_prefix = prefix_ext;
|
799
|
-
$.$mol_jsx_booked = booked_ext;
|
800
|
-
$.$mol_jsx_crumbs = crumbs_ext;
|
801
|
-
return func.call(this, ...args);
|
802
|
-
}
|
803
|
-
finally {
|
804
|
-
$.$mol_jsx_prefix = prefix;
|
805
|
-
$.$mol_jsx_booked = booked;
|
806
|
-
$.$mol_jsx_crumbs = crumbs;
|
807
|
-
}
|
808
|
-
};
|
809
|
-
$mol_func_name_from(wrapper, func);
|
810
|
-
props[field] = wrapper;
|
503
|
+
values.push(child.value);
|
811
504
|
}
|
505
|
+
return this.data + values.join("\n");
|
812
506
|
}
|
813
|
-
|
814
|
-
if (
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
507
|
+
insert(value, ...path) {
|
508
|
+
if (path.length === 0)
|
509
|
+
return value;
|
510
|
+
const type = path[0];
|
511
|
+
if (typeof type === 'string') {
|
512
|
+
let replaced = false;
|
513
|
+
const sub = this.sub.map((item, index) => {
|
514
|
+
if (item.type !== type)
|
515
|
+
return item;
|
516
|
+
replaced = true;
|
517
|
+
return item.insert(value, ...path.slice(1));
|
518
|
+
});
|
519
|
+
if (!replaced)
|
520
|
+
sub.push(new $mol_tree({ type }).insert(value, ...path.slice(1)));
|
521
|
+
return this.clone({ sub });
|
522
|
+
}
|
523
|
+
else if (typeof type === 'number') {
|
524
|
+
const sub = this.sub.slice();
|
525
|
+
sub[type] = (sub[type] || new $mol_tree).insert(value, ...path.slice(1));
|
526
|
+
return this.clone({ sub });
|
527
|
+
}
|
528
|
+
else {
|
529
|
+
return this.clone({ sub: ((this.sub.length === 0) ? [new $mol_tree()] : this.sub).map(item => item.insert(value, ...path.slice(1))) });
|
530
|
+
}
|
531
|
+
}
|
532
|
+
select(...path) {
|
533
|
+
var next = [this];
|
534
|
+
for (var type of path) {
|
535
|
+
if (!next.length)
|
536
|
+
break;
|
537
|
+
var prev = next;
|
538
|
+
next = [];
|
539
|
+
for (var item of prev) {
|
540
|
+
switch (typeof (type)) {
|
541
|
+
case 'string':
|
542
|
+
for (var child of item.sub) {
|
543
|
+
if (!type || (child.type == type)) {
|
544
|
+
next.push(child);
|
545
|
+
}
|
546
|
+
}
|
547
|
+
break;
|
548
|
+
case 'number':
|
549
|
+
if (type < item.sub.length)
|
550
|
+
next.push(item.sub[type]);
|
551
|
+
break;
|
552
|
+
default: next.push(...item.sub);
|
553
|
+
}
|
554
|
+
}
|
825
555
|
}
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
$.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
834
|
-
return Elem(props, ...childNodes);
|
556
|
+
return new $mol_tree({ sub: next });
|
557
|
+
}
|
558
|
+
filter(path, value) {
|
559
|
+
var sub = this.sub.filter(function (item) {
|
560
|
+
var found = item.select(...path);
|
561
|
+
if (value == null) {
|
562
|
+
return Boolean(found.sub.length);
|
835
563
|
}
|
836
|
-
|
837
|
-
|
838
|
-
$.$mol_jsx_booked = booked;
|
839
|
-
$.$mol_jsx_crumbs = crumbs;
|
564
|
+
else {
|
565
|
+
return found.sub.some(child => child.value == value);
|
840
566
|
}
|
841
|
-
}
|
567
|
+
});
|
568
|
+
return new $mol_tree({ sub: sub });
|
842
569
|
}
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
: $.$mol_jsx_document.createDocumentFragment();
|
570
|
+
transform(visit, stack = []) {
|
571
|
+
const sub_stack = [this, ...stack];
|
572
|
+
return visit(sub_stack, () => this.sub.map(node => node.transform(visit, sub_stack)).filter(n => n));
|
847
573
|
}
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
}
|
860
|
-
else if (props[key] &&
|
861
|
-
typeof props[key] === 'object' &&
|
862
|
-
Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
|
863
|
-
if (typeof node[key] === 'object') {
|
864
|
-
Object.assign(node[key], props[key]);
|
865
|
-
continue;
|
866
|
-
}
|
867
|
-
}
|
868
|
-
else {
|
869
|
-
node[key] = props[key];
|
870
|
-
}
|
574
|
+
hack(context) {
|
575
|
+
const sub = [].concat(...this.sub.map(child => {
|
576
|
+
const handle = context[child.type] || context[''];
|
577
|
+
if (!handle)
|
578
|
+
$mol_fail(child.error('Handler not defined'));
|
579
|
+
return handle(child, context);
|
580
|
+
}));
|
581
|
+
return this.clone({ sub });
|
582
|
+
}
|
583
|
+
error(message) {
|
584
|
+
return new Error(`${message}:\n${this} ${this.baseUri}:${this.row}:${this.col}`);
|
871
585
|
}
|
872
|
-
if ($.$mol_jsx_crumbs)
|
873
|
-
node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
|
874
|
-
return node;
|
875
586
|
}
|
876
|
-
$.$
|
587
|
+
$.$mol_tree = $mol_tree;
|
877
588
|
})($ || ($ = {}));
|
878
|
-
//mol/
|
589
|
+
//mol/tree/tree.ts
|
879
590
|
;
|
880
591
|
"use strict";
|
881
592
|
var $;
|
882
593
|
(function ($) {
|
883
|
-
$
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
}
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
}
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
594
|
+
class $mol_term_color {
|
595
|
+
static reset = this.ansi(0, 0);
|
596
|
+
static bold = this.ansi(1, 22);
|
597
|
+
static italic = this.ansi(3, 23);
|
598
|
+
static underline = this.ansi(4, 24);
|
599
|
+
static inverse = this.ansi(7, 27);
|
600
|
+
static hidden = this.ansi(8, 28);
|
601
|
+
static strike = this.ansi(9, 29);
|
602
|
+
static gray = this.ansi(90, 39);
|
603
|
+
static red = this.ansi(91, 39);
|
604
|
+
static green = this.ansi(92, 39);
|
605
|
+
static yellow = this.ansi(93, 39);
|
606
|
+
static blue = this.ansi(94, 39);
|
607
|
+
static magenta = this.ansi(95, 39);
|
608
|
+
static cyan = this.ansi(96, 39);
|
609
|
+
static white = this.ansi(97, 39);
|
610
|
+
static Red = (str) => this.inverse(this.red(str));
|
611
|
+
static Green = (str) => this.inverse(this.green(str));
|
612
|
+
static Yellow = (str) => this.inverse(this.yellow(str));
|
613
|
+
static Blue = (str) => this.inverse(this.blue(str));
|
614
|
+
static Magenta = (str) => this.inverse(this.magenta(str));
|
615
|
+
static Cyan = (str) => this.inverse(this.cyan(str));
|
616
|
+
static White = (str) => this.inverse(this.white(str));
|
617
|
+
static ansi(open, close) {
|
618
|
+
if (typeof process === 'undefined')
|
619
|
+
return String;
|
620
|
+
if (!process.stdout.isTTY)
|
621
|
+
return String;
|
622
|
+
const prefix = `\x1b[${open}m`;
|
623
|
+
const postfix = `\x1b[${close}m`;
|
624
|
+
const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
|
625
|
+
return function colorer(str) {
|
626
|
+
str = String(str);
|
627
|
+
if (str === '')
|
628
|
+
return str;
|
629
|
+
const suffix = str.replace(suffix_regexp, prefix);
|
630
|
+
return prefix + suffix + postfix;
|
631
|
+
};
|
632
|
+
}
|
633
|
+
}
|
634
|
+
$.$mol_term_color = $mol_term_color;
|
635
|
+
})($ || ($ = {}));
|
636
|
+
//mol/term/color/color.ts
|
637
|
+
;
|
638
|
+
"use strict";
|
639
|
+
var $;
|
640
|
+
(function ($) {
|
641
|
+
function $mol_log3_node_make(level, output, type, color) {
|
642
|
+
return function $mol_log3_logger(event) {
|
643
|
+
if (!event.time)
|
644
|
+
event = { time: new Date().toISOString(), ...event };
|
645
|
+
const tree = this.$mol_tree.fromJSON(event).clone({ type });
|
646
|
+
let str = color(tree.toString());
|
647
|
+
this.console[level](str);
|
648
|
+
const self = this;
|
649
|
+
return () => self.console.groupEnd();
|
650
|
+
};
|
651
|
+
}
|
652
|
+
$.$mol_log3_node_make = $mol_log3_node_make;
|
653
|
+
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
|
654
|
+
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
|
655
|
+
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
|
656
|
+
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
|
657
|
+
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
|
658
|
+
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
659
|
+
})($ || ($ = {}));
|
660
|
+
//mol/log3/log3.node.ts
|
661
|
+
;
|
662
|
+
"use strict";
|
663
|
+
var $;
|
664
|
+
(function ($) {
|
665
|
+
function $mol_env() {
|
666
|
+
return {};
|
667
|
+
}
|
668
|
+
$.$mol_env = $mol_env;
|
669
|
+
})($ || ($ = {}));
|
670
|
+
//mol/env/env.ts
|
671
|
+
;
|
672
|
+
"use strict";
|
673
|
+
var $;
|
674
|
+
(function ($) {
|
675
|
+
$.$mol_env = function $mol_env() {
|
676
|
+
return this.process.env;
|
677
|
+
};
|
678
|
+
})($ || ($ = {}));
|
679
|
+
//mol/env/env.node.ts
|
680
|
+
;
|
681
|
+
"use strict";
|
682
|
+
var $;
|
683
|
+
(function ($) {
|
684
|
+
function $mol_exec(dir, command, ...args) {
|
685
|
+
let [app, ...args0] = command.split(' ');
|
686
|
+
args = [...args0, ...args];
|
687
|
+
this.$mol_log3_come({
|
688
|
+
place: '$mol_exec',
|
689
|
+
dir: $node.path.relative('', dir),
|
690
|
+
message: 'Run',
|
691
|
+
command: `${app} ${args.join(' ')}`,
|
692
|
+
});
|
693
|
+
var res = $node['child_process'].spawnSync(app, args, {
|
694
|
+
cwd: $node.path.resolve(dir),
|
695
|
+
shell: true,
|
696
|
+
env: this.$mol_env(),
|
697
|
+
});
|
698
|
+
if (res.status || res.error)
|
699
|
+
return $mol_fail(res.error || new Error(res.stderr.toString()));
|
700
|
+
if (!res.stdout)
|
701
|
+
res.stdout = Buffer.from([]);
|
702
|
+
return res;
|
703
|
+
}
|
704
|
+
$.$mol_exec = $mol_exec;
|
972
705
|
})($ || ($ = {}));
|
973
|
-
//mol/
|
706
|
+
//mol/exec/exec.node.ts
|
974
707
|
;
|
975
708
|
"use strict";
|
976
709
|
var $;
|
977
710
|
(function ($) {
|
978
|
-
$.$
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
998
|
-
if (left instanceof String)
|
999
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
1000
|
-
if (left instanceof Date)
|
1001
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
1002
|
-
if (left instanceof RegExp)
|
1003
|
-
return left.source === right['source'] && left.flags === right['flags'];
|
1004
|
-
if (left instanceof Error)
|
1005
|
-
return left.stack === right['stack'];
|
1006
|
-
let left_cache = $.$mol_compare_deep_cache.get(left);
|
1007
|
-
if (left_cache) {
|
1008
|
-
const right_cache = left_cache.get(right);
|
1009
|
-
if (typeof right_cache === 'boolean')
|
1010
|
-
return right_cache;
|
1011
|
-
}
|
1012
|
-
else {
|
1013
|
-
left_cache = new WeakMap([[right, true]]);
|
1014
|
-
$.$mol_compare_deep_cache.set(left, left_cache);
|
1015
|
-
}
|
1016
|
-
let result;
|
1017
|
-
try {
|
1018
|
-
if (left_proto && !Reflect.getPrototypeOf(left_proto))
|
1019
|
-
result = compare_pojo(left, right);
|
1020
|
-
else if (Array.isArray(left))
|
1021
|
-
result = compare_array(left, right);
|
1022
|
-
else if (left instanceof Set)
|
1023
|
-
result = compare_set(left, right);
|
1024
|
-
else if (left instanceof Map)
|
1025
|
-
result = compare_map(left, right);
|
1026
|
-
else if (ArrayBuffer.isView(left))
|
1027
|
-
result = compare_buffer(left, right);
|
1028
|
-
else if (Symbol.toPrimitive in left)
|
1029
|
-
result = compare_primitive(left, right);
|
1030
|
-
else
|
1031
|
-
result = false;
|
711
|
+
$.$mol_crypto_native = $node.crypto.webcrypto;
|
712
|
+
})($ || ($ = {}));
|
713
|
+
//mol/crypto/native/native.node.ts
|
714
|
+
;
|
715
|
+
"use strict";
|
716
|
+
var $;
|
717
|
+
(function ($) {
|
718
|
+
const algorithm = {
|
719
|
+
name: 'AES-GCM',
|
720
|
+
length: 128,
|
721
|
+
tagLength: 32,
|
722
|
+
};
|
723
|
+
class $mol_crypto_secret extends Object {
|
724
|
+
native;
|
725
|
+
static size = 16;
|
726
|
+
static extra = 4;
|
727
|
+
constructor(native) {
|
728
|
+
super();
|
729
|
+
this.native = native;
|
1032
730
|
}
|
1033
|
-
|
1034
|
-
|
731
|
+
static async generate() {
|
732
|
+
return new this(await $mol_crypto_native.subtle.generateKey(algorithm, true, ['encrypt', 'decrypt']));
|
1035
733
|
}
|
1036
|
-
|
1037
|
-
|
1038
|
-
$.$mol_compare_deep = $mol_compare_deep;
|
1039
|
-
function compare_array(left, right) {
|
1040
|
-
const len = left.length;
|
1041
|
-
if (len !== right.length)
|
1042
|
-
return false;
|
1043
|
-
for (let i = 0; i < len; ++i) {
|
1044
|
-
if (!$mol_compare_deep(left[i], right[i]))
|
1045
|
-
return false;
|
734
|
+
static async from(serial) {
|
735
|
+
return new this(await $mol_crypto_native.subtle.importKey('raw', serial, algorithm, true, ['encrypt', 'decrypt']));
|
1046
736
|
}
|
1047
|
-
|
1048
|
-
|
1049
|
-
function compare_buffer(left, right) {
|
1050
|
-
const len = left.byteLength;
|
1051
|
-
if (len !== right.byteLength)
|
1052
|
-
return false;
|
1053
|
-
for (let i = 0; i < len; ++i) {
|
1054
|
-
if (left[i] !== right[i])
|
1055
|
-
return false;
|
737
|
+
async serial() {
|
738
|
+
return await $mol_crypto_native.subtle.exportKey('raw', this.native);
|
1056
739
|
}
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
const right_next = right.next();
|
1063
|
-
if (left_next.done !== right_next.done)
|
1064
|
-
return false;
|
1065
|
-
if (left_next.done)
|
1066
|
-
break;
|
1067
|
-
if (!compare(left_next.value, right_next.value))
|
1068
|
-
return false;
|
740
|
+
async encrypt(open, salt) {
|
741
|
+
return await $mol_crypto_native.subtle.encrypt({
|
742
|
+
...algorithm,
|
743
|
+
iv: salt,
|
744
|
+
}, this.native, open);
|
1069
745
|
}
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
return compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
1076
|
-
}
|
1077
|
-
function compare_map(left, right) {
|
1078
|
-
if (left.size !== right.size)
|
1079
|
-
return false;
|
1080
|
-
return compare_iterator(left.keys(), right.keys(), Object.is)
|
1081
|
-
&& compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
1082
|
-
}
|
1083
|
-
function compare_pojo(left, right) {
|
1084
|
-
const left_keys = Object.getOwnPropertyNames(left);
|
1085
|
-
const right_keys = Object.getOwnPropertyNames(right);
|
1086
|
-
if (left_keys.length !== right_keys.length)
|
1087
|
-
return false;
|
1088
|
-
for (let key of left_keys) {
|
1089
|
-
if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
|
1090
|
-
return false;
|
746
|
+
async decrypt(closed, salt) {
|
747
|
+
return await $mol_crypto_native.subtle.decrypt({
|
748
|
+
...algorithm,
|
749
|
+
iv: salt,
|
750
|
+
}, this.native, closed);
|
1091
751
|
}
|
1092
|
-
return true;
|
1093
|
-
}
|
1094
|
-
function compare_primitive(left, right) {
|
1095
|
-
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
1096
752
|
}
|
753
|
+
$.$mol_crypto_secret = $mol_crypto_secret;
|
1097
754
|
})($ || ($ = {}));
|
1098
|
-
//mol/
|
755
|
+
//mol/crypto/secret/secret.ts
|
1099
756
|
;
|
1100
757
|
"use strict";
|
1101
758
|
var $;
|
1102
759
|
(function ($) {
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
760
|
+
const algorithm = {
|
761
|
+
name: 'RSA-OAEP',
|
762
|
+
modulusLength: 1024,
|
763
|
+
publicExponent: new Uint8Array([1, 0, 1]),
|
764
|
+
hash: 'SHA-1',
|
765
|
+
};
|
766
|
+
async function $mol_crypto_cipher_pair() {
|
767
|
+
const pair = await $mol_crypto_native.subtle.generateKey(algorithm, true, ['encrypt', 'decrypt']);
|
768
|
+
return {
|
769
|
+
public: new $mol_crypto_cipher_public(pair.publicKey),
|
770
|
+
private: new $mol_crypto_cipher_private(pair.privateKey),
|
771
|
+
};
|
1106
772
|
}
|
1107
|
-
$.$
|
1108
|
-
|
1109
|
-
|
1110
|
-
;
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
$
|
1117
|
-
}
|
1118
|
-
|
1119
|
-
$
|
1120
|
-
}
|
1121
|
-
|
1122
|
-
$
|
1123
|
-
}
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
773
|
+
$.$mol_crypto_cipher_pair = $mol_crypto_cipher_pair;
|
774
|
+
class $mol_crypto_cipher_public extends Object {
|
775
|
+
native;
|
776
|
+
static size = 162;
|
777
|
+
constructor(native) {
|
778
|
+
super();
|
779
|
+
this.native = native;
|
780
|
+
}
|
781
|
+
static async from(serial) {
|
782
|
+
return new this(await $mol_crypto_native.subtle.importKey('spki', serial, algorithm, true, ['encrypt']));
|
783
|
+
}
|
784
|
+
async serial() {
|
785
|
+
return await $mol_crypto_native.subtle.exportKey('spki', this.native);
|
786
|
+
}
|
787
|
+
async encrypt(data) {
|
788
|
+
return await $mol_crypto_native.subtle.encrypt(algorithm, this.native, data);
|
789
|
+
}
|
790
|
+
}
|
791
|
+
$.$mol_crypto_cipher_public = $mol_crypto_cipher_public;
|
792
|
+
class $mol_crypto_cipher_private extends Object {
|
793
|
+
native;
|
794
|
+
constructor(native) {
|
795
|
+
super();
|
796
|
+
this.native = native;
|
797
|
+
}
|
798
|
+
static async from(serial) {
|
799
|
+
return new this(await $mol_crypto_native.subtle.importKey('pkcs8', serial, algorithm, true, ['decrypt']));
|
800
|
+
}
|
801
|
+
async serial() {
|
802
|
+
return await $mol_crypto_native.subtle.exportKey('pkcs8', this.native);
|
803
|
+
}
|
804
|
+
async decrypt(data) {
|
805
|
+
return await $mol_crypto_native.subtle.decrypt(algorithm, this.native, data);
|
806
|
+
}
|
807
|
+
}
|
808
|
+
$.$mol_crypto_cipher_private = $mol_crypto_cipher_private;
|
809
|
+
$.$mol_crypto_cipher_ecrypted_size = 128;
|
1140
810
|
})($ || ($ = {}));
|
1141
|
-
//mol/
|
811
|
+
//mol/crypto/cipher/cipher.ts
|
1142
812
|
;
|
1143
813
|
"use strict";
|
1144
814
|
var $;
|
1145
|
-
(function ($) {
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
815
|
+
(function ($) {
|
816
|
+
const algorithm = {
|
817
|
+
name: 'RSA-PSS',
|
818
|
+
modulusLength: 256,
|
819
|
+
publicExponent: new Uint8Array([1, 0, 1]),
|
820
|
+
hash: 'SHA-1',
|
821
|
+
saltLength: 8,
|
822
|
+
};
|
823
|
+
async function $mol_crypto_auditor_pair() {
|
824
|
+
const pair = await $mol_crypto_native.subtle.generateKey(algorithm, true, ['sign', 'verify']);
|
825
|
+
return {
|
826
|
+
public: new $mol_crypto_auditor_public(pair.publicKey),
|
827
|
+
private: new $mol_crypto_auditor_private(pair.privateKey),
|
828
|
+
};
|
1156
829
|
}
|
1157
|
-
$.$
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
830
|
+
$.$mol_crypto_auditor_pair = $mol_crypto_auditor_pair;
|
831
|
+
class $mol_crypto_auditor_public extends Object {
|
832
|
+
native;
|
833
|
+
static size = 62;
|
834
|
+
constructor(native) {
|
835
|
+
super();
|
836
|
+
this.native = native;
|
1163
837
|
}
|
1164
|
-
|
1165
|
-
|
1166
|
-
return error;
|
1167
|
-
$.$mol_fail = fail;
|
1168
|
-
if (typeof ErrorRight === 'string') {
|
1169
|
-
$mol_assert_equal(error.message, ErrorRight);
|
1170
|
-
}
|
1171
|
-
else {
|
1172
|
-
$mol_assert_ok(error instanceof ErrorRight);
|
1173
|
-
}
|
1174
|
-
return error;
|
838
|
+
static async from(serial) {
|
839
|
+
return new this(await $mol_crypto_native.subtle.importKey('spki', serial, algorithm, true, ['verify']));
|
1175
840
|
}
|
1176
|
-
|
1177
|
-
|
841
|
+
async serial() {
|
842
|
+
return await $mol_crypto_native.subtle.exportKey('spki', this.native);
|
1178
843
|
}
|
1179
|
-
|
1180
|
-
|
1181
|
-
$.$mol_assert_fail = $mol_assert_fail;
|
1182
|
-
function $mol_assert_equal(...args) {
|
1183
|
-
for (let i = 0; i < args.length; ++i) {
|
1184
|
-
for (let j = 0; j < args.length; ++j) {
|
1185
|
-
if (i === j)
|
1186
|
-
continue;
|
1187
|
-
if (Number.isNaN(args[i]) && Number.isNaN(args[j]))
|
1188
|
-
continue;
|
1189
|
-
if (args[i] !== args[j])
|
1190
|
-
$mol_fail(new Error(`Not equal (${i + 1}:${j + 1})\n${args[i]}\n${args[j]}`));
|
1191
|
-
}
|
844
|
+
async verify(data, sign) {
|
845
|
+
return await $mol_crypto_native.subtle.verify(algorithm, this.native, sign, data);
|
1192
846
|
}
|
1193
847
|
}
|
1194
|
-
$.$
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
848
|
+
$.$mol_crypto_auditor_public = $mol_crypto_auditor_public;
|
849
|
+
class $mol_crypto_auditor_private extends Object {
|
850
|
+
native;
|
851
|
+
static size = 200;
|
852
|
+
constructor(native) {
|
853
|
+
super();
|
854
|
+
this.native = native;
|
855
|
+
}
|
856
|
+
static async from(serial) {
|
857
|
+
return new this(await $mol_crypto_native.subtle.importKey('pkcs8', serial, algorithm, true, ['sign']));
|
858
|
+
}
|
859
|
+
async serial() {
|
860
|
+
return await $mol_crypto_native.subtle.exportKey('pkcs8', this.native);
|
861
|
+
}
|
862
|
+
async sign(data) {
|
863
|
+
return await $mol_crypto_native.subtle.sign(algorithm, this.native, data);
|
1204
864
|
}
|
1205
865
|
}
|
1206
|
-
$.$
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
866
|
+
$.$mol_crypto_auditor_private = $mol_crypto_auditor_private;
|
867
|
+
$.$mol_crypto_auditor_sign_size = 32;
|
868
|
+
})($ || ($ = {}));
|
869
|
+
//mol/crypto/auditor/auditor.ts
|
870
|
+
;
|
871
|
+
"use strict";
|
872
|
+
var $;
|
873
|
+
(function ($) {
|
874
|
+
let sponge = new Uint32Array(80);
|
875
|
+
function $mol_crypto_hash(data) {
|
876
|
+
const bits = data.byteLength << 3;
|
877
|
+
const kbits = bits >> 5;
|
878
|
+
const kword = 0x80 << (24 - bits & 0b11111);
|
879
|
+
const bytes = 16 + (bits + 64 >>> 9 << 4);
|
880
|
+
const klens = bytes - 1;
|
881
|
+
const words = new Int32Array(data.buffer, data.byteOffset, data.byteLength >> 2);
|
882
|
+
let tail = 0;
|
883
|
+
for (let i = words.length * 4; i < data.length; ++i) {
|
884
|
+
tail |= data[i] << (i << 3 & 0b11000);
|
885
|
+
}
|
886
|
+
const hash = new Int32Array([1732584193, -271733879, -1732584194, 271733878, -1009589776]);
|
887
|
+
for (let i = 0; i < bytes; i += 16) {
|
888
|
+
let h0 = hash[0];
|
889
|
+
let h1 = hash[1];
|
890
|
+
let h2 = hash[2];
|
891
|
+
let h3 = hash[3];
|
892
|
+
let h4 = hash[4];
|
893
|
+
for (let j = 0; j < 80; ++j) {
|
894
|
+
let turn;
|
895
|
+
if (j < 16) {
|
896
|
+
const k = i + j;
|
897
|
+
if (k === klens) {
|
898
|
+
sponge[j] = bits;
|
1219
899
|
}
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
900
|
+
else {
|
901
|
+
let word = k === words.length ? tail :
|
902
|
+
k > words.length ? 0 :
|
903
|
+
words[k];
|
904
|
+
word = word << 24 | word << 8 & 0xFF0000 | word >>> 8 & 0xFF00 | word >>> 24 & 0xFF;
|
905
|
+
if (k === kbits)
|
906
|
+
word |= kword;
|
907
|
+
sponge[j] = word;
|
1223
908
|
}
|
1224
|
-
|
1225
|
-
|
909
|
+
turn = (h1 & h2 | ~h1 & h3) + 1518500249;
|
910
|
+
}
|
911
|
+
else {
|
912
|
+
const shuffle = sponge[j - 3] ^ sponge[j - 8] ^ sponge[j - 14] ^ sponge[j - 16];
|
913
|
+
sponge[j] = shuffle << 1 | shuffle >>> 31;
|
914
|
+
turn =
|
915
|
+
j < 20 ? (h1 & h2 | ~h1 & h3) + 1518500249 :
|
916
|
+
j < 40 ? (h1 ^ h2 ^ h3) + 1859775393 :
|
917
|
+
j < 60 ? (h1 & h2 | h1 & h3 | h2 & h3) - 1894007588 :
|
918
|
+
(h1 ^ h2 ^ h3) - 899497514;
|
919
|
+
}
|
920
|
+
const next = turn + h4 + (sponge[j] >>> 0) + ((h0 << 5) | (h0 >>> 27));
|
921
|
+
h4 = h3;
|
922
|
+
h3 = h2;
|
923
|
+
h2 = (h1 << 30) | (h1 >>> 2);
|
924
|
+
h1 = h0;
|
925
|
+
h0 = next;
|
1226
926
|
}
|
927
|
+
hash[0] += h0;
|
928
|
+
hash[1] += h1;
|
929
|
+
hash[2] += h2;
|
930
|
+
hash[3] += h3;
|
931
|
+
hash[4] += h4;
|
1227
932
|
}
|
933
|
+
for (let i = 0; i < 20; ++i) {
|
934
|
+
const word = hash[i];
|
935
|
+
hash[i] = word << 24 | word << 8 & 0xFF0000 | word >>> 8 & 0xFF00 | word >>> 24 & 0xFF;
|
936
|
+
}
|
937
|
+
return new Uint8Array(hash.buffer);
|
1228
938
|
}
|
1229
|
-
$.$
|
1230
|
-
function $mol_assert_dom(left, right) {
|
1231
|
-
$mol_assert_equal($mol_dom_serialize(left), $mol_dom_serialize(right));
|
1232
|
-
}
|
1233
|
-
$.$mol_assert_dom = $mol_assert_dom;
|
939
|
+
$.$mol_crypto_hash = $mol_crypto_hash;
|
1234
940
|
})($ || ($ = {}));
|
1235
|
-
//mol/
|
941
|
+
//mol/crypto/hash/hash.ts
|
1236
942
|
;
|
1237
943
|
"use strict";
|
1238
944
|
var $;
|
1239
945
|
(function ($) {
|
1240
|
-
|
1241
|
-
|
1242
|
-
return Object.setPrototypeOf(overrides, this || $);
|
946
|
+
function $mol_crypto_salt() {
|
947
|
+
return $mol_crypto_native.getRandomValues(new Uint8Array(12));
|
1243
948
|
}
|
1244
|
-
$.$
|
949
|
+
$.$mol_crypto_salt = $mol_crypto_salt;
|
1245
950
|
})($ || ($ = {}));
|
1246
|
-
//mol/
|
951
|
+
//mol/crypto/salt/salt.ts
|
1247
952
|
;
|
1248
953
|
"use strict";
|
1249
954
|
var $;
|
1250
955
|
(function ($) {
|
1251
|
-
$
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
956
|
+
function $mol_test_complete() {
|
957
|
+
process.exit(0);
|
958
|
+
}
|
959
|
+
$.$mol_test_complete = $mol_test_complete;
|
960
|
+
})($ || ($ = {}));
|
961
|
+
//mol/test/test.node.test.ts
|
962
|
+
;
|
963
|
+
"use strict";
|
964
|
+
var $;
|
965
|
+
(function ($_1) {
|
966
|
+
function $mol_test(set) {
|
967
|
+
for (let name in set) {
|
968
|
+
const code = set[name];
|
969
|
+
const test = (typeof code === 'string') ? new Function('', code) : code;
|
970
|
+
$_1.$mol_test_all.push(test);
|
971
|
+
}
|
972
|
+
$mol_test_schedule();
|
973
|
+
}
|
974
|
+
$_1.$mol_test = $mol_test;
|
975
|
+
$_1.$mol_test_mocks = [];
|
976
|
+
$_1.$mol_test_all = [];
|
977
|
+
async function $mol_test_run() {
|
978
|
+
for (var test of $_1.$mol_test_all) {
|
979
|
+
let context = Object.create($$);
|
980
|
+
for (let mock of $_1.$mol_test_mocks)
|
981
|
+
await mock(context);
|
982
|
+
const res = test(context);
|
983
|
+
if (res instanceof Promise) {
|
984
|
+
await new Promise((done, fail) => {
|
985
|
+
res.then(done, fail);
|
986
|
+
setTimeout(() => fail(new Error('Test timeout: ' + test.name)), 1000);
|
987
|
+
});
|
988
|
+
}
|
989
|
+
}
|
990
|
+
$$.$mol_log3_done({
|
991
|
+
place: '$mol_test',
|
992
|
+
message: 'All tests passed',
|
993
|
+
count: $_1.$mol_test_all.length,
|
994
|
+
});
|
995
|
+
}
|
996
|
+
$_1.$mol_test_run = $mol_test_run;
|
997
|
+
let scheduled = false;
|
998
|
+
function $mol_test_schedule() {
|
999
|
+
if (scheduled)
|
1000
|
+
return;
|
1001
|
+
scheduled = true;
|
1002
|
+
setTimeout(async () => {
|
1003
|
+
scheduled = false;
|
1004
|
+
await $mol_test_run();
|
1005
|
+
$$.$mol_test_complete();
|
1006
|
+
}, 0);
|
1007
|
+
}
|
1008
|
+
$_1.$mol_test_schedule = $mol_test_schedule;
|
1009
|
+
$_1.$mol_test_mocks.push(context => {
|
1010
|
+
let seed = 0;
|
1011
|
+
context.Math = Object.create(Math);
|
1012
|
+
context.Math.random = () => Math.sin(seed++);
|
1013
|
+
const forbidden = ['XMLHttpRequest', 'fetch'];
|
1014
|
+
for (let api of forbidden) {
|
1015
|
+
context[api] = new Proxy(function () { }, {
|
1016
|
+
get() {
|
1017
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
1018
|
+
},
|
1019
|
+
apply() {
|
1020
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
1021
|
+
},
|
1273
1022
|
});
|
1023
|
+
}
|
1024
|
+
});
|
1025
|
+
$mol_test({
|
1026
|
+
'mocked Math.random'($) {
|
1027
|
+
console.assert($.Math.random() === 0);
|
1028
|
+
console.assert($.Math.random() === Math.sin(1));
|
1274
1029
|
},
|
1275
|
-
'
|
1276
|
-
|
1277
|
-
|
1278
|
-
},
|
1279
|
-
'getPrototypeOf'() {
|
1280
|
-
class Foo {
|
1030
|
+
'forbidden XMLHttpRequest'($) {
|
1031
|
+
try {
|
1032
|
+
console.assert(void new $.XMLHttpRequest);
|
1281
1033
|
}
|
1282
|
-
|
1283
|
-
|
1284
|
-
},
|
1285
|
-
'setPrototypeOf'() {
|
1286
|
-
class Foo {
|
1034
|
+
catch (error) {
|
1035
|
+
console.assert(error.message === 'XMLHttpRequest is forbidden in tests');
|
1287
1036
|
}
|
1288
|
-
const target = {};
|
1289
|
-
const proxy = $mol_delegate({}, () => target);
|
1290
|
-
Object.setPrototypeOf(proxy, Foo.prototype);
|
1291
|
-
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
1292
1037
|
},
|
1293
|
-
'
|
1294
|
-
|
1038
|
+
'forbidden fetch'($) {
|
1039
|
+
try {
|
1040
|
+
console.assert(void $.fetch(''));
|
1295
1041
|
}
|
1296
|
-
|
1297
|
-
|
1298
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
1299
|
-
},
|
1300
|
-
'autobind'() {
|
1301
|
-
class Foo {
|
1042
|
+
catch (error) {
|
1043
|
+
console.assert(error.message === 'fetch is forbidden in tests');
|
1302
1044
|
}
|
1303
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
1304
|
-
$mol_assert_ok(proxy instanceof Foo);
|
1305
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
1306
1045
|
},
|
1307
1046
|
});
|
1308
1047
|
})($ || ($ = {}));
|
1309
|
-
//mol/
|
1048
|
+
//mol/test/test.test.ts
|
1310
1049
|
;
|
1311
1050
|
"use strict";
|
1312
1051
|
var $;
|
1313
1052
|
(function ($) {
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
1328
|
-
ownKeys: () => Reflect.ownKeys(target()),
|
1329
|
-
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
1330
|
-
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
1331
|
-
isExtensible: () => Reflect.isExtensible(target()),
|
1332
|
-
preventExtensions: () => Reflect.preventExtensions(target()),
|
1333
|
-
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
1334
|
-
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
1335
|
-
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
1336
|
-
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
1337
|
-
});
|
1338
|
-
instances.add(proxy);
|
1339
|
-
return proxy;
|
1340
|
-
}
|
1341
|
-
$.$mol_delegate = $mol_delegate;
|
1342
|
-
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
1343
|
-
value: (obj) => instances.has(obj),
|
1053
|
+
})($ || ($ = {}));
|
1054
|
+
//mol/dom/context/context.ts
|
1055
|
+
;
|
1056
|
+
"use strict";
|
1057
|
+
var $;
|
1058
|
+
(function ($_1) {
|
1059
|
+
$mol_test_mocks.push($ => {
|
1060
|
+
$.$mol_log3_come = () => { };
|
1061
|
+
$.$mol_log3_done = () => { };
|
1062
|
+
$.$mol_log3_fail = () => { };
|
1063
|
+
$.$mol_log3_warn = () => { };
|
1064
|
+
$.$mol_log3_rise = () => { };
|
1065
|
+
$.$mol_log3_area = () => () => { };
|
1344
1066
|
});
|
1345
1067
|
})($ || ($ = {}));
|
1346
|
-
//mol/
|
1068
|
+
//mol/log3/log3.test.ts
|
1347
1069
|
;
|
1348
1070
|
"use strict";
|
1349
1071
|
var $;
|
1350
1072
|
(function ($) {
|
1351
|
-
$.$
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1073
|
+
$.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
|
1074
|
+
})($ || ($ = {}));
|
1075
|
+
//mol/dom/context/context.node.ts
|
1076
|
+
;
|
1077
|
+
"use strict";
|
1078
|
+
var $;
|
1079
|
+
(function ($) {
|
1080
|
+
function $mol_dom_render_children(el, childNodes) {
|
1081
|
+
const node_set = new Set(childNodes);
|
1082
|
+
let nextNode = el.firstChild;
|
1083
|
+
for (let view of childNodes) {
|
1084
|
+
if (view == null)
|
1085
|
+
continue;
|
1086
|
+
if (view instanceof $mol_dom_context.Node) {
|
1087
|
+
while (true) {
|
1088
|
+
if (!nextNode) {
|
1089
|
+
el.appendChild(view);
|
1090
|
+
break;
|
1091
|
+
}
|
1092
|
+
if (nextNode == view) {
|
1093
|
+
nextNode = nextNode.nextSibling;
|
1094
|
+
break;
|
1095
|
+
}
|
1096
|
+
else {
|
1097
|
+
if (node_set.has(nextNode)) {
|
1098
|
+
el.insertBefore(view, nextNode);
|
1099
|
+
break;
|
1100
|
+
}
|
1101
|
+
else {
|
1102
|
+
const nn = nextNode.nextSibling;
|
1103
|
+
el.removeChild(nextNode);
|
1104
|
+
nextNode = nn;
|
1105
|
+
}
|
1106
|
+
}
|
1107
|
+
}
|
1108
|
+
}
|
1109
|
+
else {
|
1110
|
+
if (nextNode && nextNode.nodeName === '#text') {
|
1111
|
+
const str = String(view);
|
1112
|
+
if (nextNode.nodeValue !== str)
|
1113
|
+
nextNode.nodeValue = str;
|
1114
|
+
nextNode = nextNode.nextSibling;
|
1115
|
+
}
|
1116
|
+
else {
|
1117
|
+
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
1118
|
+
el.insertBefore(textNode, nextNode);
|
1119
|
+
}
|
1120
|
+
}
|
1366
1121
|
}
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
return null;
|
1372
|
-
while (true) {
|
1373
|
-
const owner = $.$mol_owning_map.get(having);
|
1374
|
-
if (!owner)
|
1375
|
-
return owner;
|
1376
|
-
if (!Owner)
|
1377
|
-
return owner;
|
1378
|
-
if (owner instanceof Owner)
|
1379
|
-
return owner;
|
1380
|
-
having = owner;
|
1122
|
+
while (nextNode) {
|
1123
|
+
const currNode = nextNode;
|
1124
|
+
nextNode = currNode.nextSibling;
|
1125
|
+
el.removeChild(currNode);
|
1381
1126
|
}
|
1382
1127
|
}
|
1383
|
-
$.$
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1128
|
+
$.$mol_dom_render_children = $mol_dom_render_children;
|
1129
|
+
})($ || ($ = {}));
|
1130
|
+
//mol/dom/render/children/children.ts
|
1131
|
+
;
|
1132
|
+
"use strict";
|
1133
|
+
//mol/type/error/error.ts
|
1134
|
+
;
|
1135
|
+
"use strict";
|
1136
|
+
//mol/type/assert/assert.test.ts
|
1137
|
+
;
|
1138
|
+
"use strict";
|
1139
|
+
//mol/type/assert/assert.ts
|
1140
|
+
;
|
1141
|
+
"use strict";
|
1142
|
+
//mol/type/equals/equals.test.ts
|
1143
|
+
;
|
1144
|
+
"use strict";
|
1145
|
+
//mol/type/equals/equals.ts
|
1146
|
+
;
|
1147
|
+
"use strict";
|
1148
|
+
//mol/type/partial/deep/deep.test.ts
|
1149
|
+
;
|
1150
|
+
"use strict";
|
1151
|
+
//mol/type/partial/deep/deep.ts
|
1152
|
+
;
|
1153
|
+
"use strict";
|
1154
|
+
var $;
|
1155
|
+
(function ($) {
|
1156
|
+
$mol_test({
|
1157
|
+
'Make empty div'() {
|
1158
|
+
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
1159
|
+
},
|
1160
|
+
'Define native field'() {
|
1161
|
+
const dom = $mol_jsx("input", { value: '123' });
|
1162
|
+
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
1163
|
+
$mol_assert_equal(dom.value, '123');
|
1164
|
+
},
|
1165
|
+
'Define classes'() {
|
1166
|
+
const dom = $mol_jsx("div", { class: 'foo bar' });
|
1167
|
+
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
1168
|
+
},
|
1169
|
+
'Define styles'() {
|
1170
|
+
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
1171
|
+
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
1172
|
+
},
|
1173
|
+
'Define dataset'() {
|
1174
|
+
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
1175
|
+
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
1176
|
+
},
|
1177
|
+
'Define attributes'() {
|
1178
|
+
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
1179
|
+
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
1180
|
+
},
|
1181
|
+
'Define child nodes'() {
|
1182
|
+
const dom = $mol_jsx("div", null,
|
1183
|
+
"hello",
|
1184
|
+
$mol_jsx("strong", null, "world"),
|
1185
|
+
"!");
|
1186
|
+
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
1187
|
+
},
|
1188
|
+
'Function as component'() {
|
1189
|
+
const Button = (props, target) => {
|
1190
|
+
return $mol_jsx("button", { title: props.hint }, target());
|
1191
|
+
};
|
1192
|
+
const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
|
1193
|
+
$mol_assert_equal(dom.outerHTML, '<button id="foo" title="click me" class="Button">hey!</button>');
|
1194
|
+
},
|
1195
|
+
'Nested guid generation'() {
|
1196
|
+
const Foo = () => {
|
1197
|
+
return $mol_jsx("div", null,
|
1198
|
+
$mol_jsx(Bar, { id: "bar" },
|
1199
|
+
$mol_jsx("img", { id: "icon" })));
|
1200
|
+
};
|
1201
|
+
const Bar = (props, icon) => {
|
1202
|
+
return $mol_jsx("span", null,
|
1203
|
+
icon,
|
1204
|
+
$mol_jsx("i", { id: "label" }));
|
1205
|
+
};
|
1206
|
+
const dom = $mol_jsx(Foo, { id: "foo" });
|
1207
|
+
$mol_assert_equal(dom.outerHTML, '<div id="foo" class="Foo"><span id="foo/bar" class="Foo_bar Bar"><img id="foo/icon" class="Foo_icon"><i id="foo/bar/label" class="Foo_bar_label Bar_label"></i></span></div>');
|
1208
|
+
},
|
1209
|
+
'Fail on non unique ids'() {
|
1210
|
+
const App = () => {
|
1211
|
+
return $mol_jsx("div", null,
|
1212
|
+
$mol_jsx("span", { id: "bar" }),
|
1213
|
+
$mol_jsx("span", { id: "bar" }));
|
1214
|
+
};
|
1215
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
1216
|
+
},
|
1217
|
+
'Owner based guid generationn'() {
|
1218
|
+
const Foo = () => {
|
1219
|
+
return $mol_jsx("div", null,
|
1220
|
+
$mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
1221
|
+
};
|
1222
|
+
const Bar = (props) => {
|
1223
|
+
return $mol_jsx("span", null, props.icon());
|
1224
|
+
};
|
1225
|
+
const dom = $mol_jsx(Foo, { id: "app" });
|
1226
|
+
$mol_assert_equal(dom.outerHTML, '<div id="app" class="Foo"><span id="app/middle" class="Foo_middle Bar"><img id="app/icon" class="Foo_icon"></span></div>');
|
1227
|
+
},
|
1228
|
+
'Fail on same ids from different caller'() {
|
1229
|
+
const Foo = () => {
|
1230
|
+
return $mol_jsx("div", null,
|
1231
|
+
$mol_jsx("img", { id: "icon" }),
|
1232
|
+
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
1233
|
+
};
|
1234
|
+
const Bar = (props) => {
|
1235
|
+
return $mol_jsx("span", null, props.icon());
|
1236
|
+
};
|
1237
|
+
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
1238
|
+
},
|
1239
|
+
});
|
1401
1240
|
})($ || ($ = {}));
|
1402
|
-
//mol/
|
1403
|
-
;
|
1404
|
-
"use strict";
|
1405
|
-
//mol/type/writable/writable.test.ts
|
1406
|
-
;
|
1407
|
-
"use strict";
|
1408
|
-
//mol/type/writable/writable.ts
|
1241
|
+
//mol/jsx/jsx.test.tsx
|
1409
1242
|
;
|
1410
1243
|
"use strict";
|
1411
1244
|
var $;
|
1412
1245
|
(function ($) {
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1246
|
+
$.$mol_jsx_prefix = '';
|
1247
|
+
$.$mol_jsx_crumbs = '';
|
1248
|
+
$.$mol_jsx_booked = null;
|
1249
|
+
$.$mol_jsx_document = {
|
1250
|
+
getElementById: () => null,
|
1251
|
+
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
1252
|
+
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
1253
|
+
};
|
1254
|
+
$.$mol_jsx_frag = '';
|
1255
|
+
function $mol_jsx(Elem, props, ...childNodes) {
|
1256
|
+
const id = props && props.id || '';
|
1257
|
+
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
1258
|
+
const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
|
1259
|
+
if (Elem && $.$mol_jsx_booked) {
|
1260
|
+
if ($.$mol_jsx_booked.has(id)) {
|
1261
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
|
1262
|
+
}
|
1263
|
+
else {
|
1264
|
+
$.$mol_jsx_booked.add(id);
|
1265
|
+
}
|
1432
1266
|
}
|
1433
|
-
|
1434
|
-
|
1267
|
+
let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
|
1268
|
+
if ($.$mol_jsx_prefix) {
|
1269
|
+
const prefix_ext = $.$mol_jsx_prefix;
|
1270
|
+
const booked_ext = $.$mol_jsx_booked;
|
1271
|
+
const crumbs_ext = $.$mol_jsx_crumbs;
|
1272
|
+
for (const field in props) {
|
1273
|
+
const func = props[field];
|
1274
|
+
if (typeof func !== 'function')
|
1275
|
+
continue;
|
1276
|
+
const wrapper = function (...args) {
|
1277
|
+
const prefix = $.$mol_jsx_prefix;
|
1278
|
+
const booked = $.$mol_jsx_booked;
|
1279
|
+
const crumbs = $.$mol_jsx_crumbs;
|
1280
|
+
try {
|
1281
|
+
$.$mol_jsx_prefix = prefix_ext;
|
1282
|
+
$.$mol_jsx_booked = booked_ext;
|
1283
|
+
$.$mol_jsx_crumbs = crumbs_ext;
|
1284
|
+
return func.call(this, ...args);
|
1285
|
+
}
|
1286
|
+
finally {
|
1287
|
+
$.$mol_jsx_prefix = prefix;
|
1288
|
+
$.$mol_jsx_booked = booked;
|
1289
|
+
$.$mol_jsx_crumbs = crumbs;
|
1290
|
+
}
|
1291
|
+
};
|
1292
|
+
$mol_func_name_from(wrapper, func);
|
1293
|
+
props[field] = wrapper;
|
1294
|
+
}
|
1435
1295
|
}
|
1436
|
-
|
1437
|
-
if (
|
1438
|
-
|
1439
|
-
|
1296
|
+
if (typeof Elem !== 'string') {
|
1297
|
+
if ('prototype' in Elem) {
|
1298
|
+
const view = node && node[Elem] || new Elem;
|
1299
|
+
Object.assign(view, props);
|
1300
|
+
view[Symbol.toStringTag] = guid;
|
1301
|
+
view.childNodes = childNodes;
|
1302
|
+
if (!view.ownerDocument)
|
1303
|
+
view.ownerDocument = $.$mol_jsx_document;
|
1304
|
+
view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
1305
|
+
node = view.valueOf();
|
1306
|
+
node[Elem] = view;
|
1307
|
+
return node;
|
1308
|
+
}
|
1309
|
+
else {
|
1310
|
+
const prefix = $.$mol_jsx_prefix;
|
1311
|
+
const booked = $.$mol_jsx_booked;
|
1312
|
+
const crumbs = $.$mol_jsx_crumbs;
|
1313
|
+
try {
|
1314
|
+
$.$mol_jsx_prefix = guid;
|
1315
|
+
$.$mol_jsx_booked = new Set;
|
1316
|
+
$.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
1317
|
+
return Elem(props, ...childNodes);
|
1318
|
+
}
|
1319
|
+
finally {
|
1320
|
+
$.$mol_jsx_prefix = prefix;
|
1321
|
+
$.$mol_jsx_booked = booked;
|
1322
|
+
$.$mol_jsx_crumbs = crumbs;
|
1323
|
+
}
|
1324
|
+
}
|
1440
1325
|
}
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1326
|
+
if (!node) {
|
1327
|
+
node = Elem
|
1328
|
+
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
1329
|
+
: $.$mol_jsx_document.createDocumentFragment();
|
1444
1330
|
}
|
1445
|
-
|
1446
|
-
|
1331
|
+
$mol_dom_render_children(node, [].concat(...childNodes));
|
1332
|
+
if (!Elem)
|
1333
|
+
return node;
|
1334
|
+
if (guid)
|
1335
|
+
node.id = guid;
|
1336
|
+
for (const key in props) {
|
1337
|
+
if (key === 'id')
|
1338
|
+
continue;
|
1339
|
+
if (typeof props[key] === 'string') {
|
1340
|
+
;
|
1341
|
+
node.setAttribute(key, props[key]);
|
1342
|
+
}
|
1343
|
+
else if (props[key] &&
|
1344
|
+
typeof props[key] === 'object' &&
|
1345
|
+
Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
|
1346
|
+
if (typeof node[key] === 'object') {
|
1347
|
+
Object.assign(node[key], props[key]);
|
1348
|
+
continue;
|
1349
|
+
}
|
1350
|
+
}
|
1351
|
+
else {
|
1352
|
+
node[key] = props[key];
|
1353
|
+
}
|
1447
1354
|
}
|
1355
|
+
if ($.$mol_jsx_crumbs)
|
1356
|
+
node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
|
1357
|
+
return node;
|
1448
1358
|
}
|
1449
|
-
$.$
|
1359
|
+
$.$mol_jsx = $mol_jsx;
|
1450
1360
|
})($ || ($ = {}));
|
1451
|
-
//mol/
|
1361
|
+
//mol/jsx/jsx.ts
|
1452
1362
|
;
|
1453
1363
|
"use strict";
|
1454
1364
|
var $;
|
1455
|
-
(function ($
|
1365
|
+
(function ($) {
|
1456
1366
|
$mol_test({
|
1457
|
-
'
|
1458
|
-
$
|
1459
|
-
$
|
1460
|
-
$
|
1461
|
-
$
|
1462
|
-
|
1463
|
-
|
1464
|
-
$
|
1465
|
-
$
|
1367
|
+
'nulls & undefineds'() {
|
1368
|
+
$mol_assert_ok($mol_compare_deep(null, null));
|
1369
|
+
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
1370
|
+
$mol_assert_not($mol_compare_deep(undefined, null));
|
1371
|
+
$mol_assert_not($mol_compare_deep({}, null));
|
1372
|
+
},
|
1373
|
+
'number'() {
|
1374
|
+
$mol_assert_ok($mol_compare_deep(1, 1));
|
1375
|
+
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
1376
|
+
$mol_assert_not($mol_compare_deep(1, 2));
|
1377
|
+
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
1378
|
+
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
1379
|
+
},
|
1380
|
+
'POJO'() {
|
1381
|
+
$mol_assert_ok($mol_compare_deep({}, {}));
|
1382
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
1383
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
1384
|
+
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
1385
|
+
$mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
1386
|
+
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
1387
|
+
},
|
1388
|
+
'Array'() {
|
1389
|
+
$mol_assert_ok($mol_compare_deep([], []));
|
1390
|
+
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
1391
|
+
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
1392
|
+
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
1393
|
+
},
|
1394
|
+
'Non POJO are different'() {
|
1395
|
+
class Thing extends Object {
|
1396
|
+
}
|
1397
|
+
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
1398
|
+
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
1399
|
+
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
1400
|
+
},
|
1401
|
+
'same POJOs with cyclic reference'() {
|
1402
|
+
const a = { foo: {} };
|
1403
|
+
a['self'] = a;
|
1404
|
+
const b = { foo: {} };
|
1405
|
+
b['self'] = b;
|
1406
|
+
$mol_assert_ok($mol_compare_deep(a, b));
|
1407
|
+
},
|
1408
|
+
'Date'() {
|
1409
|
+
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
1410
|
+
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
1466
1411
|
},
|
1467
|
-
'
|
1468
|
-
$
|
1469
|
-
$
|
1470
|
-
$
|
1471
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
1472
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
1473
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
1412
|
+
'RegExp'() {
|
1413
|
+
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
1414
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
1415
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
1474
1416
|
},
|
1475
|
-
'
|
1476
|
-
$
|
1477
|
-
|
1478
|
-
$
|
1479
|
-
$
|
1480
|
-
$mol_assert_equal($mol_tree.fromJSON({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
|
1417
|
+
'Error'() {
|
1418
|
+
$mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
|
1419
|
+
const fail = (message) => new Error(message);
|
1420
|
+
$mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
|
1421
|
+
$mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
|
1481
1422
|
},
|
1482
|
-
'
|
1483
|
-
$
|
1484
|
-
$
|
1485
|
-
$
|
1486
|
-
$
|
1487
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n').sub[0]), '{"foo":false,"bar\\nbaz":"lol"}');
|
1423
|
+
'Map'() {
|
1424
|
+
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
1425
|
+
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
1426
|
+
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
1427
|
+
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
1488
1428
|
},
|
1489
|
-
'
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
});
|
1494
|
-
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
1429
|
+
'Set'() {
|
1430
|
+
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
1431
|
+
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
1432
|
+
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
1495
1433
|
},
|
1496
|
-
'
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1434
|
+
'Uint8Array'() {
|
1435
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
1436
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
1437
|
+
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
1438
|
+
},
|
1439
|
+
'Custom comparator'() {
|
1440
|
+
class User {
|
1441
|
+
name;
|
1442
|
+
rand;
|
1443
|
+
constructor(name, rand = Math.random()) {
|
1444
|
+
this.name = name;
|
1445
|
+
this.rand = rand;
|
1446
|
+
}
|
1447
|
+
[Symbol.toPrimitive](mode) {
|
1448
|
+
return this.name;
|
1449
|
+
}
|
1502
1450
|
}
|
1503
|
-
|
1504
|
-
|
1505
|
-
bar \\data
|
1506
|
-
`, 'test');
|
1507
|
-
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
1451
|
+
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
1452
|
+
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
1508
1453
|
},
|
1509
1454
|
});
|
1510
1455
|
})($ || ($ = {}));
|
1511
|
-
//mol/
|
1456
|
+
//mol/compare/deep/deep.test.tsx
|
1512
1457
|
;
|
1513
1458
|
"use strict";
|
1514
1459
|
var $;
|
1515
1460
|
(function ($) {
|
1516
|
-
$.$
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
return str.split('\n').map((data, index) => new $mol_tree({
|
1550
|
-
data: data,
|
1551
|
-
baseUri: baseUri,
|
1552
|
-
row: index + 1,
|
1553
|
-
length: data.length,
|
1554
|
-
}));
|
1555
|
-
}
|
1556
|
-
clone(config = {}) {
|
1557
|
-
return new $mol_tree({
|
1558
|
-
type: ('type' in config) ? config.type : this.type,
|
1559
|
-
data: ('data' in config) ? config.data : this.data,
|
1560
|
-
sub: ('sub' in config) ? config.sub : this.sub,
|
1561
|
-
baseUri: ('baseUri' in config) ? config.baseUri : this.baseUri,
|
1562
|
-
row: ('row' in config) ? config.row : this.row,
|
1563
|
-
col: ('col' in config) ? config.col : this.col,
|
1564
|
-
length: ('length' in config) ? config.length : this.length,
|
1565
|
-
value: config.value
|
1566
|
-
});
|
1567
|
-
}
|
1568
|
-
make(config) {
|
1569
|
-
return new $mol_tree({
|
1570
|
-
baseUri: this.baseUri,
|
1571
|
-
row: this.row,
|
1572
|
-
col: this.col,
|
1573
|
-
length: this.length,
|
1574
|
-
...config,
|
1575
|
-
});
|
1576
|
-
}
|
1577
|
-
make_data(value, sub) {
|
1578
|
-
return this.make({ value, sub });
|
1579
|
-
}
|
1580
|
-
make_struct(type, sub) {
|
1581
|
-
return this.make({ type, sub });
|
1582
|
-
}
|
1583
|
-
static fromString(str, baseUri) {
|
1584
|
-
var root = new $mol_tree({ baseUri: baseUri });
|
1585
|
-
var stack = [root];
|
1586
|
-
var row = 0;
|
1587
|
-
var prefix = str.replace(/^\n?(\t*)[\s\S]*/, '$1');
|
1588
|
-
var lines = str.replace(new RegExp('^\\t{0,' + prefix.length + '}', 'mg'), '').split('\n');
|
1589
|
-
lines.forEach(line => {
|
1590
|
-
++row;
|
1591
|
-
var chunks = /^(\t*)((?:[^\n\t\\ ]+ *)*)(\\[^\n]*)?(.*?)(?:$|\n)/m.exec(line);
|
1592
|
-
if (!chunks || chunks[4])
|
1593
|
-
return this.$.$mol_fail(new Error(`Syntax error at ${baseUri}:${row}\n${line}`));
|
1594
|
-
var indent = chunks[1];
|
1595
|
-
var path = chunks[2];
|
1596
|
-
var data = chunks[3];
|
1597
|
-
var deep = indent.length;
|
1598
|
-
var types = path ? path.replace(/ $/, '').split(/ +/) : [];
|
1599
|
-
if (stack.length <= deep)
|
1600
|
-
return this.$.$mol_fail(new Error(`Too many tabs at ${baseUri}:${row}\n${line}`));
|
1601
|
-
stack.length = deep + 1;
|
1602
|
-
var parent = stack[deep];
|
1603
|
-
let col = deep;
|
1604
|
-
types.forEach(type => {
|
1605
|
-
if (!type)
|
1606
|
-
return this.$.$mol_fail(new Error(`Unexpected space symbol ${baseUri}:${row}\n${line}`));
|
1607
|
-
var next = new $mol_tree({ type, baseUri, row, col, length: type.length });
|
1608
|
-
const parent_sub = parent.sub;
|
1609
|
-
parent_sub.push(next);
|
1610
|
-
parent = next;
|
1611
|
-
col += type.length + 1;
|
1612
|
-
});
|
1613
|
-
if (data) {
|
1614
|
-
var next = new $mol_tree({ data: data.substring(1), baseUri, row, col, length: data.length });
|
1615
|
-
const parent_sub = parent.sub;
|
1616
|
-
parent_sub.push(next);
|
1617
|
-
parent = next;
|
1618
|
-
}
|
1619
|
-
stack.push(parent);
|
1620
|
-
});
|
1621
|
-
return root;
|
1622
|
-
}
|
1623
|
-
static fromJSON(json, baseUri = '') {
|
1624
|
-
switch (true) {
|
1625
|
-
case typeof json === 'boolean':
|
1626
|
-
case typeof json === 'number':
|
1627
|
-
case json === null:
|
1628
|
-
return new $mol_tree({
|
1629
|
-
type: String(json),
|
1630
|
-
baseUri: baseUri
|
1631
|
-
});
|
1632
|
-
case typeof json === 'string':
|
1633
|
-
return new $mol_tree({
|
1634
|
-
value: json,
|
1635
|
-
baseUri: baseUri
|
1636
|
-
});
|
1637
|
-
case Array.isArray(json):
|
1638
|
-
return new $mol_tree({
|
1639
|
-
type: "/",
|
1640
|
-
sub: json.map(json => $mol_tree.fromJSON(json, baseUri))
|
1641
|
-
});
|
1642
|
-
case json instanceof Date:
|
1643
|
-
return new $mol_tree({
|
1644
|
-
value: json.toISOString(),
|
1645
|
-
baseUri: baseUri
|
1646
|
-
});
|
1647
|
-
default:
|
1648
|
-
if (typeof json[$.$mol_tree_convert] === 'function') {
|
1649
|
-
return json[$.$mol_tree_convert]();
|
1650
|
-
}
|
1651
|
-
if (typeof json.toJSON === 'function') {
|
1652
|
-
return $mol_tree.fromJSON(json.toJSON());
|
1653
|
-
}
|
1654
|
-
if (json instanceof Error) {
|
1655
|
-
const { name, message, stack } = json;
|
1656
|
-
json = { ...json, name, message, stack };
|
1657
|
-
}
|
1658
|
-
var sub = [];
|
1659
|
-
for (var key in json) {
|
1660
|
-
if (json[key] === undefined)
|
1661
|
-
continue;
|
1662
|
-
const subsub = $mol_tree.fromJSON(json[key], baseUri);
|
1663
|
-
if (/^[^\n\t\\ ]+$/.test(key)) {
|
1664
|
-
var child = new $mol_tree({
|
1665
|
-
type: key,
|
1666
|
-
baseUri: baseUri,
|
1667
|
-
sub: [subsub],
|
1668
|
-
});
|
1669
|
-
}
|
1670
|
-
else {
|
1671
|
-
var child = new $mol_tree({
|
1672
|
-
value: key,
|
1673
|
-
baseUri: baseUri,
|
1674
|
-
sub: [subsub],
|
1675
|
-
});
|
1676
|
-
}
|
1677
|
-
sub.push(child);
|
1678
|
-
}
|
1679
|
-
return new $mol_tree({
|
1680
|
-
type: "*",
|
1681
|
-
sub: sub,
|
1682
|
-
baseUri: baseUri
|
1683
|
-
});
|
1684
|
-
}
|
1461
|
+
$.$mol_compare_deep_cache = new WeakMap();
|
1462
|
+
function $mol_compare_deep(left, right) {
|
1463
|
+
if (Object.is(left, right))
|
1464
|
+
return true;
|
1465
|
+
if (left === null)
|
1466
|
+
return false;
|
1467
|
+
if (right === null)
|
1468
|
+
return false;
|
1469
|
+
if (typeof left !== 'object')
|
1470
|
+
return false;
|
1471
|
+
if (typeof right !== 'object')
|
1472
|
+
return false;
|
1473
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
1474
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
1475
|
+
if (left_proto !== right_proto)
|
1476
|
+
return false;
|
1477
|
+
if (left instanceof Boolean)
|
1478
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
1479
|
+
if (left instanceof Number)
|
1480
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
1481
|
+
if (left instanceof String)
|
1482
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
1483
|
+
if (left instanceof Date)
|
1484
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
1485
|
+
if (left instanceof RegExp)
|
1486
|
+
return left.source === right['source'] && left.flags === right['flags'];
|
1487
|
+
if (left instanceof Error)
|
1488
|
+
return left.stack === right['stack'];
|
1489
|
+
let left_cache = $.$mol_compare_deep_cache.get(left);
|
1490
|
+
if (left_cache) {
|
1491
|
+
const right_cache = left_cache.get(right);
|
1492
|
+
if (typeof right_cache === 'boolean')
|
1493
|
+
return right_cache;
|
1685
1494
|
}
|
1686
|
-
|
1687
|
-
|
1495
|
+
else {
|
1496
|
+
left_cache = new WeakMap([[right, true]]);
|
1497
|
+
$.$mol_compare_deep_cache.set(left, left_cache);
|
1688
1498
|
}
|
1689
|
-
|
1690
|
-
|
1691
|
-
if (
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
else if (
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
output += prefix;
|
1706
|
-
output += child.toString(prefix + "\t");
|
1707
|
-
}
|
1708
|
-
return output;
|
1499
|
+
let result;
|
1500
|
+
try {
|
1501
|
+
if (left_proto && !Reflect.getPrototypeOf(left_proto))
|
1502
|
+
result = compare_pojo(left, right);
|
1503
|
+
else if (Array.isArray(left))
|
1504
|
+
result = compare_array(left, right);
|
1505
|
+
else if (left instanceof Set)
|
1506
|
+
result = compare_set(left, right);
|
1507
|
+
else if (left instanceof Map)
|
1508
|
+
result = compare_map(left, right);
|
1509
|
+
else if (ArrayBuffer.isView(left))
|
1510
|
+
result = compare_buffer(left, right);
|
1511
|
+
else if (Symbol.toPrimitive in left)
|
1512
|
+
result = compare_primitive(left, right);
|
1513
|
+
else
|
1514
|
+
result = false;
|
1709
1515
|
}
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1516
|
+
finally {
|
1517
|
+
left_cache.set(right, result);
|
1518
|
+
}
|
1519
|
+
return result;
|
1520
|
+
}
|
1521
|
+
$.$mol_compare_deep = $mol_compare_deep;
|
1522
|
+
function compare_array(left, right) {
|
1523
|
+
const len = left.length;
|
1524
|
+
if (len !== right.length)
|
1525
|
+
return false;
|
1526
|
+
for (let i = 0; i < len; ++i) {
|
1527
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
1716
1528
|
return false;
|
1717
|
-
if (this.type === 'null')
|
1718
|
-
return null;
|
1719
|
-
if (this.type === '*') {
|
1720
|
-
var obj = {};
|
1721
|
-
for (var child of this.sub) {
|
1722
|
-
if (child.type === '-')
|
1723
|
-
continue;
|
1724
|
-
var key = child.type || child.clone({ sub: child.sub.slice(0, child.sub.length - 1) }).value;
|
1725
|
-
var val = child.sub[child.sub.length - 1].toJSON();
|
1726
|
-
if (val !== undefined)
|
1727
|
-
obj[key] = val;
|
1728
|
-
}
|
1729
|
-
return obj;
|
1730
|
-
}
|
1731
|
-
if (this.type === '/') {
|
1732
|
-
var res = [];
|
1733
|
-
this.sub.forEach(child => {
|
1734
|
-
if (child.type === '-')
|
1735
|
-
return;
|
1736
|
-
var val = child.toJSON();
|
1737
|
-
if (val !== undefined)
|
1738
|
-
res.push(val);
|
1739
|
-
});
|
1740
|
-
return res;
|
1741
|
-
}
|
1742
|
-
if (this.type === 'time') {
|
1743
|
-
return new Date(this.value);
|
1744
|
-
}
|
1745
|
-
const numb = Number(this.type);
|
1746
|
-
if (!Number.isNaN(numb) || this.type === 'NaN')
|
1747
|
-
return numb;
|
1748
|
-
throw new Error(`Unknown type (${this.type}) at ${this.uri}`);
|
1749
1529
|
}
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1530
|
+
return true;
|
1531
|
+
}
|
1532
|
+
function compare_buffer(left, right) {
|
1533
|
+
const len = left.byteLength;
|
1534
|
+
if (len !== right.byteLength)
|
1535
|
+
return false;
|
1536
|
+
for (let i = 0; i < len; ++i) {
|
1537
|
+
if (left[i] !== right[i])
|
1538
|
+
return false;
|
1758
1539
|
}
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1540
|
+
return true;
|
1541
|
+
}
|
1542
|
+
function compare_iterator(left, right, compare) {
|
1543
|
+
while (true) {
|
1544
|
+
const left_next = left.next();
|
1545
|
+
const right_next = right.next();
|
1546
|
+
if (left_next.done !== right_next.done)
|
1547
|
+
return false;
|
1548
|
+
if (left_next.done)
|
1549
|
+
break;
|
1550
|
+
if (!compare(left_next.value, right_next.value))
|
1551
|
+
return false;
|
1552
|
+
}
|
1553
|
+
return true;
|
1554
|
+
}
|
1555
|
+
function compare_set(left, right) {
|
1556
|
+
if (left.size !== right.size)
|
1557
|
+
return false;
|
1558
|
+
return compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
1559
|
+
}
|
1560
|
+
function compare_map(left, right) {
|
1561
|
+
if (left.size !== right.size)
|
1562
|
+
return false;
|
1563
|
+
return compare_iterator(left.keys(), right.keys(), Object.is)
|
1564
|
+
&& compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
1565
|
+
}
|
1566
|
+
function compare_pojo(left, right) {
|
1567
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
1568
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
1569
|
+
if (left_keys.length !== right_keys.length)
|
1570
|
+
return false;
|
1571
|
+
for (let key of left_keys) {
|
1572
|
+
if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
|
1573
|
+
return false;
|
1574
|
+
}
|
1575
|
+
return true;
|
1576
|
+
}
|
1577
|
+
function compare_primitive(left, right) {
|
1578
|
+
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
1579
|
+
}
|
1580
|
+
})($ || ($ = {}));
|
1581
|
+
//mol/compare/deep/deep.ts
|
1582
|
+
;
|
1583
|
+
"use strict";
|
1584
|
+
var $;
|
1585
|
+
(function ($) {
|
1586
|
+
function $mol_dom_serialize(node) {
|
1587
|
+
const serializer = new $mol_dom_context.XMLSerializer;
|
1588
|
+
return serializer.serializeToString(node);
|
1589
|
+
}
|
1590
|
+
$.$mol_dom_serialize = $mol_dom_serialize;
|
1591
|
+
})($ || ($ = {}));
|
1592
|
+
//mol/dom/serialize/serialize.ts
|
1593
|
+
;
|
1594
|
+
"use strict";
|
1595
|
+
var $;
|
1596
|
+
(function ($) {
|
1597
|
+
$mol_test({
|
1598
|
+
'must be false'() {
|
1599
|
+
$mol_assert_not(0);
|
1600
|
+
},
|
1601
|
+
'must be true'() {
|
1602
|
+
$mol_assert_ok(1);
|
1603
|
+
},
|
1604
|
+
'two must be equal'() {
|
1605
|
+
$mol_assert_equal(2, 2);
|
1606
|
+
},
|
1607
|
+
'three must be equal'() {
|
1608
|
+
$mol_assert_equal(2, 2, 2);
|
1609
|
+
},
|
1610
|
+
'two must be unique'() {
|
1611
|
+
$mol_assert_unique([3], [3]);
|
1612
|
+
},
|
1613
|
+
'three must be unique'() {
|
1614
|
+
$mol_assert_unique([3], [3], [3]);
|
1615
|
+
},
|
1616
|
+
'two must be alike'() {
|
1617
|
+
$mol_assert_like([3], [3]);
|
1618
|
+
},
|
1619
|
+
'three must be alike'() {
|
1620
|
+
$mol_assert_like([3], [3], [3]);
|
1621
|
+
},
|
1622
|
+
});
|
1623
|
+
})($ || ($ = {}));
|
1624
|
+
//mol/assert/assert.test.ts
|
1625
|
+
;
|
1626
|
+
"use strict";
|
1627
|
+
var $;
|
1628
|
+
(function ($) {
|
1629
|
+
function $mol_assert_ok(value) {
|
1630
|
+
if (value)
|
1631
|
+
return;
|
1632
|
+
$mol_fail(new Error(`${value} ≠ true`));
|
1633
|
+
}
|
1634
|
+
$.$mol_assert_ok = $mol_assert_ok;
|
1635
|
+
function $mol_assert_not(value) {
|
1636
|
+
if (!value)
|
1637
|
+
return;
|
1638
|
+
$mol_fail(new Error(`${value} ≠ false`));
|
1639
|
+
}
|
1640
|
+
$.$mol_assert_not = $mol_assert_not;
|
1641
|
+
function $mol_assert_fail(handler, ErrorRight) {
|
1642
|
+
const fail = $.$mol_fail;
|
1643
|
+
try {
|
1644
|
+
$.$mol_fail = $.$mol_fail_hidden;
|
1645
|
+
handler();
|
1646
|
+
}
|
1647
|
+
catch (error) {
|
1648
|
+
if (!ErrorRight)
|
1649
|
+
return error;
|
1650
|
+
$.$mol_fail = fail;
|
1651
|
+
if (typeof ErrorRight === 'string') {
|
1652
|
+
$mol_assert_equal(error.message, ErrorRight);
|
1779
1653
|
}
|
1780
1654
|
else {
|
1781
|
-
|
1655
|
+
$mol_assert_ok(error instanceof ErrorRight);
|
1782
1656
|
}
|
1657
|
+
return error;
|
1783
1658
|
}
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
break;
|
1800
|
-
case 'number':
|
1801
|
-
if (type < item.sub.length)
|
1802
|
-
next.push(item.sub[type]);
|
1803
|
-
break;
|
1804
|
-
default: next.push(...item.sub);
|
1805
|
-
}
|
1806
|
-
}
|
1659
|
+
finally {
|
1660
|
+
$.$mol_fail = fail;
|
1661
|
+
}
|
1662
|
+
$mol_fail(new Error('Not failed'));
|
1663
|
+
}
|
1664
|
+
$.$mol_assert_fail = $mol_assert_fail;
|
1665
|
+
function $mol_assert_equal(...args) {
|
1666
|
+
for (let i = 0; i < args.length; ++i) {
|
1667
|
+
for (let j = 0; j < args.length; ++j) {
|
1668
|
+
if (i === j)
|
1669
|
+
continue;
|
1670
|
+
if (Number.isNaN(args[i]) && Number.isNaN(args[j]))
|
1671
|
+
continue;
|
1672
|
+
if (args[i] !== args[j])
|
1673
|
+
$mol_fail(new Error(`Not equal (${i + 1}:${j + 1})\n${args[i]}\n${args[j]}`));
|
1807
1674
|
}
|
1808
|
-
return new $mol_tree({ sub: next });
|
1809
1675
|
}
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1817
|
-
|
1676
|
+
}
|
1677
|
+
$.$mol_assert_equal = $mol_assert_equal;
|
1678
|
+
function $mol_assert_unique(...args) {
|
1679
|
+
for (let i = 0; i < args.length; ++i) {
|
1680
|
+
for (let j = 0; j < args.length; ++j) {
|
1681
|
+
if (i === j)
|
1682
|
+
continue;
|
1683
|
+
if (args[i] === args[j] || (Number.isNaN(args[i]) && Number.isNaN(args[j]))) {
|
1684
|
+
$mol_fail(new Error(`args[${i}] = args[${j}] = ${args[i]}`));
|
1818
1685
|
}
|
1819
|
-
}
|
1820
|
-
return new $mol_tree({ sub: sub });
|
1821
|
-
}
|
1822
|
-
transform(visit, stack = []) {
|
1823
|
-
const sub_stack = [this, ...stack];
|
1824
|
-
return visit(sub_stack, () => this.sub.map(node => node.transform(visit, sub_stack)).filter(n => n));
|
1825
|
-
}
|
1826
|
-
hack(context) {
|
1827
|
-
const sub = [].concat(...this.sub.map(child => {
|
1828
|
-
const handle = context[child.type] || context[''];
|
1829
|
-
if (!handle)
|
1830
|
-
$mol_fail(child.error('Handler not defined'));
|
1831
|
-
return handle(child, context);
|
1832
|
-
}));
|
1833
|
-
return this.clone({ sub });
|
1686
|
+
}
|
1834
1687
|
}
|
1835
|
-
|
1836
|
-
|
1688
|
+
}
|
1689
|
+
$.$mol_assert_unique = $mol_assert_unique;
|
1690
|
+
function $mol_assert_like(head, ...tail) {
|
1691
|
+
for (let [index, value] of Object.entries(tail)) {
|
1692
|
+
if (!$mol_compare_deep(value, head)) {
|
1693
|
+
const print = (val) => {
|
1694
|
+
if (!val)
|
1695
|
+
return val;
|
1696
|
+
if (typeof val !== 'object')
|
1697
|
+
return val;
|
1698
|
+
if ('outerHTML' in val)
|
1699
|
+
return val.outerHTML;
|
1700
|
+
try {
|
1701
|
+
return JSON.stringify(val);
|
1702
|
+
}
|
1703
|
+
catch (error) {
|
1704
|
+
console.error(error);
|
1705
|
+
return val;
|
1706
|
+
}
|
1707
|
+
};
|
1708
|
+
return $mol_fail(new Error(`Not like (1:${+index + 2})\n${print(head)}\n---\n${print(value)}`));
|
1709
|
+
}
|
1837
1710
|
}
|
1838
1711
|
}
|
1839
|
-
$.$
|
1712
|
+
$.$mol_assert_like = $mol_assert_like;
|
1713
|
+
function $mol_assert_dom(left, right) {
|
1714
|
+
$mol_assert_equal($mol_dom_serialize(left), $mol_dom_serialize(right));
|
1715
|
+
}
|
1716
|
+
$.$mol_assert_dom = $mol_assert_dom;
|
1840
1717
|
})($ || ($ = {}));
|
1841
|
-
//mol/
|
1718
|
+
//mol/assert/assert.ts
|
1719
|
+
;
|
1720
|
+
"use strict";
|
1721
|
+
var $;
|
1722
|
+
(function ($) {
|
1723
|
+
$mol_test({
|
1724
|
+
'get'() {
|
1725
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
1726
|
+
$mol_assert_equal(proxy.foo, 777);
|
1727
|
+
},
|
1728
|
+
'has'() {
|
1729
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
1730
|
+
$mol_assert_equal('foo' in proxy, true);
|
1731
|
+
},
|
1732
|
+
'set'() {
|
1733
|
+
const target = { foo: 777 };
|
1734
|
+
const proxy = $mol_delegate({}, () => target);
|
1735
|
+
proxy.foo = 123;
|
1736
|
+
$mol_assert_equal(target.foo, 123);
|
1737
|
+
},
|
1738
|
+
'getOwnPropertyDescriptor'() {
|
1739
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
1740
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
1741
|
+
value: 777,
|
1742
|
+
writable: true,
|
1743
|
+
enumerable: true,
|
1744
|
+
configurable: true,
|
1745
|
+
});
|
1746
|
+
},
|
1747
|
+
'ownKeys'() {
|
1748
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
1749
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
1750
|
+
},
|
1751
|
+
'getPrototypeOf'() {
|
1752
|
+
class Foo {
|
1753
|
+
}
|
1754
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
1755
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
1756
|
+
},
|
1757
|
+
'setPrototypeOf'() {
|
1758
|
+
class Foo {
|
1759
|
+
}
|
1760
|
+
const target = {};
|
1761
|
+
const proxy = $mol_delegate({}, () => target);
|
1762
|
+
Object.setPrototypeOf(proxy, Foo.prototype);
|
1763
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
1764
|
+
},
|
1765
|
+
'instanceof'() {
|
1766
|
+
class Foo {
|
1767
|
+
}
|
1768
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
1769
|
+
$mol_assert_ok(proxy instanceof Foo);
|
1770
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
1771
|
+
},
|
1772
|
+
'autobind'() {
|
1773
|
+
class Foo {
|
1774
|
+
}
|
1775
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
1776
|
+
$mol_assert_ok(proxy instanceof Foo);
|
1777
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
1778
|
+
},
|
1779
|
+
});
|
1780
|
+
})($ || ($ = {}));
|
1781
|
+
//mol/delegate/delegate.test.ts
|
1782
|
+
;
|
1783
|
+
"use strict";
|
1784
|
+
//mol/type/writable/writable.test.ts
|
1785
|
+
;
|
1786
|
+
"use strict";
|
1787
|
+
var $;
|
1788
|
+
(function ($_1) {
|
1789
|
+
$mol_test({
|
1790
|
+
'tree parsing'() {
|
1791
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
1792
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
1793
|
+
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
1794
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
1795
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
1796
|
+
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
1797
|
+
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
1798
|
+
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
1799
|
+
},
|
1800
|
+
'inserting'() {
|
1801
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
1802
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
1803
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
1804
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
1805
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
1806
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
1807
|
+
},
|
1808
|
+
'fromJSON'() {
|
1809
|
+
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
1810
|
+
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
1811
|
+
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
1812
|
+
$mol_assert_equal($mol_tree.fromJSON(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
|
1813
|
+
$mol_assert_equal($mol_tree.fromJSON({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
|
1814
|
+
},
|
1815
|
+
'toJSON'() {
|
1816
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
1817
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
1818
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
1819
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n').sub[0]), '["","foo","bar\\nbaz"]');
|
1820
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n').sub[0]), '{"foo":false,"bar\\nbaz":"lol"}');
|
1821
|
+
},
|
1822
|
+
'hack'() {
|
1823
|
+
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
1824
|
+
'': (tree, context) => [tree.hack(context)],
|
1825
|
+
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
1826
|
+
});
|
1827
|
+
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
1828
|
+
},
|
1829
|
+
'errors handling'($) {
|
1830
|
+
const errors = [];
|
1831
|
+
class Tree extends $mol_tree {
|
1832
|
+
static $ = $.$mol_ambient({
|
1833
|
+
$mol_fail: error => errors.push(error.message)
|
1834
|
+
});
|
1835
|
+
}
|
1836
|
+
Tree.fromString(`
|
1837
|
+
\t \tfoo
|
1838
|
+
bar \\data
|
1839
|
+
`, 'test');
|
1840
|
+
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
1841
|
+
},
|
1842
|
+
});
|
1843
|
+
})($ || ($ = {}));
|
1844
|
+
//mol/tree/tree.test.ts
|
1842
1845
|
;
|
1843
1846
|
"use strict";
|
1844
1847
|
var $;
|
@@ -1953,38 +1956,6 @@ var $;
|
|
1953
1956
|
;
|
1954
1957
|
"use strict";
|
1955
1958
|
var $;
|
1956
|
-
(function ($) {
|
1957
|
-
$mol_test({
|
1958
|
-
async 'sizes'() {
|
1959
|
-
const pair = await $$.$mol_crypto_auditor_pair();
|
1960
|
-
const key_public = await pair.public.serial();
|
1961
|
-
$mol_assert_equal(key_public.byteLength, $mol_crypto_auditor_public.size);
|
1962
|
-
const key_private = await pair.private.serial();
|
1963
|
-
$mol_assert_ok(key_private.byteLength < $mol_crypto_auditor_private.size);
|
1964
|
-
const data = new Uint8Array([1, 2, 3]);
|
1965
|
-
const sign = await pair.private.sign(data);
|
1966
|
-
$mol_assert_equal(sign.byteLength, $mol_crypto_auditor_sign_size);
|
1967
|
-
},
|
1968
|
-
async 'verify self signed with auto generated key'() {
|
1969
|
-
const auditor = await $$.$mol_crypto_auditor_pair();
|
1970
|
-
const data = new Uint8Array([1, 2, 3]);
|
1971
|
-
const sign = await auditor.private.sign(data);
|
1972
|
-
$mol_assert_ok(await auditor.public.verify(data, sign));
|
1973
|
-
},
|
1974
|
-
async 'verify signed with exported auto generated key'() {
|
1975
|
-
const pair = await $$.$mol_crypto_auditor_pair();
|
1976
|
-
const data = new Uint8Array([1, 2, 3]);
|
1977
|
-
const Alice = await $mol_crypto_auditor_private.from(await pair.private.serial());
|
1978
|
-
const sign = await Alice.sign(data);
|
1979
|
-
const Bob = await $mol_crypto_auditor_public.from(await pair.public.serial());
|
1980
|
-
$mol_assert_ok(await Bob.verify(data, sign));
|
1981
|
-
},
|
1982
|
-
});
|
1983
|
-
})($ || ($ = {}));
|
1984
|
-
//mol/crypto/auditor/auditor.test.ts
|
1985
|
-
;
|
1986
|
-
"use strict";
|
1987
|
-
var $;
|
1988
1959
|
(function ($) {
|
1989
1960
|
$mol_test({
|
1990
1961
|
'empty hash'() {
|