mol_charset_ucf_lib 0.0.1 → 0.0.3
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/README.md +11 -0
- package/node.d.ts +12 -0
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +114 -0
- package/node.js.map +1 -1
- package/node.meta.tree +3 -0
- package/node.mjs +114 -0
- package/node.test.js +4151 -0
- package/node.test.js.map +1 -1
- package/package.json +5 -2
- package/web.d.ts +12 -0
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +114 -0
- package/web.js.map +1 -1
- package/web.meta.tree +3 -0
- package/web.mjs +114 -0
- package/web.test.js +1492 -1
- package/web.test.js.map +1 -1
package/web.test.js
CHANGED
|
@@ -1,3 +1,1494 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
function require( path ){ return $node[ path ] }
|
|
2
|
+
function require( path ){ return $node[ path ] };
|
|
3
|
+
"use strict";
|
|
4
|
+
var $;
|
|
5
|
+
(function ($) {
|
|
6
|
+
function $mol_promise_like(val) {
|
|
7
|
+
try {
|
|
8
|
+
return val && typeof val === 'object' && 'then' in val && typeof val.then === 'function';
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
$.$mol_promise_like = $mol_promise_like;
|
|
15
|
+
})($ || ($ = {}));
|
|
16
|
+
|
|
17
|
+
;
|
|
18
|
+
"use strict";
|
|
19
|
+
var $;
|
|
20
|
+
(function ($) {
|
|
21
|
+
function $mol_fail(error) {
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
$.$mol_fail = $mol_fail;
|
|
25
|
+
})($ || ($ = {}));
|
|
26
|
+
|
|
27
|
+
;
|
|
28
|
+
"use strict";
|
|
29
|
+
var $;
|
|
30
|
+
(function ($) {
|
|
31
|
+
function $mol_fail_hidden(error) {
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
35
|
+
})($ || ($ = {}));
|
|
36
|
+
|
|
37
|
+
;
|
|
38
|
+
"use strict";
|
|
39
|
+
var $;
|
|
40
|
+
(function ($_1) {
|
|
41
|
+
function $mol_test(set) {
|
|
42
|
+
for (let name in set) {
|
|
43
|
+
const code = set[name];
|
|
44
|
+
const test = (typeof code === 'string') ? new Function('', code) : code;
|
|
45
|
+
$_1.$mol_test_all.push(test);
|
|
46
|
+
}
|
|
47
|
+
$mol_test_schedule();
|
|
48
|
+
}
|
|
49
|
+
$_1.$mol_test = $mol_test;
|
|
50
|
+
$_1.$mol_test_mocks = [];
|
|
51
|
+
$_1.$mol_test_all = [];
|
|
52
|
+
async function $mol_test_run() {
|
|
53
|
+
for (var test of $_1.$mol_test_all) {
|
|
54
|
+
let context = Object.create($$);
|
|
55
|
+
for (let mock of $_1.$mol_test_mocks)
|
|
56
|
+
await mock(context);
|
|
57
|
+
const res = test(context);
|
|
58
|
+
if ($mol_promise_like(res)) {
|
|
59
|
+
await new Promise((done, fail) => {
|
|
60
|
+
res.then(done, fail);
|
|
61
|
+
setTimeout(() => fail(new Error('Test timeout: ' + test.name)), 1000);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
$$.$mol_log3_done({
|
|
66
|
+
place: '$mol_test',
|
|
67
|
+
message: 'All tests passed',
|
|
68
|
+
count: $_1.$mol_test_all.length,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
$_1.$mol_test_run = $mol_test_run;
|
|
72
|
+
let scheduled = false;
|
|
73
|
+
function $mol_test_schedule() {
|
|
74
|
+
if (scheduled)
|
|
75
|
+
return;
|
|
76
|
+
scheduled = true;
|
|
77
|
+
setTimeout(async () => {
|
|
78
|
+
scheduled = false;
|
|
79
|
+
await $mol_test_run();
|
|
80
|
+
$$.$mol_test_complete();
|
|
81
|
+
}, 1000);
|
|
82
|
+
}
|
|
83
|
+
$_1.$mol_test_schedule = $mol_test_schedule;
|
|
84
|
+
$_1.$mol_test_mocks.push(context => {
|
|
85
|
+
let seed = 0;
|
|
86
|
+
context.Math = Object.create(Math);
|
|
87
|
+
context.Math.random = () => Math.sin(seed++);
|
|
88
|
+
const forbidden = ['XMLHttpRequest', 'fetch'];
|
|
89
|
+
for (let api of forbidden) {
|
|
90
|
+
context[api] = new Proxy(function () { }, {
|
|
91
|
+
get() {
|
|
92
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
93
|
+
},
|
|
94
|
+
apply() {
|
|
95
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
$mol_test({
|
|
101
|
+
'mocked Math.random'($) {
|
|
102
|
+
console.assert($.Math.random() === 0);
|
|
103
|
+
console.assert($.Math.random() === Math.sin(1));
|
|
104
|
+
},
|
|
105
|
+
'forbidden XMLHttpRequest'($) {
|
|
106
|
+
try {
|
|
107
|
+
console.assert(void new $.XMLHttpRequest);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
console.assert(error.message === 'XMLHttpRequest is forbidden in tests');
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
'forbidden fetch'($) {
|
|
114
|
+
try {
|
|
115
|
+
console.assert(void $.fetch(''));
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
console.assert(error.message === 'fetch is forbidden in tests');
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
})($ || ($ = {}));
|
|
123
|
+
|
|
124
|
+
;
|
|
125
|
+
"use strict";
|
|
126
|
+
var $;
|
|
127
|
+
(function ($) {
|
|
128
|
+
function $mol_test_complete() {
|
|
129
|
+
}
|
|
130
|
+
$.$mol_test_complete = $mol_test_complete;
|
|
131
|
+
})($ || ($ = {}));
|
|
132
|
+
|
|
133
|
+
;
|
|
134
|
+
"use strict";
|
|
135
|
+
var $;
|
|
136
|
+
(function ($) {
|
|
137
|
+
})($ || ($ = {}));
|
|
138
|
+
|
|
139
|
+
;
|
|
140
|
+
"use strict";
|
|
141
|
+
var $;
|
|
142
|
+
(function ($) {
|
|
143
|
+
$.$mol_dom_context = self;
|
|
144
|
+
})($ || ($ = {}));
|
|
145
|
+
|
|
146
|
+
;
|
|
147
|
+
"use strict";
|
|
148
|
+
var $;
|
|
149
|
+
(function ($) {
|
|
150
|
+
$.$mol_dom = $mol_dom_context;
|
|
151
|
+
})($ || ($ = {}));
|
|
152
|
+
|
|
153
|
+
;
|
|
154
|
+
"use strict";
|
|
155
|
+
var $;
|
|
156
|
+
(function ($) {
|
|
157
|
+
function $mol_dom_render_children(el, childNodes) {
|
|
158
|
+
const node_set = new Set(childNodes);
|
|
159
|
+
let nextNode = el.firstChild;
|
|
160
|
+
for (let view of childNodes) {
|
|
161
|
+
if (view == null)
|
|
162
|
+
continue;
|
|
163
|
+
if (view instanceof $mol_dom_context.Node) {
|
|
164
|
+
while (true) {
|
|
165
|
+
if (!nextNode) {
|
|
166
|
+
el.appendChild(view);
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
if (nextNode == view) {
|
|
170
|
+
nextNode = nextNode.nextSibling;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
if (node_set.has(nextNode)) {
|
|
175
|
+
el.insertBefore(view, nextNode);
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
const nn = nextNode.nextSibling;
|
|
180
|
+
el.removeChild(nextNode);
|
|
181
|
+
nextNode = nn;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
if (nextNode && nextNode.nodeName === '#text') {
|
|
188
|
+
const str = String(view);
|
|
189
|
+
if (nextNode.nodeValue !== str)
|
|
190
|
+
nextNode.nodeValue = str;
|
|
191
|
+
nextNode = nextNode.nextSibling;
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
|
195
|
+
el.insertBefore(textNode, nextNode);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
while (nextNode) {
|
|
200
|
+
const currNode = nextNode;
|
|
201
|
+
nextNode = currNode.nextSibling;
|
|
202
|
+
el.removeChild(currNode);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
$.$mol_dom_render_children = $mol_dom_render_children;
|
|
206
|
+
})($ || ($ = {}));
|
|
207
|
+
|
|
208
|
+
;
|
|
209
|
+
"use strict";
|
|
210
|
+
|
|
211
|
+
;
|
|
212
|
+
"use strict";
|
|
213
|
+
|
|
214
|
+
;
|
|
215
|
+
"use strict";
|
|
216
|
+
|
|
217
|
+
;
|
|
218
|
+
"use strict";
|
|
219
|
+
|
|
220
|
+
;
|
|
221
|
+
"use strict";
|
|
222
|
+
|
|
223
|
+
;
|
|
224
|
+
"use strict";
|
|
225
|
+
var $;
|
|
226
|
+
(function ($) {
|
|
227
|
+
function $mol_dom_serialize(node) {
|
|
228
|
+
const serializer = new $mol_dom_context.XMLSerializer;
|
|
229
|
+
return serializer.serializeToString(node);
|
|
230
|
+
}
|
|
231
|
+
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
232
|
+
})($ || ($ = {}));
|
|
233
|
+
|
|
234
|
+
;
|
|
235
|
+
"use strict";
|
|
236
|
+
var $;
|
|
237
|
+
(function ($) {
|
|
238
|
+
$.$mol_jsx_prefix = '';
|
|
239
|
+
$.$mol_jsx_crumbs = '';
|
|
240
|
+
$.$mol_jsx_booked = null;
|
|
241
|
+
$.$mol_jsx_document = {
|
|
242
|
+
getElementById: () => null,
|
|
243
|
+
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
|
244
|
+
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
245
|
+
};
|
|
246
|
+
$.$mol_jsx_frag = '';
|
|
247
|
+
function $mol_jsx(Elem, props, ...childNodes) {
|
|
248
|
+
const id = props && props.id || '';
|
|
249
|
+
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
|
250
|
+
const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
|
|
251
|
+
if (Elem && $.$mol_jsx_booked) {
|
|
252
|
+
if ($.$mol_jsx_booked.has(id)) {
|
|
253
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
$.$mol_jsx_booked.add(id);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
|
|
260
|
+
if ($.$mol_jsx_prefix) {
|
|
261
|
+
const prefix_ext = $.$mol_jsx_prefix;
|
|
262
|
+
const booked_ext = $.$mol_jsx_booked;
|
|
263
|
+
const crumbs_ext = $.$mol_jsx_crumbs;
|
|
264
|
+
for (const field in props) {
|
|
265
|
+
const func = props[field];
|
|
266
|
+
if (typeof func !== 'function')
|
|
267
|
+
continue;
|
|
268
|
+
const wrapper = function (...args) {
|
|
269
|
+
const prefix = $.$mol_jsx_prefix;
|
|
270
|
+
const booked = $.$mol_jsx_booked;
|
|
271
|
+
const crumbs = $.$mol_jsx_crumbs;
|
|
272
|
+
try {
|
|
273
|
+
$.$mol_jsx_prefix = prefix_ext;
|
|
274
|
+
$.$mol_jsx_booked = booked_ext;
|
|
275
|
+
$.$mol_jsx_crumbs = crumbs_ext;
|
|
276
|
+
return func.call(this, ...args);
|
|
277
|
+
}
|
|
278
|
+
finally {
|
|
279
|
+
$.$mol_jsx_prefix = prefix;
|
|
280
|
+
$.$mol_jsx_booked = booked;
|
|
281
|
+
$.$mol_jsx_crumbs = crumbs;
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
$mol_func_name_from(wrapper, func);
|
|
285
|
+
props[field] = wrapper;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
if (typeof Elem !== 'string') {
|
|
289
|
+
if ('prototype' in Elem) {
|
|
290
|
+
const view = node && node[String(Elem)] || new Elem;
|
|
291
|
+
Object.assign(view, props);
|
|
292
|
+
view[Symbol.toStringTag] = guid;
|
|
293
|
+
view.childNodes = childNodes;
|
|
294
|
+
if (!view.ownerDocument)
|
|
295
|
+
view.ownerDocument = $.$mol_jsx_document;
|
|
296
|
+
view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
297
|
+
node = view.valueOf();
|
|
298
|
+
node[String(Elem)] = view;
|
|
299
|
+
return node;
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
const prefix = $.$mol_jsx_prefix;
|
|
303
|
+
const booked = $.$mol_jsx_booked;
|
|
304
|
+
const crumbs = $.$mol_jsx_crumbs;
|
|
305
|
+
try {
|
|
306
|
+
$.$mol_jsx_prefix = guid;
|
|
307
|
+
$.$mol_jsx_booked = new Set;
|
|
308
|
+
$.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
309
|
+
return Elem(props, ...childNodes);
|
|
310
|
+
}
|
|
311
|
+
finally {
|
|
312
|
+
$.$mol_jsx_prefix = prefix;
|
|
313
|
+
$.$mol_jsx_booked = booked;
|
|
314
|
+
$.$mol_jsx_crumbs = crumbs;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (!node) {
|
|
319
|
+
node = Elem
|
|
320
|
+
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
321
|
+
: $.$mol_jsx_document.createDocumentFragment();
|
|
322
|
+
}
|
|
323
|
+
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
324
|
+
if (!Elem)
|
|
325
|
+
return node;
|
|
326
|
+
if (guid)
|
|
327
|
+
node.id = guid;
|
|
328
|
+
for (const key in props) {
|
|
329
|
+
if (key === 'id')
|
|
330
|
+
continue;
|
|
331
|
+
if (typeof props[key] === 'string') {
|
|
332
|
+
if (typeof node[key] === 'string')
|
|
333
|
+
node[key] = props[key];
|
|
334
|
+
node.setAttribute(key, props[key]);
|
|
335
|
+
}
|
|
336
|
+
else if (props[key] &&
|
|
337
|
+
typeof props[key] === 'object' &&
|
|
338
|
+
Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
|
|
339
|
+
if (typeof node[key] === 'object') {
|
|
340
|
+
Object.assign(node[key], props[key]);
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
node[key] = props[key];
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
if ($.$mol_jsx_crumbs)
|
|
349
|
+
node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
|
|
350
|
+
return node;
|
|
351
|
+
}
|
|
352
|
+
$.$mol_jsx = $mol_jsx;
|
|
353
|
+
})($ || ($ = {}));
|
|
354
|
+
|
|
355
|
+
;
|
|
356
|
+
"use strict";
|
|
357
|
+
var $;
|
|
358
|
+
(function ($) {
|
|
359
|
+
$mol_test({
|
|
360
|
+
'Make empty div'() {
|
|
361
|
+
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
|
362
|
+
},
|
|
363
|
+
'Define native field'() {
|
|
364
|
+
const dom = $mol_jsx("input", { value: '123' });
|
|
365
|
+
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
366
|
+
$mol_assert_equal(dom.value, '123');
|
|
367
|
+
},
|
|
368
|
+
'Define classes'() {
|
|
369
|
+
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
370
|
+
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
371
|
+
},
|
|
372
|
+
'Define styles'() {
|
|
373
|
+
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
374
|
+
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
375
|
+
},
|
|
376
|
+
'Define dataset'() {
|
|
377
|
+
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
378
|
+
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
379
|
+
},
|
|
380
|
+
'Define attributes'() {
|
|
381
|
+
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
382
|
+
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
383
|
+
},
|
|
384
|
+
'Define child nodes'() {
|
|
385
|
+
const dom = $mol_jsx("div", null,
|
|
386
|
+
"hello",
|
|
387
|
+
$mol_jsx("strong", null, "world"),
|
|
388
|
+
"!");
|
|
389
|
+
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
390
|
+
},
|
|
391
|
+
'Make fragment'() {
|
|
392
|
+
const dom = $mol_jsx($mol_jsx_frag, null,
|
|
393
|
+
$mol_jsx("br", null),
|
|
394
|
+
$mol_jsx("hr", null));
|
|
395
|
+
$mol_assert_equal($mol_dom_serialize(dom), '<br xmlns="http://www.w3.org/1999/xhtml" /><hr xmlns="http://www.w3.org/1999/xhtml" />');
|
|
396
|
+
},
|
|
397
|
+
'Spread fragment'() {
|
|
398
|
+
const dom = $mol_jsx("div", null,
|
|
399
|
+
$mol_jsx($mol_jsx_frag, null,
|
|
400
|
+
$mol_jsx("br", null),
|
|
401
|
+
$mol_jsx("hr", null)));
|
|
402
|
+
$mol_assert_equal(dom.outerHTML, '<div><br><hr></div>');
|
|
403
|
+
},
|
|
404
|
+
'Function as component'() {
|
|
405
|
+
const Button = (props, target) => {
|
|
406
|
+
return $mol_jsx("button", { title: props.hint }, target());
|
|
407
|
+
};
|
|
408
|
+
const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
|
|
409
|
+
$mol_assert_equal(dom.outerHTML, '<button id="foo" title="click me" class="Button">hey!</button>');
|
|
410
|
+
},
|
|
411
|
+
'Nested guid generation'() {
|
|
412
|
+
const Foo = () => {
|
|
413
|
+
return $mol_jsx("div", null,
|
|
414
|
+
$mol_jsx(Bar, { id: "bar" },
|
|
415
|
+
$mol_jsx("img", { id: "icon" })));
|
|
416
|
+
};
|
|
417
|
+
const Bar = (props, icon) => {
|
|
418
|
+
return $mol_jsx("span", null,
|
|
419
|
+
icon,
|
|
420
|
+
$mol_jsx("i", { id: "label" }));
|
|
421
|
+
};
|
|
422
|
+
const dom = $mol_jsx(Foo, { id: "foo" });
|
|
423
|
+
$mol_assert_equal(dom.outerHTML, '<div id="foo" class="Foo"><span id="foo/bar" class="Foo_bar Bar"><img id="foo/icon" class="Foo_icon"><i id="foo/bar/label" class="Foo_bar_label Bar_label"></i></span></div>');
|
|
424
|
+
},
|
|
425
|
+
'Fail on non unique ids'() {
|
|
426
|
+
const App = () => {
|
|
427
|
+
return $mol_jsx("div", null,
|
|
428
|
+
$mol_jsx("span", { id: "bar" }),
|
|
429
|
+
$mol_jsx("span", { id: "bar" }));
|
|
430
|
+
};
|
|
431
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
|
432
|
+
},
|
|
433
|
+
'Owner based guid generationn'() {
|
|
434
|
+
const Foo = () => {
|
|
435
|
+
return $mol_jsx("div", null,
|
|
436
|
+
$mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
437
|
+
};
|
|
438
|
+
const Bar = (props) => {
|
|
439
|
+
return $mol_jsx("span", null, props.icon());
|
|
440
|
+
};
|
|
441
|
+
const dom = $mol_jsx(Foo, { id: "app" });
|
|
442
|
+
$mol_assert_equal(dom.outerHTML, '<div id="app" class="Foo"><span id="app/middle" class="Foo_middle Bar"><img id="app/icon" class="Foo_icon"></span></div>');
|
|
443
|
+
},
|
|
444
|
+
'Fail on same ids from different caller'() {
|
|
445
|
+
const Foo = () => {
|
|
446
|
+
return $mol_jsx("div", null,
|
|
447
|
+
$mol_jsx("img", { id: "icon" }),
|
|
448
|
+
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
449
|
+
};
|
|
450
|
+
const Bar = (props) => {
|
|
451
|
+
return $mol_jsx("span", null, props.icon());
|
|
452
|
+
};
|
|
453
|
+
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
|
454
|
+
},
|
|
455
|
+
});
|
|
456
|
+
})($ || ($ = {}));
|
|
457
|
+
|
|
458
|
+
;
|
|
459
|
+
"use strict";
|
|
460
|
+
var $;
|
|
461
|
+
(function ($) {
|
|
462
|
+
function $mol_guid(length = 8, exists = () => false) {
|
|
463
|
+
for (;;) {
|
|
464
|
+
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
465
|
+
if (exists(id))
|
|
466
|
+
continue;
|
|
467
|
+
return id;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
$.$mol_guid = $mol_guid;
|
|
471
|
+
})($ || ($ = {}));
|
|
472
|
+
|
|
473
|
+
;
|
|
474
|
+
"use strict";
|
|
475
|
+
var $;
|
|
476
|
+
(function ($) {
|
|
477
|
+
function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
|
|
478
|
+
const source = typeof item === 'function' ? new $mol_range2_array() : item;
|
|
479
|
+
if (typeof item !== 'function') {
|
|
480
|
+
item = index => source[index];
|
|
481
|
+
size = () => source.length;
|
|
482
|
+
}
|
|
483
|
+
return new Proxy(source, {
|
|
484
|
+
get(target, field) {
|
|
485
|
+
if (typeof field === 'string') {
|
|
486
|
+
if (field === 'length')
|
|
487
|
+
return size();
|
|
488
|
+
const index = Number(field);
|
|
489
|
+
if (index < 0)
|
|
490
|
+
return undefined;
|
|
491
|
+
if (index >= size())
|
|
492
|
+
return undefined;
|
|
493
|
+
if (index === Math.trunc(index))
|
|
494
|
+
return item(index);
|
|
495
|
+
}
|
|
496
|
+
return $mol_range2_array.prototype[field];
|
|
497
|
+
},
|
|
498
|
+
set(target, field) {
|
|
499
|
+
return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
|
|
500
|
+
},
|
|
501
|
+
ownKeys(target) {
|
|
502
|
+
return [...Array(size())].map((v, i) => String(i)).concat('length');
|
|
503
|
+
},
|
|
504
|
+
getOwnPropertyDescriptor(target, field) {
|
|
505
|
+
if (field === "length")
|
|
506
|
+
return {
|
|
507
|
+
value: size(),
|
|
508
|
+
writable: true,
|
|
509
|
+
enumerable: false,
|
|
510
|
+
configurable: false,
|
|
511
|
+
};
|
|
512
|
+
const index = Number(field);
|
|
513
|
+
if (index === Math.trunc(index))
|
|
514
|
+
return {
|
|
515
|
+
get: () => this.get(target, field, this),
|
|
516
|
+
enumerable: true,
|
|
517
|
+
configurable: true,
|
|
518
|
+
};
|
|
519
|
+
return Object.getOwnPropertyDescriptor(target, field);
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
$.$mol_range2 = $mol_range2;
|
|
524
|
+
class $mol_range2_array extends Array {
|
|
525
|
+
concat(...tail) {
|
|
526
|
+
if (tail.length === 0)
|
|
527
|
+
return this;
|
|
528
|
+
if (tail.length > 1) {
|
|
529
|
+
let list = this;
|
|
530
|
+
for (let item of tail)
|
|
531
|
+
list = list.concat(item);
|
|
532
|
+
return list;
|
|
533
|
+
}
|
|
534
|
+
return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
|
|
535
|
+
}
|
|
536
|
+
filter(check, context) {
|
|
537
|
+
const filtered = [];
|
|
538
|
+
let cursor = -1;
|
|
539
|
+
return $mol_range2(index => {
|
|
540
|
+
while (cursor < this.length && index >= filtered.length - 1) {
|
|
541
|
+
const val = this[++cursor];
|
|
542
|
+
if (check(val, cursor, this))
|
|
543
|
+
filtered.push(val);
|
|
544
|
+
}
|
|
545
|
+
return filtered[index];
|
|
546
|
+
}, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
|
|
547
|
+
}
|
|
548
|
+
forEach(proceed, context) {
|
|
549
|
+
for (let [key, value] of this.entries())
|
|
550
|
+
proceed.call(context, value, key, this);
|
|
551
|
+
}
|
|
552
|
+
map(proceed, context) {
|
|
553
|
+
return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
|
|
554
|
+
}
|
|
555
|
+
reduce(merge, result) {
|
|
556
|
+
let index = 0;
|
|
557
|
+
if (arguments.length === 1) {
|
|
558
|
+
result = this[index++];
|
|
559
|
+
}
|
|
560
|
+
for (; index < this.length; ++index) {
|
|
561
|
+
result = merge(result, this[index], index, this);
|
|
562
|
+
}
|
|
563
|
+
return result;
|
|
564
|
+
}
|
|
565
|
+
toReversed() {
|
|
566
|
+
return $mol_range2(index => this[this.length - 1 - index], () => this.length);
|
|
567
|
+
}
|
|
568
|
+
slice(from = 0, to = this.length) {
|
|
569
|
+
return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
|
|
570
|
+
}
|
|
571
|
+
some(check, context) {
|
|
572
|
+
for (let index = 0; index < this.length; ++index) {
|
|
573
|
+
if (check.call(context, this[index], index, this))
|
|
574
|
+
return true;
|
|
575
|
+
}
|
|
576
|
+
return false;
|
|
577
|
+
}
|
|
578
|
+
every(check, context) {
|
|
579
|
+
for (let index = 0; index < this.length; ++index) {
|
|
580
|
+
if (!check.call(context, this[index], index, this))
|
|
581
|
+
return false;
|
|
582
|
+
}
|
|
583
|
+
return true;
|
|
584
|
+
}
|
|
585
|
+
reverse() {
|
|
586
|
+
return $mol_fail(new TypeError(`Mutable reverse is forbidden. Use toReversed instead.`));
|
|
587
|
+
}
|
|
588
|
+
sort() {
|
|
589
|
+
return $mol_fail(new TypeError(`Mutable sort is forbidden. Use toSorted instead.`));
|
|
590
|
+
}
|
|
591
|
+
indexOf(needle) {
|
|
592
|
+
return this.findIndex(item => item === needle);
|
|
593
|
+
}
|
|
594
|
+
[Symbol.toPrimitive]() {
|
|
595
|
+
return $mol_guid();
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
$.$mol_range2_array = $mol_range2_array;
|
|
599
|
+
})($ || ($ = {}));
|
|
600
|
+
|
|
601
|
+
;
|
|
602
|
+
"use strict";
|
|
603
|
+
var $;
|
|
604
|
+
(function ($) {
|
|
605
|
+
$mol_test({
|
|
606
|
+
'lazy calls'() {
|
|
607
|
+
let calls = 0;
|
|
608
|
+
const list = $mol_range2(index => (++calls, index), () => 10);
|
|
609
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
610
|
+
$mol_assert_equal(list.length, 10);
|
|
611
|
+
$mol_assert_equal(list[-1], undefined);
|
|
612
|
+
$mol_assert_equal(list[0], 0);
|
|
613
|
+
$mol_assert_equal(list[9], 9);
|
|
614
|
+
$mol_assert_equal(list[9.5], undefined);
|
|
615
|
+
$mol_assert_equal(list[10], undefined);
|
|
616
|
+
$mol_assert_equal(calls, 2);
|
|
617
|
+
},
|
|
618
|
+
'infinity list'() {
|
|
619
|
+
let calls = 0;
|
|
620
|
+
const list = $mol_range2(index => (++calls, index));
|
|
621
|
+
$mol_assert_equal(list.length, Number.POSITIVE_INFINITY);
|
|
622
|
+
$mol_assert_equal(list[0], 0);
|
|
623
|
+
$mol_assert_equal(list[4], 4);
|
|
624
|
+
$mol_assert_equal(list[Number.MAX_SAFE_INTEGER], Number.MAX_SAFE_INTEGER);
|
|
625
|
+
$mol_assert_equal(list[Number.POSITIVE_INFINITY], undefined);
|
|
626
|
+
$mol_assert_equal(calls, 3);
|
|
627
|
+
},
|
|
628
|
+
'stringify'() {
|
|
629
|
+
const list = $mol_range2(i => i, () => 5);
|
|
630
|
+
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
|
631
|
+
$mol_assert_equal(list.join(';'), '0;1;2;3;4');
|
|
632
|
+
},
|
|
633
|
+
'for-of'() {
|
|
634
|
+
let log = '';
|
|
635
|
+
for (let i of $mol_range2(i => i + 1, () => 5)) {
|
|
636
|
+
log += i;
|
|
637
|
+
}
|
|
638
|
+
$mol_assert_equal(log, '12345');
|
|
639
|
+
},
|
|
640
|
+
'for-in'() {
|
|
641
|
+
let log = '';
|
|
642
|
+
for (let i in $mol_range2(i => i, () => 5)) {
|
|
643
|
+
log += i;
|
|
644
|
+
}
|
|
645
|
+
$mol_assert_equal(log, '01234');
|
|
646
|
+
},
|
|
647
|
+
'forEach'() {
|
|
648
|
+
let log = '';
|
|
649
|
+
$mol_range2(i => i, () => 5).forEach(i => log += i);
|
|
650
|
+
$mol_assert_equal(log, '01234');
|
|
651
|
+
},
|
|
652
|
+
'reduce'() {
|
|
653
|
+
let calls = 0;
|
|
654
|
+
const list = $mol_range2().slice(1, 6);
|
|
655
|
+
$mol_assert_equal(list.reduce((s, v) => s + v), 15);
|
|
656
|
+
$mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
|
|
657
|
+
},
|
|
658
|
+
'lazy concat'() {
|
|
659
|
+
let calls1 = 0;
|
|
660
|
+
let calls2 = 0;
|
|
661
|
+
const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
|
|
662
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
663
|
+
$mol_assert_equal(list.length, 15);
|
|
664
|
+
$mol_assert_equal(list[0], 0);
|
|
665
|
+
$mol_assert_equal(list[4], 4);
|
|
666
|
+
$mol_assert_equal(list[5], 0);
|
|
667
|
+
$mol_assert_equal(list[9], 4);
|
|
668
|
+
$mol_assert_equal(list[10], 0);
|
|
669
|
+
$mol_assert_equal(list[14], 4);
|
|
670
|
+
$mol_assert_equal(list[15], undefined);
|
|
671
|
+
$mol_assert_equal(calls1, 2);
|
|
672
|
+
$mol_assert_equal(calls2, 2);
|
|
673
|
+
},
|
|
674
|
+
'lazy filter'() {
|
|
675
|
+
let calls = 0;
|
|
676
|
+
const list = $mol_range2(index => (++calls, index), () => 15).filter(v => v % 2).slice(0, 3);
|
|
677
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
678
|
+
$mol_assert_equal(list.length, 3);
|
|
679
|
+
$mol_assert_equal(list[0], 1);
|
|
680
|
+
$mol_assert_equal(list[2], 5);
|
|
681
|
+
$mol_assert_equal(list[3], undefined);
|
|
682
|
+
$mol_assert_equal(calls, 8);
|
|
683
|
+
},
|
|
684
|
+
'lazy reverse'() {
|
|
685
|
+
let calls = 0;
|
|
686
|
+
const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
|
|
687
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
688
|
+
$mol_assert_equal(list.length, 3);
|
|
689
|
+
$mol_assert_equal(list[0], 9);
|
|
690
|
+
$mol_assert_equal(list[2], 7);
|
|
691
|
+
$mol_assert_equal(list[3], undefined);
|
|
692
|
+
$mol_assert_equal(calls, 2);
|
|
693
|
+
},
|
|
694
|
+
'lazy map'() {
|
|
695
|
+
let calls1 = 0;
|
|
696
|
+
let calls2 = 0;
|
|
697
|
+
const source = $mol_range2(index => (++calls1, index), () => 5);
|
|
698
|
+
const target = source.map((item, index, self) => {
|
|
699
|
+
++calls2;
|
|
700
|
+
$mol_assert_equal(source, self);
|
|
701
|
+
return index + 10;
|
|
702
|
+
}, () => 5);
|
|
703
|
+
$mol_assert_equal(true, target instanceof Array);
|
|
704
|
+
$mol_assert_equal(target.length, 5);
|
|
705
|
+
$mol_assert_equal(target[0], 10);
|
|
706
|
+
$mol_assert_equal(target[4], 14);
|
|
707
|
+
$mol_assert_equal(target[5], undefined);
|
|
708
|
+
$mol_assert_equal(calls1, 2);
|
|
709
|
+
$mol_assert_equal(calls2, 2);
|
|
710
|
+
},
|
|
711
|
+
'lazy slice'() {
|
|
712
|
+
let calls = 0;
|
|
713
|
+
const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
|
|
714
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
715
|
+
$mol_assert_equal(list.length, 4);
|
|
716
|
+
$mol_assert_equal(list[0], 3);
|
|
717
|
+
$mol_assert_equal(list[3], 6);
|
|
718
|
+
$mol_assert_equal(list[4], undefined);
|
|
719
|
+
$mol_assert_equal(calls, 2);
|
|
720
|
+
},
|
|
721
|
+
'lazy some'() {
|
|
722
|
+
let calls = 0;
|
|
723
|
+
$mol_assert_equal(true, $mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
|
|
724
|
+
$mol_assert_equal(calls, 3);
|
|
725
|
+
$mol_assert_equal(false, $mol_range2(i => i, () => 0).some(v => true));
|
|
726
|
+
$mol_assert_equal(true, $mol_range2(i => i).some(v => v > 5));
|
|
727
|
+
},
|
|
728
|
+
'lazy every'() {
|
|
729
|
+
let calls = 0;
|
|
730
|
+
$mol_assert_equal(false, $mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
|
|
731
|
+
$mol_assert_equal(calls, 3);
|
|
732
|
+
$mol_assert_equal(true, $mol_range2(i => i, () => 0).every(v => false));
|
|
733
|
+
$mol_assert_equal(false, $mol_range2(i => i).every(v => v < 5));
|
|
734
|
+
},
|
|
735
|
+
'lazyfy'() {
|
|
736
|
+
let calls = 0;
|
|
737
|
+
const list = $mol_range2([0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
|
|
738
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
739
|
+
$mol_assert_equal(list.length, 4);
|
|
740
|
+
$mol_assert_equal(calls, 0);
|
|
741
|
+
$mol_assert_equal(list[0], 12);
|
|
742
|
+
$mol_assert_equal(list[3], 15);
|
|
743
|
+
$mol_assert_equal(list[4], undefined);
|
|
744
|
+
$mol_assert_equal(calls, 2);
|
|
745
|
+
},
|
|
746
|
+
'prevent modification'() {
|
|
747
|
+
const list = $mol_range2(i => i, () => 5);
|
|
748
|
+
$mol_assert_fail(() => list.push(4), TypeError);
|
|
749
|
+
$mol_assert_fail(() => list.pop(), TypeError);
|
|
750
|
+
$mol_assert_fail(() => list.unshift(4), TypeError);
|
|
751
|
+
$mol_assert_fail(() => list.shift(), TypeError);
|
|
752
|
+
$mol_assert_fail(() => list.splice(1, 2), TypeError);
|
|
753
|
+
$mol_assert_fail(() => list[1] = 2, TypeError);
|
|
754
|
+
$mol_assert_fail(() => list.reverse(), TypeError);
|
|
755
|
+
$mol_assert_fail(() => list.sort(), TypeError);
|
|
756
|
+
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
})($ || ($ = {}));
|
|
760
|
+
|
|
761
|
+
;
|
|
762
|
+
"use strict";
|
|
763
|
+
var $;
|
|
764
|
+
(function ($) {
|
|
765
|
+
$.$mol_compare_deep_cache = new WeakMap();
|
|
766
|
+
function $mol_compare_deep(left, right) {
|
|
767
|
+
if (Object.is(left, right))
|
|
768
|
+
return true;
|
|
769
|
+
if (left === null)
|
|
770
|
+
return false;
|
|
771
|
+
if (right === null)
|
|
772
|
+
return false;
|
|
773
|
+
if (typeof left !== 'object')
|
|
774
|
+
return false;
|
|
775
|
+
if (typeof right !== 'object')
|
|
776
|
+
return false;
|
|
777
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
|
778
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
|
779
|
+
if (left_proto !== right_proto)
|
|
780
|
+
return false;
|
|
781
|
+
if (left instanceof Boolean)
|
|
782
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
783
|
+
if (left instanceof Number)
|
|
784
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
785
|
+
if (left instanceof String)
|
|
786
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
787
|
+
if (left instanceof Date)
|
|
788
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
789
|
+
if (left instanceof RegExp)
|
|
790
|
+
return left.source === right.source && left.flags === right.flags;
|
|
791
|
+
if (left instanceof Error)
|
|
792
|
+
return left.message === right.message && $mol_compare_deep(left.stack, right.stack);
|
|
793
|
+
let left_cache = $.$mol_compare_deep_cache.get(left);
|
|
794
|
+
if (left_cache) {
|
|
795
|
+
const right_cache = left_cache.get(right);
|
|
796
|
+
if (typeof right_cache === 'boolean')
|
|
797
|
+
return right_cache;
|
|
798
|
+
}
|
|
799
|
+
else {
|
|
800
|
+
left_cache = new WeakMap();
|
|
801
|
+
$.$mol_compare_deep_cache.set(left, left_cache);
|
|
802
|
+
}
|
|
803
|
+
left_cache.set(right, true);
|
|
804
|
+
let result;
|
|
805
|
+
try {
|
|
806
|
+
if (!left_proto)
|
|
807
|
+
result = compare_pojo(left, right);
|
|
808
|
+
else if (!Reflect.getPrototypeOf(left_proto))
|
|
809
|
+
result = compare_pojo(left, right);
|
|
810
|
+
else if (Symbol.toPrimitive in left)
|
|
811
|
+
result = compare_primitive(left, right);
|
|
812
|
+
else if (Array.isArray(left))
|
|
813
|
+
result = compare_array(left, right);
|
|
814
|
+
else if (left instanceof Set)
|
|
815
|
+
result = compare_set(left, right);
|
|
816
|
+
else if (left instanceof Map)
|
|
817
|
+
result = compare_map(left, right);
|
|
818
|
+
else if (ArrayBuffer.isView(left))
|
|
819
|
+
result = compare_buffer(left, right);
|
|
820
|
+
else if (Symbol.iterator in left)
|
|
821
|
+
result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
|
|
822
|
+
else
|
|
823
|
+
result = false;
|
|
824
|
+
}
|
|
825
|
+
finally {
|
|
826
|
+
left_cache.set(right, result);
|
|
827
|
+
}
|
|
828
|
+
return result;
|
|
829
|
+
}
|
|
830
|
+
$.$mol_compare_deep = $mol_compare_deep;
|
|
831
|
+
function compare_array(left, right) {
|
|
832
|
+
const len = left.length;
|
|
833
|
+
if (len !== right.length)
|
|
834
|
+
return false;
|
|
835
|
+
for (let i = 0; i < len; ++i) {
|
|
836
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
|
837
|
+
return false;
|
|
838
|
+
}
|
|
839
|
+
return true;
|
|
840
|
+
}
|
|
841
|
+
function compare_buffer(left, right) {
|
|
842
|
+
const len = left.byteLength;
|
|
843
|
+
if (len !== right.byteLength)
|
|
844
|
+
return false;
|
|
845
|
+
if (left instanceof DataView)
|
|
846
|
+
return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, right.byteOffset, right.byteLength));
|
|
847
|
+
for (let i = 0; i < len; ++i) {
|
|
848
|
+
if (left[i] !== right[i])
|
|
849
|
+
return false;
|
|
850
|
+
}
|
|
851
|
+
return true;
|
|
852
|
+
}
|
|
853
|
+
function compare_iterator(left, right) {
|
|
854
|
+
while (true) {
|
|
855
|
+
const left_next = left.next();
|
|
856
|
+
const right_next = right.next();
|
|
857
|
+
if (left_next.done !== right_next.done)
|
|
858
|
+
return false;
|
|
859
|
+
if (left_next.done)
|
|
860
|
+
break;
|
|
861
|
+
if (!$mol_compare_deep(left_next.value, right_next.value))
|
|
862
|
+
return false;
|
|
863
|
+
}
|
|
864
|
+
return true;
|
|
865
|
+
}
|
|
866
|
+
function compare_set(left, right) {
|
|
867
|
+
if (left.size !== right.size)
|
|
868
|
+
return false;
|
|
869
|
+
return compare_iterator(left.values(), right.values());
|
|
870
|
+
}
|
|
871
|
+
function compare_map(left, right) {
|
|
872
|
+
if (left.size !== right.size)
|
|
873
|
+
return false;
|
|
874
|
+
return compare_iterator(left.keys(), right.keys())
|
|
875
|
+
&& compare_iterator(left.values(), right.values());
|
|
876
|
+
}
|
|
877
|
+
function compare_pojo(left, right) {
|
|
878
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
|
879
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
|
880
|
+
if (!compare_array(left_keys, right_keys))
|
|
881
|
+
return false;
|
|
882
|
+
for (let key of left_keys) {
|
|
883
|
+
if (!$mol_compare_deep(left[key], right[key]))
|
|
884
|
+
return false;
|
|
885
|
+
}
|
|
886
|
+
const left_syms = Object.getOwnPropertySymbols(left);
|
|
887
|
+
const right_syms = Object.getOwnPropertySymbols(right);
|
|
888
|
+
if (!compare_array(left_syms, right_syms))
|
|
889
|
+
return false;
|
|
890
|
+
for (let key of left_syms) {
|
|
891
|
+
if (!$mol_compare_deep(left[key], right[key]))
|
|
892
|
+
return false;
|
|
893
|
+
}
|
|
894
|
+
return true;
|
|
895
|
+
}
|
|
896
|
+
function compare_primitive(left, right) {
|
|
897
|
+
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
898
|
+
}
|
|
899
|
+
})($ || ($ = {}));
|
|
900
|
+
|
|
901
|
+
;
|
|
902
|
+
"use strict";
|
|
903
|
+
var $;
|
|
904
|
+
(function ($) {
|
|
905
|
+
$mol_test({
|
|
906
|
+
'nulls & undefineds'() {
|
|
907
|
+
$mol_assert_ok($mol_compare_deep(null, null));
|
|
908
|
+
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
909
|
+
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
910
|
+
$mol_assert_not($mol_compare_deep({}, null));
|
|
911
|
+
},
|
|
912
|
+
'number'() {
|
|
913
|
+
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
914
|
+
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
915
|
+
$mol_assert_not($mol_compare_deep(1, 2));
|
|
916
|
+
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
917
|
+
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
918
|
+
},
|
|
919
|
+
'POJO'() {
|
|
920
|
+
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
921
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
922
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
923
|
+
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
924
|
+
$mol_assert_not($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
925
|
+
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
926
|
+
$mol_assert_ok($mol_compare_deep(Object.create(null), Object.create(null)));
|
|
927
|
+
},
|
|
928
|
+
'Array'() {
|
|
929
|
+
$mol_assert_ok($mol_compare_deep([], []));
|
|
930
|
+
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
931
|
+
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
932
|
+
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
933
|
+
$mol_assert_not($mol_compare_deep($mol_range2().slice(0, 0), new Array()));
|
|
934
|
+
$mol_assert_not($mol_compare_deep($mol_range2(), $mol_range2()));
|
|
935
|
+
},
|
|
936
|
+
'Non POJO are different'() {
|
|
937
|
+
class Thing extends Object {
|
|
938
|
+
}
|
|
939
|
+
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
940
|
+
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
941
|
+
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
942
|
+
},
|
|
943
|
+
'POJO with symbols'() {
|
|
944
|
+
const sym = Symbol();
|
|
945
|
+
$mol_assert_ok($mol_compare_deep({ [sym]: true }, { [sym]: true }));
|
|
946
|
+
$mol_assert_not($mol_compare_deep({ [Symbol()]: true }, { [Symbol()]: true }));
|
|
947
|
+
},
|
|
948
|
+
'same POJOs with cyclic reference'() {
|
|
949
|
+
const a = { foo: {} };
|
|
950
|
+
a['self'] = a;
|
|
951
|
+
const b = { foo: {} };
|
|
952
|
+
b['self'] = b;
|
|
953
|
+
$mol_assert_ok($mol_compare_deep(a, b));
|
|
954
|
+
},
|
|
955
|
+
'same POJOs with cyclic reference with cache warmup'() {
|
|
956
|
+
const obj1 = { test: 1, obj3: null };
|
|
957
|
+
const obj1_copy = { test: 1, obj3: null };
|
|
958
|
+
const obj2 = { test: 2, obj1 };
|
|
959
|
+
const obj2_copy = { test: 2, obj1: obj1_copy };
|
|
960
|
+
const obj3 = { test: 3, obj2 };
|
|
961
|
+
const obj3_copy = { test: 3, obj2: obj2_copy };
|
|
962
|
+
obj1.obj3 = obj3;
|
|
963
|
+
obj1_copy.obj3 = obj3_copy;
|
|
964
|
+
$mol_assert_not($mol_compare_deep(obj1, {}));
|
|
965
|
+
$mol_assert_not($mol_compare_deep(obj2, {}));
|
|
966
|
+
$mol_assert_not($mol_compare_deep(obj3, {}));
|
|
967
|
+
$mol_assert_ok($mol_compare_deep(obj3, obj3_copy));
|
|
968
|
+
},
|
|
969
|
+
'Date'() {
|
|
970
|
+
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
971
|
+
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
972
|
+
},
|
|
973
|
+
'RegExp'() {
|
|
974
|
+
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
975
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
976
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
977
|
+
},
|
|
978
|
+
'Error'() {
|
|
979
|
+
$mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
|
|
980
|
+
const fail = (message) => new Error(message);
|
|
981
|
+
$mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
|
|
982
|
+
$mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
|
|
983
|
+
},
|
|
984
|
+
'Map'() {
|
|
985
|
+
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
986
|
+
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
987
|
+
$mol_assert_ok($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
988
|
+
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
989
|
+
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[3], 2]])));
|
|
990
|
+
},
|
|
991
|
+
'Set'() {
|
|
992
|
+
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
993
|
+
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
994
|
+
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
995
|
+
},
|
|
996
|
+
'Uint8Array'() {
|
|
997
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
998
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
999
|
+
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
1000
|
+
},
|
|
1001
|
+
'DataView'() {
|
|
1002
|
+
$mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array().buffer), new DataView(new Uint8Array().buffer)));
|
|
1003
|
+
$mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([0]).buffer)));
|
|
1004
|
+
$mol_assert_not($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([1]).buffer)));
|
|
1005
|
+
},
|
|
1006
|
+
'Serializale'() {
|
|
1007
|
+
class User {
|
|
1008
|
+
name;
|
|
1009
|
+
rand;
|
|
1010
|
+
constructor(name, rand = Math.random()) {
|
|
1011
|
+
this.name = name;
|
|
1012
|
+
this.rand = rand;
|
|
1013
|
+
}
|
|
1014
|
+
[Symbol.toPrimitive](mode) {
|
|
1015
|
+
return this.name;
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
1019
|
+
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
1020
|
+
},
|
|
1021
|
+
'Iterable'() {
|
|
1022
|
+
$mol_assert_ok($mol_compare_deep(new URLSearchParams({ foo: 'bar' }), new URLSearchParams({ foo: 'bar' })));
|
|
1023
|
+
$mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx' }), new URLSearchParams({ foo: 'yyy' })));
|
|
1024
|
+
$mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx', bar: 'yyy' }), new URLSearchParams({ bar: 'yyy', foo: 'xxx' })));
|
|
1025
|
+
},
|
|
1026
|
+
});
|
|
1027
|
+
})($ || ($ = {}));
|
|
1028
|
+
|
|
1029
|
+
;
|
|
1030
|
+
"use strict";
|
|
1031
|
+
var $;
|
|
1032
|
+
(function ($) {
|
|
1033
|
+
$['devtoolsFormatters'] ||= [];
|
|
1034
|
+
function $mol_dev_format_register(config) {
|
|
1035
|
+
$['devtoolsFormatters'].push(config);
|
|
1036
|
+
}
|
|
1037
|
+
$.$mol_dev_format_register = $mol_dev_format_register;
|
|
1038
|
+
$.$mol_dev_format_head = Symbol('$mol_dev_format_head');
|
|
1039
|
+
$.$mol_dev_format_body = Symbol('$mol_dev_format_body');
|
|
1040
|
+
function $mol_dev_format_button(label, click) {
|
|
1041
|
+
return $mol_dev_format_auto({
|
|
1042
|
+
[$.$mol_dev_format_head]() {
|
|
1043
|
+
return $.$mol_dev_format_span({ color: 'cornflowerblue' }, label);
|
|
1044
|
+
},
|
|
1045
|
+
[$.$mol_dev_format_body]() {
|
|
1046
|
+
Promise.resolve().then(click);
|
|
1047
|
+
return $.$mol_dev_format_span({});
|
|
1048
|
+
}
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
$mol_dev_format_register({
|
|
1052
|
+
header: (val, config = false) => {
|
|
1053
|
+
if (config)
|
|
1054
|
+
return null;
|
|
1055
|
+
if (!val)
|
|
1056
|
+
return null;
|
|
1057
|
+
if ($.$mol_dev_format_head in val) {
|
|
1058
|
+
try {
|
|
1059
|
+
return val[$.$mol_dev_format_head]();
|
|
1060
|
+
}
|
|
1061
|
+
catch (error) {
|
|
1062
|
+
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
if (typeof val === 'function') {
|
|
1066
|
+
return $mol_dev_format_native(val);
|
|
1067
|
+
}
|
|
1068
|
+
if (val instanceof Error) {
|
|
1069
|
+
return $.$mol_dev_format_span({}, $mol_dev_format_native(val), ' ', $mol_dev_format_button('throw', () => $mol_fail_hidden(val)));
|
|
1070
|
+
}
|
|
1071
|
+
if (val instanceof Promise) {
|
|
1072
|
+
return $.$mol_dev_format_shade($mol_dev_format_native(val), ' ', val[Symbol.toStringTag] ?? '');
|
|
1073
|
+
}
|
|
1074
|
+
if (Symbol.toStringTag in val) {
|
|
1075
|
+
return $mol_dev_format_native(val);
|
|
1076
|
+
}
|
|
1077
|
+
return null;
|
|
1078
|
+
},
|
|
1079
|
+
hasBody: (val, config = false) => {
|
|
1080
|
+
if (config)
|
|
1081
|
+
return false;
|
|
1082
|
+
if (!val)
|
|
1083
|
+
return false;
|
|
1084
|
+
if (val[$.$mol_dev_format_body])
|
|
1085
|
+
return true;
|
|
1086
|
+
return false;
|
|
1087
|
+
},
|
|
1088
|
+
body: (val, config = false) => {
|
|
1089
|
+
if (config)
|
|
1090
|
+
return null;
|
|
1091
|
+
if (!val)
|
|
1092
|
+
return null;
|
|
1093
|
+
if ($.$mol_dev_format_body in val) {
|
|
1094
|
+
try {
|
|
1095
|
+
return val[$.$mol_dev_format_body]();
|
|
1096
|
+
}
|
|
1097
|
+
catch (error) {
|
|
1098
|
+
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
return null;
|
|
1102
|
+
},
|
|
1103
|
+
});
|
|
1104
|
+
function $mol_dev_format_native(obj) {
|
|
1105
|
+
if (typeof obj === 'undefined')
|
|
1106
|
+
return $.$mol_dev_format_shade('undefined');
|
|
1107
|
+
return [
|
|
1108
|
+
'object',
|
|
1109
|
+
{
|
|
1110
|
+
object: obj,
|
|
1111
|
+
config: true,
|
|
1112
|
+
},
|
|
1113
|
+
];
|
|
1114
|
+
}
|
|
1115
|
+
$.$mol_dev_format_native = $mol_dev_format_native;
|
|
1116
|
+
function $mol_dev_format_auto(obj) {
|
|
1117
|
+
if (obj == null)
|
|
1118
|
+
return $.$mol_dev_format_shade(String(obj));
|
|
1119
|
+
return [
|
|
1120
|
+
'object',
|
|
1121
|
+
{
|
|
1122
|
+
object: obj,
|
|
1123
|
+
config: false,
|
|
1124
|
+
},
|
|
1125
|
+
];
|
|
1126
|
+
}
|
|
1127
|
+
$.$mol_dev_format_auto = $mol_dev_format_auto;
|
|
1128
|
+
function $mol_dev_format_element(element, style, ...content) {
|
|
1129
|
+
const styles = [];
|
|
1130
|
+
for (let key in style)
|
|
1131
|
+
styles.push(`${key} : ${style[key]}`);
|
|
1132
|
+
return [
|
|
1133
|
+
element,
|
|
1134
|
+
{
|
|
1135
|
+
style: styles.join(' ; '),
|
|
1136
|
+
},
|
|
1137
|
+
...content,
|
|
1138
|
+
];
|
|
1139
|
+
}
|
|
1140
|
+
$.$mol_dev_format_element = $mol_dev_format_element;
|
|
1141
|
+
$.$mol_dev_format_span = $mol_dev_format_element.bind(null, 'span');
|
|
1142
|
+
$.$mol_dev_format_div = $mol_dev_format_element.bind(null, 'div');
|
|
1143
|
+
$.$mol_dev_format_ol = $mol_dev_format_element.bind(null, 'ol');
|
|
1144
|
+
$.$mol_dev_format_li = $mol_dev_format_element.bind(null, 'li');
|
|
1145
|
+
$.$mol_dev_format_table = $mol_dev_format_element.bind(null, 'table');
|
|
1146
|
+
$.$mol_dev_format_tr = $mol_dev_format_element.bind(null, 'tr');
|
|
1147
|
+
$.$mol_dev_format_td = $mol_dev_format_element.bind(null, 'td');
|
|
1148
|
+
$.$mol_dev_format_accent = $.$mol_dev_format_span.bind(null, {
|
|
1149
|
+
'color': 'magenta',
|
|
1150
|
+
});
|
|
1151
|
+
$.$mol_dev_format_strong = $.$mol_dev_format_span.bind(null, {
|
|
1152
|
+
'font-weight': 'bold',
|
|
1153
|
+
});
|
|
1154
|
+
$.$mol_dev_format_string = $.$mol_dev_format_span.bind(null, {
|
|
1155
|
+
'color': 'green',
|
|
1156
|
+
});
|
|
1157
|
+
$.$mol_dev_format_shade = $.$mol_dev_format_span.bind(null, {
|
|
1158
|
+
'color': 'gray',
|
|
1159
|
+
});
|
|
1160
|
+
$.$mol_dev_format_indent = $.$mol_dev_format_div.bind(null, {
|
|
1161
|
+
'margin-left': '13px'
|
|
1162
|
+
});
|
|
1163
|
+
class Stack extends Array {
|
|
1164
|
+
toString() {
|
|
1165
|
+
return this.join('\n');
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
class Call extends Object {
|
|
1169
|
+
type;
|
|
1170
|
+
function;
|
|
1171
|
+
method;
|
|
1172
|
+
eval;
|
|
1173
|
+
source;
|
|
1174
|
+
offset;
|
|
1175
|
+
pos;
|
|
1176
|
+
object;
|
|
1177
|
+
flags;
|
|
1178
|
+
[Symbol.toStringTag];
|
|
1179
|
+
constructor(call) {
|
|
1180
|
+
super();
|
|
1181
|
+
this.type = call.getTypeName() ?? '';
|
|
1182
|
+
this.function = call.getFunctionName() ?? '';
|
|
1183
|
+
this.method = call.getMethodName() ?? '';
|
|
1184
|
+
if (this.method === this.function)
|
|
1185
|
+
this.method = '';
|
|
1186
|
+
this.pos = [call.getEnclosingLineNumber() ?? 0, call.getEnclosingColumnNumber() ?? 0];
|
|
1187
|
+
this.eval = call.getEvalOrigin() ?? '';
|
|
1188
|
+
this.source = call.getScriptNameOrSourceURL() ?? '';
|
|
1189
|
+
this.object = call.getThis();
|
|
1190
|
+
this.offset = call.getPosition();
|
|
1191
|
+
const flags = [];
|
|
1192
|
+
if (call.isAsync())
|
|
1193
|
+
flags.push('async');
|
|
1194
|
+
if (call.isConstructor())
|
|
1195
|
+
flags.push('constructor');
|
|
1196
|
+
if (call.isEval())
|
|
1197
|
+
flags.push('eval');
|
|
1198
|
+
if (call.isNative())
|
|
1199
|
+
flags.push('native');
|
|
1200
|
+
if (call.isPromiseAll())
|
|
1201
|
+
flags.push('PromiseAll');
|
|
1202
|
+
if (call.isToplevel())
|
|
1203
|
+
flags.push('top');
|
|
1204
|
+
this.flags = flags;
|
|
1205
|
+
const type = this.type ? this.type + '.' : '';
|
|
1206
|
+
const func = this.function || '<anon>';
|
|
1207
|
+
const method = this.method ? ' [' + this.method + '] ' : '';
|
|
1208
|
+
this[Symbol.toStringTag] = `${type}${func}${method}`;
|
|
1209
|
+
}
|
|
1210
|
+
[Symbol.toPrimitive]() {
|
|
1211
|
+
return this.toString();
|
|
1212
|
+
}
|
|
1213
|
+
toString() {
|
|
1214
|
+
const object = this.object || '';
|
|
1215
|
+
const label = this[Symbol.toStringTag];
|
|
1216
|
+
const source = `${this.source}:${this.pos.join(':')} #${this.offset}`;
|
|
1217
|
+
return `\tat ${object}${label} (${source})`;
|
|
1218
|
+
}
|
|
1219
|
+
[$.$mol_dev_format_head]() {
|
|
1220
|
+
return $.$mol_dev_format_div({}, $mol_dev_format_native(this), $.$mol_dev_format_shade(' '), ...this.object ? [
|
|
1221
|
+
$mol_dev_format_native(this.object),
|
|
1222
|
+
] : [], ...this.method ? [$.$mol_dev_format_shade(' ', ' [', this.method, ']')] : [], $.$mol_dev_format_shade(' ', this.flags.join(', ')));
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
Error.prepareStackTrace ??= (error, stack) => new Stack(...stack.map(call => new Call(call)));
|
|
1226
|
+
})($ || ($ = {}));
|
|
1227
|
+
|
|
1228
|
+
;
|
|
1229
|
+
"use strict";
|
|
1230
|
+
var $;
|
|
1231
|
+
(function ($) {
|
|
1232
|
+
function $mol_assert_ok(value) {
|
|
1233
|
+
if (value)
|
|
1234
|
+
return;
|
|
1235
|
+
$mol_fail(new Error(`${value} ≠ true`));
|
|
1236
|
+
}
|
|
1237
|
+
$.$mol_assert_ok = $mol_assert_ok;
|
|
1238
|
+
function $mol_assert_not(value) {
|
|
1239
|
+
if (!value)
|
|
1240
|
+
return;
|
|
1241
|
+
$mol_fail(new Error(`${value} ≠ false`));
|
|
1242
|
+
}
|
|
1243
|
+
$.$mol_assert_not = $mol_assert_not;
|
|
1244
|
+
function $mol_assert_fail(handler, ErrorRight) {
|
|
1245
|
+
const fail = $.$mol_fail;
|
|
1246
|
+
try {
|
|
1247
|
+
$.$mol_fail = $.$mol_fail_hidden;
|
|
1248
|
+
handler();
|
|
1249
|
+
}
|
|
1250
|
+
catch (error) {
|
|
1251
|
+
$.$mol_fail = fail;
|
|
1252
|
+
if (typeof ErrorRight === 'string') {
|
|
1253
|
+
$mol_assert_equal(error.message ?? error, ErrorRight);
|
|
1254
|
+
}
|
|
1255
|
+
else {
|
|
1256
|
+
$mol_assert_equal(error instanceof ErrorRight, true);
|
|
1257
|
+
}
|
|
1258
|
+
return error;
|
|
1259
|
+
}
|
|
1260
|
+
finally {
|
|
1261
|
+
$.$mol_fail = fail;
|
|
1262
|
+
}
|
|
1263
|
+
$mol_fail(new Error('Not failed'));
|
|
1264
|
+
}
|
|
1265
|
+
$.$mol_assert_fail = $mol_assert_fail;
|
|
1266
|
+
function $mol_assert_like(...args) {
|
|
1267
|
+
$mol_assert_equal(...args);
|
|
1268
|
+
}
|
|
1269
|
+
$.$mol_assert_like = $mol_assert_like;
|
|
1270
|
+
function $mol_assert_unique(...args) {
|
|
1271
|
+
for (let i = 0; i < args.length; ++i) {
|
|
1272
|
+
for (let j = 0; j < args.length; ++j) {
|
|
1273
|
+
if (i === j)
|
|
1274
|
+
continue;
|
|
1275
|
+
if (!$mol_compare_deep(args[i], args[j]))
|
|
1276
|
+
continue;
|
|
1277
|
+
return $mol_fail(new Error(`Uniquesess assertion failure`, { cause: { [i]: args[i], [i]: args[i] } }));
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
$.$mol_assert_unique = $mol_assert_unique;
|
|
1282
|
+
function $mol_assert_equal(...args) {
|
|
1283
|
+
for (let i = 1; i < args.length; ++i) {
|
|
1284
|
+
if ($mol_compare_deep(args[0], args[i]))
|
|
1285
|
+
continue;
|
|
1286
|
+
return $mol_fail(new Error(`Equality assertion failure`, { cause: { 0: args[0], [i]: args[i] } }));
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
$.$mol_assert_equal = $mol_assert_equal;
|
|
1290
|
+
})($ || ($ = {}));
|
|
1291
|
+
|
|
1292
|
+
;
|
|
1293
|
+
"use strict";
|
|
1294
|
+
var $;
|
|
1295
|
+
(function ($) {
|
|
1296
|
+
$mol_test({
|
|
1297
|
+
'must be false'() {
|
|
1298
|
+
$mol_assert_not(0);
|
|
1299
|
+
},
|
|
1300
|
+
'must be true'() {
|
|
1301
|
+
$mol_assert_ok(1);
|
|
1302
|
+
},
|
|
1303
|
+
'two must be equal'() {
|
|
1304
|
+
$mol_assert_equal(2, 2);
|
|
1305
|
+
},
|
|
1306
|
+
'three must be equal'() {
|
|
1307
|
+
$mol_assert_equal(2, 2, 2);
|
|
1308
|
+
},
|
|
1309
|
+
'two must be unique'() {
|
|
1310
|
+
$mol_assert_unique([2], [3]);
|
|
1311
|
+
},
|
|
1312
|
+
'three must be unique'() {
|
|
1313
|
+
$mol_assert_unique([1], [2], [3]);
|
|
1314
|
+
},
|
|
1315
|
+
'two must be alike'() {
|
|
1316
|
+
$mol_assert_equal([3], [3]);
|
|
1317
|
+
},
|
|
1318
|
+
'three must be alike'() {
|
|
1319
|
+
$mol_assert_equal([3], [3], [3]);
|
|
1320
|
+
},
|
|
1321
|
+
'two object must be alike'() {
|
|
1322
|
+
$mol_assert_equal({ a: 1 }, { a: 1 });
|
|
1323
|
+
},
|
|
1324
|
+
'three object must be alike'() {
|
|
1325
|
+
$mol_assert_equal({ a: 1 }, { a: 1 }, { a: 1 });
|
|
1326
|
+
},
|
|
1327
|
+
});
|
|
1328
|
+
})($ || ($ = {}));
|
|
1329
|
+
|
|
1330
|
+
;
|
|
1331
|
+
"use strict";
|
|
1332
|
+
var $;
|
|
1333
|
+
(function ($) {
|
|
1334
|
+
function $mol_log3_area_lazy(event) {
|
|
1335
|
+
const self = this.$;
|
|
1336
|
+
const stack = self.$mol_log3_stack;
|
|
1337
|
+
const deep = stack.length;
|
|
1338
|
+
let logged = false;
|
|
1339
|
+
stack.push(() => {
|
|
1340
|
+
logged = true;
|
|
1341
|
+
self.$mol_log3_area.call(self, event);
|
|
1342
|
+
});
|
|
1343
|
+
return () => {
|
|
1344
|
+
if (logged)
|
|
1345
|
+
self.console.groupEnd();
|
|
1346
|
+
if (stack.length > deep)
|
|
1347
|
+
stack.length = deep;
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
1351
|
+
$.$mol_log3_stack = [];
|
|
1352
|
+
})($ || ($ = {}));
|
|
1353
|
+
|
|
1354
|
+
;
|
|
1355
|
+
"use strict";
|
|
1356
|
+
|
|
1357
|
+
;
|
|
1358
|
+
"use strict";
|
|
1359
|
+
|
|
1360
|
+
;
|
|
1361
|
+
"use strict";
|
|
1362
|
+
|
|
1363
|
+
;
|
|
1364
|
+
"use strict";
|
|
1365
|
+
|
|
1366
|
+
;
|
|
1367
|
+
"use strict";
|
|
1368
|
+
var $;
|
|
1369
|
+
(function ($) {
|
|
1370
|
+
function $mol_log3_web_make(level, color) {
|
|
1371
|
+
return function $mol_log3_logger(event) {
|
|
1372
|
+
const pending = this.$mol_log3_stack.pop();
|
|
1373
|
+
if (pending)
|
|
1374
|
+
pending();
|
|
1375
|
+
let tpl = '%c';
|
|
1376
|
+
const chunks = Object.entries(event);
|
|
1377
|
+
for (let i = 0; i < chunks.length; ++i) {
|
|
1378
|
+
tpl += (typeof chunks[i][1] === 'string') ? '%s: %s\n' : '%s: %o\n';
|
|
1379
|
+
}
|
|
1380
|
+
const style = `color:${color};font-weight:bolder`;
|
|
1381
|
+
this.console[level](tpl.trim(), style, ...[].concat(...chunks));
|
|
1382
|
+
const self = this;
|
|
1383
|
+
return () => self.console.groupEnd();
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
$.$mol_log3_web_make = $mol_log3_web_make;
|
|
1387
|
+
$.$mol_log3_come = $mol_log3_web_make('info', 'royalblue');
|
|
1388
|
+
$.$mol_log3_done = $mol_log3_web_make('info', 'forestgreen');
|
|
1389
|
+
$.$mol_log3_fail = $mol_log3_web_make('error', 'orangered');
|
|
1390
|
+
$.$mol_log3_warn = $mol_log3_web_make('warn', 'goldenrod');
|
|
1391
|
+
$.$mol_log3_rise = $mol_log3_web_make('log', 'magenta');
|
|
1392
|
+
$.$mol_log3_area = $mol_log3_web_make('group', 'cyan');
|
|
1393
|
+
})($ || ($ = {}));
|
|
1394
|
+
|
|
1395
|
+
;
|
|
1396
|
+
"use strict";
|
|
1397
|
+
var $;
|
|
1398
|
+
(function ($_1) {
|
|
1399
|
+
$mol_test_mocks.push($ => {
|
|
1400
|
+
$.$mol_log3_come = () => { };
|
|
1401
|
+
$.$mol_log3_done = () => { };
|
|
1402
|
+
$.$mol_log3_fail = () => { };
|
|
1403
|
+
$.$mol_log3_warn = () => { };
|
|
1404
|
+
$.$mol_log3_rise = () => { };
|
|
1405
|
+
$.$mol_log3_area = () => () => { };
|
|
1406
|
+
});
|
|
1407
|
+
})($ || ($ = {}));
|
|
1408
|
+
|
|
1409
|
+
;
|
|
1410
|
+
"use strict";
|
|
1411
|
+
var $;
|
|
1412
|
+
(function ($) {
|
|
1413
|
+
const named = new WeakSet();
|
|
1414
|
+
function $mol_func_name(func) {
|
|
1415
|
+
let name = func.name;
|
|
1416
|
+
if (name?.length > 1)
|
|
1417
|
+
return name;
|
|
1418
|
+
if (named.has(func))
|
|
1419
|
+
return name;
|
|
1420
|
+
for (let key in this) {
|
|
1421
|
+
try {
|
|
1422
|
+
if (this[key] !== func)
|
|
1423
|
+
continue;
|
|
1424
|
+
name = key;
|
|
1425
|
+
Object.defineProperty(func, 'name', { value: name });
|
|
1426
|
+
break;
|
|
1427
|
+
}
|
|
1428
|
+
catch { }
|
|
1429
|
+
}
|
|
1430
|
+
named.add(func);
|
|
1431
|
+
return name;
|
|
1432
|
+
}
|
|
1433
|
+
$.$mol_func_name = $mol_func_name;
|
|
1434
|
+
function $mol_func_name_from(target, source) {
|
|
1435
|
+
Object.defineProperty(target, 'name', { value: source.name });
|
|
1436
|
+
return target;
|
|
1437
|
+
}
|
|
1438
|
+
$.$mol_func_name_from = $mol_func_name_from;
|
|
1439
|
+
})($ || ($ = {}));
|
|
1440
|
+
|
|
1441
|
+
;
|
|
1442
|
+
"use strict";
|
|
1443
|
+
var $;
|
|
1444
|
+
(function ($_1) {
|
|
1445
|
+
$mol_test({
|
|
1446
|
+
'FQN of anon function'($) {
|
|
1447
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
1448
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
1449
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
1450
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
1451
|
+
},
|
|
1452
|
+
});
|
|
1453
|
+
})($ || ($ = {}));
|
|
1454
|
+
|
|
1455
|
+
;
|
|
1456
|
+
"use strict";
|
|
1457
|
+
var $;
|
|
1458
|
+
(function ($_1) {
|
|
1459
|
+
var $$;
|
|
1460
|
+
(function ($$) {
|
|
1461
|
+
$mol_test({
|
|
1462
|
+
"Complex UCF encoding"($) {
|
|
1463
|
+
$mol_assert_equal($mol_charset_ucf_encode('hi мир, 你好 世界 🏴☠\t\n'), new Uint8Array([
|
|
1464
|
+
0x68, 0x69, 0x20,
|
|
1465
|
+
0x16, 0xBC, 0xB8, 0xC0, 0x2C, 0x20,
|
|
1466
|
+
0x00, 0xE0, 0x9E, 0xFD, 0xB2, 0x20, 0x96, 0x9C, 0xCC, 0xEA, 0x20,
|
|
1467
|
+
0x03, 0xF4, 0xE7, 0x00, 0x8D, 0x40, 0xA0, 0x4C, 0x09, 0x0A,
|
|
1468
|
+
]));
|
|
1469
|
+
},
|
|
1470
|
+
});
|
|
1471
|
+
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
1472
|
+
})($ || ($ = {}));
|
|
1473
|
+
|
|
1474
|
+
;
|
|
1475
|
+
"use strict";
|
|
1476
|
+
var $;
|
|
1477
|
+
(function ($_1) {
|
|
1478
|
+
var $$;
|
|
1479
|
+
(function ($$) {
|
|
1480
|
+
$mol_test({
|
|
1481
|
+
"Complex UCF eecoding"($) {
|
|
1482
|
+
$mol_assert_equal('hi мир, 你好 世界 🏴☠\t\n', $mol_charset_ucf_decode(new Uint8Array([
|
|
1483
|
+
0x68, 0x69, 0x20,
|
|
1484
|
+
0x16, 0xBC, 0xB8, 0xC0, 0x2C, 0x20,
|
|
1485
|
+
0x00, 0xE0, 0x9E, 0xFD, 0xB2, 0x20, 0x96, 0x9C, 0xCC, 0xEA, 0x20,
|
|
1486
|
+
0x03, 0xF4, 0xE7, 0x00, 0x8D, 0x40, 0xA0, 0x4C, 0x09, 0x0A,
|
|
1487
|
+
])));
|
|
1488
|
+
},
|
|
1489
|
+
});
|
|
1490
|
+
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
1491
|
+
})($ || ($ = {}));
|
|
1492
|
+
|
|
1493
|
+
|
|
3
1494
|
//# sourceMappingURL=web.test.js.map
|