mol_key 0.0.392 → 0.0.394
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.deps.json +1 -1
- package/node.js +13 -13
- package/node.js.map +1 -1
- package/node.mjs +13 -13
- package/node.mjs.map +1 -1
- package/node.test.js +619 -619
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.deps.json +1 -1
- package/web.js +13 -13
- package/web.js.map +1 -1
- package/web.mjs +13 -13
- package/web.mjs.map +1 -1
- package/web.test.js +391 -391
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
"use strict";
|
|
3
|
+
Error.stackTraceLimit = 50;
|
|
4
|
+
var $;
|
|
5
|
+
(function ($) {
|
|
6
|
+
})($ || ($ = {}));
|
|
7
|
+
module.exports = $;
|
|
8
|
+
//mam.ts
|
|
9
|
+
;
|
|
2
10
|
"use strict"
|
|
3
11
|
|
|
4
12
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
@@ -11,14 +19,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
11
19
|
var $ = ( typeof module === 'object' ) ? ( module['export'+'s'] = globalThis ) : globalThis
|
|
12
20
|
$.$$ = $
|
|
13
21
|
|
|
14
|
-
;
|
|
15
|
-
"use strict";
|
|
16
|
-
Error.stackTraceLimit = 50;
|
|
17
|
-
var $;
|
|
18
|
-
(function ($) {
|
|
19
|
-
})($ || ($ = {}));
|
|
20
|
-
module.exports = $;
|
|
21
|
-
//mam.ts
|
|
22
22
|
;
|
|
23
23
|
"use strict";
|
|
24
24
|
var $;
|
|
@@ -74,6 +74,63 @@ var $;
|
|
|
74
74
|
;
|
|
75
75
|
"use strict";
|
|
76
76
|
var $;
|
|
77
|
+
(function ($) {
|
|
78
|
+
})($ || ($ = {}));
|
|
79
|
+
//mol/dom/context/context.ts
|
|
80
|
+
;
|
|
81
|
+
"use strict";
|
|
82
|
+
//node/node.ts
|
|
83
|
+
;
|
|
84
|
+
"use strict";
|
|
85
|
+
var $node = new Proxy({ require }, {
|
|
86
|
+
get(target, name, wrapper) {
|
|
87
|
+
if (target[name])
|
|
88
|
+
return target[name];
|
|
89
|
+
const mod = target.require('module');
|
|
90
|
+
if (mod.builtinModules.indexOf(name) >= 0)
|
|
91
|
+
return target.require(name);
|
|
92
|
+
if (name[0] === '.')
|
|
93
|
+
return target.require(name);
|
|
94
|
+
const path = target.require('path');
|
|
95
|
+
const fs = target.require('fs');
|
|
96
|
+
let dir = path.resolve('.');
|
|
97
|
+
const suffix = `./node_modules/${name}`;
|
|
98
|
+
const $$ = $;
|
|
99
|
+
while (!fs.existsSync(path.join(dir, suffix))) {
|
|
100
|
+
const parent = path.resolve(dir, '..');
|
|
101
|
+
if (parent === dir) {
|
|
102
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
103
|
+
try {
|
|
104
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
105
|
+
}
|
|
106
|
+
catch { }
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
dir = parent;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return target.require(name);
|
|
114
|
+
},
|
|
115
|
+
set(target, name, value) {
|
|
116
|
+
target[name] = value;
|
|
117
|
+
return true;
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
require = (req => Object.assign(function require(name) {
|
|
121
|
+
return $node[name];
|
|
122
|
+
}, req))(require);
|
|
123
|
+
//node/node.node.ts
|
|
124
|
+
;
|
|
125
|
+
"use strict";
|
|
126
|
+
var $;
|
|
127
|
+
(function ($) {
|
|
128
|
+
$.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
|
|
129
|
+
})($ || ($ = {}));
|
|
130
|
+
//mol/dom/context/context.node.ts
|
|
131
|
+
;
|
|
132
|
+
"use strict";
|
|
133
|
+
var $;
|
|
77
134
|
(function ($) {
|
|
78
135
|
function $mol_fail(error) {
|
|
79
136
|
throw error;
|
|
@@ -85,22 +142,82 @@ var $;
|
|
|
85
142
|
"use strict";
|
|
86
143
|
var $;
|
|
87
144
|
(function ($) {
|
|
88
|
-
function $
|
|
89
|
-
|
|
145
|
+
function $mol_dom_render_children(el, childNodes) {
|
|
146
|
+
const node_set = new Set(childNodes);
|
|
147
|
+
let nextNode = el.firstChild;
|
|
148
|
+
for (let view of childNodes) {
|
|
149
|
+
if (view == null)
|
|
150
|
+
continue;
|
|
151
|
+
if (view instanceof $mol_dom_context.Node) {
|
|
152
|
+
while (true) {
|
|
153
|
+
if (!nextNode) {
|
|
154
|
+
el.appendChild(view);
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
if (nextNode == view) {
|
|
158
|
+
nextNode = nextNode.nextSibling;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
if (node_set.has(nextNode)) {
|
|
163
|
+
el.insertBefore(view, nextNode);
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
const nn = nextNode.nextSibling;
|
|
168
|
+
el.removeChild(nextNode);
|
|
169
|
+
nextNode = nn;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
if (nextNode && nextNode.nodeName === '#text') {
|
|
176
|
+
const str = String(view);
|
|
177
|
+
if (nextNode.nodeValue !== str)
|
|
178
|
+
nextNode.nodeValue = str;
|
|
179
|
+
nextNode = nextNode.nextSibling;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
|
183
|
+
el.insertBefore(textNode, nextNode);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
while (nextNode) {
|
|
188
|
+
const currNode = nextNode;
|
|
189
|
+
nextNode = currNode.nextSibling;
|
|
190
|
+
el.removeChild(currNode);
|
|
191
|
+
}
|
|
90
192
|
}
|
|
91
|
-
$.$
|
|
193
|
+
$.$mol_dom_render_children = $mol_dom_render_children;
|
|
92
194
|
})($ || ($ = {}));
|
|
93
|
-
//mol/
|
|
195
|
+
//mol/dom/render/children/children.ts
|
|
196
|
+
;
|
|
197
|
+
"use strict";
|
|
198
|
+
//mol/type/error/error.ts
|
|
199
|
+
;
|
|
200
|
+
"use strict";
|
|
201
|
+
//mol/type/assert/assert.ts
|
|
202
|
+
;
|
|
203
|
+
"use strict";
|
|
204
|
+
//mol/type/assert/assert.test.ts
|
|
205
|
+
;
|
|
206
|
+
"use strict";
|
|
207
|
+
//mol/type/partial/deep/deep.ts
|
|
208
|
+
;
|
|
209
|
+
"use strict";
|
|
210
|
+
//mol/type/partial/deep/deep.test.ts
|
|
94
211
|
;
|
|
95
212
|
"use strict";
|
|
96
213
|
var $;
|
|
97
214
|
(function ($) {
|
|
98
|
-
function $
|
|
99
|
-
|
|
215
|
+
function $mol_fail_hidden(error) {
|
|
216
|
+
throw error;
|
|
100
217
|
}
|
|
101
|
-
$.$
|
|
218
|
+
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
102
219
|
})($ || ($ = {}));
|
|
103
|
-
//mol/
|
|
220
|
+
//mol/fail/hidden/hidden.ts
|
|
104
221
|
;
|
|
105
222
|
"use strict";
|
|
106
223
|
var $;
|
|
@@ -192,224 +309,23 @@ var $;
|
|
|
192
309
|
"use strict";
|
|
193
310
|
var $;
|
|
194
311
|
(function ($) {
|
|
312
|
+
function $mol_test_complete() {
|
|
313
|
+
process.exit(0);
|
|
314
|
+
}
|
|
315
|
+
$.$mol_test_complete = $mol_test_complete;
|
|
195
316
|
})($ || ($ = {}));
|
|
196
|
-
//mol/
|
|
197
|
-
;
|
|
198
|
-
"use strict";
|
|
199
|
-
//node/node.ts
|
|
200
|
-
;
|
|
201
|
-
"use strict";
|
|
202
|
-
var $node = new Proxy({ require }, {
|
|
203
|
-
get(target, name, wrapper) {
|
|
204
|
-
if (target[name])
|
|
205
|
-
return target[name];
|
|
206
|
-
const mod = target.require('module');
|
|
207
|
-
if (mod.builtinModules.indexOf(name) >= 0)
|
|
208
|
-
return target.require(name);
|
|
209
|
-
if (name[0] === '.')
|
|
210
|
-
return target.require(name);
|
|
211
|
-
const path = target.require('path');
|
|
212
|
-
const fs = target.require('fs');
|
|
213
|
-
let dir = path.resolve('.');
|
|
214
|
-
const suffix = `./node_modules/${name}`;
|
|
215
|
-
const $$ = $;
|
|
216
|
-
while (!fs.existsSync(path.join(dir, suffix))) {
|
|
217
|
-
const parent = path.resolve(dir, '..');
|
|
218
|
-
if (parent === dir) {
|
|
219
|
-
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
220
|
-
try {
|
|
221
|
-
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
222
|
-
}
|
|
223
|
-
catch { }
|
|
224
|
-
break;
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
dir = parent;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return target.require(name);
|
|
231
|
-
},
|
|
232
|
-
set(target, name, value) {
|
|
233
|
-
target[name] = value;
|
|
234
|
-
return true;
|
|
235
|
-
},
|
|
236
|
-
});
|
|
237
|
-
require = (req => Object.assign(function require(name) {
|
|
238
|
-
return $node[name];
|
|
239
|
-
}, req))(require);
|
|
240
|
-
//node/node.node.ts
|
|
317
|
+
//mol/test/test.node.test.ts
|
|
241
318
|
;
|
|
242
319
|
"use strict";
|
|
243
320
|
var $;
|
|
244
321
|
(function ($) {
|
|
245
|
-
function $
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
const deep = stack.length;
|
|
249
|
-
let logged = false;
|
|
250
|
-
stack.push(() => {
|
|
251
|
-
logged = true;
|
|
252
|
-
self.$mol_log3_area.call(self, event);
|
|
253
|
-
});
|
|
254
|
-
return () => {
|
|
255
|
-
if (logged)
|
|
256
|
-
self.console.groupEnd();
|
|
257
|
-
if (stack.length > deep)
|
|
258
|
-
stack.length = deep;
|
|
259
|
-
};
|
|
322
|
+
function $mol_dom_serialize(node) {
|
|
323
|
+
const serializer = new $mol_dom_context.XMLSerializer;
|
|
324
|
+
return serializer.serializeToString(node);
|
|
260
325
|
}
|
|
261
|
-
$.$
|
|
262
|
-
$.$mol_log3_stack = [];
|
|
326
|
+
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
263
327
|
})($ || ($ = {}));
|
|
264
|
-
//mol/
|
|
265
|
-
;
|
|
266
|
-
"use strict";
|
|
267
|
-
var $;
|
|
268
|
-
(function ($) {
|
|
269
|
-
class $mol_term_color {
|
|
270
|
-
static reset = this.ansi(0, 0);
|
|
271
|
-
static bold = this.ansi(1, 22);
|
|
272
|
-
static italic = this.ansi(3, 23);
|
|
273
|
-
static underline = this.ansi(4, 24);
|
|
274
|
-
static inverse = this.ansi(7, 27);
|
|
275
|
-
static hidden = this.ansi(8, 28);
|
|
276
|
-
static strike = this.ansi(9, 29);
|
|
277
|
-
static gray = this.ansi(90, 39);
|
|
278
|
-
static red = this.ansi(91, 39);
|
|
279
|
-
static green = this.ansi(92, 39);
|
|
280
|
-
static yellow = this.ansi(93, 39);
|
|
281
|
-
static blue = this.ansi(94, 39);
|
|
282
|
-
static magenta = this.ansi(95, 39);
|
|
283
|
-
static cyan = this.ansi(96, 39);
|
|
284
|
-
static Gray = (str) => this.inverse(this.gray(str));
|
|
285
|
-
static Red = (str) => this.inverse(this.red(str));
|
|
286
|
-
static Green = (str) => this.inverse(this.green(str));
|
|
287
|
-
static Yellow = (str) => this.inverse(this.yellow(str));
|
|
288
|
-
static Blue = (str) => this.inverse(this.blue(str));
|
|
289
|
-
static Magenta = (str) => this.inverse(this.magenta(str));
|
|
290
|
-
static Cyan = (str) => this.inverse(this.cyan(str));
|
|
291
|
-
static ansi(open, close) {
|
|
292
|
-
if (typeof process === 'undefined')
|
|
293
|
-
return String;
|
|
294
|
-
if (!process.stdout.isTTY)
|
|
295
|
-
return String;
|
|
296
|
-
const prefix = `\x1b[${open}m`;
|
|
297
|
-
const postfix = `\x1b[${close}m`;
|
|
298
|
-
const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
|
|
299
|
-
return function colorer(str) {
|
|
300
|
-
str = String(str);
|
|
301
|
-
if (str === '')
|
|
302
|
-
return str;
|
|
303
|
-
const suffix = str.replace(suffix_regexp, prefix);
|
|
304
|
-
return prefix + suffix + postfix;
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
$.$mol_term_color = $mol_term_color;
|
|
309
|
-
})($ || ($ = {}));
|
|
310
|
-
//mol/term/color/color.ts
|
|
311
|
-
;
|
|
312
|
-
"use strict";
|
|
313
|
-
var $;
|
|
314
|
-
(function ($) {
|
|
315
|
-
function $mol_log3_node_make(level, output, type, color) {
|
|
316
|
-
return function $mol_log3_logger(event) {
|
|
317
|
-
if (!event.time)
|
|
318
|
-
event = { time: new Date().toISOString(), ...event };
|
|
319
|
-
const tree = this.$mol_tree.fromJSON(event).clone({ type });
|
|
320
|
-
let str = color(tree.toString());
|
|
321
|
-
this.console[level](str);
|
|
322
|
-
const self = this;
|
|
323
|
-
return () => self.console.groupEnd();
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
|
-
$.$mol_log3_node_make = $mol_log3_node_make;
|
|
327
|
-
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
|
|
328
|
-
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
|
|
329
|
-
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
|
|
330
|
-
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
|
|
331
|
-
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
|
|
332
|
-
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
|
333
|
-
})($ || ($ = {}));
|
|
334
|
-
//mol/log3/log3.node.ts
|
|
335
|
-
;
|
|
336
|
-
"use strict";
|
|
337
|
-
var $;
|
|
338
|
-
(function ($_1) {
|
|
339
|
-
$mol_test_mocks.push($ => {
|
|
340
|
-
$.$mol_log3_come = () => { };
|
|
341
|
-
$.$mol_log3_done = () => { };
|
|
342
|
-
$.$mol_log3_fail = () => { };
|
|
343
|
-
$.$mol_log3_warn = () => { };
|
|
344
|
-
$.$mol_log3_rise = () => { };
|
|
345
|
-
$.$mol_log3_area = () => () => { };
|
|
346
|
-
});
|
|
347
|
-
})($ || ($ = {}));
|
|
348
|
-
//mol/log3/log3.test.ts
|
|
349
|
-
;
|
|
350
|
-
"use strict";
|
|
351
|
-
var $;
|
|
352
|
-
(function ($) {
|
|
353
|
-
function $mol_env() {
|
|
354
|
-
return {};
|
|
355
|
-
}
|
|
356
|
-
$.$mol_env = $mol_env;
|
|
357
|
-
})($ || ($ = {}));
|
|
358
|
-
//mol/env/env.ts
|
|
359
|
-
;
|
|
360
|
-
"use strict";
|
|
361
|
-
var $;
|
|
362
|
-
(function ($) {
|
|
363
|
-
$.$mol_env = function $mol_env() {
|
|
364
|
-
return this.process.env;
|
|
365
|
-
};
|
|
366
|
-
})($ || ($ = {}));
|
|
367
|
-
//mol/env/env.node.ts
|
|
368
|
-
;
|
|
369
|
-
"use strict";
|
|
370
|
-
var $;
|
|
371
|
-
(function ($) {
|
|
372
|
-
function $mol_exec(dir, command, ...args) {
|
|
373
|
-
let [app, ...args0] = command.split(' ');
|
|
374
|
-
args = [...args0, ...args];
|
|
375
|
-
this.$mol_log3_come({
|
|
376
|
-
place: '$mol_exec',
|
|
377
|
-
dir: $node.path.relative('', dir),
|
|
378
|
-
message: 'Run',
|
|
379
|
-
command: `${app} ${args.join(' ')}`,
|
|
380
|
-
});
|
|
381
|
-
var res = $node['child_process'].spawnSync(app, args, {
|
|
382
|
-
cwd: $node.path.resolve(dir),
|
|
383
|
-
shell: true,
|
|
384
|
-
env: this.$mol_env(),
|
|
385
|
-
});
|
|
386
|
-
if (res.status || res.error)
|
|
387
|
-
return $mol_fail(res.error || new Error(res.stderr.toString()));
|
|
388
|
-
if (!res.stdout)
|
|
389
|
-
res.stdout = Buffer.from([]);
|
|
390
|
-
return res;
|
|
391
|
-
}
|
|
392
|
-
$.$mol_exec = $mol_exec;
|
|
393
|
-
})($ || ($ = {}));
|
|
394
|
-
//mol/exec/exec.node.ts
|
|
395
|
-
;
|
|
396
|
-
"use strict";
|
|
397
|
-
var $;
|
|
398
|
-
(function ($) {
|
|
399
|
-
$.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
|
|
400
|
-
})($ || ($ = {}));
|
|
401
|
-
//mol/dom/context/context.node.ts
|
|
402
|
-
;
|
|
403
|
-
"use strict";
|
|
404
|
-
var $;
|
|
405
|
-
(function ($) {
|
|
406
|
-
function $mol_dom_serialize(node) {
|
|
407
|
-
const serializer = new $mol_dom_context.XMLSerializer;
|
|
408
|
-
return serializer.serializeToString(node);
|
|
409
|
-
}
|
|
410
|
-
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
411
|
-
})($ || ($ = {}));
|
|
412
|
-
//mol/dom/serialize/serialize.ts
|
|
328
|
+
//mol/dom/serialize/serialize.ts
|
|
413
329
|
;
|
|
414
330
|
"use strict";
|
|
415
331
|
var $;
|
|
@@ -540,118 +456,129 @@ var $;
|
|
|
540
456
|
"use strict";
|
|
541
457
|
var $;
|
|
542
458
|
(function ($) {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
459
|
+
function $mol_log3_area_lazy(event) {
|
|
460
|
+
const self = this;
|
|
461
|
+
const stack = self.$mol_log3_stack;
|
|
462
|
+
const deep = stack.length;
|
|
463
|
+
let logged = false;
|
|
464
|
+
stack.push(() => {
|
|
465
|
+
logged = true;
|
|
466
|
+
self.$mol_log3_area.call(self, event);
|
|
467
|
+
});
|
|
468
|
+
return () => {
|
|
469
|
+
if (logged)
|
|
470
|
+
self.console.groupEnd();
|
|
471
|
+
if (stack.length > deep)
|
|
472
|
+
stack.length = deep;
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
476
|
+
$.$mol_log3_stack = [];
|
|
477
|
+
})($ || ($ = {}));
|
|
478
|
+
//mol/log3/log3.ts
|
|
479
|
+
;
|
|
480
|
+
"use strict";
|
|
481
|
+
var $;
|
|
482
|
+
(function ($) {
|
|
483
|
+
class $mol_term_color {
|
|
484
|
+
static reset = this.ansi(0, 0);
|
|
485
|
+
static bold = this.ansi(1, 22);
|
|
486
|
+
static italic = this.ansi(3, 23);
|
|
487
|
+
static underline = this.ansi(4, 24);
|
|
488
|
+
static inverse = this.ansi(7, 27);
|
|
489
|
+
static hidden = this.ansi(8, 28);
|
|
490
|
+
static strike = this.ansi(9, 29);
|
|
491
|
+
static gray = this.ansi(90, 39);
|
|
492
|
+
static red = this.ansi(91, 39);
|
|
493
|
+
static green = this.ansi(92, 39);
|
|
494
|
+
static yellow = this.ansi(93, 39);
|
|
495
|
+
static blue = this.ansi(94, 39);
|
|
496
|
+
static magenta = this.ansi(95, 39);
|
|
497
|
+
static cyan = this.ansi(96, 39);
|
|
498
|
+
static Gray = (str) => this.inverse(this.gray(str));
|
|
499
|
+
static Red = (str) => this.inverse(this.red(str));
|
|
500
|
+
static Green = (str) => this.inverse(this.green(str));
|
|
501
|
+
static Yellow = (str) => this.inverse(this.yellow(str));
|
|
502
|
+
static Blue = (str) => this.inverse(this.blue(str));
|
|
503
|
+
static Magenta = (str) => this.inverse(this.magenta(str));
|
|
504
|
+
static Cyan = (str) => this.inverse(this.cyan(str));
|
|
505
|
+
static ansi(open, close) {
|
|
506
|
+
if (typeof process === 'undefined')
|
|
507
|
+
return String;
|
|
508
|
+
if (!process.stdout.isTTY)
|
|
509
|
+
return String;
|
|
510
|
+
const prefix = `\x1b[${open}m`;
|
|
511
|
+
const postfix = `\x1b[${close}m`;
|
|
512
|
+
const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
|
|
513
|
+
return function colorer(str) {
|
|
514
|
+
str = String(str);
|
|
515
|
+
if (str === '')
|
|
516
|
+
return str;
|
|
517
|
+
const suffix = str.replace(suffix_regexp, prefix);
|
|
518
|
+
return prefix + suffix + postfix;
|
|
519
|
+
};
|
|
559
520
|
}
|
|
560
|
-
named.add(func);
|
|
561
|
-
return name;
|
|
562
521
|
}
|
|
563
|
-
$.$
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
522
|
+
$.$mol_term_color = $mol_term_color;
|
|
523
|
+
})($ || ($ = {}));
|
|
524
|
+
//mol/term/color/color.ts
|
|
525
|
+
;
|
|
526
|
+
"use strict";
|
|
527
|
+
var $;
|
|
528
|
+
(function ($) {
|
|
529
|
+
function $mol_log3_node_make(level, output, type, color) {
|
|
530
|
+
return function $mol_log3_logger(event) {
|
|
531
|
+
if (!event.time)
|
|
532
|
+
event = { time: new Date().toISOString(), ...event };
|
|
533
|
+
const tree = this.$mol_tree.fromJSON(event).clone({ type });
|
|
534
|
+
let str = color(tree.toString());
|
|
535
|
+
this.console[level](str);
|
|
536
|
+
const self = this;
|
|
537
|
+
return () => self.console.groupEnd();
|
|
538
|
+
};
|
|
567
539
|
}
|
|
568
|
-
$.$
|
|
540
|
+
$.$mol_log3_node_make = $mol_log3_node_make;
|
|
541
|
+
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
|
|
542
|
+
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
|
|
543
|
+
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
|
|
544
|
+
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
|
|
545
|
+
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
|
|
546
|
+
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
|
569
547
|
})($ || ($ = {}));
|
|
570
|
-
//mol/
|
|
548
|
+
//mol/log3/log3.node.ts
|
|
571
549
|
;
|
|
572
550
|
"use strict";
|
|
573
551
|
var $;
|
|
574
552
|
(function ($_1) {
|
|
575
|
-
$
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
}
|
|
553
|
+
$mol_test_mocks.push($ => {
|
|
554
|
+
$.$mol_log3_come = () => { };
|
|
555
|
+
$.$mol_log3_done = () => { };
|
|
556
|
+
$.$mol_log3_fail = () => { };
|
|
557
|
+
$.$mol_log3_warn = () => { };
|
|
558
|
+
$.$mol_log3_rise = () => { };
|
|
559
|
+
$.$mol_log3_area = () => () => { };
|
|
582
560
|
});
|
|
583
561
|
})($ || ($ = {}));
|
|
584
|
-
//mol/
|
|
562
|
+
//mol/log3/log3.test.ts
|
|
585
563
|
;
|
|
586
564
|
"use strict";
|
|
587
565
|
var $;
|
|
588
566
|
(function ($) {
|
|
589
|
-
function $
|
|
590
|
-
|
|
591
|
-
let nextNode = el.firstChild;
|
|
592
|
-
for (let view of childNodes) {
|
|
593
|
-
if (view == null)
|
|
594
|
-
continue;
|
|
595
|
-
if (view instanceof $mol_dom_context.Node) {
|
|
596
|
-
while (true) {
|
|
597
|
-
if (!nextNode) {
|
|
598
|
-
el.appendChild(view);
|
|
599
|
-
break;
|
|
600
|
-
}
|
|
601
|
-
if (nextNode == view) {
|
|
602
|
-
nextNode = nextNode.nextSibling;
|
|
603
|
-
break;
|
|
604
|
-
}
|
|
605
|
-
else {
|
|
606
|
-
if (node_set.has(nextNode)) {
|
|
607
|
-
el.insertBefore(view, nextNode);
|
|
608
|
-
break;
|
|
609
|
-
}
|
|
610
|
-
else {
|
|
611
|
-
const nn = nextNode.nextSibling;
|
|
612
|
-
el.removeChild(nextNode);
|
|
613
|
-
nextNode = nn;
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
else {
|
|
619
|
-
if (nextNode && nextNode.nodeName === '#text') {
|
|
620
|
-
const str = String(view);
|
|
621
|
-
if (nextNode.nodeValue !== str)
|
|
622
|
-
nextNode.nodeValue = str;
|
|
623
|
-
nextNode = nextNode.nextSibling;
|
|
624
|
-
}
|
|
625
|
-
else {
|
|
626
|
-
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
|
627
|
-
el.insertBefore(textNode, nextNode);
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
while (nextNode) {
|
|
632
|
-
const currNode = nextNode;
|
|
633
|
-
nextNode = currNode.nextSibling;
|
|
634
|
-
el.removeChild(currNode);
|
|
635
|
-
}
|
|
567
|
+
function $mol_env() {
|
|
568
|
+
return {};
|
|
636
569
|
}
|
|
637
|
-
$.$
|
|
570
|
+
$.$mol_env = $mol_env;
|
|
638
571
|
})($ || ($ = {}));
|
|
639
|
-
//mol/
|
|
640
|
-
;
|
|
641
|
-
"use strict";
|
|
642
|
-
//mol/type/partial/deep/deep.ts
|
|
643
|
-
;
|
|
644
|
-
"use strict";
|
|
645
|
-
//mol/type/error/error.ts
|
|
646
|
-
;
|
|
647
|
-
"use strict";
|
|
648
|
-
//mol/type/assert/assert.ts
|
|
649
|
-
;
|
|
650
|
-
"use strict";
|
|
651
|
-
//mol/type/assert/assert.test.ts
|
|
572
|
+
//mol/env/env.ts
|
|
652
573
|
;
|
|
653
574
|
"use strict";
|
|
654
|
-
|
|
575
|
+
var $;
|
|
576
|
+
(function ($) {
|
|
577
|
+
$.$mol_env = function $mol_env() {
|
|
578
|
+
return this.process.env;
|
|
579
|
+
};
|
|
580
|
+
})($ || ($ = {}));
|
|
581
|
+
//mol/env/env.node.ts
|
|
655
582
|
;
|
|
656
583
|
"use strict";
|
|
657
584
|
var $;
|
|
@@ -721,15 +648,15 @@ var $;
|
|
|
721
648
|
//mol/owning/owning.ts
|
|
722
649
|
;
|
|
723
650
|
"use strict";
|
|
724
|
-
//mol/type/writable/writable.ts
|
|
725
|
-
;
|
|
726
|
-
"use strict";
|
|
727
651
|
//mol/type/equals/equals.ts
|
|
728
652
|
;
|
|
729
653
|
"use strict";
|
|
730
654
|
//mol/type/equals/equals.test.ts
|
|
731
655
|
;
|
|
732
656
|
"use strict";
|
|
657
|
+
//mol/type/writable/writable.ts
|
|
658
|
+
;
|
|
659
|
+
"use strict";
|
|
733
660
|
//mol/type/writable/writable.test.ts
|
|
734
661
|
;
|
|
735
662
|
"use strict";
|
|
@@ -777,6 +704,106 @@ var $;
|
|
|
777
704
|
;
|
|
778
705
|
"use strict";
|
|
779
706
|
var $;
|
|
707
|
+
(function ($) {
|
|
708
|
+
const instances = new WeakSet();
|
|
709
|
+
function $mol_delegate(proto, target) {
|
|
710
|
+
const proxy = new Proxy(proto, {
|
|
711
|
+
get: (_, field) => {
|
|
712
|
+
const obj = target();
|
|
713
|
+
let val = Reflect.get(obj, field);
|
|
714
|
+
if (typeof val === 'function') {
|
|
715
|
+
val = val.bind(obj);
|
|
716
|
+
}
|
|
717
|
+
return val;
|
|
718
|
+
},
|
|
719
|
+
has: (_, field) => Reflect.has(target(), field),
|
|
720
|
+
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
721
|
+
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
722
|
+
ownKeys: () => Reflect.ownKeys(target()),
|
|
723
|
+
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
724
|
+
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
725
|
+
isExtensible: () => Reflect.isExtensible(target()),
|
|
726
|
+
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
727
|
+
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
728
|
+
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
729
|
+
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
730
|
+
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
731
|
+
});
|
|
732
|
+
instances.add(proxy);
|
|
733
|
+
return proxy;
|
|
734
|
+
}
|
|
735
|
+
$.$mol_delegate = $mol_delegate;
|
|
736
|
+
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
737
|
+
value: (obj) => instances.has(obj),
|
|
738
|
+
});
|
|
739
|
+
})($ || ($ = {}));
|
|
740
|
+
//mol/delegate/delegate.ts
|
|
741
|
+
;
|
|
742
|
+
"use strict";
|
|
743
|
+
var $;
|
|
744
|
+
(function ($) {
|
|
745
|
+
$mol_test({
|
|
746
|
+
'get'() {
|
|
747
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
748
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
749
|
+
},
|
|
750
|
+
'has'() {
|
|
751
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
752
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
753
|
+
},
|
|
754
|
+
'set'() {
|
|
755
|
+
const target = { foo: 777 };
|
|
756
|
+
const proxy = $mol_delegate({}, () => target);
|
|
757
|
+
proxy.foo = 123;
|
|
758
|
+
$mol_assert_equal(target.foo, 123);
|
|
759
|
+
},
|
|
760
|
+
'getOwnPropertyDescriptor'() {
|
|
761
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
762
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
763
|
+
value: 777,
|
|
764
|
+
writable: true,
|
|
765
|
+
enumerable: true,
|
|
766
|
+
configurable: true,
|
|
767
|
+
});
|
|
768
|
+
},
|
|
769
|
+
'ownKeys'() {
|
|
770
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
771
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
772
|
+
},
|
|
773
|
+
'getPrototypeOf'() {
|
|
774
|
+
class Foo {
|
|
775
|
+
}
|
|
776
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
777
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
778
|
+
},
|
|
779
|
+
'setPrototypeOf'() {
|
|
780
|
+
class Foo {
|
|
781
|
+
}
|
|
782
|
+
const target = {};
|
|
783
|
+
const proxy = $mol_delegate({}, () => target);
|
|
784
|
+
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
785
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
786
|
+
},
|
|
787
|
+
'instanceof'() {
|
|
788
|
+
class Foo {
|
|
789
|
+
}
|
|
790
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
791
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
792
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
793
|
+
},
|
|
794
|
+
'autobind'() {
|
|
795
|
+
class Foo {
|
|
796
|
+
}
|
|
797
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
798
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
799
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
800
|
+
},
|
|
801
|
+
});
|
|
802
|
+
})($ || ($ = {}));
|
|
803
|
+
//mol/delegate/delegate.test.ts
|
|
804
|
+
;
|
|
805
|
+
"use strict";
|
|
806
|
+
var $;
|
|
780
807
|
(function ($) {
|
|
781
808
|
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
782
809
|
class $mol_tree extends $mol_object2 {
|
|
@@ -1107,146 +1134,46 @@ var $;
|
|
|
1107
1134
|
;
|
|
1108
1135
|
"use strict";
|
|
1109
1136
|
var $;
|
|
1110
|
-
(function ($) {
|
|
1111
|
-
const instances = new WeakSet();
|
|
1112
|
-
function $mol_delegate(proto, target) {
|
|
1113
|
-
const proxy = new Proxy(proto, {
|
|
1114
|
-
get: (_, field) => {
|
|
1115
|
-
const obj = target();
|
|
1116
|
-
let val = Reflect.get(obj, field);
|
|
1117
|
-
if (typeof val === 'function') {
|
|
1118
|
-
val = val.bind(obj);
|
|
1119
|
-
}
|
|
1120
|
-
return val;
|
|
1121
|
-
},
|
|
1122
|
-
has: (_, field) => Reflect.has(target(), field),
|
|
1123
|
-
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
1124
|
-
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
1125
|
-
ownKeys: () => Reflect.ownKeys(target()),
|
|
1126
|
-
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
1127
|
-
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
1128
|
-
isExtensible: () => Reflect.isExtensible(target()),
|
|
1129
|
-
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
1130
|
-
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
1131
|
-
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
1132
|
-
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
1133
|
-
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
1134
|
-
});
|
|
1135
|
-
instances.add(proxy);
|
|
1136
|
-
return proxy;
|
|
1137
|
-
}
|
|
1138
|
-
$.$mol_delegate = $mol_delegate;
|
|
1139
|
-
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
1140
|
-
value: (obj) => instances.has(obj),
|
|
1141
|
-
});
|
|
1142
|
-
})($ || ($ = {}));
|
|
1143
|
-
//mol/delegate/delegate.ts
|
|
1144
|
-
;
|
|
1145
|
-
"use strict";
|
|
1146
|
-
var $;
|
|
1147
|
-
(function ($) {
|
|
1137
|
+
(function ($_1) {
|
|
1148
1138
|
$mol_test({
|
|
1149
|
-
'
|
|
1150
|
-
|
|
1151
|
-
$mol_assert_equal(
|
|
1139
|
+
'tree parsing'() {
|
|
1140
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
1141
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
1142
|
+
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
1143
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
1144
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
1145
|
+
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
1146
|
+
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
1147
|
+
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
1152
1148
|
},
|
|
1153
|
-
'
|
|
1154
|
-
|
|
1155
|
-
$mol_assert_equal('
|
|
1149
|
+
'inserting'() {
|
|
1150
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
1151
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
1152
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
1153
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
1154
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
1155
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
1156
1156
|
},
|
|
1157
|
-
'
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
$mol_assert_equal(
|
|
1157
|
+
'fromJSON'() {
|
|
1158
|
+
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
1159
|
+
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
1160
|
+
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
1161
|
+
$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');
|
|
1162
|
+
$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');
|
|
1162
1163
|
},
|
|
1163
|
-
'
|
|
1164
|
-
|
|
1165
|
-
$
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1164
|
+
'toJSON'() {
|
|
1165
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
1166
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
1167
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
1168
|
+
$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"]');
|
|
1169
|
+
$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"}');
|
|
1170
|
+
},
|
|
1171
|
+
'hack'() {
|
|
1172
|
+
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
1173
|
+
'': (tree, context) => [tree.hack(context)],
|
|
1174
|
+
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
1170
1175
|
});
|
|
1171
|
-
|
|
1172
|
-
'ownKeys'() {
|
|
1173
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
1174
|
-
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1175
|
-
},
|
|
1176
|
-
'getPrototypeOf'() {
|
|
1177
|
-
class Foo {
|
|
1178
|
-
}
|
|
1179
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
1180
|
-
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1181
|
-
},
|
|
1182
|
-
'setPrototypeOf'() {
|
|
1183
|
-
class Foo {
|
|
1184
|
-
}
|
|
1185
|
-
const target = {};
|
|
1186
|
-
const proxy = $mol_delegate({}, () => target);
|
|
1187
|
-
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
1188
|
-
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
1189
|
-
},
|
|
1190
|
-
'instanceof'() {
|
|
1191
|
-
class Foo {
|
|
1192
|
-
}
|
|
1193
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
1194
|
-
$mol_assert_ok(proxy instanceof Foo);
|
|
1195
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1196
|
-
},
|
|
1197
|
-
'autobind'() {
|
|
1198
|
-
class Foo {
|
|
1199
|
-
}
|
|
1200
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
1201
|
-
$mol_assert_ok(proxy instanceof Foo);
|
|
1202
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1203
|
-
},
|
|
1204
|
-
});
|
|
1205
|
-
})($ || ($ = {}));
|
|
1206
|
-
//mol/delegate/delegate.test.ts
|
|
1207
|
-
;
|
|
1208
|
-
"use strict";
|
|
1209
|
-
var $;
|
|
1210
|
-
(function ($_1) {
|
|
1211
|
-
$mol_test({
|
|
1212
|
-
'tree parsing'() {
|
|
1213
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
1214
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
1215
|
-
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
1216
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
1217
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
1218
|
-
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
1219
|
-
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
1220
|
-
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
1221
|
-
},
|
|
1222
|
-
'inserting'() {
|
|
1223
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
1224
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
1225
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
1226
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
1227
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
1228
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
1229
|
-
},
|
|
1230
|
-
'fromJSON'() {
|
|
1231
|
-
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
1232
|
-
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
1233
|
-
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
1234
|
-
$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');
|
|
1235
|
-
$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');
|
|
1236
|
-
},
|
|
1237
|
-
'toJSON'() {
|
|
1238
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
1239
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
1240
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
1241
|
-
$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"]');
|
|
1242
|
-
$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"}');
|
|
1243
|
-
},
|
|
1244
|
-
'hack'() {
|
|
1245
|
-
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
1246
|
-
'': (tree, context) => [tree.hack(context)],
|
|
1247
|
-
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
1248
|
-
});
|
|
1249
|
-
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
1176
|
+
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
1250
1177
|
},
|
|
1251
1178
|
'errors handling'($) {
|
|
1252
1179
|
const errors = [];
|
|
@@ -1268,92 +1195,29 @@ var $;
|
|
|
1268
1195
|
"use strict";
|
|
1269
1196
|
var $;
|
|
1270
1197
|
(function ($) {
|
|
1271
|
-
$
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
$
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
$
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
'Define attributes'() {
|
|
1293
|
-
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
1294
|
-
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
1295
|
-
},
|
|
1296
|
-
'Define child nodes'() {
|
|
1297
|
-
const dom = $mol_jsx("div", null,
|
|
1298
|
-
"hello",
|
|
1299
|
-
$mol_jsx("strong", null, "world"),
|
|
1300
|
-
"!");
|
|
1301
|
-
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
1302
|
-
},
|
|
1303
|
-
'Function as component'() {
|
|
1304
|
-
const Button = (props, target) => {
|
|
1305
|
-
return $mol_jsx("button", { title: props.hint }, target());
|
|
1306
|
-
};
|
|
1307
|
-
const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
|
|
1308
|
-
$mol_assert_equal(dom.outerHTML, '<button id="foo" title="click me" class="Button">hey!</button>');
|
|
1309
|
-
},
|
|
1310
|
-
'Nested guid generation'() {
|
|
1311
|
-
const Foo = () => {
|
|
1312
|
-
return $mol_jsx("div", null,
|
|
1313
|
-
$mol_jsx(Bar, { id: "bar" },
|
|
1314
|
-
$mol_jsx("img", { id: "icon" })));
|
|
1315
|
-
};
|
|
1316
|
-
const Bar = (props, icon) => {
|
|
1317
|
-
return $mol_jsx("span", null,
|
|
1318
|
-
icon,
|
|
1319
|
-
$mol_jsx("i", { id: "label" }));
|
|
1320
|
-
};
|
|
1321
|
-
const dom = $mol_jsx(Foo, { id: "foo" });
|
|
1322
|
-
$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>');
|
|
1323
|
-
},
|
|
1324
|
-
'Fail on non unique ids'() {
|
|
1325
|
-
const App = () => {
|
|
1326
|
-
return $mol_jsx("div", null,
|
|
1327
|
-
$mol_jsx("span", { id: "bar" }),
|
|
1328
|
-
$mol_jsx("span", { id: "bar" }));
|
|
1329
|
-
};
|
|
1330
|
-
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
|
1331
|
-
},
|
|
1332
|
-
'Owner based guid generationn'() {
|
|
1333
|
-
const Foo = () => {
|
|
1334
|
-
return $mol_jsx("div", null,
|
|
1335
|
-
$mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
1336
|
-
};
|
|
1337
|
-
const Bar = (props) => {
|
|
1338
|
-
return $mol_jsx("span", null, props.icon());
|
|
1339
|
-
};
|
|
1340
|
-
const dom = $mol_jsx(Foo, { id: "app" });
|
|
1341
|
-
$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>');
|
|
1342
|
-
},
|
|
1343
|
-
'Fail on same ids from different caller'() {
|
|
1344
|
-
const Foo = () => {
|
|
1345
|
-
return $mol_jsx("div", null,
|
|
1346
|
-
$mol_jsx("img", { id: "icon" }),
|
|
1347
|
-
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
1348
|
-
};
|
|
1349
|
-
const Bar = (props) => {
|
|
1350
|
-
return $mol_jsx("span", null, props.icon());
|
|
1351
|
-
};
|
|
1352
|
-
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
|
1353
|
-
},
|
|
1354
|
-
});
|
|
1198
|
+
function $mol_exec(dir, command, ...args) {
|
|
1199
|
+
let [app, ...args0] = command.split(' ');
|
|
1200
|
+
args = [...args0, ...args];
|
|
1201
|
+
this.$mol_log3_come({
|
|
1202
|
+
place: '$mol_exec',
|
|
1203
|
+
dir: $node.path.relative('', dir),
|
|
1204
|
+
message: 'Run',
|
|
1205
|
+
command: `${app} ${args.join(' ')}`,
|
|
1206
|
+
});
|
|
1207
|
+
var res = $node['child_process'].spawnSync(app, args, {
|
|
1208
|
+
cwd: $node.path.resolve(dir),
|
|
1209
|
+
shell: true,
|
|
1210
|
+
env: this.$mol_env(),
|
|
1211
|
+
});
|
|
1212
|
+
if (res.status || res.error)
|
|
1213
|
+
return $mol_fail(res.error || new Error(res.stderr.toString()));
|
|
1214
|
+
if (!res.stdout)
|
|
1215
|
+
res.stdout = Buffer.from([]);
|
|
1216
|
+
return res;
|
|
1217
|
+
}
|
|
1218
|
+
$.$mol_exec = $mol_exec;
|
|
1355
1219
|
})($ || ($ = {}));
|
|
1356
|
-
//mol/
|
|
1220
|
+
//mol/exec/exec.node.ts
|
|
1357
1221
|
;
|
|
1358
1222
|
"use strict";
|
|
1359
1223
|
var $;
|
|
@@ -1480,97 +1344,137 @@ var $;
|
|
|
1480
1344
|
var $;
|
|
1481
1345
|
(function ($) {
|
|
1482
1346
|
$mol_test({
|
|
1483
|
-
'
|
|
1484
|
-
$
|
|
1485
|
-
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
1486
|
-
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
1487
|
-
$mol_assert_not($mol_compare_deep({}, null));
|
|
1347
|
+
'Make empty div'() {
|
|
1348
|
+
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
|
1488
1349
|
},
|
|
1489
|
-
'
|
|
1490
|
-
$
|
|
1491
|
-
$
|
|
1492
|
-
$
|
|
1493
|
-
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
1494
|
-
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
1350
|
+
'Define native field'() {
|
|
1351
|
+
const dom = $mol_jsx("input", { value: '123' });
|
|
1352
|
+
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
1353
|
+
$mol_assert_equal(dom.value, '123');
|
|
1495
1354
|
},
|
|
1496
|
-
'
|
|
1497
|
-
$
|
|
1498
|
-
$
|
|
1499
|
-
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
1500
|
-
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
1501
|
-
$mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
1502
|
-
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
1355
|
+
'Define classes'() {
|
|
1356
|
+
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
1357
|
+
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
1503
1358
|
},
|
|
1504
|
-
'
|
|
1505
|
-
$
|
|
1506
|
-
$
|
|
1507
|
-
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
1508
|
-
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
1359
|
+
'Define styles'() {
|
|
1360
|
+
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
1361
|
+
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
1509
1362
|
},
|
|
1510
|
-
'
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
1514
|
-
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
1515
|
-
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
1363
|
+
'Define dataset'() {
|
|
1364
|
+
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
1365
|
+
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
1516
1366
|
},
|
|
1517
|
-
'
|
|
1518
|
-
const
|
|
1519
|
-
|
|
1520
|
-
const b = { foo: {} };
|
|
1521
|
-
b['self'] = b;
|
|
1522
|
-
$mol_assert_ok($mol_compare_deep(a, b));
|
|
1367
|
+
'Define attributes'() {
|
|
1368
|
+
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
1369
|
+
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
1523
1370
|
},
|
|
1524
|
-
'
|
|
1525
|
-
$
|
|
1526
|
-
|
|
1371
|
+
'Define child nodes'() {
|
|
1372
|
+
const dom = $mol_jsx("div", null,
|
|
1373
|
+
"hello",
|
|
1374
|
+
$mol_jsx("strong", null, "world"),
|
|
1375
|
+
"!");
|
|
1376
|
+
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
1527
1377
|
},
|
|
1528
|
-
'
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1378
|
+
'Function as component'() {
|
|
1379
|
+
const Button = (props, target) => {
|
|
1380
|
+
return $mol_jsx("button", { title: props.hint }, target());
|
|
1381
|
+
};
|
|
1382
|
+
const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
|
|
1383
|
+
$mol_assert_equal(dom.outerHTML, '<button id="foo" title="click me" class="Button">hey!</button>');
|
|
1532
1384
|
},
|
|
1533
|
-
'
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1385
|
+
'Nested guid generation'() {
|
|
1386
|
+
const Foo = () => {
|
|
1387
|
+
return $mol_jsx("div", null,
|
|
1388
|
+
$mol_jsx(Bar, { id: "bar" },
|
|
1389
|
+
$mol_jsx("img", { id: "icon" })));
|
|
1390
|
+
};
|
|
1391
|
+
const Bar = (props, icon) => {
|
|
1392
|
+
return $mol_jsx("span", null,
|
|
1393
|
+
icon,
|
|
1394
|
+
$mol_jsx("i", { id: "label" }));
|
|
1395
|
+
};
|
|
1396
|
+
const dom = $mol_jsx(Foo, { id: "foo" });
|
|
1397
|
+
$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>');
|
|
1538
1398
|
},
|
|
1539
|
-
'
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1399
|
+
'Fail on non unique ids'() {
|
|
1400
|
+
const App = () => {
|
|
1401
|
+
return $mol_jsx("div", null,
|
|
1402
|
+
$mol_jsx("span", { id: "bar" }),
|
|
1403
|
+
$mol_jsx("span", { id: "bar" }));
|
|
1404
|
+
};
|
|
1405
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
|
1545
1406
|
},
|
|
1546
|
-
'
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1407
|
+
'Owner based guid generationn'() {
|
|
1408
|
+
const Foo = () => {
|
|
1409
|
+
return $mol_jsx("div", null,
|
|
1410
|
+
$mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
1411
|
+
};
|
|
1412
|
+
const Bar = (props) => {
|
|
1413
|
+
return $mol_jsx("span", null, props.icon());
|
|
1414
|
+
};
|
|
1415
|
+
const dom = $mol_jsx(Foo, { id: "app" });
|
|
1416
|
+
$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>');
|
|
1550
1417
|
},
|
|
1551
|
-
'
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1418
|
+
'Fail on same ids from different caller'() {
|
|
1419
|
+
const Foo = () => {
|
|
1420
|
+
return $mol_jsx("div", null,
|
|
1421
|
+
$mol_jsx("img", { id: "icon" }),
|
|
1422
|
+
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
1423
|
+
};
|
|
1424
|
+
const Bar = (props) => {
|
|
1425
|
+
return $mol_jsx("span", null, props.icon());
|
|
1426
|
+
};
|
|
1427
|
+
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
|
1555
1428
|
},
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1429
|
+
});
|
|
1430
|
+
})($ || ($ = {}));
|
|
1431
|
+
//mol/jsx/jsx.test.tsx
|
|
1432
|
+
;
|
|
1433
|
+
"use strict";
|
|
1434
|
+
var $;
|
|
1435
|
+
(function ($) {
|
|
1436
|
+
const named = new WeakSet();
|
|
1437
|
+
function $mol_func_name(func) {
|
|
1438
|
+
let name = func.name;
|
|
1439
|
+
if (name?.length > 1)
|
|
1440
|
+
return name;
|
|
1441
|
+
if (named.has(func))
|
|
1442
|
+
return name;
|
|
1443
|
+
for (let key in this) {
|
|
1444
|
+
try {
|
|
1445
|
+
if (this[key] !== func)
|
|
1446
|
+
continue;
|
|
1447
|
+
name = key;
|
|
1448
|
+
Object.defineProperty(func, 'name', { value: name });
|
|
1449
|
+
break;
|
|
1567
1450
|
}
|
|
1568
|
-
|
|
1569
|
-
|
|
1451
|
+
catch { }
|
|
1452
|
+
}
|
|
1453
|
+
named.add(func);
|
|
1454
|
+
return name;
|
|
1455
|
+
}
|
|
1456
|
+
$.$mol_func_name = $mol_func_name;
|
|
1457
|
+
function $mol_func_name_from(target, source) {
|
|
1458
|
+
Object.defineProperty(target, 'name', { value: source.name });
|
|
1459
|
+
return target;
|
|
1460
|
+
}
|
|
1461
|
+
$.$mol_func_name_from = $mol_func_name_from;
|
|
1462
|
+
})($ || ($ = {}));
|
|
1463
|
+
//mol/func/name/name.ts
|
|
1464
|
+
;
|
|
1465
|
+
"use strict";
|
|
1466
|
+
var $;
|
|
1467
|
+
(function ($_1) {
|
|
1468
|
+
$mol_test({
|
|
1469
|
+
'FQN of anon function'($) {
|
|
1470
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
1471
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
1472
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
1473
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
1570
1474
|
},
|
|
1571
1475
|
});
|
|
1572
1476
|
})($ || ($ = {}));
|
|
1573
|
-
//mol/
|
|
1477
|
+
//mol/func/name/name.test.ts
|
|
1574
1478
|
;
|
|
1575
1479
|
"use strict";
|
|
1576
1480
|
var $;
|
|
@@ -1699,6 +1603,102 @@ var $;
|
|
|
1699
1603
|
;
|
|
1700
1604
|
"use strict";
|
|
1701
1605
|
var $;
|
|
1606
|
+
(function ($) {
|
|
1607
|
+
$mol_test({
|
|
1608
|
+
'nulls & undefineds'() {
|
|
1609
|
+
$mol_assert_ok($mol_compare_deep(null, null));
|
|
1610
|
+
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
1611
|
+
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
1612
|
+
$mol_assert_not($mol_compare_deep({}, null));
|
|
1613
|
+
},
|
|
1614
|
+
'number'() {
|
|
1615
|
+
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
1616
|
+
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
1617
|
+
$mol_assert_not($mol_compare_deep(1, 2));
|
|
1618
|
+
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
1619
|
+
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
1620
|
+
},
|
|
1621
|
+
'POJO'() {
|
|
1622
|
+
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
1623
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
1624
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
1625
|
+
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
1626
|
+
$mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
1627
|
+
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
1628
|
+
},
|
|
1629
|
+
'Array'() {
|
|
1630
|
+
$mol_assert_ok($mol_compare_deep([], []));
|
|
1631
|
+
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
1632
|
+
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
1633
|
+
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
1634
|
+
},
|
|
1635
|
+
'Non POJO are different'() {
|
|
1636
|
+
class Thing extends Object {
|
|
1637
|
+
}
|
|
1638
|
+
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
1639
|
+
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
1640
|
+
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
1641
|
+
},
|
|
1642
|
+
'same POJOs with cyclic reference'() {
|
|
1643
|
+
const a = { foo: {} };
|
|
1644
|
+
a['self'] = a;
|
|
1645
|
+
const b = { foo: {} };
|
|
1646
|
+
b['self'] = b;
|
|
1647
|
+
$mol_assert_ok($mol_compare_deep(a, b));
|
|
1648
|
+
},
|
|
1649
|
+
'Date'() {
|
|
1650
|
+
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
1651
|
+
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
1652
|
+
},
|
|
1653
|
+
'RegExp'() {
|
|
1654
|
+
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
1655
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
1656
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
1657
|
+
},
|
|
1658
|
+
'Error'() {
|
|
1659
|
+
$mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
|
|
1660
|
+
const fail = (message) => new Error(message);
|
|
1661
|
+
$mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
|
|
1662
|
+
$mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
|
|
1663
|
+
},
|
|
1664
|
+
'Map'() {
|
|
1665
|
+
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
1666
|
+
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
1667
|
+
$mol_assert_ok($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
1668
|
+
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
1669
|
+
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[3], 2]])));
|
|
1670
|
+
},
|
|
1671
|
+
'Set'() {
|
|
1672
|
+
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
1673
|
+
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
1674
|
+
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
1675
|
+
},
|
|
1676
|
+
'Uint8Array'() {
|
|
1677
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
1678
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
1679
|
+
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
1680
|
+
},
|
|
1681
|
+
'Custom comparator'() {
|
|
1682
|
+
class User {
|
|
1683
|
+
name;
|
|
1684
|
+
rand;
|
|
1685
|
+
constructor(name, rand = Math.random()) {
|
|
1686
|
+
this.name = name;
|
|
1687
|
+
this.rand = rand;
|
|
1688
|
+
}
|
|
1689
|
+
[Symbol.toPrimitive](mode) {
|
|
1690
|
+
return this.name;
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
1694
|
+
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
1695
|
+
},
|
|
1696
|
+
});
|
|
1697
|
+
})($ || ($ = {}));
|
|
1698
|
+
//mol/compare/deep/deep.test.tsx
|
|
1699
|
+
;
|
|
1700
|
+
"use strict";
|
|
1701
|
+
var $;
|
|
1702
1702
|
(function ($) {
|
|
1703
1703
|
$mol_test({
|
|
1704
1704
|
'Primitives'() {
|