mol_db 0.0.158 → 0.0.162
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 +0 -255
- package/node.deps.json +1 -1
- package/node.esm.js +66 -66
- package/node.esm.js.map +1 -1
- package/node.js +66 -66
- package/node.js.map +1 -1
- package/node.test.js +292 -286
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/test.html +2 -2
- package/web.d.ts +0 -119
- package/web.deps.json +1 -1
- package/web.esm.js +34 -34
- package/web.esm.js.map +1 -1
- package/web.js +34 -34
- package/web.js.map +1 -1
- package/web.test.js +180 -174
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -19,16 +19,16 @@ var $;
|
|
|
19
19
|
(function ($) {
|
|
20
20
|
})($ || ($ = {}));
|
|
21
21
|
module.exports = $;
|
|
22
|
-
//mam.
|
|
22
|
+
//mam.ts
|
|
23
23
|
;
|
|
24
24
|
"use strict";
|
|
25
25
|
var $;
|
|
26
26
|
(function ($) {
|
|
27
27
|
})($ || ($ = {}));
|
|
28
|
-
//context.
|
|
28
|
+
//mol/dom/context/context.ts
|
|
29
29
|
;
|
|
30
30
|
"use strict";
|
|
31
|
-
//node.
|
|
31
|
+
//node/node.ts
|
|
32
32
|
;
|
|
33
33
|
"use strict";
|
|
34
34
|
var $node = new Proxy({ require }, {
|
|
@@ -67,14 +67,14 @@ var $node = new Proxy({ require }, {
|
|
|
67
67
|
require = (req => Object.assign(function require(name) {
|
|
68
68
|
return $node[name];
|
|
69
69
|
}, req))(require);
|
|
70
|
-
//node.node.
|
|
70
|
+
//node/node.node.ts
|
|
71
71
|
;
|
|
72
72
|
"use strict";
|
|
73
73
|
var $;
|
|
74
74
|
(function ($) {
|
|
75
75
|
$.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
|
|
76
76
|
})($ || ($ = {}));
|
|
77
|
-
//context.node.
|
|
77
|
+
//mol/dom/context/context.node.ts
|
|
78
78
|
;
|
|
79
79
|
"use strict";
|
|
80
80
|
var $;
|
|
@@ -87,7 +87,7 @@ var $;
|
|
|
87
87
|
}
|
|
88
88
|
$.$mol_db_response = $mol_db_response;
|
|
89
89
|
})($ || ($ = {}));
|
|
90
|
-
//response.
|
|
90
|
+
//mol/db/response/response.ts
|
|
91
91
|
;
|
|
92
92
|
"use strict";
|
|
93
93
|
var $;
|
|
@@ -96,16 +96,16 @@ var $;
|
|
|
96
96
|
const request = this.$mol_dom_context.indexedDB.open(name, migrations.length ? migrations.length + 1 : undefined);
|
|
97
97
|
request.onupgradeneeded = event => {
|
|
98
98
|
migrations.splice(0, event.oldVersion - 1);
|
|
99
|
-
const transaction = new
|
|
99
|
+
const transaction = new $mol_db_transaction(request.transaction);
|
|
100
100
|
for (const migrate of migrations)
|
|
101
101
|
migrate(transaction);
|
|
102
102
|
};
|
|
103
|
-
const db = await
|
|
104
|
-
return new
|
|
103
|
+
const db = await $mol_db_response(request);
|
|
104
|
+
return new $mol_db_database(db);
|
|
105
105
|
}
|
|
106
106
|
$.$mol_db = $mol_db;
|
|
107
107
|
})($ || ($ = {}));
|
|
108
|
-
//db.
|
|
108
|
+
//mol/db/db.ts
|
|
109
109
|
;
|
|
110
110
|
"use strict";
|
|
111
111
|
var $;
|
|
@@ -128,7 +128,7 @@ var $;
|
|
|
128
128
|
return new Proxy({}, {
|
|
129
129
|
ownKeys: () => [...this.native.indexNames],
|
|
130
130
|
has: (_, name) => this.native.indexNames.contains(name),
|
|
131
|
-
get: (_, name) => new
|
|
131
|
+
get: (_, name) => new $mol_db_index(this.native.index(name))
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
134
|
index_make(name, path = [], unique = false, multiEntry = false) {
|
|
@@ -139,46 +139,46 @@ var $;
|
|
|
139
139
|
return this;
|
|
140
140
|
}
|
|
141
141
|
get transaction() {
|
|
142
|
-
return new
|
|
142
|
+
return new $mol_db_transaction(this.native.transaction);
|
|
143
143
|
}
|
|
144
144
|
get db() {
|
|
145
145
|
return this.transaction.db;
|
|
146
146
|
}
|
|
147
147
|
clear() {
|
|
148
|
-
return
|
|
148
|
+
return $mol_db_response(this.native.clear());
|
|
149
149
|
}
|
|
150
150
|
count(keys) {
|
|
151
|
-
return
|
|
151
|
+
return $mol_db_response(this.native.count(keys));
|
|
152
152
|
}
|
|
153
153
|
put(doc, key) {
|
|
154
|
-
return
|
|
154
|
+
return $mol_db_response(this.native.put(doc, key));
|
|
155
155
|
}
|
|
156
156
|
get(key) {
|
|
157
|
-
return
|
|
157
|
+
return $mol_db_response(this.native.get(key));
|
|
158
158
|
}
|
|
159
159
|
select(key, count) {
|
|
160
|
-
return
|
|
160
|
+
return $mol_db_response(this.native.getAll(key, count));
|
|
161
161
|
}
|
|
162
162
|
drop(keys) {
|
|
163
|
-
return
|
|
163
|
+
return $mol_db_response(this.native.delete(keys));
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
$.$mol_db_store = $mol_db_store;
|
|
167
167
|
})($ || ($ = {}));
|
|
168
|
-
//store.
|
|
168
|
+
//mol/db/store/store.ts
|
|
169
169
|
;
|
|
170
170
|
"use strict";
|
|
171
|
-
//store_schema.
|
|
171
|
+
//mol/db/store/store_schema.ts
|
|
172
172
|
;
|
|
173
173
|
"use strict";
|
|
174
174
|
var $;
|
|
175
175
|
(function ($) {
|
|
176
|
-
|
|
176
|
+
$mol_dom_context.indexedDB = $node['fake-indexeddb'];
|
|
177
177
|
})($ || ($ = {}));
|
|
178
|
-
//db.node.
|
|
178
|
+
//mol/db/db.node.ts
|
|
179
179
|
;
|
|
180
180
|
"use strict";
|
|
181
|
-
//db_schema.
|
|
181
|
+
//mol/db/db_schema.ts
|
|
182
182
|
;
|
|
183
183
|
"use strict";
|
|
184
184
|
var $;
|
|
@@ -198,16 +198,16 @@ var $;
|
|
|
198
198
|
return [...this.native.objectStoreNames];
|
|
199
199
|
}
|
|
200
200
|
read(...names) {
|
|
201
|
-
return new
|
|
201
|
+
return new $mol_db_transaction(this.native.transaction(names, 'readonly')).stores;
|
|
202
202
|
}
|
|
203
203
|
change(...names) {
|
|
204
|
-
return new
|
|
204
|
+
return new $mol_db_transaction(this.native.transaction(names, 'readwrite'));
|
|
205
205
|
}
|
|
206
206
|
kill() {
|
|
207
207
|
this.native.close();
|
|
208
|
-
const request =
|
|
208
|
+
const request = $mol_dom_context.indexedDB.deleteDatabase(this.name);
|
|
209
209
|
request.onblocked = console.error;
|
|
210
|
-
return
|
|
210
|
+
return $mol_db_response(request).then(() => { });
|
|
211
211
|
}
|
|
212
212
|
destructor() {
|
|
213
213
|
this.native.close();
|
|
@@ -215,7 +215,7 @@ var $;
|
|
|
215
215
|
}
|
|
216
216
|
$.$mol_db_database = $mol_db_database;
|
|
217
217
|
})($ || ($ = {}));
|
|
218
|
-
//database.
|
|
218
|
+
//mol/db/database/database.ts
|
|
219
219
|
;
|
|
220
220
|
"use strict";
|
|
221
221
|
var $;
|
|
@@ -229,7 +229,7 @@ var $;
|
|
|
229
229
|
return new Proxy({}, {
|
|
230
230
|
ownKeys: () => [...this.native.objectStoreNames],
|
|
231
231
|
has: (_, name) => this.native.objectStoreNames.contains(name),
|
|
232
|
-
get: (_, name) => new
|
|
232
|
+
get: (_, name) => new $mol_db_store(this.native.objectStore(name)),
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
235
|
store_make(name) {
|
|
@@ -250,12 +250,12 @@ var $;
|
|
|
250
250
|
});
|
|
251
251
|
}
|
|
252
252
|
get db() {
|
|
253
|
-
return new
|
|
253
|
+
return new $mol_db_database(this.native.db);
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
$.$mol_db_transaction = $mol_db_transaction;
|
|
257
257
|
})($ || ($ = {}));
|
|
258
|
-
//transaction.
|
|
258
|
+
//mol/db/transaction/transaction.ts
|
|
259
259
|
;
|
|
260
260
|
"use strict";
|
|
261
261
|
var $;
|
|
@@ -278,7 +278,7 @@ var $;
|
|
|
278
278
|
return this.native.multiEntry;
|
|
279
279
|
}
|
|
280
280
|
get store() {
|
|
281
|
-
return new
|
|
281
|
+
return new $mol_db_store(this.native.objectStore);
|
|
282
282
|
}
|
|
283
283
|
get transaction() {
|
|
284
284
|
return this.store.transaction;
|
|
@@ -287,21 +287,21 @@ var $;
|
|
|
287
287
|
return this.store.db;
|
|
288
288
|
}
|
|
289
289
|
count(keys) {
|
|
290
|
-
return
|
|
290
|
+
return $mol_db_response(this.native.count(keys));
|
|
291
291
|
}
|
|
292
292
|
get(key) {
|
|
293
|
-
return
|
|
293
|
+
return $mol_db_response(this.native.get(key));
|
|
294
294
|
}
|
|
295
295
|
select(key, count) {
|
|
296
|
-
return
|
|
296
|
+
return $mol_db_response(this.native.getAll(key, count));
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
$.$mol_db_index = $mol_db_index;
|
|
300
300
|
})($ || ($ = {}));
|
|
301
|
-
//index.
|
|
301
|
+
//mol/db/index/index.ts
|
|
302
302
|
;
|
|
303
303
|
"use strict";
|
|
304
|
-
//index_schema.
|
|
304
|
+
//mol/db/index/index_schema.ts
|
|
305
305
|
;
|
|
306
306
|
"use strict";
|
|
307
307
|
var $;
|
|
@@ -325,7 +325,7 @@ var $;
|
|
|
325
325
|
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
326
326
|
$.$mol_log3_stack = [];
|
|
327
327
|
})($ || ($ = {}));
|
|
328
|
-
//log3.
|
|
328
|
+
//mol/log3/log3.ts
|
|
329
329
|
;
|
|
330
330
|
"use strict";
|
|
331
331
|
var $;
|
|
@@ -336,7 +336,7 @@ var $;
|
|
|
336
336
|
}
|
|
337
337
|
$.$mol_ambient = $mol_ambient;
|
|
338
338
|
})($ || ($ = {}));
|
|
339
|
-
//ambient.
|
|
339
|
+
//mol/ambient/ambient.ts
|
|
340
340
|
;
|
|
341
341
|
"use strict";
|
|
342
342
|
var $;
|
|
@@ -373,7 +373,7 @@ var $;
|
|
|
373
373
|
value: (obj) => instances.has(obj),
|
|
374
374
|
});
|
|
375
375
|
})($ || ($ = {}));
|
|
376
|
-
//delegate.
|
|
376
|
+
//mol/delegate/delegate.ts
|
|
377
377
|
;
|
|
378
378
|
"use strict";
|
|
379
379
|
var $;
|
|
@@ -385,7 +385,7 @@ var $;
|
|
|
385
385
|
return false;
|
|
386
386
|
if (typeof having !== 'object')
|
|
387
387
|
return false;
|
|
388
|
-
if (having instanceof
|
|
388
|
+
if (having instanceof $mol_delegate)
|
|
389
389
|
return false;
|
|
390
390
|
if (typeof having['destructor'] !== 'function')
|
|
391
391
|
return false;
|
|
@@ -429,7 +429,7 @@ var $;
|
|
|
429
429
|
}
|
|
430
430
|
$.$mol_owning_catch = $mol_owning_catch;
|
|
431
431
|
})($ || ($ = {}));
|
|
432
|
-
//owning.
|
|
432
|
+
//mol/owning/owning.ts
|
|
433
433
|
;
|
|
434
434
|
"use strict";
|
|
435
435
|
var $;
|
|
@@ -439,7 +439,7 @@ var $;
|
|
|
439
439
|
}
|
|
440
440
|
$.$mol_fail = $mol_fail;
|
|
441
441
|
})($ || ($ = {}));
|
|
442
|
-
//fail.
|
|
442
|
+
//mol/fail/fail.ts
|
|
443
443
|
;
|
|
444
444
|
"use strict";
|
|
445
445
|
var $;
|
|
@@ -449,27 +449,27 @@ var $;
|
|
|
449
449
|
}
|
|
450
450
|
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
451
451
|
})($ || ($ = {}));
|
|
452
|
-
//hidden.
|
|
452
|
+
//mol/fail/hidden/hidden.ts
|
|
453
453
|
;
|
|
454
454
|
"use strict";
|
|
455
|
-
//writable.
|
|
455
|
+
//mol/type/writable/writable.ts
|
|
456
456
|
;
|
|
457
457
|
"use strict";
|
|
458
458
|
var $;
|
|
459
459
|
(function ($) {
|
|
460
460
|
class $mol_object2 {
|
|
461
461
|
static $ = $;
|
|
462
|
-
[
|
|
462
|
+
[$mol_ambient_ref] = null;
|
|
463
463
|
get $() {
|
|
464
|
-
if (this[
|
|
465
|
-
return this[
|
|
466
|
-
const owner =
|
|
467
|
-
return this[
|
|
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.$;
|
|
468
468
|
}
|
|
469
469
|
set $(next) {
|
|
470
|
-
if (this[
|
|
471
|
-
|
|
472
|
-
this[
|
|
470
|
+
if (this[$mol_ambient_ref])
|
|
471
|
+
$mol_fail_hidden(new Error('Context already defined'));
|
|
472
|
+
this[$mol_ambient_ref] = next;
|
|
473
473
|
}
|
|
474
474
|
static create(init) {
|
|
475
475
|
const obj = new this;
|
|
@@ -495,7 +495,7 @@ var $;
|
|
|
495
495
|
}
|
|
496
496
|
$.$mol_object2 = $mol_object2;
|
|
497
497
|
})($ || ($ = {}));
|
|
498
|
-
//object2.
|
|
498
|
+
//mol/object2/object2.ts
|
|
499
499
|
;
|
|
500
500
|
"use strict";
|
|
501
501
|
var $;
|
|
@@ -506,7 +506,7 @@ var $;
|
|
|
506
506
|
let warned = false;
|
|
507
507
|
descr.value = function $mol_deprecated_wrapper(...args) {
|
|
508
508
|
if (!warned) {
|
|
509
|
-
|
|
509
|
+
$$.$mol_log3_warn({
|
|
510
510
|
place: `${host.constructor.name}::${field}`,
|
|
511
511
|
message: `Deprecated`,
|
|
512
512
|
hint: message,
|
|
@@ -519,13 +519,13 @@ var $;
|
|
|
519
519
|
}
|
|
520
520
|
$.$mol_deprecated = $mol_deprecated;
|
|
521
521
|
})($ || ($ = {}));
|
|
522
|
-
//deprecated.
|
|
522
|
+
//mol/deprecated/deprecated.ts
|
|
523
523
|
;
|
|
524
524
|
"use strict";
|
|
525
525
|
var $;
|
|
526
526
|
(function ($) {
|
|
527
527
|
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
528
|
-
class $mol_tree extends
|
|
528
|
+
class $mol_tree extends $mol_object2 {
|
|
529
529
|
type;
|
|
530
530
|
data;
|
|
531
531
|
sub;
|
|
@@ -838,7 +838,7 @@ var $;
|
|
|
838
838
|
const sub = [].concat(...this.sub.map(child => {
|
|
839
839
|
const handle = context[child.type] || context[''];
|
|
840
840
|
if (!handle)
|
|
841
|
-
|
|
841
|
+
$mol_fail(child.error('Handler not defined'));
|
|
842
842
|
return handle(child, context);
|
|
843
843
|
}));
|
|
844
844
|
return this.clone({ sub });
|
|
@@ -848,11 +848,11 @@ var $;
|
|
|
848
848
|
}
|
|
849
849
|
}
|
|
850
850
|
__decorate([
|
|
851
|
-
|
|
851
|
+
$mol_deprecated('Use $mol_tree:hack')
|
|
852
852
|
], $mol_tree.prototype, "transform", null);
|
|
853
853
|
$.$mol_tree = $mol_tree;
|
|
854
854
|
})($ || ($ = {}));
|
|
855
|
-
//tree.
|
|
855
|
+
//mol/tree/tree.ts
|
|
856
856
|
;
|
|
857
857
|
"use strict";
|
|
858
858
|
var $;
|
|
@@ -880,7 +880,7 @@ var $;
|
|
|
880
880
|
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', 'magenta');
|
|
881
881
|
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', 'cyan');
|
|
882
882
|
})($ || ($ = {}));
|
|
883
|
-
//log3.node.
|
|
883
|
+
//mol/log3/log3.node.ts
|
|
884
884
|
;
|
|
885
885
|
"use strict";
|
|
886
886
|
var $;
|
|
@@ -890,7 +890,7 @@ var $;
|
|
|
890
890
|
}
|
|
891
891
|
$.$mol_env = $mol_env;
|
|
892
892
|
})($ || ($ = {}));
|
|
893
|
-
//env.
|
|
893
|
+
//mol/env/env.ts
|
|
894
894
|
;
|
|
895
895
|
"use strict";
|
|
896
896
|
var $;
|
|
@@ -899,7 +899,7 @@ var $;
|
|
|
899
899
|
return this.process.env;
|
|
900
900
|
};
|
|
901
901
|
})($ || ($ = {}));
|
|
902
|
-
//env.node.
|
|
902
|
+
//mol/env/env.node.ts
|
|
903
903
|
;
|
|
904
904
|
"use strict";
|
|
905
905
|
var $;
|
|
@@ -919,14 +919,14 @@ var $;
|
|
|
919
919
|
env: this.$mol_env(),
|
|
920
920
|
});
|
|
921
921
|
if (res.status || res.error)
|
|
922
|
-
return
|
|
922
|
+
return $mol_fail(res.error || new Error(res.stderr.toString()));
|
|
923
923
|
if (!res.stdout)
|
|
924
924
|
res.stdout = Buffer.from([]);
|
|
925
925
|
return res;
|
|
926
926
|
}
|
|
927
927
|
$.$mol_exec = $mol_exec;
|
|
928
928
|
})($ || ($ = {}));
|
|
929
|
-
//exec.node.
|
|
929
|
+
//mol/exec/exec.node.ts
|
|
930
930
|
;
|
|
931
931
|
"use strict";
|
|
932
932
|
var $;
|
|
@@ -936,7 +936,7 @@ var $;
|
|
|
936
936
|
}
|
|
937
937
|
$.$mol_test_complete = $mol_test_complete;
|
|
938
938
|
})($ || ($ = {}));
|
|
939
|
-
//test.node.test.
|
|
939
|
+
//mol/test/test.node.test.ts
|
|
940
940
|
;
|
|
941
941
|
"use strict";
|
|
942
942
|
var $;
|
|
@@ -954,12 +954,18 @@ var $;
|
|
|
954
954
|
$_1.$mol_test_all = [];
|
|
955
955
|
async function $mol_test_run() {
|
|
956
956
|
for (var test of $_1.$mol_test_all) {
|
|
957
|
-
let context = Object.create(
|
|
957
|
+
let context = Object.create($$);
|
|
958
958
|
for (let mock of $_1.$mol_test_mocks)
|
|
959
959
|
await mock(context);
|
|
960
|
-
|
|
960
|
+
const res = test(context);
|
|
961
|
+
if (res instanceof Promise) {
|
|
962
|
+
await new Promise((done, fail) => {
|
|
963
|
+
res.then(done, fail);
|
|
964
|
+
setTimeout(() => fail(new Error('Test timeout: ' + test.name)), 1000);
|
|
965
|
+
});
|
|
966
|
+
}
|
|
961
967
|
}
|
|
962
|
-
|
|
968
|
+
$$.$mol_log3_done({
|
|
963
969
|
place: '$mol_test',
|
|
964
970
|
message: 'All tests passed',
|
|
965
971
|
count: $_1.$mol_test_all.length,
|
|
@@ -977,7 +983,7 @@ var $;
|
|
|
977
983
|
await $mol_test_run();
|
|
978
984
|
}
|
|
979
985
|
finally {
|
|
980
|
-
|
|
986
|
+
$$.$mol_test_complete();
|
|
981
987
|
}
|
|
982
988
|
}, 0);
|
|
983
989
|
}
|
|
@@ -990,10 +996,10 @@ var $;
|
|
|
990
996
|
for (let api of forbidden) {
|
|
991
997
|
context[api] = new Proxy(function () { }, {
|
|
992
998
|
get() {
|
|
993
|
-
$
|
|
999
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
994
1000
|
},
|
|
995
1001
|
apply() {
|
|
996
|
-
$
|
|
1002
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
997
1003
|
},
|
|
998
1004
|
});
|
|
999
1005
|
}
|
|
@@ -1021,7 +1027,7 @@ var $;
|
|
|
1021
1027
|
},
|
|
1022
1028
|
});
|
|
1023
1029
|
})($ || ($ = {}));
|
|
1024
|
-
//test.test.
|
|
1030
|
+
//mol/test/test.test.ts
|
|
1025
1031
|
;
|
|
1026
1032
|
"use strict";
|
|
1027
1033
|
var $;
|
|
@@ -1032,7 +1038,7 @@ var $;
|
|
|
1032
1038
|
for (let view of childNodes) {
|
|
1033
1039
|
if (view == null)
|
|
1034
1040
|
continue;
|
|
1035
|
-
if (view instanceof
|
|
1041
|
+
if (view instanceof $mol_dom_context.Node) {
|
|
1036
1042
|
while (true) {
|
|
1037
1043
|
if (!nextNode) {
|
|
1038
1044
|
el.appendChild(view);
|
|
@@ -1063,7 +1069,7 @@ var $;
|
|
|
1063
1069
|
nextNode = nextNode.nextSibling;
|
|
1064
1070
|
}
|
|
1065
1071
|
else {
|
|
1066
|
-
const textNode =
|
|
1072
|
+
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
|
1067
1073
|
el.insertBefore(textNode, nextNode);
|
|
1068
1074
|
}
|
|
1069
1075
|
}
|
|
@@ -1076,88 +1082,88 @@ var $;
|
|
|
1076
1082
|
}
|
|
1077
1083
|
$.$mol_dom_render_children = $mol_dom_render_children;
|
|
1078
1084
|
})($ || ($ = {}));
|
|
1079
|
-
//children.
|
|
1085
|
+
//mol/dom/render/children/children.ts
|
|
1080
1086
|
;
|
|
1081
1087
|
"use strict";
|
|
1082
|
-
//error.
|
|
1088
|
+
//mol/type/error/error.ts
|
|
1083
1089
|
;
|
|
1084
1090
|
"use strict";
|
|
1085
|
-
//assert.test.
|
|
1091
|
+
//mol/type/assert/assert.test.ts
|
|
1086
1092
|
;
|
|
1087
1093
|
"use strict";
|
|
1088
|
-
//assert.
|
|
1094
|
+
//mol/type/assert/assert.ts
|
|
1089
1095
|
;
|
|
1090
1096
|
"use strict";
|
|
1091
|
-
//deep.test.
|
|
1097
|
+
//mol/type/partial/deep/deep.test.ts
|
|
1092
1098
|
;
|
|
1093
1099
|
"use strict";
|
|
1094
|
-
//deep.
|
|
1100
|
+
//mol/type/partial/deep/deep.ts
|
|
1095
1101
|
;
|
|
1096
1102
|
"use strict";
|
|
1097
1103
|
var $;
|
|
1098
1104
|
(function ($) {
|
|
1099
|
-
|
|
1105
|
+
$mol_test({
|
|
1100
1106
|
'Make empty div'() {
|
|
1101
|
-
|
|
1107
|
+
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
|
1102
1108
|
},
|
|
1103
1109
|
'Define native field'() {
|
|
1104
|
-
const dom =
|
|
1105
|
-
|
|
1106
|
-
|
|
1110
|
+
const dom = $mol_jsx("input", { value: '123' });
|
|
1111
|
+
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
1112
|
+
$mol_assert_equal(dom.value, '123');
|
|
1107
1113
|
},
|
|
1108
1114
|
'Define classes'() {
|
|
1109
|
-
const dom =
|
|
1110
|
-
|
|
1115
|
+
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
1116
|
+
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
1111
1117
|
},
|
|
1112
1118
|
'Define styles'() {
|
|
1113
|
-
const dom =
|
|
1114
|
-
|
|
1119
|
+
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
1120
|
+
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
1115
1121
|
},
|
|
1116
1122
|
'Define dataset'() {
|
|
1117
|
-
const dom =
|
|
1118
|
-
|
|
1123
|
+
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
1124
|
+
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
1119
1125
|
},
|
|
1120
1126
|
'Define attributes'() {
|
|
1121
|
-
const dom =
|
|
1122
|
-
|
|
1127
|
+
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
1128
|
+
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
1123
1129
|
},
|
|
1124
1130
|
'Define child nodes'() {
|
|
1125
|
-
const dom =
|
|
1131
|
+
const dom = $mol_jsx("div", null,
|
|
1126
1132
|
"hello",
|
|
1127
|
-
|
|
1133
|
+
$mol_jsx("strong", null, "world"),
|
|
1128
1134
|
"!");
|
|
1129
|
-
|
|
1135
|
+
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
1130
1136
|
},
|
|
1131
1137
|
'Function as component'() {
|
|
1132
1138
|
const Button = ({ hint }, target) => {
|
|
1133
|
-
return
|
|
1139
|
+
return $mol_jsx("button", { title: hint }, target());
|
|
1134
1140
|
};
|
|
1135
|
-
const dom =
|
|
1136
|
-
|
|
1141
|
+
const dom = $mol_jsx(Button, { id: "/foo", hint: "click me" }, () => 'hey!');
|
|
1142
|
+
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="/foo">hey!</button>');
|
|
1137
1143
|
},
|
|
1138
1144
|
'Nested guid generation'() {
|
|
1139
1145
|
const Foo = () => {
|
|
1140
|
-
return
|
|
1141
|
-
|
|
1142
|
-
|
|
1146
|
+
return $mol_jsx("div", null,
|
|
1147
|
+
$mol_jsx(Bar, { id: "/bar" },
|
|
1148
|
+
$mol_jsx("img", { id: "/icon" })));
|
|
1143
1149
|
};
|
|
1144
1150
|
const Bar = (props, icon) => {
|
|
1145
|
-
return
|
|
1151
|
+
return $mol_jsx("span", null, icon);
|
|
1146
1152
|
};
|
|
1147
|
-
const dom =
|
|
1148
|
-
|
|
1153
|
+
const dom = $mol_jsx(Foo, { id: "/foo" });
|
|
1154
|
+
$mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
|
|
1149
1155
|
},
|
|
1150
1156
|
'Fail on non unique ids'() {
|
|
1151
1157
|
const App = () => {
|
|
1152
|
-
return
|
|
1153
|
-
|
|
1154
|
-
|
|
1158
|
+
return $mol_jsx("div", null,
|
|
1159
|
+
$mol_jsx("span", { id: "/bar" }),
|
|
1160
|
+
$mol_jsx("span", { id: "/bar" }));
|
|
1155
1161
|
};
|
|
1156
|
-
|
|
1162
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
|
|
1157
1163
|
},
|
|
1158
1164
|
});
|
|
1159
1165
|
})($ || ($ = {}));
|
|
1160
|
-
//jsx.test.
|
|
1166
|
+
//mol/jsx/jsx.test.tsx
|
|
1161
1167
|
;
|
|
1162
1168
|
"use strict";
|
|
1163
1169
|
var $;
|
|
@@ -1166,15 +1172,15 @@ var $;
|
|
|
1166
1172
|
$.$mol_jsx_booked = null;
|
|
1167
1173
|
$.$mol_jsx_document = {
|
|
1168
1174
|
getElementById: () => null,
|
|
1169
|
-
createElementNS: (space, name) =>
|
|
1170
|
-
createDocumentFragment: () =>
|
|
1175
|
+
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
|
1176
|
+
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
1171
1177
|
};
|
|
1172
1178
|
$.$mol_jsx_frag = '';
|
|
1173
1179
|
function $mol_jsx(Elem, props, ...childNodes) {
|
|
1174
1180
|
const id = props && props.id || '';
|
|
1175
1181
|
if (Elem && $.$mol_jsx_booked) {
|
|
1176
1182
|
if ($.$mol_jsx_booked.has(id)) {
|
|
1177
|
-
|
|
1183
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
|
|
1178
1184
|
}
|
|
1179
1185
|
else {
|
|
1180
1186
|
$.$mol_jsx_booked.add(id);
|
|
@@ -1213,7 +1219,7 @@ var $;
|
|
|
1213
1219
|
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
1214
1220
|
: $.$mol_jsx_document.createDocumentFragment();
|
|
1215
1221
|
}
|
|
1216
|
-
|
|
1222
|
+
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
1217
1223
|
if (!Elem)
|
|
1218
1224
|
return node;
|
|
1219
1225
|
for (const key in props) {
|
|
@@ -1239,77 +1245,77 @@ var $;
|
|
|
1239
1245
|
}
|
|
1240
1246
|
$.$mol_jsx = $mol_jsx;
|
|
1241
1247
|
})($ || ($ = {}));
|
|
1242
|
-
//jsx.
|
|
1248
|
+
//mol/jsx/jsx.ts
|
|
1243
1249
|
;
|
|
1244
1250
|
"use strict";
|
|
1245
1251
|
var $;
|
|
1246
1252
|
(function ($) {
|
|
1247
|
-
|
|
1253
|
+
$mol_test({
|
|
1248
1254
|
'nulls & undefineds'() {
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1255
|
+
$mol_assert_ok($mol_compare_deep(null, null));
|
|
1256
|
+
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
1257
|
+
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
1258
|
+
$mol_assert_not($mol_compare_deep({}, null));
|
|
1253
1259
|
},
|
|
1254
1260
|
'number'() {
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1261
|
+
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
1262
|
+
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
1263
|
+
$mol_assert_not($mol_compare_deep(1, 2));
|
|
1264
|
+
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
1265
|
+
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
1260
1266
|
},
|
|
1261
1267
|
'POJO'() {
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
+
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
1269
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
1270
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
1271
|
+
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
1272
|
+
$mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
1273
|
+
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
1268
1274
|
},
|
|
1269
1275
|
'Array'() {
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1276
|
+
$mol_assert_ok($mol_compare_deep([], []));
|
|
1277
|
+
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
1278
|
+
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
1279
|
+
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
1274
1280
|
},
|
|
1275
1281
|
'Non POJO are different'() {
|
|
1276
1282
|
class Thing extends Object {
|
|
1277
1283
|
}
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1284
|
+
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
1285
|
+
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
1286
|
+
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
1281
1287
|
},
|
|
1282
1288
|
'same POJOs with cyclic reference'() {
|
|
1283
1289
|
const a = { foo: {} };
|
|
1284
1290
|
a['self'] = a;
|
|
1285
1291
|
const b = { foo: {} };
|
|
1286
1292
|
b['self'] = b;
|
|
1287
|
-
|
|
1293
|
+
$mol_assert_ok($mol_compare_deep(a, b));
|
|
1288
1294
|
},
|
|
1289
1295
|
'Date'() {
|
|
1290
|
-
|
|
1291
|
-
|
|
1296
|
+
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
1297
|
+
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
1292
1298
|
},
|
|
1293
1299
|
'RegExp'() {
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1300
|
+
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
1301
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
1302
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
1297
1303
|
},
|
|
1298
1304
|
'Map'() {
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1305
|
+
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
1306
|
+
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
1307
|
+
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
1308
|
+
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
1303
1309
|
},
|
|
1304
1310
|
'Set'() {
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1311
|
+
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
1312
|
+
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
1313
|
+
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
1308
1314
|
},
|
|
1309
1315
|
'Uint8Array'() {
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1316
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
1317
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
1318
|
+
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
1313
1319
|
},
|
|
1314
1320
|
'Custom comparator'() {
|
|
1315
1321
|
class User {
|
|
@@ -1323,17 +1329,17 @@ var $;
|
|
|
1323
1329
|
return this.name;
|
|
1324
1330
|
}
|
|
1325
1331
|
}
|
|
1326
|
-
|
|
1327
|
-
|
|
1332
|
+
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
1333
|
+
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
1328
1334
|
},
|
|
1329
1335
|
});
|
|
1330
1336
|
})($ || ($ = {}));
|
|
1331
|
-
//deep.test.
|
|
1337
|
+
//mol/compare/deep/deep.test.tsx
|
|
1332
1338
|
;
|
|
1333
1339
|
"use strict";
|
|
1334
1340
|
var $;
|
|
1335
1341
|
(function ($) {
|
|
1336
|
-
|
|
1342
|
+
$.$mol_compare_deep_cache = new WeakMap();
|
|
1337
1343
|
function $mol_compare_deep(left, right) {
|
|
1338
1344
|
if (Object.is(left, right))
|
|
1339
1345
|
return true;
|
|
@@ -1359,7 +1365,7 @@ var $;
|
|
|
1359
1365
|
return Object.is(left.valueOf(), right['valueOf']());
|
|
1360
1366
|
if (left instanceof RegExp)
|
|
1361
1367
|
return left.source === right['source'] && left.flags === right['flags'];
|
|
1362
|
-
let left_cache =
|
|
1368
|
+
let left_cache = $.$mol_compare_deep_cache.get(left);
|
|
1363
1369
|
if (left_cache) {
|
|
1364
1370
|
const right_cache = left_cache.get(right);
|
|
1365
1371
|
if (typeof right_cache === 'boolean')
|
|
@@ -1367,7 +1373,7 @@ var $;
|
|
|
1367
1373
|
}
|
|
1368
1374
|
else {
|
|
1369
1375
|
left_cache = new WeakMap([[right, true]]);
|
|
1370
|
-
|
|
1376
|
+
$.$mol_compare_deep_cache.set(left, left_cache);
|
|
1371
1377
|
}
|
|
1372
1378
|
let result;
|
|
1373
1379
|
try {
|
|
@@ -1451,50 +1457,50 @@ var $;
|
|
|
1451
1457
|
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
1452
1458
|
}
|
|
1453
1459
|
})($ || ($ = {}));
|
|
1454
|
-
//deep.
|
|
1460
|
+
//mol/compare/deep/deep.ts
|
|
1455
1461
|
;
|
|
1456
1462
|
"use strict";
|
|
1457
1463
|
var $;
|
|
1458
1464
|
(function ($) {
|
|
1459
1465
|
function $mol_dom_serialize(node) {
|
|
1460
|
-
const serializer = new
|
|
1466
|
+
const serializer = new $mol_dom_context.XMLSerializer;
|
|
1461
1467
|
return serializer.serializeToString(node);
|
|
1462
1468
|
}
|
|
1463
1469
|
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
1464
1470
|
})($ || ($ = {}));
|
|
1465
|
-
//serialize.
|
|
1471
|
+
//mol/dom/serialize/serialize.ts
|
|
1466
1472
|
;
|
|
1467
1473
|
"use strict";
|
|
1468
1474
|
var $;
|
|
1469
1475
|
(function ($) {
|
|
1470
|
-
|
|
1476
|
+
$mol_test({
|
|
1471
1477
|
'must be false'() {
|
|
1472
|
-
|
|
1478
|
+
$mol_assert_not(0);
|
|
1473
1479
|
},
|
|
1474
1480
|
'must be true'() {
|
|
1475
|
-
|
|
1481
|
+
$mol_assert_ok(1);
|
|
1476
1482
|
},
|
|
1477
1483
|
'two must be equal'() {
|
|
1478
|
-
|
|
1484
|
+
$mol_assert_equal(2, 2);
|
|
1479
1485
|
},
|
|
1480
1486
|
'three must be equal'() {
|
|
1481
|
-
|
|
1487
|
+
$mol_assert_equal(2, 2, 2);
|
|
1482
1488
|
},
|
|
1483
1489
|
'two must be unique'() {
|
|
1484
|
-
|
|
1490
|
+
$mol_assert_unique([3], [3]);
|
|
1485
1491
|
},
|
|
1486
1492
|
'three must be unique'() {
|
|
1487
|
-
|
|
1493
|
+
$mol_assert_unique([3], [3], [3]);
|
|
1488
1494
|
},
|
|
1489
1495
|
'two must be alike'() {
|
|
1490
|
-
|
|
1496
|
+
$mol_assert_like([3], [3]);
|
|
1491
1497
|
},
|
|
1492
1498
|
'three must be alike'() {
|
|
1493
|
-
|
|
1499
|
+
$mol_assert_like([3], [3], [3]);
|
|
1494
1500
|
},
|
|
1495
1501
|
});
|
|
1496
1502
|
})($ || ($ = {}));
|
|
1497
|
-
//assert.test.
|
|
1503
|
+
//mol/assert/assert.test.ts
|
|
1498
1504
|
;
|
|
1499
1505
|
"use strict";
|
|
1500
1506
|
var $;
|
|
@@ -1502,13 +1508,13 @@ var $;
|
|
|
1502
1508
|
function $mol_assert_ok(value) {
|
|
1503
1509
|
if (value)
|
|
1504
1510
|
return;
|
|
1505
|
-
|
|
1511
|
+
$mol_fail(new Error(`${value} ≠ true`));
|
|
1506
1512
|
}
|
|
1507
1513
|
$.$mol_assert_ok = $mol_assert_ok;
|
|
1508
1514
|
function $mol_assert_not(value) {
|
|
1509
1515
|
if (!value)
|
|
1510
1516
|
return;
|
|
1511
|
-
|
|
1517
|
+
$mol_fail(new Error(`${value} ≠ false`));
|
|
1512
1518
|
}
|
|
1513
1519
|
$.$mol_assert_not = $mol_assert_not;
|
|
1514
1520
|
function $mol_assert_fail(handler, ErrorRight) {
|
|
@@ -1532,7 +1538,7 @@ var $;
|
|
|
1532
1538
|
finally {
|
|
1533
1539
|
$.$mol_fail = fail;
|
|
1534
1540
|
}
|
|
1535
|
-
|
|
1541
|
+
$mol_fail(new Error('Not failed'));
|
|
1536
1542
|
}
|
|
1537
1543
|
$.$mol_assert_fail = $mol_assert_fail;
|
|
1538
1544
|
function $mol_assert_equal(...args) {
|
|
@@ -1543,7 +1549,7 @@ var $;
|
|
|
1543
1549
|
if (Number.isNaN(args[i]) && Number.isNaN(args[j]))
|
|
1544
1550
|
continue;
|
|
1545
1551
|
if (args[i] !== args[j])
|
|
1546
|
-
|
|
1552
|
+
$mol_fail(new Error(`Not equal (${i + 1}:${j + 1})\n${args[i]}\n${args[j]}`));
|
|
1547
1553
|
}
|
|
1548
1554
|
}
|
|
1549
1555
|
}
|
|
@@ -1554,7 +1560,7 @@ var $;
|
|
|
1554
1560
|
if (i === j)
|
|
1555
1561
|
continue;
|
|
1556
1562
|
if (args[i] === args[j] || (Number.isNaN(args[i]) && Number.isNaN(args[j]))) {
|
|
1557
|
-
|
|
1563
|
+
$mol_fail(new Error(`args[${i}] = args[${j}] = ${args[i]}`));
|
|
1558
1564
|
}
|
|
1559
1565
|
}
|
|
1560
1566
|
}
|
|
@@ -1562,7 +1568,7 @@ var $;
|
|
|
1562
1568
|
$.$mol_assert_unique = $mol_assert_unique;
|
|
1563
1569
|
function $mol_assert_like(head, ...tail) {
|
|
1564
1570
|
for (let [index, value] of Object.entries(tail)) {
|
|
1565
|
-
if (
|
|
1571
|
+
if (!$mol_compare_deep(value, head)) {
|
|
1566
1572
|
const print = (val) => {
|
|
1567
1573
|
if (!val)
|
|
1568
1574
|
return val;
|
|
@@ -1578,41 +1584,41 @@ var $;
|
|
|
1578
1584
|
return val;
|
|
1579
1585
|
}
|
|
1580
1586
|
};
|
|
1581
|
-
return
|
|
1587
|
+
return $mol_fail(new Error(`Not like (1:${+index + 2})\n${print(head)}\n---\n${print(value)}`));
|
|
1582
1588
|
}
|
|
1583
1589
|
}
|
|
1584
1590
|
}
|
|
1585
1591
|
$.$mol_assert_like = $mol_assert_like;
|
|
1586
1592
|
function $mol_assert_dom(left, right) {
|
|
1587
|
-
$mol_assert_equal(
|
|
1593
|
+
$mol_assert_equal($mol_dom_serialize(left), $mol_dom_serialize(right));
|
|
1588
1594
|
}
|
|
1589
1595
|
$.$mol_assert_dom = $mol_assert_dom;
|
|
1590
1596
|
})($ || ($ = {}));
|
|
1591
|
-
//assert.
|
|
1597
|
+
//mol/assert/assert.ts
|
|
1592
1598
|
;
|
|
1593
1599
|
"use strict";
|
|
1594
1600
|
var $;
|
|
1595
1601
|
(function ($) {
|
|
1596
|
-
|
|
1602
|
+
$mol_test({
|
|
1597
1603
|
async 'put, get, drop, count records and clear store'() {
|
|
1598
|
-
const db = await
|
|
1604
|
+
const db = await $$.$mol_db('$mol_db_test', mig => mig.store_make('letters'));
|
|
1599
1605
|
const trans = db.change('letters');
|
|
1600
1606
|
try {
|
|
1601
1607
|
const { letters } = trans.stores;
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1608
|
+
$mol_assert_like(await letters.get(1), undefined);
|
|
1609
|
+
$mol_assert_like(await letters.get(2), undefined);
|
|
1610
|
+
$mol_assert_like(await letters.count(), 0);
|
|
1605
1611
|
await letters.put('a');
|
|
1606
1612
|
await letters.put('b', 1);
|
|
1607
1613
|
await letters.put('c', 2);
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1614
|
+
$mol_assert_like(await letters.get(1), 'b');
|
|
1615
|
+
$mol_assert_like(await letters.get(2), 'c');
|
|
1616
|
+
$mol_assert_like(await letters.count(), 2);
|
|
1611
1617
|
await letters.drop(1);
|
|
1612
|
-
|
|
1613
|
-
|
|
1618
|
+
$mol_assert_like(await letters.get(1), undefined);
|
|
1619
|
+
$mol_assert_like(await letters.count(), 1);
|
|
1614
1620
|
await letters.clear();
|
|
1615
|
-
|
|
1621
|
+
$mol_assert_like(await letters.count(), 0);
|
|
1616
1622
|
}
|
|
1617
1623
|
finally {
|
|
1618
1624
|
trans.abort();
|
|
@@ -1620,7 +1626,7 @@ var $;
|
|
|
1620
1626
|
}
|
|
1621
1627
|
},
|
|
1622
1628
|
async 'select by query'() {
|
|
1623
|
-
const db = await
|
|
1629
|
+
const db = await $$.$mol_db('$mol_db_test', mig => mig.store_make('letters'));
|
|
1624
1630
|
const trans = db.change('letters');
|
|
1625
1631
|
try {
|
|
1626
1632
|
const { letters } = trans.stores;
|
|
@@ -1628,9 +1634,9 @@ var $;
|
|
|
1628
1634
|
await letters.put('b');
|
|
1629
1635
|
await letters.put('c');
|
|
1630
1636
|
await letters.put('d');
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1637
|
+
$mol_assert_like(await letters.select(), ['a', 'b', 'c', 'd']);
|
|
1638
|
+
$mol_assert_like(await letters.select(null, 2), ['a', 'b']);
|
|
1639
|
+
$mol_assert_like(await letters.select(IDBKeyRange.bound(2, 3)), ['b', 'c']);
|
|
1634
1640
|
}
|
|
1635
1641
|
finally {
|
|
1636
1642
|
trans.abort();
|
|
@@ -1639,40 +1645,40 @@ var $;
|
|
|
1639
1645
|
},
|
|
1640
1646
|
});
|
|
1641
1647
|
})($ || ($ = {}));
|
|
1642
|
-
//store.test.
|
|
1648
|
+
//mol/db/store/store.test.ts
|
|
1643
1649
|
;
|
|
1644
1650
|
"use strict";
|
|
1645
1651
|
var $;
|
|
1646
1652
|
(function ($) {
|
|
1647
|
-
|
|
1653
|
+
$mol_test({
|
|
1648
1654
|
async 'take and drop db'() {
|
|
1649
|
-
const db = await
|
|
1655
|
+
const db = await $$.$mol_db('$mol_db_test');
|
|
1650
1656
|
await db.kill();
|
|
1651
1657
|
},
|
|
1652
1658
|
async 'make and drop store in separate migrations'() {
|
|
1653
1659
|
try {
|
|
1654
|
-
const db1 = await
|
|
1660
|
+
const db1 = await $$.$mol_db('$mol_db_test', mig => mig.store_make('temp'));
|
|
1655
1661
|
db1.destructor();
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
const db2 = await
|
|
1662
|
+
$mol_assert_like(db1.stores, ['temp']);
|
|
1663
|
+
$mol_assert_like(db1.version, 2);
|
|
1664
|
+
const db2 = await $$.$mol_db('$mol_db_test', mig => mig.store_make('temp'), mig => mig.store_drop('temp'));
|
|
1659
1665
|
db2.destructor();
|
|
1660
|
-
|
|
1661
|
-
|
|
1666
|
+
$mol_assert_like(db2.stores, []);
|
|
1667
|
+
$mol_assert_like(db2.version, 3);
|
|
1662
1668
|
}
|
|
1663
1669
|
finally {
|
|
1664
|
-
const db0 = await
|
|
1670
|
+
const db0 = await $$.$mol_db('$mol_db_test');
|
|
1665
1671
|
await db0.kill();
|
|
1666
1672
|
}
|
|
1667
1673
|
},
|
|
1668
1674
|
});
|
|
1669
1675
|
})($ || ($ = {}));
|
|
1670
|
-
//db.test.
|
|
1676
|
+
//mol/db/db.test.ts
|
|
1671
1677
|
;
|
|
1672
1678
|
"use strict";
|
|
1673
1679
|
var $;
|
|
1674
1680
|
(function ($_1) {
|
|
1675
|
-
$
|
|
1681
|
+
$mol_test_mocks.push($ => {
|
|
1676
1682
|
$.$mol_log3_come = () => { };
|
|
1677
1683
|
$.$mol_log3_done = () => { };
|
|
1678
1684
|
$.$mol_log3_fail = () => { };
|
|
@@ -1681,29 +1687,29 @@ var $;
|
|
|
1681
1687
|
$.$mol_log3_area = () => () => { };
|
|
1682
1688
|
});
|
|
1683
1689
|
})($ || ($ = {}));
|
|
1684
|
-
//log3.test.
|
|
1690
|
+
//mol/log3/log3.test.ts
|
|
1685
1691
|
;
|
|
1686
1692
|
"use strict";
|
|
1687
1693
|
var $;
|
|
1688
1694
|
(function ($) {
|
|
1689
|
-
|
|
1695
|
+
$mol_test({
|
|
1690
1696
|
'get'() {
|
|
1691
|
-
const proxy =
|
|
1692
|
-
|
|
1697
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1698
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
1693
1699
|
},
|
|
1694
1700
|
'has'() {
|
|
1695
|
-
const proxy =
|
|
1696
|
-
|
|
1701
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1702
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
1697
1703
|
},
|
|
1698
1704
|
'set'() {
|
|
1699
1705
|
const target = { foo: 777 };
|
|
1700
|
-
const proxy =
|
|
1706
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1701
1707
|
proxy.foo = 123;
|
|
1702
|
-
|
|
1708
|
+
$mol_assert_equal(target.foo, 123);
|
|
1703
1709
|
},
|
|
1704
1710
|
'getOwnPropertyDescriptor'() {
|
|
1705
|
-
const proxy =
|
|
1706
|
-
|
|
1711
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1712
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1707
1713
|
value: 777,
|
|
1708
1714
|
writable: true,
|
|
1709
1715
|
enumerable: true,
|
|
@@ -1711,90 +1717,90 @@ var $;
|
|
|
1711
1717
|
});
|
|
1712
1718
|
},
|
|
1713
1719
|
'ownKeys'() {
|
|
1714
|
-
const proxy =
|
|
1715
|
-
|
|
1720
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
1721
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1716
1722
|
},
|
|
1717
1723
|
'getPrototypeOf'() {
|
|
1718
1724
|
class Foo {
|
|
1719
1725
|
}
|
|
1720
|
-
const proxy =
|
|
1721
|
-
|
|
1726
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1727
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1722
1728
|
},
|
|
1723
1729
|
'setPrototypeOf'() {
|
|
1724
1730
|
class Foo {
|
|
1725
1731
|
}
|
|
1726
1732
|
const target = {};
|
|
1727
|
-
const proxy =
|
|
1733
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1728
1734
|
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
1729
|
-
|
|
1735
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
1730
1736
|
},
|
|
1731
1737
|
'instanceof'() {
|
|
1732
1738
|
class Foo {
|
|
1733
1739
|
}
|
|
1734
|
-
const proxy =
|
|
1735
|
-
|
|
1736
|
-
|
|
1740
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1741
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1742
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1737
1743
|
},
|
|
1738
1744
|
'autobind'() {
|
|
1739
1745
|
class Foo {
|
|
1740
1746
|
}
|
|
1741
|
-
const proxy =
|
|
1742
|
-
|
|
1743
|
-
|
|
1747
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1748
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1749
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1744
1750
|
},
|
|
1745
1751
|
});
|
|
1746
1752
|
})($ || ($ = {}));
|
|
1747
|
-
//delegate.test.
|
|
1753
|
+
//mol/delegate/delegate.test.ts
|
|
1748
1754
|
;
|
|
1749
1755
|
"use strict";
|
|
1750
|
-
//writable.test.
|
|
1756
|
+
//mol/type/writable/writable.test.ts
|
|
1751
1757
|
;
|
|
1752
1758
|
"use strict";
|
|
1753
1759
|
var $;
|
|
1754
1760
|
(function ($_1) {
|
|
1755
|
-
$
|
|
1761
|
+
$mol_test({
|
|
1756
1762
|
'tree parsing'() {
|
|
1757
|
-
$
|
|
1758
|
-
$
|
|
1759
|
-
$
|
|
1760
|
-
$
|
|
1761
|
-
$
|
|
1762
|
-
$
|
|
1763
|
-
$
|
|
1764
|
-
$
|
|
1763
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
1764
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
1765
|
+
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
1766
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
1767
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
1768
|
+
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
1769
|
+
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
1770
|
+
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
1765
1771
|
},
|
|
1766
1772
|
'inserting'() {
|
|
1767
|
-
$
|
|
1768
|
-
$
|
|
1769
|
-
$
|
|
1770
|
-
$
|
|
1771
|
-
$
|
|
1772
|
-
$
|
|
1773
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
1774
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
1775
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
1776
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
1777
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
1778
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
1773
1779
|
},
|
|
1774
1780
|
'fromJSON'() {
|
|
1775
|
-
$
|
|
1776
|
-
$
|
|
1777
|
-
$
|
|
1778
|
-
$
|
|
1779
|
-
$
|
|
1781
|
+
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
1782
|
+
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
1783
|
+
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
1784
|
+
$mol_assert_equal($mol_tree.fromJSON(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
|
|
1785
|
+
$mol_assert_equal($mol_tree.fromJSON({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
|
|
1780
1786
|
},
|
|
1781
1787
|
'toJSON'() {
|
|
1782
|
-
$
|
|
1783
|
-
$
|
|
1784
|
-
$
|
|
1785
|
-
$
|
|
1786
|
-
$
|
|
1788
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
1789
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
1790
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
1791
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n').sub[0]), '["","foo","bar\\nbaz"]');
|
|
1792
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n').sub[0]), '{"foo":false,"bar\\nbaz":"lol"}');
|
|
1787
1793
|
},
|
|
1788
1794
|
'hack'() {
|
|
1789
|
-
const res = $
|
|
1795
|
+
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
1790
1796
|
'': (tree, context) => [tree.hack(context)],
|
|
1791
1797
|
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
1792
1798
|
});
|
|
1793
|
-
$
|
|
1799
|
+
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
1794
1800
|
},
|
|
1795
1801
|
'errors handling'($) {
|
|
1796
1802
|
const errors = [];
|
|
1797
|
-
class Tree extends $
|
|
1803
|
+
class Tree extends $mol_tree {
|
|
1798
1804
|
static $ = $.$mol_ambient({
|
|
1799
1805
|
$mol_fail: error => errors.push(error.message)
|
|
1800
1806
|
});
|
|
@@ -1803,24 +1809,24 @@ var $;
|
|
|
1803
1809
|
\t \tfoo
|
|
1804
1810
|
bar \\data
|
|
1805
1811
|
`, 'test');
|
|
1806
|
-
$
|
|
1812
|
+
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
1807
1813
|
},
|
|
1808
1814
|
});
|
|
1809
1815
|
})($ || ($ = {}));
|
|
1810
|
-
//tree.test.
|
|
1816
|
+
//mol/tree/tree.test.ts
|
|
1811
1817
|
;
|
|
1812
1818
|
"use strict";
|
|
1813
|
-
//equals.test.
|
|
1819
|
+
//mol/type/equals/equals.test.ts
|
|
1814
1820
|
;
|
|
1815
1821
|
"use strict";
|
|
1816
|
-
//equals.
|
|
1822
|
+
//mol/type/equals/equals.ts
|
|
1817
1823
|
;
|
|
1818
1824
|
"use strict";
|
|
1819
1825
|
var $;
|
|
1820
1826
|
(function ($) {
|
|
1821
|
-
|
|
1827
|
+
$mol_test({
|
|
1822
1828
|
async 'unique index'() {
|
|
1823
|
-
const db = await
|
|
1829
|
+
const db = await $$.$mol_db('$mol_db_test', mig => mig.store_make('users'), mig => mig.stores.users.index_make('names', ['name'], !!'unique'));
|
|
1824
1830
|
const trans = db.change('users');
|
|
1825
1831
|
try {
|
|
1826
1832
|
const { users } = trans.stores;
|
|
@@ -1828,16 +1834,16 @@ var $;
|
|
|
1828
1834
|
await users.put({ name: 'John' }, 'john');
|
|
1829
1835
|
await users.put({ name: 'Bin' }, 'bin');
|
|
1830
1836
|
const { names } = users.indexes;
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1837
|
+
$mol_assert_like(await names.get(['Jin']), { name: 'Jin' });
|
|
1838
|
+
$mol_assert_like(await names.get(['John']), { name: 'John' });
|
|
1839
|
+
$mol_assert_like(await names.count(), 3);
|
|
1840
|
+
$mol_assert_like(await names.select(IDBKeyRange.bound(['J'], ['J\uFFFF'])), [{ name: 'Jin' }, { name: 'John' }]);
|
|
1835
1841
|
try {
|
|
1836
1842
|
await users.put({ name: 'Jin' }, 'jin2');
|
|
1837
|
-
|
|
1843
|
+
$mol_fail(new Error('Exception expected'));
|
|
1838
1844
|
}
|
|
1839
1845
|
catch (error) {
|
|
1840
|
-
|
|
1846
|
+
$mol_assert_unique(error.message, 'Exception expected');
|
|
1841
1847
|
}
|
|
1842
1848
|
}
|
|
1843
1849
|
finally {
|
|
@@ -1846,7 +1852,7 @@ var $;
|
|
|
1846
1852
|
}
|
|
1847
1853
|
},
|
|
1848
1854
|
async 'multi path index'() {
|
|
1849
|
-
const db = await
|
|
1855
|
+
const db = await $$.$mol_db('$mol_db_test', mig => mig.store_make('users'), mig => mig.stores.users.index_make('names', ['first', 'last']));
|
|
1850
1856
|
const trans = db.change('users');
|
|
1851
1857
|
try {
|
|
1852
1858
|
const { users } = trans.stores;
|
|
@@ -1854,10 +1860,10 @@ var $;
|
|
|
1854
1860
|
await users.put({ first: 'John', last: 'Jinson' }, 'john');
|
|
1855
1861
|
await users.put({ first: 'Bond', last: 'James' }, '007');
|
|
1856
1862
|
const { names } = users.indexes;
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1863
|
+
$mol_assert_like(await names.get(['Jin', 'Johnson']), { first: 'Jin', last: 'Johnson' });
|
|
1864
|
+
$mol_assert_like(await names.get(['John', 'Jinson']), { first: 'John', last: 'Jinson' });
|
|
1865
|
+
$mol_assert_like(await names.count(), 3);
|
|
1866
|
+
$mol_assert_like(await names.select(IDBKeyRange.bound(['Jin', 'Johnson'], ['John', 'Jinson'])), [{ first: 'Jin', last: 'Johnson' }, { first: 'John', last: 'Jinson' }]);
|
|
1861
1867
|
}
|
|
1862
1868
|
finally {
|
|
1863
1869
|
trans.abort();
|
|
@@ -1865,18 +1871,18 @@ var $;
|
|
|
1865
1871
|
}
|
|
1866
1872
|
},
|
|
1867
1873
|
async 'multiple indexes'() {
|
|
1868
|
-
const db = await
|
|
1874
|
+
const db = await $$.$mol_db('$mol_db_test', mig => mig.store_make('users'), mig => mig.stores.users.index_make('names', ['name'], !!'unique'), mig => mig.stores.users.index_make('ages', ['age']));
|
|
1869
1875
|
const trans = db.change('users');
|
|
1870
1876
|
try {
|
|
1871
1877
|
const { users } = trans.stores;
|
|
1872
1878
|
await users.put({ name: 'Jin', age: 18 }, 'jin');
|
|
1873
1879
|
await users.put({ name: 'John', age: 18 }, 'john');
|
|
1874
1880
|
const { names, ages } = users.indexes;
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1881
|
+
$mol_assert_like(await names.select(['Jin']), [{ name: 'Jin', age: 18 }]);
|
|
1882
|
+
$mol_assert_like(await names.select(['John']), [{ name: 'John', age: 18 }]);
|
|
1883
|
+
$mol_assert_like(await names.count(), 2);
|
|
1884
|
+
$mol_assert_like(await ages.select([18]), [{ name: 'Jin', age: 18 }, { name: 'John', age: 18 }]);
|
|
1885
|
+
$mol_assert_like(await ages.count(), 2);
|
|
1880
1886
|
}
|
|
1881
1887
|
finally {
|
|
1882
1888
|
trans.abort();
|
|
@@ -1885,6 +1891,6 @@ var $;
|
|
|
1885
1891
|
},
|
|
1886
1892
|
});
|
|
1887
1893
|
})($ || ($ = {}));
|
|
1888
|
-
//index.test.
|
|
1894
|
+
//mol/db/index/index.test.ts
|
|
1889
1895
|
|
|
1890
1896
|
//# sourceMappingURL=node.test.js.map
|