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