mol_time_all 1.1.9 → 1.1.13
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/.nojekyll +0 -0
- package/README.md +45 -0
- package/node.audit.js +1 -0
- package/node.d.ts +69 -40
- package/node.deps.json +1 -1
- package/node.esm.js +376 -275
- package/node.esm.js.map +1 -1
- package/node.js +377 -275
- package/node.js.map +1 -1
- package/node.test.js +2014 -601
- package/node.test.js.map +1 -1
- package/package.json +6 -3
- package/test.html +17 -0
- package/web.audit.js +1 -0
- package/web.css +1 -0
- package/web.css.map +1 -0
- package/web.d.ts +69 -40
- package/web.deps.json +1 -1
- package/web.esm.js +376 -272
- package/web.esm.js.map +1 -1
- package/web.js +377 -272
- package/web.js.map +1 -1
- package/web.test.js +703 -128
- package/web.test.js.map +1 -1
- package/web.test.html +0 -12
package/node.test.js
CHANGED
|
@@ -1,277 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
;
|
|
1
|
+
"use strict";
|
|
4
2
|
"use strict"
|
|
5
|
-
/// Fake namespace for optional overrides
|
|
6
|
-
///
|
|
7
|
-
/// namespace $ { export var x = 1 , y = 1 } // defaults
|
|
8
|
-
/// namespace $.$$ { export var x = 2 } // overrides
|
|
9
|
-
/// namespace $.$$ { console.log( x , y ) } // usage
|
|
10
|
-
///
|
|
11
|
-
var $ = $ || ( typeof module === 'object' ) && module['export'+'s'] || ( typeof window === 'object' ) && window
|
|
12
|
-
$.$$ = $
|
|
13
3
|
|
|
14
|
-
|
|
4
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
5
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if ((d = decorators[i])) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
8
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
var globalThis = globalThis || ( typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this )
|
|
12
|
+
var $ = ( typeof module === 'object' ) ? Object.setPrototypeOf( module['export'+'s'] , globalThis ) : globalThis
|
|
13
|
+
$.$$ = $
|
|
15
14
|
|
|
16
15
|
;
|
|
17
16
|
"use strict";
|
|
18
|
-
|
|
19
|
-
//mol.js.map
|
|
20
|
-
;
|
|
21
|
-
"use strict";
|
|
22
|
-
var $;
|
|
23
|
-
(function ($) {
|
|
24
|
-
function $mol_log(path, ...values) {
|
|
25
|
-
if ($.$mol_log_filter() == null)
|
|
26
|
-
return;
|
|
27
|
-
path = String(path);
|
|
28
|
-
if (path.indexOf($.$mol_log_filter()) === -1)
|
|
29
|
-
return;
|
|
30
|
-
if ($.$mol_log_context())
|
|
31
|
-
$.$mol_log_context()();
|
|
32
|
-
console.debug(path, ...values);
|
|
33
|
-
if ($.$mol_log_debug() == null)
|
|
34
|
-
return;
|
|
35
|
-
if (path.indexOf($.$mol_log_debug()) === -1)
|
|
36
|
-
return;
|
|
37
|
-
debugger;
|
|
38
|
-
}
|
|
39
|
-
$.$mol_log = $mol_log;
|
|
40
|
-
})($ || ($ = {}));
|
|
41
|
-
//log.js.map
|
|
42
|
-
;
|
|
43
|
-
"use strict";
|
|
44
|
-
var $;
|
|
45
|
-
(function ($) {
|
|
46
|
-
let context = null;
|
|
47
|
-
function $mol_log_context(next = context) {
|
|
48
|
-
return context = next;
|
|
49
|
-
}
|
|
50
|
-
$.$mol_log_context = $mol_log_context;
|
|
51
|
-
})($ || ($ = {}));
|
|
52
|
-
//log_context.js.map
|
|
53
|
-
;
|
|
54
|
-
"use strict";
|
|
55
|
-
var $;
|
|
56
|
-
(function ($) {
|
|
57
|
-
let debug;
|
|
58
|
-
function $mol_log_debug(next = debug) {
|
|
59
|
-
return debug = next;
|
|
60
|
-
}
|
|
61
|
-
$.$mol_log_debug = $mol_log_debug;
|
|
62
|
-
})($ || ($ = {}));
|
|
63
|
-
//log_debug.node.js.map
|
|
64
|
-
;
|
|
65
|
-
"use strict";
|
|
66
|
-
var $;
|
|
67
|
-
(function ($) {
|
|
68
|
-
let filter;
|
|
69
|
-
function $mol_log_filter(next = filter) {
|
|
70
|
-
return filter = next;
|
|
71
|
-
}
|
|
72
|
-
$.$mol_log_filter = $mol_log_filter;
|
|
73
|
-
})($ || ($ = {}));
|
|
74
|
-
//log_filter.node.js.map
|
|
75
|
-
;
|
|
76
|
-
"use strict";
|
|
77
|
-
var $;
|
|
78
|
-
(function ($) {
|
|
79
|
-
function $mol_log_group(name, task) {
|
|
80
|
-
return function $mol_log_group_wrapper(...args) {
|
|
81
|
-
const filter = $.$mol_log_filter();
|
|
82
|
-
if (filter == null)
|
|
83
|
-
return task.apply(this, args);
|
|
84
|
-
let started = false;
|
|
85
|
-
let prev = $.$mol_log_context();
|
|
86
|
-
$.$mol_log_context(() => {
|
|
87
|
-
if (prev)
|
|
88
|
-
prev();
|
|
89
|
-
started = true;
|
|
90
|
-
if (filter)
|
|
91
|
-
console.group(name);
|
|
92
|
-
else
|
|
93
|
-
console.groupCollapsed(name);
|
|
94
|
-
$.$mol_log_context(prev = null);
|
|
95
|
-
});
|
|
96
|
-
try {
|
|
97
|
-
return task.apply(this, args);
|
|
98
|
-
}
|
|
99
|
-
finally {
|
|
100
|
-
if (started)
|
|
101
|
-
console.groupEnd();
|
|
102
|
-
$.$mol_log_context(prev);
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
$.$mol_log_group = $mol_log_group;
|
|
107
|
-
})($ || ($ = {}));
|
|
108
|
-
//log_group.js.map
|
|
109
|
-
;
|
|
110
|
-
"use strict";
|
|
111
|
-
var $;
|
|
112
|
-
(function ($_1) {
|
|
113
|
-
let $$;
|
|
114
|
-
(function ($$) {
|
|
115
|
-
let $;
|
|
116
|
-
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
117
|
-
function $mol_test(set) {
|
|
118
|
-
for (let name in set) {
|
|
119
|
-
const code = set[name];
|
|
120
|
-
const test = (typeof code === 'string') ? new Function('', code) : code;
|
|
121
|
-
$_1.$mol_test_all.push(test);
|
|
122
|
-
}
|
|
123
|
-
$mol_test_schedule();
|
|
124
|
-
}
|
|
125
|
-
$_1.$mol_test = $mol_test;
|
|
126
|
-
$_1.$mol_test_mocks = [];
|
|
127
|
-
$_1.$mol_test_all = [];
|
|
128
|
-
function $mol_test_run() {
|
|
129
|
-
for (var test of $_1.$mol_test_all) {
|
|
130
|
-
let context = Object.create($$);
|
|
131
|
-
for (let mock of $_1.$mol_test_mocks)
|
|
132
|
-
mock(context);
|
|
133
|
-
test(context);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
$_1.$mol_test_run = $mol_test_run;
|
|
137
|
-
let scheduled = false;
|
|
138
|
-
function $mol_test_schedule() {
|
|
139
|
-
if (scheduled)
|
|
140
|
-
return;
|
|
141
|
-
scheduled = true;
|
|
142
|
-
setTimeout($_1.$mol_log_group('$mol_test_run()', () => {
|
|
143
|
-
scheduled = false;
|
|
144
|
-
$mol_test_run();
|
|
145
|
-
}));
|
|
146
|
-
}
|
|
147
|
-
$_1.$mol_test_schedule = $mol_test_schedule;
|
|
148
|
-
$_1.$mol_test_mocks.push(context => {
|
|
149
|
-
let seed = 0;
|
|
150
|
-
context.Math = Object.create(Math);
|
|
151
|
-
context.Math.random = () => Math.sin(seed++);
|
|
152
|
-
const forbidden = ['XMLHttpRequest', 'fetch'];
|
|
153
|
-
for (let api of forbidden) {
|
|
154
|
-
context[api] = new Proxy(function () { }, {
|
|
155
|
-
get() {
|
|
156
|
-
throw new Error(`${api} is forbidden in tests`);
|
|
157
|
-
},
|
|
158
|
-
apply() {
|
|
159
|
-
throw new Error(`${api} is forbidden in tests`);
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
$mol_test({
|
|
165
|
-
'mocked Math.random'($) {
|
|
166
|
-
console.assert($.Math.random() === 0);
|
|
167
|
-
console.assert($.Math.random() === Math.sin(1));
|
|
168
|
-
},
|
|
169
|
-
'forbidden XMLHttpRequest'($) {
|
|
170
|
-
try {
|
|
171
|
-
console.assert(void new $.XMLHttpRequest);
|
|
172
|
-
}
|
|
173
|
-
catch (error) {
|
|
174
|
-
console.assert(error.message === 'XMLHttpRequest is forbidden in tests');
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
'forbidden fetch'($) {
|
|
178
|
-
try {
|
|
179
|
-
console.assert(void $.fetch(''));
|
|
180
|
-
}
|
|
181
|
-
catch (error) {
|
|
182
|
-
console.assert(error.message === 'fetch is forbidden in tests');
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
});
|
|
186
|
-
})($ || ($ = {}));
|
|
187
|
-
//test.test.js.map
|
|
188
|
-
;
|
|
189
|
-
"use strict";
|
|
190
|
-
var $;
|
|
191
|
-
(function ($) {
|
|
192
|
-
$.$mol_test({
|
|
193
|
-
'must be false'() {
|
|
194
|
-
$.$mol_assert_not(0);
|
|
195
|
-
},
|
|
196
|
-
'must be true'() {
|
|
197
|
-
$.$mol_assert_ok(1);
|
|
198
|
-
},
|
|
199
|
-
'two must be equal'() {
|
|
200
|
-
$.$mol_assert_equal(2, 2);
|
|
201
|
-
},
|
|
202
|
-
'three must be equal'() {
|
|
203
|
-
$.$mol_assert_equal(2, 2, 2);
|
|
204
|
-
},
|
|
205
|
-
'two must be unique'() {
|
|
206
|
-
$.$mol_assert_unique([3], [3]);
|
|
207
|
-
},
|
|
208
|
-
'three must be unique'() {
|
|
209
|
-
$.$mol_assert_unique([3], [3], [3]);
|
|
210
|
-
},
|
|
211
|
-
});
|
|
212
|
-
})($ || ($ = {}));
|
|
213
|
-
//assert.test.js.map
|
|
214
|
-
;
|
|
215
|
-
"use strict";
|
|
17
|
+
Error.stackTraceLimit = 50;
|
|
216
18
|
var $;
|
|
217
19
|
(function ($) {
|
|
218
|
-
function $mol_assert_ok(value) {
|
|
219
|
-
if (value)
|
|
220
|
-
return;
|
|
221
|
-
throw new Error(`Not true (${value})`);
|
|
222
|
-
}
|
|
223
|
-
$.$mol_assert_ok = $mol_assert_ok;
|
|
224
|
-
function $mol_assert_not(value) {
|
|
225
|
-
if (!value)
|
|
226
|
-
return;
|
|
227
|
-
throw new Error(`Not false (${value})`);
|
|
228
|
-
}
|
|
229
|
-
$.$mol_assert_not = $mol_assert_not;
|
|
230
|
-
function $mol_assert_fail(handler, ErrorRight) {
|
|
231
|
-
try {
|
|
232
|
-
handler();
|
|
233
|
-
}
|
|
234
|
-
catch (error) {
|
|
235
|
-
if (ErrorRight)
|
|
236
|
-
if (!(error instanceof ErrorRight))
|
|
237
|
-
throw error;
|
|
238
|
-
return error;
|
|
239
|
-
}
|
|
240
|
-
throw new Error('Not failed');
|
|
241
|
-
}
|
|
242
|
-
$.$mol_assert_fail = $mol_assert_fail;
|
|
243
|
-
function $mol_assert_equal(...args) {
|
|
244
|
-
for (let i = 0; i < args.length; ++i) {
|
|
245
|
-
for (let j = 0; j < args.length; ++j) {
|
|
246
|
-
if (i === j)
|
|
247
|
-
continue;
|
|
248
|
-
if (Number.isNaN(args[i]) && Number.isNaN(args[j]))
|
|
249
|
-
continue;
|
|
250
|
-
if (args[i] !== args[j])
|
|
251
|
-
throw new Error(`Not equal (${args[i]}!==${args[j]})`);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
$.$mol_assert_equal = $mol_assert_equal;
|
|
256
|
-
function $mol_assert_unique(...args) {
|
|
257
|
-
for (let i = 0; i < args.length; ++i) {
|
|
258
|
-
for (let j = 0; j < args.length; ++j) {
|
|
259
|
-
if (i === j)
|
|
260
|
-
continue;
|
|
261
|
-
if (args[i] === args[j] || (Number.isNaN(args[i]) && Number.isNaN(args[j]))) {
|
|
262
|
-
throw new Error(`Not unique (args[${i}]===args[${j}])===${args[i]}`);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
$.$mol_assert_unique = $mol_assert_unique;
|
|
268
20
|
})($ || ($ = {}));
|
|
269
|
-
|
|
21
|
+
module.exports = $;
|
|
22
|
+
//mam.js.map
|
|
270
23
|
;
|
|
271
24
|
"use strict";
|
|
272
25
|
var $;
|
|
273
26
|
(function ($) {
|
|
274
27
|
class $mol_time_base {
|
|
28
|
+
static patterns = {};
|
|
275
29
|
static formatter(pattern) {
|
|
276
30
|
if (this.patterns[pattern])
|
|
277
31
|
return this.patterns[pattern];
|
|
@@ -293,48 +47,21 @@ var $;
|
|
|
293
47
|
};
|
|
294
48
|
}
|
|
295
49
|
toString(pattern) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
return formatter
|
|
50
|
+
const Base = this.constructor;
|
|
51
|
+
const formatter = Base.formatter(pattern);
|
|
52
|
+
return formatter(this);
|
|
299
53
|
}
|
|
300
54
|
}
|
|
301
|
-
$mol_time_base.patterns = {};
|
|
302
55
|
$.$mol_time_base = $mol_time_base;
|
|
303
56
|
})($ || ($ = {}));
|
|
304
57
|
//base.js.map
|
|
305
58
|
;
|
|
306
59
|
"use strict";
|
|
307
60
|
var $;
|
|
308
|
-
(function ($) {
|
|
309
|
-
$.$mol_test({
|
|
310
|
-
'parse and serial'() {
|
|
311
|
-
$.$mol_assert_equal(new $.$mol_time_duration('P42.1Y').toString(), 'P42.1YT');
|
|
312
|
-
$.$mol_assert_equal(new $.$mol_time_duration('P42.1M').toString(), 'P42.1MT');
|
|
313
|
-
$.$mol_assert_equal(new $.$mol_time_duration('P42.1D').toString(), 'P42.1DT');
|
|
314
|
-
$.$mol_assert_equal(new $.$mol_time_duration('PT42.1h').toString(), 'PT42.1H');
|
|
315
|
-
$.$mol_assert_equal(new $.$mol_time_duration('PT42.1m').toString(), 'PT42.1M');
|
|
316
|
-
$.$mol_assert_equal(new $.$mol_time_duration('PT42.1s').toString(), 'PT42.1S');
|
|
317
|
-
$.$mol_assert_equal(new $.$mol_time_duration('P1Y2M3DT4h5m6.7s').toString(), 'P1Y2M3DT4H5M6.7S');
|
|
318
|
-
},
|
|
319
|
-
'format typed'() {
|
|
320
|
-
$.$mol_assert_equal(new $.$mol_time_duration('P1Y2M3DT4h5m6s').toString('P#Y#M#DT#h#m#s'), 'P1Y2M3DT4H5M6S');
|
|
321
|
-
},
|
|
322
|
-
});
|
|
323
|
-
})($ || ($ = {}));
|
|
324
|
-
//duration.test.js.map
|
|
325
|
-
;
|
|
326
|
-
"use strict";
|
|
327
|
-
var $;
|
|
328
61
|
(function ($) {
|
|
329
62
|
class $mol_time_duration extends $.$mol_time_base {
|
|
330
63
|
constructor(config = 0) {
|
|
331
64
|
super();
|
|
332
|
-
this.year = 0;
|
|
333
|
-
this.month = 0;
|
|
334
|
-
this.day = 0;
|
|
335
|
-
this.hour = 0;
|
|
336
|
-
this.minute = 0;
|
|
337
|
-
this.second = 0;
|
|
338
65
|
if (typeof config === 'number') {
|
|
339
66
|
this.second = config / 1000;
|
|
340
67
|
return;
|
|
@@ -384,6 +111,12 @@ var $;
|
|
|
384
111
|
this.minute = config.minute || 0;
|
|
385
112
|
this.second = config.second || 0;
|
|
386
113
|
}
|
|
114
|
+
year = 0;
|
|
115
|
+
month = 0;
|
|
116
|
+
day = 0;
|
|
117
|
+
hour = 0;
|
|
118
|
+
minute = 0;
|
|
119
|
+
second = 0;
|
|
387
120
|
summ(config) {
|
|
388
121
|
const duration = new $mol_time_duration(config);
|
|
389
122
|
return new $mol_time_duration({
|
|
@@ -418,55 +151,39 @@ var $;
|
|
|
418
151
|
toString(pattern = 'P#Y#M#DT#h#m#s') {
|
|
419
152
|
return super.toString(pattern);
|
|
420
153
|
}
|
|
154
|
+
static patterns = {
|
|
155
|
+
'#Y': (duration) => {
|
|
156
|
+
if (!duration.year)
|
|
157
|
+
return '';
|
|
158
|
+
return duration.year + 'Y';
|
|
159
|
+
},
|
|
160
|
+
'#M': (duration) => {
|
|
161
|
+
if (!duration.month)
|
|
162
|
+
return '';
|
|
163
|
+
return duration.month + 'M';
|
|
164
|
+
},
|
|
165
|
+
'#D': (duration) => {
|
|
166
|
+
if (!duration.day)
|
|
167
|
+
return '';
|
|
168
|
+
return duration.day + 'D';
|
|
169
|
+
},
|
|
170
|
+
'#h': (duration) => {
|
|
171
|
+
if (!duration.hour)
|
|
172
|
+
return '';
|
|
173
|
+
return duration.hour + 'H';
|
|
174
|
+
},
|
|
175
|
+
'#m': (duration) => {
|
|
176
|
+
if (!duration.minute)
|
|
177
|
+
return '';
|
|
178
|
+
return duration.minute + 'M';
|
|
179
|
+
},
|
|
180
|
+
'#s': (duration) => {
|
|
181
|
+
if (!duration.second)
|
|
182
|
+
return '';
|
|
183
|
+
return duration.second + 'S';
|
|
184
|
+
},
|
|
185
|
+
};
|
|
421
186
|
}
|
|
422
|
-
$mol_time_duration.patterns = {
|
|
423
|
-
'#Y': (duration) => {
|
|
424
|
-
if (!duration.year)
|
|
425
|
-
return '';
|
|
426
|
-
return duration.year + 'Y';
|
|
427
|
-
},
|
|
428
|
-
'#M': (duration) => {
|
|
429
|
-
if (!duration.month)
|
|
430
|
-
return '';
|
|
431
|
-
return duration.month + 'M';
|
|
432
|
-
},
|
|
433
|
-
'#D': (duration) => {
|
|
434
|
-
if (!duration.day)
|
|
435
|
-
return '';
|
|
436
|
-
return duration.day + 'D';
|
|
437
|
-
},
|
|
438
|
-
'#h': (duration) => {
|
|
439
|
-
if (!duration.hour)
|
|
440
|
-
return '';
|
|
441
|
-
return duration.hour + 'H';
|
|
442
|
-
},
|
|
443
|
-
'#m': (duration) => {
|
|
444
|
-
if (!duration.minute)
|
|
445
|
-
return '';
|
|
446
|
-
return duration.minute + 'M';
|
|
447
|
-
},
|
|
448
|
-
'#s': (duration) => {
|
|
449
|
-
if (!duration.second)
|
|
450
|
-
return '';
|
|
451
|
-
return duration.second + 'S';
|
|
452
|
-
},
|
|
453
|
-
'+hh': (duration) => {
|
|
454
|
-
var hour = duration.hour;
|
|
455
|
-
var sign = '+';
|
|
456
|
-
if (hour < 0) {
|
|
457
|
-
sign = '-';
|
|
458
|
-
hour = -hour;
|
|
459
|
-
}
|
|
460
|
-
return (hour < 10)
|
|
461
|
-
? (sign + '0' + hour)
|
|
462
|
-
: (sign + hour);
|
|
463
|
-
},
|
|
464
|
-
'mm': (duration) => {
|
|
465
|
-
return (duration.minute < 10)
|
|
466
|
-
? ('0' + duration.minute)
|
|
467
|
-
: String(duration.minute);
|
|
468
|
-
},
|
|
469
|
-
};
|
|
470
187
|
$.$mol_time_duration = $mol_time_duration;
|
|
471
188
|
})($ || ($ = {}));
|
|
472
189
|
//duration.js.map
|
|
@@ -474,80 +191,53 @@ var $;
|
|
|
474
191
|
"use strict";
|
|
475
192
|
var $;
|
|
476
193
|
(function ($) {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02').toString(), '2014-01-02');
|
|
482
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T03').toString(), '2014-01-02T03');
|
|
483
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T03:04').toString(), '2014-01-02T03:04');
|
|
484
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T03:04:05').toString(), '2014-01-02T03:04:05');
|
|
485
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T03:04:05.006').toString(), '2014-01-02T03:04:05.006');
|
|
486
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T03:04:05.006Z').toString(), '2014-01-02T03:04:05.006+00:00');
|
|
487
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T03:04:05.006+07:00').toString(), '2014-01-02T03:04:05.006+07:00');
|
|
488
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T03:04:05+07:08').toString(), '2014-01-02T03:04:05+07:08');
|
|
489
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T03:04+07:08').toString(), '2014-01-02T03:04+07:08');
|
|
490
|
-
$.$mol_assert_equal(new $.$mol_time_moment('T03:04+07:08').toString(), 'T03:04+07:08');
|
|
491
|
-
$.$mol_assert_equal(new $.$mol_time_moment('T03:04:05').toString(), 'T03:04:05');
|
|
492
|
-
$.$mol_assert_equal(new $.$mol_time_moment('T03:04').toString(), 'T03:04');
|
|
493
|
-
$.$mol_assert_equal(new $.$mol_time_moment('T03').toString(), 'T03');
|
|
494
|
-
},
|
|
495
|
-
'format simple'() {
|
|
496
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T01:02:03.000').toString('AD YY-M-D h:m:s'), '21 14-1-2 1:2:3');
|
|
497
|
-
},
|
|
498
|
-
'format padded'() {
|
|
499
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T01:02:03.000').toString('YYYY-MM-DD hh:mm:ss'), '2014-01-02 01:02:03');
|
|
500
|
-
},
|
|
501
|
-
'format time zone'() {
|
|
502
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T01:02:03+05:00').toString('Z'), '+05:00');
|
|
503
|
-
},
|
|
504
|
-
'format names'() {
|
|
505
|
-
$.$mol_assert_ok(new $.$mol_time_moment('2014-01-02T01:02:03.000').toString('Month Mon | WeekDay WD'));
|
|
506
|
-
},
|
|
507
|
-
'shifting'() {
|
|
508
|
-
$.$mol_assert_equal(new $.$mol_time_moment('T15:54:58.243+03:00').shift({}).toString(), 'T15:54:58.243+03:00');
|
|
509
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02').shift('P1Y').toString(), '2015-01-02');
|
|
510
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02').shift('P12M').toString(), '2015-01-02');
|
|
511
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02').shift('P365D').toString(), '2015-01-02');
|
|
512
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02').shift('PT8760h').toString(), '2015-01-02');
|
|
513
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2014-01').shift('PT8760h').toString(), '2015-01');
|
|
514
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2014-01').shift('PT-8760h').toString(), '2013-01');
|
|
515
|
-
},
|
|
516
|
-
'normalization'() {
|
|
517
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2015-07-35').normal.toString(), '2015-08-04');
|
|
518
|
-
},
|
|
519
|
-
'iso week day'() {
|
|
520
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2017-09-17').weekday, 6);
|
|
521
|
-
$.$mol_assert_equal(new $.$mol_time_moment('2017-09-18').weekday, 0);
|
|
522
|
-
},
|
|
523
|
-
});
|
|
194
|
+
function $mol_fail(error) {
|
|
195
|
+
throw error;
|
|
196
|
+
}
|
|
197
|
+
$.$mol_fail = $mol_fail;
|
|
524
198
|
})($ || ($ = {}));
|
|
525
|
-
//
|
|
199
|
+
//fail.js.map
|
|
526
200
|
;
|
|
527
201
|
"use strict";
|
|
528
202
|
var $;
|
|
529
203
|
(function ($) {
|
|
204
|
+
let $mol_time_moment_weekdays;
|
|
205
|
+
(function ($mol_time_moment_weekdays) {
|
|
206
|
+
$mol_time_moment_weekdays[$mol_time_moment_weekdays["monday"] = 0] = "monday";
|
|
207
|
+
$mol_time_moment_weekdays[$mol_time_moment_weekdays["tuesday"] = 1] = "tuesday";
|
|
208
|
+
$mol_time_moment_weekdays[$mol_time_moment_weekdays["wednesday"] = 2] = "wednesday";
|
|
209
|
+
$mol_time_moment_weekdays[$mol_time_moment_weekdays["thursday"] = 3] = "thursday";
|
|
210
|
+
$mol_time_moment_weekdays[$mol_time_moment_weekdays["friday"] = 4] = "friday";
|
|
211
|
+
$mol_time_moment_weekdays[$mol_time_moment_weekdays["saturday"] = 5] = "saturday";
|
|
212
|
+
$mol_time_moment_weekdays[$mol_time_moment_weekdays["sunday"] = 6] = "sunday";
|
|
213
|
+
})($mol_time_moment_weekdays = $.$mol_time_moment_weekdays || ($.$mol_time_moment_weekdays = {}));
|
|
214
|
+
function numb(str, max) {
|
|
215
|
+
const numb = Number(str);
|
|
216
|
+
if (numb < max)
|
|
217
|
+
return numb;
|
|
218
|
+
$.$mol_fail(new Error(`Wrong time component ${str}`));
|
|
219
|
+
}
|
|
530
220
|
class $mol_time_moment extends $.$mol_time_base {
|
|
531
221
|
constructor(config = new Date) {
|
|
532
222
|
super();
|
|
533
223
|
if (typeof config === 'number')
|
|
534
224
|
config = new Date(config);
|
|
535
225
|
if (typeof config === 'string') {
|
|
536
|
-
|
|
226
|
+
const parsed = /^(?:(\d\d?\d?\d?)(?:-?(\d\d?)(?:-?(\d\d?))?)?)?(?:[T ](?:(\d\d?)(?::?(\d\d?)(?::?(\d\d?(?:\.\d+)?))?)?)?(Z|[\+\-]\d\d?(?::?(?:\d\d?)?)?)?)?$/.exec(config);
|
|
537
227
|
if (!parsed)
|
|
538
228
|
throw new Error(`Can not parse time moment (${config})`);
|
|
539
229
|
if (parsed[1])
|
|
540
|
-
this.year =
|
|
230
|
+
this.year = numb(parsed[1], 9999);
|
|
541
231
|
if (parsed[2])
|
|
542
|
-
this.month =
|
|
232
|
+
this.month = numb(parsed[2], 13) - 1;
|
|
543
233
|
if (parsed[3])
|
|
544
|
-
this.day =
|
|
234
|
+
this.day = numb(parsed[3], 32) - 1;
|
|
545
235
|
if (parsed[4])
|
|
546
|
-
this.hour =
|
|
236
|
+
this.hour = numb(parsed[4], 60);
|
|
547
237
|
if (parsed[5])
|
|
548
|
-
this.minute =
|
|
238
|
+
this.minute = numb(parsed[5], 60);
|
|
549
239
|
if (parsed[6])
|
|
550
|
-
this.second =
|
|
240
|
+
this.second = numb(parsed[6], 60);
|
|
551
241
|
if (parsed[7])
|
|
552
242
|
this.offset = new $.$mol_time_duration(parsed[7]);
|
|
553
243
|
return;
|
|
@@ -559,7 +249,7 @@ var $;
|
|
|
559
249
|
this.hour = config.getHours();
|
|
560
250
|
this.minute = config.getMinutes();
|
|
561
251
|
this.second = config.getSeconds() + config.getMilliseconds() / 1000;
|
|
562
|
-
|
|
252
|
+
const offset = -config.getTimezoneOffset();
|
|
563
253
|
this.offset = new $.$mol_time_duration({
|
|
564
254
|
hour: (offset < 0) ? Math.ceil(offset / 60) : Math.floor(offset / 60),
|
|
565
255
|
minute: offset % 60
|
|
@@ -572,65 +262,94 @@ var $;
|
|
|
572
262
|
this.hour = config.hour;
|
|
573
263
|
this.minute = config.minute;
|
|
574
264
|
this.second = config.second;
|
|
575
|
-
|
|
576
|
-
this.offset = new $.$mol_time_duration(config.offset);
|
|
265
|
+
this.offset = config.offset == null ? config.offset : new $.$mol_time_duration(config.offset);
|
|
577
266
|
}
|
|
267
|
+
year;
|
|
268
|
+
month;
|
|
269
|
+
day;
|
|
270
|
+
hour;
|
|
271
|
+
minute;
|
|
272
|
+
second;
|
|
273
|
+
offset;
|
|
578
274
|
get weekday() {
|
|
579
275
|
return (this.native.getDay() + 6) % 7;
|
|
580
276
|
}
|
|
277
|
+
_native;
|
|
581
278
|
get native() {
|
|
582
279
|
if (this._native)
|
|
583
280
|
return this._native;
|
|
584
|
-
|
|
585
|
-
return this._native = new Date(Date.UTC(
|
|
281
|
+
const utc = this.toOffset('Z');
|
|
282
|
+
return this._native = new Date(Date.UTC(utc.year ?? 0, utc.month ?? 0, (utc.day ?? 0) + 1, utc.hour ?? 0, utc.minute ?? 0, utc.second != undefined ? Math.floor(utc.second) : 0, utc.second != undefined ? Math.floor((utc.second - Math.floor(utc.second)) * 1000) : 0));
|
|
586
283
|
}
|
|
284
|
+
_normal;
|
|
587
285
|
get normal() {
|
|
588
286
|
if (this._normal)
|
|
589
287
|
return this._normal;
|
|
590
288
|
const moment = new $mol_time_moment(this.native);
|
|
591
289
|
return this._normal = new $mol_time_moment({
|
|
592
|
-
year:
|
|
593
|
-
month:
|
|
594
|
-
day:
|
|
595
|
-
hour:
|
|
596
|
-
minute:
|
|
597
|
-
second:
|
|
598
|
-
offset:
|
|
290
|
+
year: this.year === undefined ? undefined : moment.year,
|
|
291
|
+
month: this.month === undefined ? undefined : moment.month,
|
|
292
|
+
day: this.day === undefined ? undefined : moment.day,
|
|
293
|
+
hour: this.hour === undefined ? undefined : moment.hour,
|
|
294
|
+
minute: this.minute === undefined ? undefined : moment.minute,
|
|
295
|
+
second: this.second === undefined ? undefined : moment.second,
|
|
296
|
+
offset: this.offset === undefined ? undefined : moment.offset,
|
|
599
297
|
});
|
|
600
298
|
}
|
|
601
299
|
merge(config) {
|
|
602
|
-
|
|
300
|
+
const moment = new $mol_time_moment(config);
|
|
603
301
|
return new $mol_time_moment({
|
|
604
|
-
year:
|
|
605
|
-
month:
|
|
606
|
-
day:
|
|
607
|
-
hour:
|
|
608
|
-
minute:
|
|
609
|
-
second:
|
|
610
|
-
offset:
|
|
302
|
+
year: moment.year === undefined ? this.year : moment.year,
|
|
303
|
+
month: moment.month === undefined ? this.month : moment.month,
|
|
304
|
+
day: moment.day === undefined ? this.day : moment.day,
|
|
305
|
+
hour: moment.hour === undefined ? this.hour : moment.hour,
|
|
306
|
+
minute: moment.minute === undefined ? this.minute : moment.minute,
|
|
307
|
+
second: moment.second === undefined ? this.second : moment.second,
|
|
308
|
+
offset: moment.offset === undefined ? this.offset : moment.offset,
|
|
611
309
|
});
|
|
612
310
|
}
|
|
613
311
|
shift(config) {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
312
|
+
const duration = new $.$mol_time_duration(config);
|
|
313
|
+
const moment = new $mol_time_moment().merge({
|
|
314
|
+
year: this.year,
|
|
315
|
+
month: this.month,
|
|
316
|
+
day: this.day,
|
|
317
|
+
hour: this.hour ?? 0,
|
|
318
|
+
minute: this.minute ?? 0,
|
|
319
|
+
second: this.second ?? 0,
|
|
320
|
+
offset: this.offset ?? 0
|
|
321
|
+
});
|
|
322
|
+
const second = moment.second + (duration.second ?? 0);
|
|
323
|
+
const native = new Date(moment.year + (duration.year ?? 0), moment.month + (duration.month ?? 0), moment.day + 1 + (duration.day ?? 0), moment.hour + (duration.hour ?? 0), moment.minute + (duration.minute ?? 0), Math.floor(second), (second - Math.floor(second)) * 1000);
|
|
618
324
|
if (isNaN(native.valueOf()))
|
|
619
325
|
throw new Error('Wrong time');
|
|
620
326
|
return new $mol_time_moment({
|
|
621
|
-
year:
|
|
622
|
-
month:
|
|
623
|
-
day:
|
|
624
|
-
hour:
|
|
625
|
-
minute:
|
|
626
|
-
second:
|
|
327
|
+
year: this.year === undefined ? undefined : native.getFullYear(),
|
|
328
|
+
month: this.month === undefined ? undefined : native.getMonth(),
|
|
329
|
+
day: this.day === undefined ? undefined : native.getDate() - 1,
|
|
330
|
+
hour: this.hour === undefined ? undefined : native.getHours(),
|
|
331
|
+
minute: this.minute === undefined ? undefined : native.getMinutes(),
|
|
332
|
+
second: this.second === undefined ? undefined : native.getSeconds() + native.getMilliseconds() / 1000,
|
|
627
333
|
offset: this.offset,
|
|
628
334
|
});
|
|
629
335
|
}
|
|
630
|
-
|
|
631
|
-
const
|
|
336
|
+
mask(config) {
|
|
337
|
+
const mask = new $mol_time_moment(config);
|
|
338
|
+
return new $mol_time_moment({
|
|
339
|
+
year: mask.year === undefined ? undefined : this.year,
|
|
340
|
+
month: mask.month === undefined ? undefined : this.month,
|
|
341
|
+
day: mask.day === undefined ? undefined : this.day,
|
|
342
|
+
hour: mask.hour === undefined ? undefined : this.hour,
|
|
343
|
+
minute: mask.minute === undefined ? undefined : this.minute,
|
|
344
|
+
second: mask.second === undefined ? undefined : this.second,
|
|
345
|
+
offset: mask.offset === undefined ? undefined : this.offset,
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
toOffset(config) {
|
|
349
|
+
const duration = new $.$mol_time_duration(config);
|
|
632
350
|
const offset = this.offset || new $mol_time_moment().offset;
|
|
633
|
-
|
|
351
|
+
let with_time = new $mol_time_moment('T00:00:00').merge(this);
|
|
352
|
+
const moment = with_time.shift(duration.summ(offset.mult(-1)));
|
|
634
353
|
return moment.merge({ offset: duration });
|
|
635
354
|
}
|
|
636
355
|
valueOf() { return this.native.getTime(); }
|
|
@@ -638,186 +357,230 @@ var $;
|
|
|
638
357
|
toString(pattern = 'YYYY-MM-DDThh:mm:ss.sssZ') {
|
|
639
358
|
return super.toString(pattern);
|
|
640
359
|
}
|
|
360
|
+
static patterns = {
|
|
361
|
+
'YYYY': (moment) => {
|
|
362
|
+
if (moment.year == null)
|
|
363
|
+
return '';
|
|
364
|
+
return String(moment.year);
|
|
365
|
+
},
|
|
366
|
+
'AD': (moment) => {
|
|
367
|
+
if (moment.year == null)
|
|
368
|
+
return '';
|
|
369
|
+
return String(Math.floor(moment.year / 100) + 1);
|
|
370
|
+
},
|
|
371
|
+
'YY': (moment) => {
|
|
372
|
+
if (moment.year == null)
|
|
373
|
+
return '';
|
|
374
|
+
return String(moment.year % 100);
|
|
375
|
+
},
|
|
376
|
+
'Month': (pattern => (moment) => {
|
|
377
|
+
if (moment.month == null)
|
|
378
|
+
return '';
|
|
379
|
+
return pattern.format(moment.native);
|
|
380
|
+
})(new Intl.DateTimeFormat(undefined, { month: 'long' })),
|
|
381
|
+
'DD Month': (pattern => (moment) => {
|
|
382
|
+
if (moment.month == null) {
|
|
383
|
+
if (moment.day == null) {
|
|
384
|
+
return '';
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
return $mol_time_moment.patterns['DD'](moment);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
if (moment.day == null) {
|
|
392
|
+
return $mol_time_moment.patterns['Month'](moment);
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
return pattern.format(moment.native);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
})(new Intl.DateTimeFormat(undefined, { day: '2-digit', month: 'long' })),
|
|
399
|
+
'D Month': (pattern => (moment) => {
|
|
400
|
+
if (moment.month == null) {
|
|
401
|
+
if (moment.day == null) {
|
|
402
|
+
return '';
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
return $mol_time_moment.patterns['D'](moment);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
if (moment.day == null) {
|
|
410
|
+
return $mol_time_moment.patterns['Month'](moment);
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
return pattern.format(moment.native);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
})(new Intl.DateTimeFormat(undefined, { day: 'numeric', month: 'long' })),
|
|
417
|
+
'Mon': (pattern => (moment) => {
|
|
418
|
+
if (moment.month == null)
|
|
419
|
+
return '';
|
|
420
|
+
return pattern.format(moment.native);
|
|
421
|
+
})(new Intl.DateTimeFormat(undefined, { month: 'short' })),
|
|
422
|
+
'DD Mon': (pattern => (moment) => {
|
|
423
|
+
if (moment.month == null) {
|
|
424
|
+
if (moment.day == null) {
|
|
425
|
+
return '';
|
|
426
|
+
}
|
|
427
|
+
else {
|
|
428
|
+
return $mol_time_moment.patterns['DD'](moment);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
if (moment.day == null) {
|
|
433
|
+
return $mol_time_moment.patterns['Mon'](moment);
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
return pattern.format(moment.native);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
})(new Intl.DateTimeFormat(undefined, { day: '2-digit', month: 'short' })),
|
|
440
|
+
'D Mon': (pattern => (moment) => {
|
|
441
|
+
if (moment.month == null) {
|
|
442
|
+
if (moment.day == null) {
|
|
443
|
+
return '';
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
return $mol_time_moment.patterns['D'](moment);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
if (moment.day == null) {
|
|
451
|
+
return $mol_time_moment.patterns['Mon'](moment);
|
|
452
|
+
}
|
|
453
|
+
else {
|
|
454
|
+
return pattern.format(moment.native);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
})(new Intl.DateTimeFormat(undefined, { day: 'numeric', month: 'short' })),
|
|
458
|
+
'-MM': (moment) => {
|
|
459
|
+
if (moment.month == null)
|
|
460
|
+
return '';
|
|
461
|
+
return '-' + $mol_time_moment.patterns['MM'](moment);
|
|
462
|
+
},
|
|
463
|
+
'MM': (moment) => {
|
|
464
|
+
if (moment.month == null)
|
|
465
|
+
return '';
|
|
466
|
+
return String(100 + moment.month + 1).slice(1);
|
|
467
|
+
},
|
|
468
|
+
'M': (moment) => {
|
|
469
|
+
if (moment.month == null)
|
|
470
|
+
return '';
|
|
471
|
+
return String(moment.month + 1);
|
|
472
|
+
},
|
|
473
|
+
'WeekDay': (pattern => (moment) => {
|
|
474
|
+
if (moment.day == null)
|
|
475
|
+
return '';
|
|
476
|
+
if (moment.month == null)
|
|
477
|
+
return '';
|
|
478
|
+
if (moment.year == null)
|
|
479
|
+
return '';
|
|
480
|
+
return pattern.format(moment.native);
|
|
481
|
+
})(new Intl.DateTimeFormat(undefined, { weekday: 'long' })),
|
|
482
|
+
'WD': (pattern => (moment) => {
|
|
483
|
+
if (moment.day == null)
|
|
484
|
+
return '';
|
|
485
|
+
if (moment.month == null)
|
|
486
|
+
return '';
|
|
487
|
+
if (moment.year == null)
|
|
488
|
+
return '';
|
|
489
|
+
return pattern.format(moment.native);
|
|
490
|
+
})(new Intl.DateTimeFormat(undefined, { weekday: 'short' })),
|
|
491
|
+
'-DD': (moment) => {
|
|
492
|
+
if (moment.day == null)
|
|
493
|
+
return '';
|
|
494
|
+
return '-' + $mol_time_moment.patterns['DD'](moment);
|
|
495
|
+
},
|
|
496
|
+
'DD': (moment) => {
|
|
497
|
+
if (moment.day == null)
|
|
498
|
+
return '';
|
|
499
|
+
return String(100 + moment.day + 1).slice(1);
|
|
500
|
+
},
|
|
501
|
+
'D': (moment) => {
|
|
502
|
+
if (moment.day == null)
|
|
503
|
+
return '';
|
|
504
|
+
return String(moment.day + 1);
|
|
505
|
+
},
|
|
506
|
+
'Thh': (moment) => {
|
|
507
|
+
if (moment.hour == null)
|
|
508
|
+
return '';
|
|
509
|
+
return 'T' + $mol_time_moment.patterns['hh'](moment);
|
|
510
|
+
},
|
|
511
|
+
'hh': (moment) => {
|
|
512
|
+
if (moment.hour == null)
|
|
513
|
+
return '';
|
|
514
|
+
return String(100 + moment.hour).slice(1);
|
|
515
|
+
},
|
|
516
|
+
'h': (moment) => {
|
|
517
|
+
if (moment.hour == null)
|
|
518
|
+
return '';
|
|
519
|
+
return String(moment.hour);
|
|
520
|
+
},
|
|
521
|
+
':mm': (moment) => {
|
|
522
|
+
if (moment.minute == null)
|
|
523
|
+
return '';
|
|
524
|
+
return ':' + $mol_time_moment.patterns['mm'](moment);
|
|
525
|
+
},
|
|
526
|
+
'mm': (moment) => {
|
|
527
|
+
if (moment.minute == null)
|
|
528
|
+
return '';
|
|
529
|
+
return String(100 + moment.minute).slice(1);
|
|
530
|
+
},
|
|
531
|
+
'm': (moment) => {
|
|
532
|
+
if (moment.minute == null)
|
|
533
|
+
return '';
|
|
534
|
+
return String(moment.minute);
|
|
535
|
+
},
|
|
536
|
+
':ss': (moment) => {
|
|
537
|
+
if (moment.second == null)
|
|
538
|
+
return '';
|
|
539
|
+
return ':' + $mol_time_moment.patterns['ss'](moment);
|
|
540
|
+
},
|
|
541
|
+
'ss': (moment) => {
|
|
542
|
+
if (moment.second == null)
|
|
543
|
+
return '';
|
|
544
|
+
return String(100 + moment.second | 0).slice(1);
|
|
545
|
+
},
|
|
546
|
+
's': (moment) => {
|
|
547
|
+
if (moment.second == null)
|
|
548
|
+
return '';
|
|
549
|
+
return String(moment.second | 0);
|
|
550
|
+
},
|
|
551
|
+
'.sss': (moment) => {
|
|
552
|
+
if (moment.second == null)
|
|
553
|
+
return '';
|
|
554
|
+
if (moment.second === (moment.second | 0))
|
|
555
|
+
return '';
|
|
556
|
+
return '.' + $mol_time_moment.patterns['sss'](moment);
|
|
557
|
+
},
|
|
558
|
+
'sss': (moment) => {
|
|
559
|
+
if (moment.second == null)
|
|
560
|
+
return '';
|
|
561
|
+
const millisecond = Math.floor((moment.second - Math.floor(moment.second)) * 1000);
|
|
562
|
+
return String(1000 + millisecond).slice(1);
|
|
563
|
+
},
|
|
564
|
+
'Z': (moment) => {
|
|
565
|
+
const offset = moment.offset;
|
|
566
|
+
if (!offset)
|
|
567
|
+
return '';
|
|
568
|
+
let hour = offset.hour;
|
|
569
|
+
let sign = '+';
|
|
570
|
+
if (hour < 0) {
|
|
571
|
+
sign = '-';
|
|
572
|
+
hour = -hour;
|
|
573
|
+
}
|
|
574
|
+
return sign + String(100 + hour).slice(1) + ':' + String(100 + offset.minute).slice(1);
|
|
575
|
+
}
|
|
576
|
+
};
|
|
641
577
|
}
|
|
642
|
-
$mol_time_moment.patterns = {
|
|
643
|
-
'YYYY': (moment) => {
|
|
644
|
-
if (moment.year == null)
|
|
645
|
-
return '';
|
|
646
|
-
return String(moment.year);
|
|
647
|
-
},
|
|
648
|
-
'AD': (moment) => {
|
|
649
|
-
if (moment.year == null)
|
|
650
|
-
return '';
|
|
651
|
-
return String(Math.floor(moment.year / 100) + 1);
|
|
652
|
-
},
|
|
653
|
-
'YY': (moment) => {
|
|
654
|
-
if (moment.year == null)
|
|
655
|
-
return '';
|
|
656
|
-
return String(moment.year % 100);
|
|
657
|
-
},
|
|
658
|
-
'Month': (moment) => {
|
|
659
|
-
if (moment.month == null)
|
|
660
|
-
return '';
|
|
661
|
-
return moment.native.toLocaleString(undefined, { month: 'long' });
|
|
662
|
-
},
|
|
663
|
-
'DD Month': (moment) => {
|
|
664
|
-
return moment.native.toLocaleString(undefined, { day: '2-digit', month: 'long' });
|
|
665
|
-
},
|
|
666
|
-
'D Month': (moment) => {
|
|
667
|
-
return moment.native.toLocaleString(undefined, { day: 'numeric', month: 'long' });
|
|
668
|
-
},
|
|
669
|
-
'Mon': (moment) => {
|
|
670
|
-
if (moment.month == null)
|
|
671
|
-
return '';
|
|
672
|
-
return moment.native.toLocaleString(undefined, { month: 'short' });
|
|
673
|
-
},
|
|
674
|
-
'DD Mon': (moment) => {
|
|
675
|
-
return moment.native.toLocaleString(undefined, { day: '2-digit', month: 'short' });
|
|
676
|
-
},
|
|
677
|
-
'D Mon': (moment) => {
|
|
678
|
-
return moment.native.toLocaleString(undefined, { day: 'numeric', month: 'short' });
|
|
679
|
-
},
|
|
680
|
-
'-MM': (moment) => {
|
|
681
|
-
if (moment.month == null)
|
|
682
|
-
return '';
|
|
683
|
-
return '-' + $mol_time_moment.patterns['MM'](moment);
|
|
684
|
-
},
|
|
685
|
-
'MM': (moment) => {
|
|
686
|
-
if (moment.month == null)
|
|
687
|
-
return '';
|
|
688
|
-
var month = moment.month + 1;
|
|
689
|
-
return (month < 10)
|
|
690
|
-
? ('0' + month)
|
|
691
|
-
: ('' + month);
|
|
692
|
-
},
|
|
693
|
-
'M': (moment) => {
|
|
694
|
-
if (moment.month == null)
|
|
695
|
-
return '';
|
|
696
|
-
return String(moment.month + 1);
|
|
697
|
-
},
|
|
698
|
-
'WeekDay': (moment) => {
|
|
699
|
-
if (moment.weekday == null)
|
|
700
|
-
return '';
|
|
701
|
-
return moment.native.toLocaleString(undefined, { weekday: 'long' });
|
|
702
|
-
},
|
|
703
|
-
'WD': (moment) => {
|
|
704
|
-
if (moment.weekday == null)
|
|
705
|
-
return '';
|
|
706
|
-
return moment.native.toLocaleString(undefined, { weekday: 'short' });
|
|
707
|
-
},
|
|
708
|
-
'-DD': (moment) => {
|
|
709
|
-
if (moment.day == null)
|
|
710
|
-
return '';
|
|
711
|
-
return '-' + $mol_time_moment.patterns['DD'](moment);
|
|
712
|
-
},
|
|
713
|
-
'DD': (moment) => {
|
|
714
|
-
if (moment.day == null)
|
|
715
|
-
return '';
|
|
716
|
-
var day = moment.day + 1;
|
|
717
|
-
return (day < 10)
|
|
718
|
-
? ('0' + day)
|
|
719
|
-
: String(day);
|
|
720
|
-
},
|
|
721
|
-
'D': (moment) => {
|
|
722
|
-
if (moment.day == null)
|
|
723
|
-
return '';
|
|
724
|
-
return String(moment.day + 1);
|
|
725
|
-
},
|
|
726
|
-
'Thh': (moment) => {
|
|
727
|
-
if (moment.hour == null)
|
|
728
|
-
return '';
|
|
729
|
-
return 'T' + $mol_time_moment.patterns['hh'](moment);
|
|
730
|
-
},
|
|
731
|
-
'hh': (moment) => {
|
|
732
|
-
if (moment.hour == null)
|
|
733
|
-
return '';
|
|
734
|
-
return (moment.hour < 10)
|
|
735
|
-
? ('0' + moment.hour)
|
|
736
|
-
: String(moment.hour);
|
|
737
|
-
},
|
|
738
|
-
'h': (moment) => {
|
|
739
|
-
if (moment.hour == null)
|
|
740
|
-
return '';
|
|
741
|
-
return String(moment.hour);
|
|
742
|
-
},
|
|
743
|
-
':mm': (moment) => {
|
|
744
|
-
if (moment.minute == null)
|
|
745
|
-
return '';
|
|
746
|
-
return ':' + $mol_time_moment.patterns['mm'](moment);
|
|
747
|
-
},
|
|
748
|
-
'mm': (moment) => {
|
|
749
|
-
if (moment.minute == null)
|
|
750
|
-
return '';
|
|
751
|
-
return (moment.minute < 10)
|
|
752
|
-
? ('0' + moment.minute)
|
|
753
|
-
: String(moment.minute);
|
|
754
|
-
},
|
|
755
|
-
'm': (moment) => {
|
|
756
|
-
if (moment.minute == null)
|
|
757
|
-
return '';
|
|
758
|
-
return String(moment.minute);
|
|
759
|
-
},
|
|
760
|
-
':ss': (moment) => {
|
|
761
|
-
if (moment.second == null)
|
|
762
|
-
return '';
|
|
763
|
-
return ':' + $mol_time_moment.patterns['ss'](moment);
|
|
764
|
-
},
|
|
765
|
-
'ss': (moment) => {
|
|
766
|
-
if (moment.second == null)
|
|
767
|
-
return '';
|
|
768
|
-
var second = Math.floor(moment.second);
|
|
769
|
-
return (second < 10)
|
|
770
|
-
? ('0' + second)
|
|
771
|
-
: String(second);
|
|
772
|
-
},
|
|
773
|
-
's': (moment) => {
|
|
774
|
-
if (moment.second == null)
|
|
775
|
-
return '';
|
|
776
|
-
return String(Math.floor(moment.second));
|
|
777
|
-
},
|
|
778
|
-
'.sss': (moment) => {
|
|
779
|
-
if (moment.second == null)
|
|
780
|
-
return '';
|
|
781
|
-
if (moment.second - Math.floor(moment.second) === 0)
|
|
782
|
-
return '';
|
|
783
|
-
return '.' + $mol_time_moment.patterns['sss'](moment);
|
|
784
|
-
},
|
|
785
|
-
'sss': (moment) => {
|
|
786
|
-
if (moment.second == null)
|
|
787
|
-
return '';
|
|
788
|
-
var millisecond = Math.floor((moment.second - Math.floor(moment.second)) * 1000);
|
|
789
|
-
return (millisecond < 10)
|
|
790
|
-
? ('00' + millisecond)
|
|
791
|
-
: (millisecond < 100)
|
|
792
|
-
? ('0' + millisecond)
|
|
793
|
-
: String(millisecond);
|
|
794
|
-
},
|
|
795
|
-
'Z': (moment) => {
|
|
796
|
-
var offset = moment.offset;
|
|
797
|
-
if (!offset)
|
|
798
|
-
return '';
|
|
799
|
-
return offset.toString('+hh:mm');
|
|
800
|
-
}
|
|
801
|
-
};
|
|
802
578
|
$.$mol_time_moment = $mol_time_moment;
|
|
803
579
|
})($ || ($ = {}));
|
|
804
580
|
//moment.js.map
|
|
805
581
|
;
|
|
806
582
|
"use strict";
|
|
807
583
|
var $;
|
|
808
|
-
(function ($) {
|
|
809
|
-
$.$mol_test({
|
|
810
|
-
'triplets'() {
|
|
811
|
-
$.$mol_assert_equal(new $.$mol_time_interval('2015-01-01/P1M').end.toString(), '2015-02-01');
|
|
812
|
-
$.$mol_assert_equal(new $.$mol_time_interval('P1M/2015-02-01').start.toString(), '2015-01-01');
|
|
813
|
-
$.$mol_assert_equal(new $.$mol_time_interval('2015-01-01/2015-02-01').duration.toString(), 'PT2678400S');
|
|
814
|
-
}
|
|
815
|
-
});
|
|
816
|
-
})($ || ($ = {}));
|
|
817
|
-
//interval.test.js.map
|
|
818
|
-
;
|
|
819
|
-
"use strict";
|
|
820
|
-
var $;
|
|
821
584
|
(function ($) {
|
|
822
585
|
class $mol_time_interval extends $.$mol_time_base {
|
|
823
586
|
constructor(config) {
|
|
@@ -855,16 +618,19 @@ var $;
|
|
|
855
618
|
if (config.duration !== undefined)
|
|
856
619
|
this._duration = new $.$mol_time_duration(config.duration);
|
|
857
620
|
}
|
|
621
|
+
_start;
|
|
858
622
|
get start() {
|
|
859
623
|
if (this._start)
|
|
860
624
|
return this._start;
|
|
861
625
|
return this._start = this._end.shift(this._duration.mult(-1));
|
|
862
626
|
}
|
|
627
|
+
_end;
|
|
863
628
|
get end() {
|
|
864
629
|
if (this._end)
|
|
865
630
|
return this._end;
|
|
866
631
|
return this._end = this._start.shift(this._duration);
|
|
867
632
|
}
|
|
633
|
+
_duration;
|
|
868
634
|
get duration() {
|
|
869
635
|
if (this._duration)
|
|
870
636
|
return this._duration;
|
|
@@ -878,4 +644,1651 @@ var $;
|
|
|
878
644
|
$.$mol_time_interval = $mol_time_interval;
|
|
879
645
|
})($ || ($ = {}));
|
|
880
646
|
//interval.js.map
|
|
881
|
-
|
|
647
|
+
;
|
|
648
|
+
"use strict";
|
|
649
|
+
var $;
|
|
650
|
+
(function ($) {
|
|
651
|
+
function $mol_fail_hidden(error) {
|
|
652
|
+
throw error;
|
|
653
|
+
}
|
|
654
|
+
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
655
|
+
})($ || ($ = {}));
|
|
656
|
+
//hidden.js.map
|
|
657
|
+
;
|
|
658
|
+
"use strict";
|
|
659
|
+
var $;
|
|
660
|
+
(function ($) {
|
|
661
|
+
function $mol_test_complete() {
|
|
662
|
+
process.exit(0);
|
|
663
|
+
}
|
|
664
|
+
$.$mol_test_complete = $mol_test_complete;
|
|
665
|
+
})($ || ($ = {}));
|
|
666
|
+
//test.node.test.js.map
|
|
667
|
+
;
|
|
668
|
+
"use strict";
|
|
669
|
+
var $;
|
|
670
|
+
(function ($_1) {
|
|
671
|
+
function $mol_test(set) {
|
|
672
|
+
for (let name in set) {
|
|
673
|
+
const code = set[name];
|
|
674
|
+
const test = (typeof code === 'string') ? new Function('', code) : code;
|
|
675
|
+
$_1.$mol_test_all.push(test);
|
|
676
|
+
}
|
|
677
|
+
$mol_test_schedule();
|
|
678
|
+
}
|
|
679
|
+
$_1.$mol_test = $mol_test;
|
|
680
|
+
$_1.$mol_test_mocks = [];
|
|
681
|
+
$_1.$mol_test_all = [];
|
|
682
|
+
async function $mol_test_run() {
|
|
683
|
+
for (var test of $_1.$mol_test_all) {
|
|
684
|
+
let context = Object.create($_1.$$);
|
|
685
|
+
for (let mock of $_1.$mol_test_mocks)
|
|
686
|
+
await mock(context);
|
|
687
|
+
await test(context);
|
|
688
|
+
}
|
|
689
|
+
$_1.$$.$mol_log3_done({
|
|
690
|
+
place: '$mol_test',
|
|
691
|
+
message: 'All tests passed',
|
|
692
|
+
count: $_1.$mol_test_all.length,
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
$_1.$mol_test_run = $mol_test_run;
|
|
696
|
+
let scheduled = false;
|
|
697
|
+
function $mol_test_schedule() {
|
|
698
|
+
if (scheduled)
|
|
699
|
+
return;
|
|
700
|
+
scheduled = true;
|
|
701
|
+
setTimeout(async () => {
|
|
702
|
+
scheduled = false;
|
|
703
|
+
try {
|
|
704
|
+
await $mol_test_run();
|
|
705
|
+
}
|
|
706
|
+
finally {
|
|
707
|
+
$_1.$$.$mol_test_complete();
|
|
708
|
+
}
|
|
709
|
+
}, 0);
|
|
710
|
+
}
|
|
711
|
+
$_1.$mol_test_schedule = $mol_test_schedule;
|
|
712
|
+
$_1.$mol_test_mocks.push(context => {
|
|
713
|
+
let seed = 0;
|
|
714
|
+
context.Math = Object.create(Math);
|
|
715
|
+
context.Math.random = () => Math.sin(seed++);
|
|
716
|
+
const forbidden = ['XMLHttpRequest', 'fetch'];
|
|
717
|
+
for (let api of forbidden) {
|
|
718
|
+
context[api] = new Proxy(function () { }, {
|
|
719
|
+
get() {
|
|
720
|
+
$_1.$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
721
|
+
},
|
|
722
|
+
apply() {
|
|
723
|
+
$_1.$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
724
|
+
},
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
$mol_test({
|
|
729
|
+
'mocked Math.random'($) {
|
|
730
|
+
console.assert($.Math.random() === 0);
|
|
731
|
+
console.assert($.Math.random() === Math.sin(1));
|
|
732
|
+
},
|
|
733
|
+
'forbidden XMLHttpRequest'($) {
|
|
734
|
+
try {
|
|
735
|
+
console.assert(void new $.XMLHttpRequest);
|
|
736
|
+
}
|
|
737
|
+
catch (error) {
|
|
738
|
+
console.assert(error.message === 'XMLHttpRequest is forbidden in tests');
|
|
739
|
+
}
|
|
740
|
+
},
|
|
741
|
+
'forbidden fetch'($) {
|
|
742
|
+
try {
|
|
743
|
+
console.assert(void $.fetch(''));
|
|
744
|
+
}
|
|
745
|
+
catch (error) {
|
|
746
|
+
console.assert(error.message === 'fetch is forbidden in tests');
|
|
747
|
+
}
|
|
748
|
+
},
|
|
749
|
+
});
|
|
750
|
+
})($ || ($ = {}));
|
|
751
|
+
//test.test.js.map
|
|
752
|
+
;
|
|
753
|
+
"use strict";
|
|
754
|
+
var $;
|
|
755
|
+
(function ($) {
|
|
756
|
+
})($ || ($ = {}));
|
|
757
|
+
//context.js.map
|
|
758
|
+
;
|
|
759
|
+
"use strict";
|
|
760
|
+
//node.js.map
|
|
761
|
+
;
|
|
762
|
+
"use strict";
|
|
763
|
+
var $node = new Proxy({ require }, {
|
|
764
|
+
get(target, name, wrapper) {
|
|
765
|
+
if (target[name])
|
|
766
|
+
return target[name];
|
|
767
|
+
const mod = target.require('module');
|
|
768
|
+
if (mod.builtinModules.indexOf(name) >= 0)
|
|
769
|
+
return target.require(name);
|
|
770
|
+
const path = target.require('path');
|
|
771
|
+
const fs = target.require('fs');
|
|
772
|
+
let dir = path.resolve('.');
|
|
773
|
+
const suffix = `./node_modules/${name}`;
|
|
774
|
+
const $$ = $;
|
|
775
|
+
while (!fs.existsSync(path.join(dir, suffix))) {
|
|
776
|
+
const parent = path.resolve(dir, '..');
|
|
777
|
+
if (parent === dir) {
|
|
778
|
+
$$.$mol_exec('.', 'npm', 'install', name);
|
|
779
|
+
try {
|
|
780
|
+
$$.$mol_exec('.', 'npm', 'install', '@types/' + name);
|
|
781
|
+
}
|
|
782
|
+
catch { }
|
|
783
|
+
break;
|
|
784
|
+
}
|
|
785
|
+
else {
|
|
786
|
+
dir = parent;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
return target.require(name);
|
|
790
|
+
},
|
|
791
|
+
set(target, name, value) {
|
|
792
|
+
target[name] = value;
|
|
793
|
+
return true;
|
|
794
|
+
},
|
|
795
|
+
});
|
|
796
|
+
require = (req => Object.assign(function require(name) {
|
|
797
|
+
return $node[name];
|
|
798
|
+
}, req))(require);
|
|
799
|
+
//node.node.js.map
|
|
800
|
+
;
|
|
801
|
+
"use strict";
|
|
802
|
+
var $;
|
|
803
|
+
(function ($) {
|
|
804
|
+
$.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
|
|
805
|
+
})($ || ($ = {}));
|
|
806
|
+
//context.node.js.map
|
|
807
|
+
;
|
|
808
|
+
"use strict";
|
|
809
|
+
var $;
|
|
810
|
+
(function ($) {
|
|
811
|
+
function $mol_dom_render_children(el, childNodes) {
|
|
812
|
+
const node_set = new Set(childNodes);
|
|
813
|
+
let nextNode = el.firstChild;
|
|
814
|
+
for (let view of childNodes) {
|
|
815
|
+
if (view == null)
|
|
816
|
+
continue;
|
|
817
|
+
if (view instanceof $.$mol_dom_context.Node) {
|
|
818
|
+
while (true) {
|
|
819
|
+
if (!nextNode) {
|
|
820
|
+
el.appendChild(view);
|
|
821
|
+
break;
|
|
822
|
+
}
|
|
823
|
+
if (nextNode == view) {
|
|
824
|
+
nextNode = nextNode.nextSibling;
|
|
825
|
+
break;
|
|
826
|
+
}
|
|
827
|
+
else {
|
|
828
|
+
if (node_set.has(nextNode)) {
|
|
829
|
+
el.insertBefore(view, nextNode);
|
|
830
|
+
break;
|
|
831
|
+
}
|
|
832
|
+
else {
|
|
833
|
+
const nn = nextNode.nextSibling;
|
|
834
|
+
el.removeChild(nextNode);
|
|
835
|
+
nextNode = nn;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
else {
|
|
841
|
+
if (nextNode && nextNode.nodeName === '#text') {
|
|
842
|
+
const str = String(view);
|
|
843
|
+
if (nextNode.nodeValue !== str)
|
|
844
|
+
nextNode.nodeValue = str;
|
|
845
|
+
nextNode = nextNode.nextSibling;
|
|
846
|
+
}
|
|
847
|
+
else {
|
|
848
|
+
const textNode = $.$mol_dom_context.document.createTextNode(String(view));
|
|
849
|
+
el.insertBefore(textNode, nextNode);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
while (nextNode) {
|
|
854
|
+
const currNode = nextNode;
|
|
855
|
+
nextNode = currNode.nextSibling;
|
|
856
|
+
el.removeChild(currNode);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
$.$mol_dom_render_children = $mol_dom_render_children;
|
|
860
|
+
})($ || ($ = {}));
|
|
861
|
+
//children.js.map
|
|
862
|
+
;
|
|
863
|
+
"use strict";
|
|
864
|
+
//error.js.map
|
|
865
|
+
;
|
|
866
|
+
"use strict";
|
|
867
|
+
//assert.test.js.map
|
|
868
|
+
;
|
|
869
|
+
"use strict";
|
|
870
|
+
//assert.js.map
|
|
871
|
+
;
|
|
872
|
+
"use strict";
|
|
873
|
+
//deep.test.js.map
|
|
874
|
+
;
|
|
875
|
+
"use strict";
|
|
876
|
+
//deep.js.map
|
|
877
|
+
;
|
|
878
|
+
"use strict";
|
|
879
|
+
var $;
|
|
880
|
+
(function ($) {
|
|
881
|
+
$.$mol_test({
|
|
882
|
+
'Make empty div'() {
|
|
883
|
+
$.$mol_assert_equal(($.$mol_jsx("div", null)).outerHTML, '<div></div>');
|
|
884
|
+
},
|
|
885
|
+
'Define native field'() {
|
|
886
|
+
const dom = $.$mol_jsx("input", { value: '123' });
|
|
887
|
+
$.$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
888
|
+
$.$mol_assert_equal(dom.value, '123');
|
|
889
|
+
},
|
|
890
|
+
'Define classes'() {
|
|
891
|
+
const dom = $.$mol_jsx("div", { class: 'foo bar' });
|
|
892
|
+
$.$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
893
|
+
},
|
|
894
|
+
'Define styles'() {
|
|
895
|
+
const dom = $.$mol_jsx("div", { style: { color: 'red' } });
|
|
896
|
+
$.$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
897
|
+
},
|
|
898
|
+
'Define dataset'() {
|
|
899
|
+
const dom = $.$mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
900
|
+
$.$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
901
|
+
},
|
|
902
|
+
'Define attributes'() {
|
|
903
|
+
const dom = $.$mol_jsx("div", { lang: "ru", hidden: true });
|
|
904
|
+
$.$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
905
|
+
},
|
|
906
|
+
'Define child nodes'() {
|
|
907
|
+
const dom = $.$mol_jsx("div", null,
|
|
908
|
+
"hello",
|
|
909
|
+
$.$mol_jsx("strong", null, "world"),
|
|
910
|
+
"!");
|
|
911
|
+
$.$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
912
|
+
},
|
|
913
|
+
'Function as component'() {
|
|
914
|
+
const Button = ({ hint }, target) => {
|
|
915
|
+
return $.$mol_jsx("button", { title: hint }, target());
|
|
916
|
+
};
|
|
917
|
+
const dom = $.$mol_jsx(Button, { id: "/foo", hint: "click me" }, () => 'hey!');
|
|
918
|
+
$.$mol_assert_equal(dom.outerHTML, '<button title="click me" id="/foo">hey!</button>');
|
|
919
|
+
},
|
|
920
|
+
'Nested guid generation'() {
|
|
921
|
+
const Foo = () => {
|
|
922
|
+
return $.$mol_jsx("div", null,
|
|
923
|
+
$.$mol_jsx(Bar, { id: "/bar" },
|
|
924
|
+
$.$mol_jsx("img", { id: "/icon" })));
|
|
925
|
+
};
|
|
926
|
+
const Bar = (props, icon) => {
|
|
927
|
+
return $.$mol_jsx("span", null, icon);
|
|
928
|
+
};
|
|
929
|
+
const dom = $.$mol_jsx(Foo, { id: "/foo" });
|
|
930
|
+
$.$mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
|
|
931
|
+
},
|
|
932
|
+
'Fail on non unique ids'() {
|
|
933
|
+
const App = () => {
|
|
934
|
+
return $.$mol_jsx("div", null,
|
|
935
|
+
$.$mol_jsx("span", { id: "/bar" }),
|
|
936
|
+
$.$mol_jsx("span", { id: "/bar" }));
|
|
937
|
+
};
|
|
938
|
+
$.$mol_assert_fail(() => $.$mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
|
|
939
|
+
},
|
|
940
|
+
});
|
|
941
|
+
})($ || ($ = {}));
|
|
942
|
+
//jsx.test.js.map
|
|
943
|
+
;
|
|
944
|
+
"use strict";
|
|
945
|
+
var $;
|
|
946
|
+
(function ($) {
|
|
947
|
+
$.$mol_jsx_prefix = '';
|
|
948
|
+
$.$mol_jsx_booked = null;
|
|
949
|
+
$.$mol_jsx_document = {
|
|
950
|
+
getElementById: () => null,
|
|
951
|
+
createElementNS: (space, name) => $.$mol_dom_context.document.createElementNS(space, name),
|
|
952
|
+
createDocumentFragment: () => $.$mol_dom_context.document.createDocumentFragment(),
|
|
953
|
+
};
|
|
954
|
+
$.$mol_jsx_frag = '';
|
|
955
|
+
function $mol_jsx(Elem, props, ...childNodes) {
|
|
956
|
+
const id = props && props.id || '';
|
|
957
|
+
if (Elem && $.$mol_jsx_booked) {
|
|
958
|
+
if ($.$mol_jsx_booked.has(id)) {
|
|
959
|
+
$.$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
|
|
960
|
+
}
|
|
961
|
+
else {
|
|
962
|
+
$.$mol_jsx_booked.add(id);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
const guid = $.$mol_jsx_prefix + id;
|
|
966
|
+
let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
|
|
967
|
+
if (typeof Elem !== 'string') {
|
|
968
|
+
if ('prototype' in Elem) {
|
|
969
|
+
const view = node && node[Elem] || new Elem;
|
|
970
|
+
Object.assign(view, props);
|
|
971
|
+
view[Symbol.toStringTag] = guid;
|
|
972
|
+
view.childNodes = childNodes;
|
|
973
|
+
if (!view.ownerDocument)
|
|
974
|
+
view.ownerDocument = $.$mol_jsx_document;
|
|
975
|
+
node = view.valueOf();
|
|
976
|
+
node[Elem] = view;
|
|
977
|
+
return node;
|
|
978
|
+
}
|
|
979
|
+
else {
|
|
980
|
+
const prefix = $.$mol_jsx_prefix;
|
|
981
|
+
const booked = $.$mol_jsx_booked;
|
|
982
|
+
try {
|
|
983
|
+
$.$mol_jsx_prefix = guid;
|
|
984
|
+
$.$mol_jsx_booked = new Set;
|
|
985
|
+
return Elem(props, ...childNodes);
|
|
986
|
+
}
|
|
987
|
+
finally {
|
|
988
|
+
$.$mol_jsx_prefix = prefix;
|
|
989
|
+
$.$mol_jsx_booked = booked;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
if (!node) {
|
|
994
|
+
node = Elem
|
|
995
|
+
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
996
|
+
: $.$mol_jsx_document.createDocumentFragment();
|
|
997
|
+
}
|
|
998
|
+
$.$mol_dom_render_children(node, [].concat(...childNodes));
|
|
999
|
+
if (!Elem)
|
|
1000
|
+
return node;
|
|
1001
|
+
for (const key in props) {
|
|
1002
|
+
if (typeof props[key] === 'string') {
|
|
1003
|
+
;
|
|
1004
|
+
node.setAttribute(key, props[key]);
|
|
1005
|
+
}
|
|
1006
|
+
else if (props[key] &&
|
|
1007
|
+
typeof props[key] === 'object' &&
|
|
1008
|
+
Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
|
|
1009
|
+
if (typeof node[key] === 'object') {
|
|
1010
|
+
Object.assign(node[key], props[key]);
|
|
1011
|
+
continue;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
else {
|
|
1015
|
+
node[key] = props[key];
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
if (guid)
|
|
1019
|
+
node.id = guid;
|
|
1020
|
+
return node;
|
|
1021
|
+
}
|
|
1022
|
+
$.$mol_jsx = $mol_jsx;
|
|
1023
|
+
})($ || ($ = {}));
|
|
1024
|
+
//jsx.js.map
|
|
1025
|
+
;
|
|
1026
|
+
"use strict";
|
|
1027
|
+
var $;
|
|
1028
|
+
(function ($) {
|
|
1029
|
+
$.$mol_test({
|
|
1030
|
+
'nulls & undefineds'() {
|
|
1031
|
+
$.$mol_assert_ok($.$mol_compare_deep(null, null));
|
|
1032
|
+
$.$mol_assert_ok($.$mol_compare_deep(undefined, undefined));
|
|
1033
|
+
$.$mol_assert_not($.$mol_compare_deep(undefined, null));
|
|
1034
|
+
$.$mol_assert_not($.$mol_compare_deep({}, null));
|
|
1035
|
+
},
|
|
1036
|
+
'number'() {
|
|
1037
|
+
$.$mol_assert_ok($.$mol_compare_deep(1, 1));
|
|
1038
|
+
$.$mol_assert_ok($.$mol_compare_deep(Number.NaN, Number.NaN));
|
|
1039
|
+
$.$mol_assert_not($.$mol_compare_deep(1, 2));
|
|
1040
|
+
},
|
|
1041
|
+
'Number'() {
|
|
1042
|
+
$.$mol_assert_ok($.$mol_compare_deep(Object(1), Object(1)));
|
|
1043
|
+
$.$mol_assert_ok($.$mol_compare_deep(Object(Number.NaN), Object(Number.NaN)));
|
|
1044
|
+
$.$mol_assert_not($.$mol_compare_deep(Object(1), Object(2)));
|
|
1045
|
+
},
|
|
1046
|
+
'empty POJOs'() {
|
|
1047
|
+
$.$mol_assert_ok($.$mol_compare_deep({}, {}));
|
|
1048
|
+
},
|
|
1049
|
+
'different POJOs'() {
|
|
1050
|
+
$.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
1051
|
+
},
|
|
1052
|
+
'different POJOs with same keys but different values'() {
|
|
1053
|
+
$.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
1054
|
+
},
|
|
1055
|
+
'different POJOs with different keys but same values'() {
|
|
1056
|
+
$.$mol_assert_not($.$mol_compare_deep({}, { a: undefined }));
|
|
1057
|
+
},
|
|
1058
|
+
'Array'() {
|
|
1059
|
+
$.$mol_assert_ok($.$mol_compare_deep([], []));
|
|
1060
|
+
$.$mol_assert_ok($.$mol_compare_deep([1, [2]], [1, [2]]));
|
|
1061
|
+
$.$mol_assert_not($.$mol_compare_deep([1, 2], [1, 3]));
|
|
1062
|
+
$.$mol_assert_not($.$mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
1063
|
+
},
|
|
1064
|
+
'same POJO trees'() {
|
|
1065
|
+
$.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
1066
|
+
},
|
|
1067
|
+
'different classes with same values'() {
|
|
1068
|
+
class Obj {
|
|
1069
|
+
foo = 1;
|
|
1070
|
+
}
|
|
1071
|
+
const a = new Obj;
|
|
1072
|
+
const b = new class extends Obj {
|
|
1073
|
+
};
|
|
1074
|
+
$.$mol_assert_not($.$mol_compare_deep(a, b));
|
|
1075
|
+
},
|
|
1076
|
+
'same POJOs with cyclic reference'() {
|
|
1077
|
+
const a = { foo: {} };
|
|
1078
|
+
a['self'] = a;
|
|
1079
|
+
const b = { foo: {} };
|
|
1080
|
+
b['self'] = b;
|
|
1081
|
+
$.$mol_assert_ok($.$mol_compare_deep(a, b));
|
|
1082
|
+
},
|
|
1083
|
+
'empty Element'() {
|
|
1084
|
+
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("div", null)));
|
|
1085
|
+
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("span", null)));
|
|
1086
|
+
},
|
|
1087
|
+
'Element with attributes'() {
|
|
1088
|
+
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "rtl" })));
|
|
1089
|
+
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", null)));
|
|
1090
|
+
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "ltr" })));
|
|
1091
|
+
},
|
|
1092
|
+
'Element with styles'() {
|
|
1093
|
+
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'red' } })));
|
|
1094
|
+
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: {} })));
|
|
1095
|
+
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'blue' } })));
|
|
1096
|
+
},
|
|
1097
|
+
'Element with content'() {
|
|
1098
|
+
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
1099
|
+
"foo",
|
|
1100
|
+
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
1101
|
+
"foo",
|
|
1102
|
+
$.$mol_jsx("br", null))));
|
|
1103
|
+
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
1104
|
+
"foo",
|
|
1105
|
+
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
1106
|
+
"bar",
|
|
1107
|
+
$.$mol_jsx("br", null))));
|
|
1108
|
+
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
1109
|
+
"foo",
|
|
1110
|
+
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
1111
|
+
"foo",
|
|
1112
|
+
$.$mol_jsx("hr", null))));
|
|
1113
|
+
},
|
|
1114
|
+
'Element with handlers'() {
|
|
1115
|
+
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 1 })));
|
|
1116
|
+
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 2 })));
|
|
1117
|
+
},
|
|
1118
|
+
'Date'() {
|
|
1119
|
+
$.$mol_assert_ok($.$mol_compare_deep(new Date(12345), new Date(12345)));
|
|
1120
|
+
$.$mol_assert_not($.$mol_compare_deep(new Date(12345), new Date(12346)));
|
|
1121
|
+
},
|
|
1122
|
+
'RegExp'() {
|
|
1123
|
+
$.$mol_assert_ok($.$mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
1124
|
+
$.$mol_assert_not($.$mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
1125
|
+
$.$mol_assert_not($.$mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
1126
|
+
},
|
|
1127
|
+
'Map'() {
|
|
1128
|
+
$.$mol_assert_ok($.$mol_compare_deep(new Map, new Map));
|
|
1129
|
+
$.$mol_assert_ok($.$mol_compare_deep(new Map([[[1], [2]]]), new Map([[[1], [2]]])));
|
|
1130
|
+
$.$mol_assert_not($.$mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
1131
|
+
},
|
|
1132
|
+
'Set'() {
|
|
1133
|
+
$.$mol_assert_ok($.$mol_compare_deep(new Set, new Set));
|
|
1134
|
+
$.$mol_assert_ok($.$mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
1135
|
+
$.$mol_assert_not($.$mol_compare_deep(new Set([1]), new Set([2])));
|
|
1136
|
+
},
|
|
1137
|
+
'Uint8Array'() {
|
|
1138
|
+
$.$mol_assert_ok($.$mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
1139
|
+
$.$mol_assert_ok($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
1140
|
+
$.$mol_assert_not($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
1141
|
+
},
|
|
1142
|
+
});
|
|
1143
|
+
})($ || ($ = {}));
|
|
1144
|
+
//deep.test.js.map
|
|
1145
|
+
;
|
|
1146
|
+
"use strict";
|
|
1147
|
+
var $;
|
|
1148
|
+
(function ($) {
|
|
1149
|
+
const a_stack = [];
|
|
1150
|
+
const b_stack = [];
|
|
1151
|
+
let cache = null;
|
|
1152
|
+
function $mol_compare_deep(a, b) {
|
|
1153
|
+
if (Object.is(a, b))
|
|
1154
|
+
return true;
|
|
1155
|
+
const a_type = typeof a;
|
|
1156
|
+
const b_type = typeof b;
|
|
1157
|
+
if (a_type !== b_type)
|
|
1158
|
+
return false;
|
|
1159
|
+
if (a_type === 'function')
|
|
1160
|
+
return a['toString']() === b['toString']();
|
|
1161
|
+
if (a_type !== 'object')
|
|
1162
|
+
return false;
|
|
1163
|
+
if (!a || !b)
|
|
1164
|
+
return false;
|
|
1165
|
+
if (a instanceof Error)
|
|
1166
|
+
return false;
|
|
1167
|
+
if (a['constructor'] !== b['constructor'])
|
|
1168
|
+
return false;
|
|
1169
|
+
if (a instanceof RegExp)
|
|
1170
|
+
return a.toString() === b['toString']();
|
|
1171
|
+
const ref = a_stack.indexOf(a);
|
|
1172
|
+
if (ref >= 0) {
|
|
1173
|
+
return Object.is(b_stack[ref], b);
|
|
1174
|
+
}
|
|
1175
|
+
if (!cache)
|
|
1176
|
+
cache = new WeakMap;
|
|
1177
|
+
let a_cache = cache.get(a);
|
|
1178
|
+
if (a_cache) {
|
|
1179
|
+
const b_cache = a_cache.get(b);
|
|
1180
|
+
if (typeof b_cache === 'boolean')
|
|
1181
|
+
return b_cache;
|
|
1182
|
+
}
|
|
1183
|
+
else {
|
|
1184
|
+
a_cache = new WeakMap();
|
|
1185
|
+
cache.set(a, a_cache);
|
|
1186
|
+
}
|
|
1187
|
+
a_stack.push(a);
|
|
1188
|
+
b_stack.push(b);
|
|
1189
|
+
let result;
|
|
1190
|
+
try {
|
|
1191
|
+
if (Symbol.iterator in a) {
|
|
1192
|
+
const a_iter = a[Symbol.iterator]();
|
|
1193
|
+
const b_iter = b[Symbol.iterator]();
|
|
1194
|
+
while (true) {
|
|
1195
|
+
const a_next = a_iter.next();
|
|
1196
|
+
const b_next = b_iter.next();
|
|
1197
|
+
if (a_next.done !== b_next.done)
|
|
1198
|
+
return result = false;
|
|
1199
|
+
if (a_next.done)
|
|
1200
|
+
break;
|
|
1201
|
+
if (!$mol_compare_deep(a_next.value, b_next.value))
|
|
1202
|
+
return result = false;
|
|
1203
|
+
}
|
|
1204
|
+
return result = true;
|
|
1205
|
+
}
|
|
1206
|
+
let count = 0;
|
|
1207
|
+
for (let key in a) {
|
|
1208
|
+
try {
|
|
1209
|
+
if (!$mol_compare_deep(a[key], b[key]))
|
|
1210
|
+
return result = false;
|
|
1211
|
+
}
|
|
1212
|
+
catch (error) {
|
|
1213
|
+
$.$mol_fail_hidden(new $.$mol_error_mix(`Failed ${JSON.stringify(key)} fields comparison of ${a} and ${b}`, error));
|
|
1214
|
+
}
|
|
1215
|
+
++count;
|
|
1216
|
+
}
|
|
1217
|
+
for (let key in b) {
|
|
1218
|
+
--count;
|
|
1219
|
+
if (count < 0)
|
|
1220
|
+
return result = false;
|
|
1221
|
+
}
|
|
1222
|
+
if (a instanceof Number || a instanceof String || a instanceof Symbol || a instanceof Boolean || a instanceof Date) {
|
|
1223
|
+
if (!Object.is(a['valueOf'](), b['valueOf']()))
|
|
1224
|
+
return result = false;
|
|
1225
|
+
}
|
|
1226
|
+
return result = true;
|
|
1227
|
+
}
|
|
1228
|
+
finally {
|
|
1229
|
+
a_stack.pop();
|
|
1230
|
+
b_stack.pop();
|
|
1231
|
+
if (a_stack.length === 0) {
|
|
1232
|
+
cache = null;
|
|
1233
|
+
}
|
|
1234
|
+
else {
|
|
1235
|
+
a_cache.set(b, result);
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
$.$mol_compare_deep = $mol_compare_deep;
|
|
1240
|
+
})($ || ($ = {}));
|
|
1241
|
+
//deep.js.map
|
|
1242
|
+
;
|
|
1243
|
+
"use strict";
|
|
1244
|
+
var $;
|
|
1245
|
+
(function ($) {
|
|
1246
|
+
$.$mol_test({
|
|
1247
|
+
'must be false'() {
|
|
1248
|
+
$.$mol_assert_not(0);
|
|
1249
|
+
},
|
|
1250
|
+
'must be true'() {
|
|
1251
|
+
$.$mol_assert_ok(1);
|
|
1252
|
+
},
|
|
1253
|
+
'two must be equal'() {
|
|
1254
|
+
$.$mol_assert_equal(2, 2);
|
|
1255
|
+
},
|
|
1256
|
+
'three must be equal'() {
|
|
1257
|
+
$.$mol_assert_equal(2, 2, 2);
|
|
1258
|
+
},
|
|
1259
|
+
'two must be unique'() {
|
|
1260
|
+
$.$mol_assert_unique([3], [3]);
|
|
1261
|
+
},
|
|
1262
|
+
'three must be unique'() {
|
|
1263
|
+
$.$mol_assert_unique([3], [3], [3]);
|
|
1264
|
+
},
|
|
1265
|
+
'two must be alike'() {
|
|
1266
|
+
$.$mol_assert_like([3], [3]);
|
|
1267
|
+
},
|
|
1268
|
+
'three must be alike'() {
|
|
1269
|
+
$.$mol_assert_like([3], [3], [3]);
|
|
1270
|
+
},
|
|
1271
|
+
});
|
|
1272
|
+
})($ || ($ = {}));
|
|
1273
|
+
//assert.test.js.map
|
|
1274
|
+
;
|
|
1275
|
+
"use strict";
|
|
1276
|
+
var $;
|
|
1277
|
+
(function ($) {
|
|
1278
|
+
function $mol_assert_ok(value) {
|
|
1279
|
+
if (value)
|
|
1280
|
+
return;
|
|
1281
|
+
$.$mol_fail(new Error(`${value} ≠ true`));
|
|
1282
|
+
}
|
|
1283
|
+
$.$mol_assert_ok = $mol_assert_ok;
|
|
1284
|
+
function $mol_assert_not(value) {
|
|
1285
|
+
if (!value)
|
|
1286
|
+
return;
|
|
1287
|
+
$.$mol_fail(new Error(`${value} ≠ false`));
|
|
1288
|
+
}
|
|
1289
|
+
$.$mol_assert_not = $mol_assert_not;
|
|
1290
|
+
function $mol_assert_fail(handler, ErrorRight) {
|
|
1291
|
+
const fail = $.$mol_fail;
|
|
1292
|
+
try {
|
|
1293
|
+
$.$mol_fail = $.$mol_fail_hidden;
|
|
1294
|
+
handler();
|
|
1295
|
+
}
|
|
1296
|
+
catch (error) {
|
|
1297
|
+
if (!ErrorRight)
|
|
1298
|
+
return error;
|
|
1299
|
+
$.$mol_fail = fail;
|
|
1300
|
+
if (typeof ErrorRight === 'string') {
|
|
1301
|
+
$mol_assert_equal(error.message, ErrorRight);
|
|
1302
|
+
}
|
|
1303
|
+
else {
|
|
1304
|
+
$mol_assert_ok(error instanceof ErrorRight);
|
|
1305
|
+
}
|
|
1306
|
+
return error;
|
|
1307
|
+
}
|
|
1308
|
+
finally {
|
|
1309
|
+
$.$mol_fail = fail;
|
|
1310
|
+
}
|
|
1311
|
+
$.$mol_fail(new Error('Not failed'));
|
|
1312
|
+
}
|
|
1313
|
+
$.$mol_assert_fail = $mol_assert_fail;
|
|
1314
|
+
function $mol_assert_equal(...args) {
|
|
1315
|
+
for (let i = 0; i < args.length; ++i) {
|
|
1316
|
+
for (let j = 0; j < args.length; ++j) {
|
|
1317
|
+
if (i === j)
|
|
1318
|
+
continue;
|
|
1319
|
+
if (Number.isNaN(args[i]) && Number.isNaN(args[j]))
|
|
1320
|
+
continue;
|
|
1321
|
+
if (args[i] !== args[j])
|
|
1322
|
+
$.$mol_fail(new Error(`Not equal (${i + 1}:${j + 1})\n${args[i]}\n${args[j]}`));
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
$.$mol_assert_equal = $mol_assert_equal;
|
|
1327
|
+
function $mol_assert_unique(...args) {
|
|
1328
|
+
for (let i = 0; i < args.length; ++i) {
|
|
1329
|
+
for (let j = 0; j < args.length; ++j) {
|
|
1330
|
+
if (i === j)
|
|
1331
|
+
continue;
|
|
1332
|
+
if (args[i] === args[j] || (Number.isNaN(args[i]) && Number.isNaN(args[j]))) {
|
|
1333
|
+
$.$mol_fail(new Error(`args[${i}] = args[${j}] = ${args[i]}`));
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
$.$mol_assert_unique = $mol_assert_unique;
|
|
1339
|
+
function $mol_assert_like(head, ...tail) {
|
|
1340
|
+
for (let [index, value] of Object.entries(tail)) {
|
|
1341
|
+
if (!$.$mol_compare_deep(value, head)) {
|
|
1342
|
+
const print = (val) => {
|
|
1343
|
+
if (!val)
|
|
1344
|
+
return val;
|
|
1345
|
+
if (typeof val !== 'object')
|
|
1346
|
+
return val;
|
|
1347
|
+
if ('outerHTML' in val)
|
|
1348
|
+
return val.outerHTML;
|
|
1349
|
+
try {
|
|
1350
|
+
return JSON.stringify(val);
|
|
1351
|
+
}
|
|
1352
|
+
catch (error) {
|
|
1353
|
+
console.error(error);
|
|
1354
|
+
return val;
|
|
1355
|
+
}
|
|
1356
|
+
};
|
|
1357
|
+
return $.$mol_fail(new Error(`Not like (1:${+index + 2})\n${print(head)}\n---\n${print(value)}`));
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
$.$mol_assert_like = $mol_assert_like;
|
|
1362
|
+
})($ || ($ = {}));
|
|
1363
|
+
//assert.js.map
|
|
1364
|
+
;
|
|
1365
|
+
"use strict";
|
|
1366
|
+
var $;
|
|
1367
|
+
(function ($) {
|
|
1368
|
+
$.$mol_test({
|
|
1369
|
+
'parse and serial'() {
|
|
1370
|
+
$.$mol_assert_equal(new $.$mol_time_duration('P42.1Y').toString(), 'P42.1YT');
|
|
1371
|
+
$.$mol_assert_equal(new $.$mol_time_duration('P42.1M').toString(), 'P42.1MT');
|
|
1372
|
+
$.$mol_assert_equal(new $.$mol_time_duration('P42.1D').toString(), 'P42.1DT');
|
|
1373
|
+
$.$mol_assert_equal(new $.$mol_time_duration('PT42.1h').toString(), 'PT42.1H');
|
|
1374
|
+
$.$mol_assert_equal(new $.$mol_time_duration('PT42.1m').toString(), 'PT42.1M');
|
|
1375
|
+
$.$mol_assert_equal(new $.$mol_time_duration('PT42.1s').toString(), 'PT42.1S');
|
|
1376
|
+
$.$mol_assert_equal(new $.$mol_time_duration('P1Y2M3DT4h5m6.7s').toString(), 'P1Y2M3DT4H5M6.7S');
|
|
1377
|
+
},
|
|
1378
|
+
'format typed'() {
|
|
1379
|
+
$.$mol_assert_equal(new $.$mol_time_duration('P1Y2M3DT4h5m6s').toString('P#Y#M#DT#h#m#s'), 'P1Y2M3DT4H5M6S');
|
|
1380
|
+
},
|
|
1381
|
+
});
|
|
1382
|
+
})($ || ($ = {}));
|
|
1383
|
+
//duration.test.js.map
|
|
1384
|
+
;
|
|
1385
|
+
"use strict";
|
|
1386
|
+
var $;
|
|
1387
|
+
(function ($) {
|
|
1388
|
+
$.$mol_test({
|
|
1389
|
+
'parse and serial'() {
|
|
1390
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014').toString(), '2014');
|
|
1391
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014-01').toString(), '2014-01');
|
|
1392
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02').toString(), '2014-01-02');
|
|
1393
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T03').toString(), '2014-01-02T03');
|
|
1394
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T03:04').toString(), '2014-01-02T03:04');
|
|
1395
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T03:04:05').toString(), '2014-01-02T03:04:05');
|
|
1396
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T03:04:05.006').toString(), '2014-01-02T03:04:05.006');
|
|
1397
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T03:04:05.006Z').toString(), '2014-01-02T03:04:05.006+00:00');
|
|
1398
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T03:04:05.006+07:00').toString(), '2014-01-02T03:04:05.006+07:00');
|
|
1399
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T03:04:05+07:08').toString(), '2014-01-02T03:04:05+07:08');
|
|
1400
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T03:04+07:08').toString(), '2014-01-02T03:04+07:08');
|
|
1401
|
+
$.$mol_assert_equal(new $.$mol_time_moment('T03:04+07:08').toString(), 'T03:04+07:08');
|
|
1402
|
+
$.$mol_assert_equal(new $.$mol_time_moment('T03:04:05').toString(), 'T03:04:05');
|
|
1403
|
+
$.$mol_assert_equal(new $.$mol_time_moment('T03:04').toString(), 'T03:04');
|
|
1404
|
+
$.$mol_assert_equal(new $.$mol_time_moment('T03').toString(), 'T03');
|
|
1405
|
+
},
|
|
1406
|
+
'format simple'() {
|
|
1407
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T01:02:03.000000').toString('AD YY-M-D h:m:s'), '21 14-1-2 1:2:3');
|
|
1408
|
+
},
|
|
1409
|
+
'format padded'() {
|
|
1410
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T01:02:03.000').toString('YYYY-MM-DD hh:mm:ss'), '2014-01-02 01:02:03');
|
|
1411
|
+
},
|
|
1412
|
+
'format time zone'() {
|
|
1413
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02T01:02:03+05:00').toString('Z'), '+05:00');
|
|
1414
|
+
},
|
|
1415
|
+
'format names'() {
|
|
1416
|
+
$.$mol_assert_ok(new $.$mol_time_moment('2014-01-02T01:02:03.000').toString('Month Mon | WeekDay WD'));
|
|
1417
|
+
},
|
|
1418
|
+
'shifting'() {
|
|
1419
|
+
$.$mol_assert_equal(new $.$mol_time_moment('T15:54:58.243+03:00').shift({}).toString(), 'T15:54:58.243+03:00');
|
|
1420
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02').shift('P1Y').toString(), '2015-01-02');
|
|
1421
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02').shift('P12M').toString(), '2015-01-02');
|
|
1422
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02').shift('P365D').toString(), '2015-01-02');
|
|
1423
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014-01-02').shift('PT8760h').toString(), '2015-01-02');
|
|
1424
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014-01').shift('PT8760h').toString(), '2015-01');
|
|
1425
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2014-01').shift('PT-8760h').toString(), '2013-01');
|
|
1426
|
+
},
|
|
1427
|
+
'normalization'() {
|
|
1428
|
+
$.$mol_assert_equal(new $.$mol_time_moment({ year: 2015, month: 6, day: 34 }).normal.toString(), '2015-08-04');
|
|
1429
|
+
},
|
|
1430
|
+
'iso week day'() {
|
|
1431
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2017-09-17').weekday, $.$mol_time_moment_weekdays.sunday);
|
|
1432
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2017-09-18').weekday, $.$mol_time_moment_weekdays.monday);
|
|
1433
|
+
},
|
|
1434
|
+
'change offset'() {
|
|
1435
|
+
$.$mol_assert_equal(new $.$mol_time_moment('2021-04-10 +03:00').toOffset('Z').toString(), '2021-04-09T21:00:00+00:00');
|
|
1436
|
+
}
|
|
1437
|
+
});
|
|
1438
|
+
})($ || ($ = {}));
|
|
1439
|
+
//moment.test.js.map
|
|
1440
|
+
;
|
|
1441
|
+
"use strict";
|
|
1442
|
+
var $;
|
|
1443
|
+
(function ($) {
|
|
1444
|
+
$.$mol_test({
|
|
1445
|
+
'triplets'() {
|
|
1446
|
+
$.$mol_assert_equal(new $.$mol_time_interval('2015-01-01/P1M').end.toString(), '2015-02-01');
|
|
1447
|
+
$.$mol_assert_equal(new $.$mol_time_interval('P1M/2015-02-01').start.toString(), '2015-01-01');
|
|
1448
|
+
$.$mol_assert_equal(new $.$mol_time_interval('2015-01-01/2015-02-01').duration.toString(), 'PT2678400S');
|
|
1449
|
+
}
|
|
1450
|
+
});
|
|
1451
|
+
})($ || ($ = {}));
|
|
1452
|
+
//interval.test.js.map
|
|
1453
|
+
;
|
|
1454
|
+
"use strict";
|
|
1455
|
+
var $;
|
|
1456
|
+
(function ($) {
|
|
1457
|
+
function $mol_log3_area_lazy(event) {
|
|
1458
|
+
const self = this;
|
|
1459
|
+
const stack = self.$mol_log3_stack;
|
|
1460
|
+
const deep = stack.length;
|
|
1461
|
+
let logged = false;
|
|
1462
|
+
stack.push(() => {
|
|
1463
|
+
logged = true;
|
|
1464
|
+
self.$mol_log3_area.call(self, event);
|
|
1465
|
+
});
|
|
1466
|
+
return () => {
|
|
1467
|
+
if (logged)
|
|
1468
|
+
self.console.groupEnd();
|
|
1469
|
+
if (stack.length > deep)
|
|
1470
|
+
stack.length = deep;
|
|
1471
|
+
};
|
|
1472
|
+
}
|
|
1473
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
1474
|
+
$.$mol_log3_stack = [];
|
|
1475
|
+
})($ || ($ = {}));
|
|
1476
|
+
//log3.js.map
|
|
1477
|
+
;
|
|
1478
|
+
"use strict";
|
|
1479
|
+
var $;
|
|
1480
|
+
(function ($) {
|
|
1481
|
+
function $mol_log3_node_make(level, output, type, color) {
|
|
1482
|
+
return function $mol_log3_logger(event) {
|
|
1483
|
+
if (!event.time)
|
|
1484
|
+
event = { time: new Date().toISOString(), ...event };
|
|
1485
|
+
const tree = this.$mol_tree.fromJSON(event).clone({ type });
|
|
1486
|
+
let str = tree.toString();
|
|
1487
|
+
if (process[output].isTTY) {
|
|
1488
|
+
str = $node.colorette[color + 'Bright'](str);
|
|
1489
|
+
}
|
|
1490
|
+
;
|
|
1491
|
+
this.console[level](str);
|
|
1492
|
+
const self = this;
|
|
1493
|
+
return () => self.console.groupEnd();
|
|
1494
|
+
};
|
|
1495
|
+
}
|
|
1496
|
+
$.$mol_log3_node_make = $mol_log3_node_make;
|
|
1497
|
+
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', 'blue');
|
|
1498
|
+
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', 'green');
|
|
1499
|
+
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', 'red');
|
|
1500
|
+
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', 'yellow');
|
|
1501
|
+
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', 'magenta');
|
|
1502
|
+
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', 'cyan');
|
|
1503
|
+
})($ || ($ = {}));
|
|
1504
|
+
//log3.node.js.map
|
|
1505
|
+
;
|
|
1506
|
+
"use strict";
|
|
1507
|
+
var $;
|
|
1508
|
+
(function ($_1) {
|
|
1509
|
+
$_1.$mol_test_mocks.push($ => {
|
|
1510
|
+
$.$mol_log3_come = () => { };
|
|
1511
|
+
$.$mol_log3_done = () => { };
|
|
1512
|
+
$.$mol_log3_fail = () => { };
|
|
1513
|
+
$.$mol_log3_warn = () => { };
|
|
1514
|
+
$.$mol_log3_rise = () => { };
|
|
1515
|
+
$.$mol_log3_area = () => () => { };
|
|
1516
|
+
});
|
|
1517
|
+
})($ || ($ = {}));
|
|
1518
|
+
//log3.test.js.map
|
|
1519
|
+
;
|
|
1520
|
+
"use strict";
|
|
1521
|
+
var $;
|
|
1522
|
+
(function ($) {
|
|
1523
|
+
function $mol_env() {
|
|
1524
|
+
return {};
|
|
1525
|
+
}
|
|
1526
|
+
$.$mol_env = $mol_env;
|
|
1527
|
+
})($ || ($ = {}));
|
|
1528
|
+
//env.js.map
|
|
1529
|
+
;
|
|
1530
|
+
"use strict";
|
|
1531
|
+
var $;
|
|
1532
|
+
(function ($) {
|
|
1533
|
+
$.$mol_env = function $mol_env() {
|
|
1534
|
+
return this.process.env;
|
|
1535
|
+
};
|
|
1536
|
+
})($ || ($ = {}));
|
|
1537
|
+
//env.node.js.map
|
|
1538
|
+
;
|
|
1539
|
+
"use strict";
|
|
1540
|
+
var $;
|
|
1541
|
+
(function ($) {
|
|
1542
|
+
function $mol_exec(dir, command, ...args) {
|
|
1543
|
+
let [app, ...args0] = command.split(' ');
|
|
1544
|
+
args = [...args0, ...args];
|
|
1545
|
+
this.$mol_log3_come({
|
|
1546
|
+
place: '$mol_exec',
|
|
1547
|
+
dir: $node.path.relative('', dir),
|
|
1548
|
+
message: 'Run',
|
|
1549
|
+
command: `${app} ${args.join(' ')}`,
|
|
1550
|
+
});
|
|
1551
|
+
var res = $node['child_process'].spawnSync(app, args, {
|
|
1552
|
+
cwd: $node.path.resolve(dir),
|
|
1553
|
+
shell: true,
|
|
1554
|
+
env: this.$mol_env(),
|
|
1555
|
+
});
|
|
1556
|
+
if (res.status || res.error)
|
|
1557
|
+
return $.$mol_fail(res.error || new Error(res.stderr.toString()));
|
|
1558
|
+
if (!res.stdout)
|
|
1559
|
+
res.stdout = Buffer.from([]);
|
|
1560
|
+
return res;
|
|
1561
|
+
}
|
|
1562
|
+
$.$mol_exec = $mol_exec;
|
|
1563
|
+
})($ || ($ = {}));
|
|
1564
|
+
//exec.node.js.map
|
|
1565
|
+
;
|
|
1566
|
+
"use strict";
|
|
1567
|
+
var $;
|
|
1568
|
+
(function ($) {
|
|
1569
|
+
$.$mol_ambient_ref = Symbol('$mol_ambient_ref');
|
|
1570
|
+
function $mol_ambient(overrides) {
|
|
1571
|
+
return Object.setPrototypeOf(overrides, this || $);
|
|
1572
|
+
}
|
|
1573
|
+
$.$mol_ambient = $mol_ambient;
|
|
1574
|
+
})($ || ($ = {}));
|
|
1575
|
+
//ambient.js.map
|
|
1576
|
+
;
|
|
1577
|
+
"use strict";
|
|
1578
|
+
var $;
|
|
1579
|
+
(function ($) {
|
|
1580
|
+
$.$mol_test({
|
|
1581
|
+
'get'() {
|
|
1582
|
+
const proxy = $.$mol_delegate({}, () => ({ foo: 777 }));
|
|
1583
|
+
$.$mol_assert_equal(proxy.foo, 777);
|
|
1584
|
+
},
|
|
1585
|
+
'has'() {
|
|
1586
|
+
const proxy = $.$mol_delegate({}, () => ({ foo: 777 }));
|
|
1587
|
+
$.$mol_assert_equal('foo' in proxy, true);
|
|
1588
|
+
},
|
|
1589
|
+
'set'() {
|
|
1590
|
+
const target = { foo: 777 };
|
|
1591
|
+
const proxy = $.$mol_delegate({}, () => target);
|
|
1592
|
+
proxy.foo = 123;
|
|
1593
|
+
$.$mol_assert_equal(target.foo, 123);
|
|
1594
|
+
},
|
|
1595
|
+
'getOwnPropertyDescriptor'() {
|
|
1596
|
+
const proxy = $.$mol_delegate({}, () => ({ foo: 777 }));
|
|
1597
|
+
$.$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1598
|
+
value: 777,
|
|
1599
|
+
writable: true,
|
|
1600
|
+
enumerable: true,
|
|
1601
|
+
configurable: true,
|
|
1602
|
+
});
|
|
1603
|
+
},
|
|
1604
|
+
'ownKeys'() {
|
|
1605
|
+
const proxy = $.$mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
1606
|
+
$.$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1607
|
+
},
|
|
1608
|
+
'getPrototypeOf'() {
|
|
1609
|
+
class Foo {
|
|
1610
|
+
}
|
|
1611
|
+
const proxy = $.$mol_delegate({}, () => new Foo);
|
|
1612
|
+
$.$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1613
|
+
},
|
|
1614
|
+
'setPrototypeOf'() {
|
|
1615
|
+
class Foo {
|
|
1616
|
+
}
|
|
1617
|
+
const target = {};
|
|
1618
|
+
const proxy = $.$mol_delegate({}, () => target);
|
|
1619
|
+
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
1620
|
+
$.$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
1621
|
+
},
|
|
1622
|
+
'instanceof'() {
|
|
1623
|
+
class Foo {
|
|
1624
|
+
}
|
|
1625
|
+
const proxy = $.$mol_delegate({}, () => new Foo);
|
|
1626
|
+
$.$mol_assert_ok(proxy instanceof Foo);
|
|
1627
|
+
$.$mol_assert_ok(proxy instanceof $.$mol_delegate);
|
|
1628
|
+
},
|
|
1629
|
+
'autobind'() {
|
|
1630
|
+
class Foo {
|
|
1631
|
+
}
|
|
1632
|
+
const proxy = $.$mol_delegate({}, () => new Foo);
|
|
1633
|
+
$.$mol_assert_ok(proxy instanceof Foo);
|
|
1634
|
+
$.$mol_assert_ok(proxy instanceof $.$mol_delegate);
|
|
1635
|
+
},
|
|
1636
|
+
});
|
|
1637
|
+
})($ || ($ = {}));
|
|
1638
|
+
//delegate.test.js.map
|
|
1639
|
+
;
|
|
1640
|
+
"use strict";
|
|
1641
|
+
var $;
|
|
1642
|
+
(function ($) {
|
|
1643
|
+
const instances = new WeakSet();
|
|
1644
|
+
function $mol_delegate(proto, target) {
|
|
1645
|
+
const proxy = new Proxy(proto, {
|
|
1646
|
+
get: (_, field) => {
|
|
1647
|
+
const obj = target();
|
|
1648
|
+
let val = Reflect.get(obj, field);
|
|
1649
|
+
if (typeof val === 'function') {
|
|
1650
|
+
val = val.bind(obj);
|
|
1651
|
+
}
|
|
1652
|
+
return val;
|
|
1653
|
+
},
|
|
1654
|
+
has: (_, field) => Reflect.has(target(), field),
|
|
1655
|
+
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
1656
|
+
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
1657
|
+
ownKeys: () => Reflect.ownKeys(target()),
|
|
1658
|
+
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
1659
|
+
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
1660
|
+
isExtensible: () => Reflect.isExtensible(target()),
|
|
1661
|
+
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
1662
|
+
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
1663
|
+
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
1664
|
+
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
1665
|
+
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
1666
|
+
});
|
|
1667
|
+
instances.add(proxy);
|
|
1668
|
+
return proxy;
|
|
1669
|
+
}
|
|
1670
|
+
$.$mol_delegate = $mol_delegate;
|
|
1671
|
+
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
1672
|
+
value: (obj) => instances.has(obj),
|
|
1673
|
+
});
|
|
1674
|
+
})($ || ($ = {}));
|
|
1675
|
+
//delegate.js.map
|
|
1676
|
+
;
|
|
1677
|
+
"use strict";
|
|
1678
|
+
var $;
|
|
1679
|
+
(function ($) {
|
|
1680
|
+
$.$mol_owning_map = new WeakMap();
|
|
1681
|
+
function $mol_owning_allow(having) {
|
|
1682
|
+
try {
|
|
1683
|
+
if (!having)
|
|
1684
|
+
return false;
|
|
1685
|
+
if (typeof having !== 'object')
|
|
1686
|
+
return false;
|
|
1687
|
+
if (having instanceof $.$mol_delegate)
|
|
1688
|
+
return false;
|
|
1689
|
+
if (typeof having['destructor'] !== 'function')
|
|
1690
|
+
return false;
|
|
1691
|
+
return true;
|
|
1692
|
+
}
|
|
1693
|
+
catch {
|
|
1694
|
+
return false;
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
$.$mol_owning_allow = $mol_owning_allow;
|
|
1698
|
+
function $mol_owning_get(having, Owner) {
|
|
1699
|
+
if (!$mol_owning_allow(having))
|
|
1700
|
+
return null;
|
|
1701
|
+
while (true) {
|
|
1702
|
+
const owner = $.$mol_owning_map.get(having);
|
|
1703
|
+
if (!owner)
|
|
1704
|
+
return owner;
|
|
1705
|
+
if (!Owner)
|
|
1706
|
+
return owner;
|
|
1707
|
+
if (owner instanceof Owner)
|
|
1708
|
+
return owner;
|
|
1709
|
+
having = owner;
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
$.$mol_owning_get = $mol_owning_get;
|
|
1713
|
+
function $mol_owning_check(owner, having) {
|
|
1714
|
+
if (!$mol_owning_allow(having))
|
|
1715
|
+
return false;
|
|
1716
|
+
if ($.$mol_owning_map.get(having) !== owner)
|
|
1717
|
+
return false;
|
|
1718
|
+
return true;
|
|
1719
|
+
}
|
|
1720
|
+
$.$mol_owning_check = $mol_owning_check;
|
|
1721
|
+
function $mol_owning_catch(owner, having) {
|
|
1722
|
+
if (!$mol_owning_allow(having))
|
|
1723
|
+
return false;
|
|
1724
|
+
if ($.$mol_owning_map.get(having))
|
|
1725
|
+
return false;
|
|
1726
|
+
$.$mol_owning_map.set(having, owner);
|
|
1727
|
+
return true;
|
|
1728
|
+
}
|
|
1729
|
+
$.$mol_owning_catch = $mol_owning_catch;
|
|
1730
|
+
})($ || ($ = {}));
|
|
1731
|
+
//owning.js.map
|
|
1732
|
+
;
|
|
1733
|
+
"use strict";
|
|
1734
|
+
//writable.test.js.map
|
|
1735
|
+
;
|
|
1736
|
+
"use strict";
|
|
1737
|
+
//writable.js.map
|
|
1738
|
+
;
|
|
1739
|
+
"use strict";
|
|
1740
|
+
var $;
|
|
1741
|
+
(function ($) {
|
|
1742
|
+
class $mol_object2 {
|
|
1743
|
+
static $ = $;
|
|
1744
|
+
[$.$mol_ambient_ref] = null;
|
|
1745
|
+
get $() {
|
|
1746
|
+
if (this[$.$mol_ambient_ref])
|
|
1747
|
+
return this[$.$mol_ambient_ref];
|
|
1748
|
+
const owner = $.$mol_owning_get(this);
|
|
1749
|
+
return this[$.$mol_ambient_ref] = owner?.$ || $mol_object2.$;
|
|
1750
|
+
}
|
|
1751
|
+
set $(next) {
|
|
1752
|
+
if (this[$.$mol_ambient_ref])
|
|
1753
|
+
$.$mol_fail_hidden(new Error('Context already defined'));
|
|
1754
|
+
this[$.$mol_ambient_ref] = next;
|
|
1755
|
+
}
|
|
1756
|
+
static create(init) {
|
|
1757
|
+
const obj = new this;
|
|
1758
|
+
if (init)
|
|
1759
|
+
init(obj);
|
|
1760
|
+
return obj;
|
|
1761
|
+
}
|
|
1762
|
+
static [Symbol.toPrimitive]() {
|
|
1763
|
+
return this.toString();
|
|
1764
|
+
}
|
|
1765
|
+
static toString() {
|
|
1766
|
+
if (Symbol.toStringTag in this)
|
|
1767
|
+
return this[Symbol.toStringTag];
|
|
1768
|
+
return this.name;
|
|
1769
|
+
}
|
|
1770
|
+
destructor() { }
|
|
1771
|
+
[Symbol.toPrimitive](hint) {
|
|
1772
|
+
return hint === 'number' ? this.valueOf() : this.toString();
|
|
1773
|
+
}
|
|
1774
|
+
toString() {
|
|
1775
|
+
return this[Symbol.toStringTag] || this.constructor.name + '()';
|
|
1776
|
+
}
|
|
1777
|
+
toJSON() {
|
|
1778
|
+
return this.toString();
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
$.$mol_object2 = $mol_object2;
|
|
1782
|
+
})($ || ($ = {}));
|
|
1783
|
+
//object2.js.map
|
|
1784
|
+
;
|
|
1785
|
+
"use strict";
|
|
1786
|
+
var $;
|
|
1787
|
+
(function ($) {
|
|
1788
|
+
function $mol_deprecated(message) {
|
|
1789
|
+
return (host, field, descr) => {
|
|
1790
|
+
const value = descr.value;
|
|
1791
|
+
let warned = false;
|
|
1792
|
+
descr.value = function $mol_deprecated_wrapper(...args) {
|
|
1793
|
+
if (!warned) {
|
|
1794
|
+
$.$$.$mol_log3_warn({
|
|
1795
|
+
place: `${host.constructor.name}::${field}`,
|
|
1796
|
+
message: `Deprecated`,
|
|
1797
|
+
hint: message,
|
|
1798
|
+
});
|
|
1799
|
+
warned = true;
|
|
1800
|
+
}
|
|
1801
|
+
return value.call(this, ...args);
|
|
1802
|
+
};
|
|
1803
|
+
};
|
|
1804
|
+
}
|
|
1805
|
+
$.$mol_deprecated = $mol_deprecated;
|
|
1806
|
+
})($ || ($ = {}));
|
|
1807
|
+
//deprecated.js.map
|
|
1808
|
+
;
|
|
1809
|
+
"use strict";
|
|
1810
|
+
var $;
|
|
1811
|
+
(function ($_1) {
|
|
1812
|
+
$_1.$mol_test({
|
|
1813
|
+
'tree parsing'() {
|
|
1814
|
+
$_1.$mol_assert_equal($_1.$mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
1815
|
+
$_1.$mol_assert_equal($_1.$mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
1816
|
+
$_1.$mol_assert_equal($_1.$mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
1817
|
+
$_1.$mol_assert_equal($_1.$mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
1818
|
+
$_1.$mol_assert_equal($_1.$mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
1819
|
+
$_1.$mol_assert_equal($_1.$mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
1820
|
+
$_1.$mol_assert_equal($_1.$mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
1821
|
+
$_1.$mol_assert_equal($_1.$mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
1822
|
+
},
|
|
1823
|
+
'inserting'() {
|
|
1824
|
+
$_1.$mol_assert_equal($_1.$mol_tree.fromString('a b c d').insert(new $_1.$mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
1825
|
+
$_1.$mol_assert_equal($_1.$mol_tree.fromString('a b').insert(new $_1.$mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
1826
|
+
$_1.$mol_assert_equal($_1.$mol_tree.fromString('a b c d').insert(new $_1.$mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
1827
|
+
$_1.$mol_assert_equal($_1.$mol_tree.fromString('a b').insert(new $_1.$mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
1828
|
+
$_1.$mol_assert_equal($_1.$mol_tree.fromString('a b c d').insert(new $_1.$mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
1829
|
+
$_1.$mol_assert_equal($_1.$mol_tree.fromString('a b').insert(new $_1.$mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
1830
|
+
},
|
|
1831
|
+
'fromJSON'() {
|
|
1832
|
+
$_1.$mol_assert_equal($_1.$mol_tree.fromJSON([]).toString(), '/\n');
|
|
1833
|
+
$_1.$mol_assert_equal($_1.$mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
1834
|
+
$_1.$mol_assert_equal($_1.$mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
1835
|
+
$_1.$mol_assert_equal($_1.$mol_tree.fromJSON(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
|
|
1836
|
+
$_1.$mol_assert_equal($_1.$mol_tree.fromJSON({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
|
|
1837
|
+
},
|
|
1838
|
+
'toJSON'() {
|
|
1839
|
+
$_1.$mol_assert_equal(JSON.stringify($_1.$mol_tree.fromString('/\n').sub[0]), '[]');
|
|
1840
|
+
$_1.$mol_assert_equal(JSON.stringify($_1.$mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
1841
|
+
$_1.$mol_assert_equal(JSON.stringify($_1.$mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
1842
|
+
$_1.$mol_assert_equal(JSON.stringify($_1.$mol_tree.fromString('/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n').sub[0]), '["","foo","bar\\nbaz"]');
|
|
1843
|
+
$_1.$mol_assert_equal(JSON.stringify($_1.$mol_tree.fromString('*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n').sub[0]), '{"foo":false,"bar\\nbaz":"lol"}');
|
|
1844
|
+
},
|
|
1845
|
+
'hack'() {
|
|
1846
|
+
const res = $_1.$mol_tree.fromString(`foo bar xxx`).hack({
|
|
1847
|
+
'': (tree, context) => [tree.hack(context)],
|
|
1848
|
+
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
1849
|
+
});
|
|
1850
|
+
$_1.$mol_assert_equal(res.toString(), new $_1.$mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
1851
|
+
},
|
|
1852
|
+
'errors handling'($) {
|
|
1853
|
+
const errors = [];
|
|
1854
|
+
class Tree extends $_1.$mol_tree {
|
|
1855
|
+
static $ = $.$mol_ambient({
|
|
1856
|
+
$mol_fail: error => errors.push(error.message)
|
|
1857
|
+
});
|
|
1858
|
+
}
|
|
1859
|
+
Tree.fromString(`
|
|
1860
|
+
\t \tfoo
|
|
1861
|
+
bar \\data
|
|
1862
|
+
`, 'test');
|
|
1863
|
+
$_1.$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
1864
|
+
},
|
|
1865
|
+
});
|
|
1866
|
+
})($ || ($ = {}));
|
|
1867
|
+
//tree.test.js.map
|
|
1868
|
+
;
|
|
1869
|
+
"use strict";
|
|
1870
|
+
var $;
|
|
1871
|
+
(function ($) {
|
|
1872
|
+
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
1873
|
+
class $mol_tree extends $.$mol_object2 {
|
|
1874
|
+
type;
|
|
1875
|
+
data;
|
|
1876
|
+
sub;
|
|
1877
|
+
baseUri;
|
|
1878
|
+
row;
|
|
1879
|
+
col;
|
|
1880
|
+
length;
|
|
1881
|
+
constructor(config = {}) {
|
|
1882
|
+
super();
|
|
1883
|
+
this.type = config.type || '';
|
|
1884
|
+
if (config.value !== undefined) {
|
|
1885
|
+
var sub = $mol_tree.values(config.value);
|
|
1886
|
+
if (config.type || sub.length > 1) {
|
|
1887
|
+
this.sub = [...sub, ...(config.sub || [])];
|
|
1888
|
+
this.data = config.data || '';
|
|
1889
|
+
}
|
|
1890
|
+
else {
|
|
1891
|
+
this.data = sub[0].data;
|
|
1892
|
+
this.sub = config.sub || [];
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
else {
|
|
1896
|
+
this.data = config.data || '';
|
|
1897
|
+
this.sub = config.sub || [];
|
|
1898
|
+
}
|
|
1899
|
+
this.baseUri = config.baseUri || '';
|
|
1900
|
+
this.row = config.row || 0;
|
|
1901
|
+
this.col = config.col || 0;
|
|
1902
|
+
this.length = config.length || 0;
|
|
1903
|
+
}
|
|
1904
|
+
static values(str, baseUri) {
|
|
1905
|
+
return str.split('\n').map((data, index) => new $mol_tree({
|
|
1906
|
+
data: data,
|
|
1907
|
+
baseUri: baseUri,
|
|
1908
|
+
row: index + 1,
|
|
1909
|
+
length: data.length,
|
|
1910
|
+
}));
|
|
1911
|
+
}
|
|
1912
|
+
clone(config = {}) {
|
|
1913
|
+
return new $mol_tree({
|
|
1914
|
+
type: ('type' in config) ? config.type : this.type,
|
|
1915
|
+
data: ('data' in config) ? config.data : this.data,
|
|
1916
|
+
sub: ('sub' in config) ? config.sub : this.sub,
|
|
1917
|
+
baseUri: ('baseUri' in config) ? config.baseUri : this.baseUri,
|
|
1918
|
+
row: ('row' in config) ? config.row : this.row,
|
|
1919
|
+
col: ('col' in config) ? config.col : this.col,
|
|
1920
|
+
length: ('length' in config) ? config.length : this.length,
|
|
1921
|
+
value: config.value
|
|
1922
|
+
});
|
|
1923
|
+
}
|
|
1924
|
+
make(config) {
|
|
1925
|
+
return new $mol_tree({
|
|
1926
|
+
baseUri: this.baseUri,
|
|
1927
|
+
row: this.row,
|
|
1928
|
+
col: this.col,
|
|
1929
|
+
length: this.length,
|
|
1930
|
+
...config,
|
|
1931
|
+
});
|
|
1932
|
+
}
|
|
1933
|
+
make_data(value, sub) {
|
|
1934
|
+
return this.make({ value, sub });
|
|
1935
|
+
}
|
|
1936
|
+
make_struct(type, sub) {
|
|
1937
|
+
return this.make({ type, sub });
|
|
1938
|
+
}
|
|
1939
|
+
static fromString(str, baseUri) {
|
|
1940
|
+
var root = new $mol_tree({ baseUri: baseUri });
|
|
1941
|
+
var stack = [root];
|
|
1942
|
+
var row = 0;
|
|
1943
|
+
var prefix = str.replace(/^\n?(\t*)[\s\S]*/, '$1');
|
|
1944
|
+
var lines = str.replace(new RegExp('^\\t{0,' + prefix.length + '}', 'mg'), '').split('\n');
|
|
1945
|
+
lines.forEach(line => {
|
|
1946
|
+
++row;
|
|
1947
|
+
var chunks = /^(\t*)((?:[^\n\t\\ ]+ *)*)(\\[^\n]*)?(.*?)(?:$|\n)/m.exec(line);
|
|
1948
|
+
if (!chunks || chunks[4])
|
|
1949
|
+
return this.$.$mol_fail(new Error(`Syntax error at ${baseUri}:${row}\n${line}`));
|
|
1950
|
+
var indent = chunks[1];
|
|
1951
|
+
var path = chunks[2];
|
|
1952
|
+
var data = chunks[3];
|
|
1953
|
+
var deep = indent.length;
|
|
1954
|
+
var types = path ? path.replace(/ $/, '').split(/ +/) : [];
|
|
1955
|
+
if (stack.length <= deep)
|
|
1956
|
+
return this.$.$mol_fail(new Error(`Too many tabs at ${baseUri}:${row}\n${line}`));
|
|
1957
|
+
stack.length = deep + 1;
|
|
1958
|
+
var parent = stack[deep];
|
|
1959
|
+
let col = deep;
|
|
1960
|
+
types.forEach(type => {
|
|
1961
|
+
if (!type)
|
|
1962
|
+
return this.$.$mol_fail(new Error(`Unexpected space symbol ${baseUri}:${row}\n${line}`));
|
|
1963
|
+
var next = new $mol_tree({ type, baseUri, row, col, length: type.length });
|
|
1964
|
+
const parent_sub = parent.sub;
|
|
1965
|
+
parent_sub.push(next);
|
|
1966
|
+
parent = next;
|
|
1967
|
+
col += type.length + 1;
|
|
1968
|
+
});
|
|
1969
|
+
if (data) {
|
|
1970
|
+
var next = new $mol_tree({ data: data.substring(1), baseUri, row, col, length: data.length });
|
|
1971
|
+
const parent_sub = parent.sub;
|
|
1972
|
+
parent_sub.push(next);
|
|
1973
|
+
parent = next;
|
|
1974
|
+
}
|
|
1975
|
+
stack.push(parent);
|
|
1976
|
+
});
|
|
1977
|
+
return root;
|
|
1978
|
+
}
|
|
1979
|
+
static fromJSON(json, baseUri = '') {
|
|
1980
|
+
switch (true) {
|
|
1981
|
+
case typeof json === 'boolean':
|
|
1982
|
+
case typeof json === 'number':
|
|
1983
|
+
case json === null:
|
|
1984
|
+
return new $mol_tree({
|
|
1985
|
+
type: String(json),
|
|
1986
|
+
baseUri: baseUri
|
|
1987
|
+
});
|
|
1988
|
+
case typeof json === 'string':
|
|
1989
|
+
return new $mol_tree({
|
|
1990
|
+
value: json,
|
|
1991
|
+
baseUri: baseUri
|
|
1992
|
+
});
|
|
1993
|
+
case Array.isArray(json):
|
|
1994
|
+
return new $mol_tree({
|
|
1995
|
+
type: "/",
|
|
1996
|
+
sub: json.map(json => $mol_tree.fromJSON(json, baseUri))
|
|
1997
|
+
});
|
|
1998
|
+
case json instanceof Date:
|
|
1999
|
+
return new $mol_tree({
|
|
2000
|
+
value: json.toISOString(),
|
|
2001
|
+
baseUri: baseUri
|
|
2002
|
+
});
|
|
2003
|
+
default:
|
|
2004
|
+
if (typeof json[$.$mol_tree_convert] === 'function') {
|
|
2005
|
+
return json[$.$mol_tree_convert]();
|
|
2006
|
+
}
|
|
2007
|
+
if (typeof json.toJSON === 'function') {
|
|
2008
|
+
return $mol_tree.fromJSON(json.toJSON());
|
|
2009
|
+
}
|
|
2010
|
+
if (json instanceof Error) {
|
|
2011
|
+
const { name, message, stack } = json;
|
|
2012
|
+
json = { ...json, name, message, stack };
|
|
2013
|
+
}
|
|
2014
|
+
var sub = [];
|
|
2015
|
+
for (var key in json) {
|
|
2016
|
+
if (json[key] === undefined)
|
|
2017
|
+
continue;
|
|
2018
|
+
const subsub = $mol_tree.fromJSON(json[key], baseUri);
|
|
2019
|
+
if (/^[^\n\t\\ ]+$/.test(key)) {
|
|
2020
|
+
var child = new $mol_tree({
|
|
2021
|
+
type: key,
|
|
2022
|
+
baseUri: baseUri,
|
|
2023
|
+
sub: [subsub],
|
|
2024
|
+
});
|
|
2025
|
+
}
|
|
2026
|
+
else {
|
|
2027
|
+
var child = new $mol_tree({
|
|
2028
|
+
value: key,
|
|
2029
|
+
baseUri: baseUri,
|
|
2030
|
+
sub: [subsub],
|
|
2031
|
+
});
|
|
2032
|
+
}
|
|
2033
|
+
sub.push(child);
|
|
2034
|
+
}
|
|
2035
|
+
return new $mol_tree({
|
|
2036
|
+
type: "*",
|
|
2037
|
+
sub: sub,
|
|
2038
|
+
baseUri: baseUri
|
|
2039
|
+
});
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
get uri() {
|
|
2043
|
+
return this.baseUri + '#' + this.row + ':' + this.col;
|
|
2044
|
+
}
|
|
2045
|
+
toString(prefix = '') {
|
|
2046
|
+
var output = '';
|
|
2047
|
+
if (this.type.length) {
|
|
2048
|
+
if (!prefix.length) {
|
|
2049
|
+
prefix = "\t";
|
|
2050
|
+
}
|
|
2051
|
+
output += this.type;
|
|
2052
|
+
if (this.sub.length == 1) {
|
|
2053
|
+
return output + ' ' + this.sub[0].toString(prefix);
|
|
2054
|
+
}
|
|
2055
|
+
output += "\n";
|
|
2056
|
+
}
|
|
2057
|
+
else if (this.data.length || prefix.length) {
|
|
2058
|
+
output += "\\" + this.data + "\n";
|
|
2059
|
+
}
|
|
2060
|
+
for (var child of this.sub) {
|
|
2061
|
+
output += prefix;
|
|
2062
|
+
output += child.toString(prefix + "\t");
|
|
2063
|
+
}
|
|
2064
|
+
return output;
|
|
2065
|
+
}
|
|
2066
|
+
toJSON() {
|
|
2067
|
+
if (!this.type)
|
|
2068
|
+
return this.value;
|
|
2069
|
+
if (this.type === 'true')
|
|
2070
|
+
return true;
|
|
2071
|
+
if (this.type === 'false')
|
|
2072
|
+
return false;
|
|
2073
|
+
if (this.type === 'null')
|
|
2074
|
+
return null;
|
|
2075
|
+
if (this.type === '*') {
|
|
2076
|
+
var obj = {};
|
|
2077
|
+
for (var child of this.sub) {
|
|
2078
|
+
if (child.type === '-')
|
|
2079
|
+
continue;
|
|
2080
|
+
var key = child.type || child.clone({ sub: child.sub.slice(0, child.sub.length - 1) }).value;
|
|
2081
|
+
var val = child.sub[child.sub.length - 1].toJSON();
|
|
2082
|
+
if (val !== undefined)
|
|
2083
|
+
obj[key] = val;
|
|
2084
|
+
}
|
|
2085
|
+
return obj;
|
|
2086
|
+
}
|
|
2087
|
+
if (this.type === '/') {
|
|
2088
|
+
var res = [];
|
|
2089
|
+
this.sub.forEach(child => {
|
|
2090
|
+
if (child.type === '-')
|
|
2091
|
+
return;
|
|
2092
|
+
var val = child.toJSON();
|
|
2093
|
+
if (val !== undefined)
|
|
2094
|
+
res.push(val);
|
|
2095
|
+
});
|
|
2096
|
+
return res;
|
|
2097
|
+
}
|
|
2098
|
+
if (this.type === 'time') {
|
|
2099
|
+
return new Date(this.value);
|
|
2100
|
+
}
|
|
2101
|
+
const numb = Number(this.type);
|
|
2102
|
+
if (!Number.isNaN(numb) || this.type === 'NaN')
|
|
2103
|
+
return numb;
|
|
2104
|
+
throw new Error(`Unknown type (${this.type}) at ${this.uri}`);
|
|
2105
|
+
}
|
|
2106
|
+
get value() {
|
|
2107
|
+
var values = [];
|
|
2108
|
+
for (var child of this.sub) {
|
|
2109
|
+
if (child.type)
|
|
2110
|
+
continue;
|
|
2111
|
+
values.push(child.value);
|
|
2112
|
+
}
|
|
2113
|
+
return this.data + values.join("\n");
|
|
2114
|
+
}
|
|
2115
|
+
insert(value, ...path) {
|
|
2116
|
+
if (path.length === 0)
|
|
2117
|
+
return value;
|
|
2118
|
+
const type = path[0];
|
|
2119
|
+
if (typeof type === 'string') {
|
|
2120
|
+
let replaced = false;
|
|
2121
|
+
const sub = this.sub.map((item, index) => {
|
|
2122
|
+
if (item.type !== type)
|
|
2123
|
+
return item;
|
|
2124
|
+
replaced = true;
|
|
2125
|
+
return item.insert(value, ...path.slice(1));
|
|
2126
|
+
});
|
|
2127
|
+
if (!replaced)
|
|
2128
|
+
sub.push(new $mol_tree({ type }).insert(value, ...path.slice(1)));
|
|
2129
|
+
return this.clone({ sub });
|
|
2130
|
+
}
|
|
2131
|
+
else if (typeof type === 'number') {
|
|
2132
|
+
const sub = this.sub.slice();
|
|
2133
|
+
sub[type] = (sub[type] || new $mol_tree).insert(value, ...path.slice(1));
|
|
2134
|
+
return this.clone({ sub });
|
|
2135
|
+
}
|
|
2136
|
+
else {
|
|
2137
|
+
return this.clone({ sub: ((this.sub.length === 0) ? [new $mol_tree()] : this.sub).map(item => item.insert(value, ...path.slice(1))) });
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
select(...path) {
|
|
2141
|
+
var next = [this];
|
|
2142
|
+
for (var type of path) {
|
|
2143
|
+
if (!next.length)
|
|
2144
|
+
break;
|
|
2145
|
+
var prev = next;
|
|
2146
|
+
next = [];
|
|
2147
|
+
for (var item of prev) {
|
|
2148
|
+
switch (typeof (type)) {
|
|
2149
|
+
case 'string':
|
|
2150
|
+
for (var child of item.sub) {
|
|
2151
|
+
if (!type || (child.type == type)) {
|
|
2152
|
+
next.push(child);
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
break;
|
|
2156
|
+
case 'number':
|
|
2157
|
+
if (type < item.sub.length)
|
|
2158
|
+
next.push(item.sub[type]);
|
|
2159
|
+
break;
|
|
2160
|
+
default: next.push(...item.sub);
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
return new $mol_tree({ sub: next });
|
|
2165
|
+
}
|
|
2166
|
+
filter(path, value) {
|
|
2167
|
+
var sub = this.sub.filter(function (item) {
|
|
2168
|
+
var found = item.select(...path);
|
|
2169
|
+
if (value == null) {
|
|
2170
|
+
return Boolean(found.sub.length);
|
|
2171
|
+
}
|
|
2172
|
+
else {
|
|
2173
|
+
return found.sub.some(child => child.value == value);
|
|
2174
|
+
}
|
|
2175
|
+
});
|
|
2176
|
+
return new $mol_tree({ sub: sub });
|
|
2177
|
+
}
|
|
2178
|
+
transform(visit, stack = []) {
|
|
2179
|
+
const sub_stack = [this, ...stack];
|
|
2180
|
+
return visit(sub_stack, () => this.sub.map(node => node.transform(visit, sub_stack)).filter(n => n));
|
|
2181
|
+
}
|
|
2182
|
+
hack(context) {
|
|
2183
|
+
const sub = [].concat(...this.sub.map(child => {
|
|
2184
|
+
const handle = context[child.type] || context[''];
|
|
2185
|
+
if (!handle)
|
|
2186
|
+
$.$mol_fail(child.error('Handler not defined'));
|
|
2187
|
+
return handle(child, context);
|
|
2188
|
+
}));
|
|
2189
|
+
return this.clone({ sub });
|
|
2190
|
+
}
|
|
2191
|
+
error(message) {
|
|
2192
|
+
return new Error(`${message}:\n${this} ${this.baseUri}:${this.row}:${this.col}`);
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
__decorate([
|
|
2196
|
+
$.$mol_deprecated('Use $mol_tree:hack')
|
|
2197
|
+
], $mol_tree.prototype, "transform", null);
|
|
2198
|
+
$.$mol_tree = $mol_tree;
|
|
2199
|
+
})($ || ($ = {}));
|
|
2200
|
+
//tree.js.map
|
|
2201
|
+
;
|
|
2202
|
+
"use strict";
|
|
2203
|
+
//equals.test.js.map
|
|
2204
|
+
;
|
|
2205
|
+
"use strict";
|
|
2206
|
+
//equals.js.map
|
|
2207
|
+
;
|
|
2208
|
+
"use strict";
|
|
2209
|
+
var $;
|
|
2210
|
+
(function ($) {
|
|
2211
|
+
$.$mol_test({
|
|
2212
|
+
'equal paths'() {
|
|
2213
|
+
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]);
|
|
2214
|
+
$.$mol_assert_like(diff, {
|
|
2215
|
+
prefix: [1, 2, 3, 4],
|
|
2216
|
+
suffix: [[], [], []],
|
|
2217
|
+
});
|
|
2218
|
+
},
|
|
2219
|
+
'different suffix'() {
|
|
2220
|
+
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 5, 4]);
|
|
2221
|
+
$.$mol_assert_like(diff, {
|
|
2222
|
+
prefix: [1, 2],
|
|
2223
|
+
suffix: [[3, 4], [3, 5], [5, 4]],
|
|
2224
|
+
});
|
|
2225
|
+
},
|
|
2226
|
+
'one contains other'() {
|
|
2227
|
+
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2], [1, 2, 3]);
|
|
2228
|
+
$.$mol_assert_like(diff, {
|
|
2229
|
+
prefix: [1, 2],
|
|
2230
|
+
suffix: [[3, 4], [], [3]],
|
|
2231
|
+
});
|
|
2232
|
+
},
|
|
2233
|
+
'fully different'() {
|
|
2234
|
+
const diff = $.$mol_diff_path([1, 2], [3, 4], [5, 6]);
|
|
2235
|
+
$.$mol_assert_like(diff, {
|
|
2236
|
+
prefix: [],
|
|
2237
|
+
suffix: [[1, 2], [3, 4], [5, 6]],
|
|
2238
|
+
});
|
|
2239
|
+
},
|
|
2240
|
+
});
|
|
2241
|
+
})($ || ($ = {}));
|
|
2242
|
+
//path.test.js.map
|
|
2243
|
+
;
|
|
2244
|
+
"use strict";
|
|
2245
|
+
var $;
|
|
2246
|
+
(function ($) {
|
|
2247
|
+
function $mol_diff_path(...paths) {
|
|
2248
|
+
const limit = Math.min(...paths.map(path => path.length));
|
|
2249
|
+
lookup: for (var i = 0; i < limit; ++i) {
|
|
2250
|
+
const first = paths[0][i];
|
|
2251
|
+
for (let j = 1; j < paths.length; ++j) {
|
|
2252
|
+
if (paths[j][i] !== first)
|
|
2253
|
+
break lookup;
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
return {
|
|
2257
|
+
prefix: paths[0].slice(0, i),
|
|
2258
|
+
suffix: paths.map(path => path.slice(i)),
|
|
2259
|
+
};
|
|
2260
|
+
}
|
|
2261
|
+
$.$mol_diff_path = $mol_diff_path;
|
|
2262
|
+
})($ || ($ = {}));
|
|
2263
|
+
//path.js.map
|
|
2264
|
+
;
|
|
2265
|
+
"use strict";
|
|
2266
|
+
var $;
|
|
2267
|
+
(function ($) {
|
|
2268
|
+
class $mol_error_mix extends Error {
|
|
2269
|
+
errors;
|
|
2270
|
+
constructor(message, ...errors) {
|
|
2271
|
+
super(message);
|
|
2272
|
+
this.errors = errors;
|
|
2273
|
+
if (errors.length) {
|
|
2274
|
+
const stacks = [...errors.map(error => error.stack), this.stack];
|
|
2275
|
+
const diff = $.$mol_diff_path(...stacks.map(stack => {
|
|
2276
|
+
if (!stack)
|
|
2277
|
+
return [];
|
|
2278
|
+
return stack.split('\n').reverse();
|
|
2279
|
+
}));
|
|
2280
|
+
const head = diff.prefix.reverse().join('\n');
|
|
2281
|
+
const tails = diff.suffix.map(path => path.reverse().map(line => line.replace(/^(?!\s+at)/, '\tat (.) ')).join('\n')).join('\n\tat (.) -----\n');
|
|
2282
|
+
this.stack = `Error: ${this.constructor.name}\n\tat (.) /"""\\\n${tails}\n\tat (.) \\___/\n${head}`;
|
|
2283
|
+
this.message += errors.map(error => '\n' + error.message).join('');
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
toJSON() {
|
|
2287
|
+
return this.message;
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
$.$mol_error_mix = $mol_error_mix;
|
|
2291
|
+
})($ || ($ = {}));
|
|
2292
|
+
//mix.js.map
|
|
2293
|
+
|
|
2294
|
+
//# sourceMappingURL=node.test.js.map
|