mol_db 0.0.1007 → 0.0.1009
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node.d.ts +31 -201
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +91 -916
- package/node.js.map +1 -1
- package/node.mjs +91 -916
- package/node.test.js +314 -1360
- package/node.test.js.map +1 -1
- package/package.json +2 -17
package/node.test.js
CHANGED
|
@@ -42,341 +42,131 @@ var $;
|
|
|
42
42
|
"use strict";
|
|
43
43
|
var $;
|
|
44
44
|
(function ($) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
50
|
-
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
51
|
-
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
45
|
+
function $mol_promise_like(val) {
|
|
46
|
+
return val && typeof val === 'object' && 'then' in val && typeof val.then === 'function';
|
|
47
|
+
}
|
|
48
|
+
$.$mol_promise_like = $mol_promise_like;
|
|
52
49
|
})($ || ($ = {}));
|
|
53
50
|
|
|
54
51
|
;
|
|
55
52
|
"use strict";
|
|
56
53
|
var $;
|
|
57
54
|
(function ($) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
static get [Symbol.species]() {
|
|
61
|
-
return Array;
|
|
62
|
-
}
|
|
63
|
-
sub_from = 0;
|
|
64
|
-
get sub_list() {
|
|
65
|
-
const res = [];
|
|
66
|
-
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
67
|
-
res.push(this.data[i]);
|
|
68
|
-
}
|
|
69
|
-
return res;
|
|
70
|
-
}
|
|
71
|
-
get sub_empty() {
|
|
72
|
-
return this.sub_from === this.data.length;
|
|
73
|
-
}
|
|
74
|
-
sub_on(sub, pub_pos) {
|
|
75
|
-
const pos = this.data.length;
|
|
76
|
-
this.data.push(sub, pub_pos);
|
|
77
|
-
return pos;
|
|
78
|
-
}
|
|
79
|
-
sub_off(sub_pos) {
|
|
80
|
-
if (!(sub_pos < this.data.length)) {
|
|
81
|
-
$mol_fail(new Error(`Wrong pos ${sub_pos}`));
|
|
82
|
-
}
|
|
83
|
-
const end = this.data.length - 2;
|
|
84
|
-
if (sub_pos !== end) {
|
|
85
|
-
this.peer_move(end, sub_pos);
|
|
86
|
-
}
|
|
87
|
-
this.data.pop();
|
|
88
|
-
this.data.pop();
|
|
89
|
-
if (this.data.length === this.sub_from)
|
|
90
|
-
this.reap();
|
|
91
|
-
}
|
|
92
|
-
reap() { }
|
|
93
|
-
promote() {
|
|
94
|
-
$mol_wire_auto()?.track_next(this);
|
|
95
|
-
}
|
|
96
|
-
fresh() { }
|
|
97
|
-
complete() { }
|
|
98
|
-
get incompleted() {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
emit(quant = $mol_wire_cursor.stale) {
|
|
102
|
-
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
103
|
-
;
|
|
104
|
-
this.data[i].absorb(quant);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
peer_move(from_pos, to_pos) {
|
|
108
|
-
const peer = this.data[from_pos];
|
|
109
|
-
const self_pos = this.data[from_pos + 1];
|
|
110
|
-
this.data[to_pos] = peer;
|
|
111
|
-
this.data[to_pos + 1] = self_pos;
|
|
112
|
-
peer.peer_repos(self_pos, to_pos);
|
|
113
|
-
}
|
|
114
|
-
peer_repos(peer_pos, self_pos) {
|
|
115
|
-
this.data[peer_pos + 1] = self_pos;
|
|
116
|
-
}
|
|
55
|
+
function $mol_fail_hidden(error) {
|
|
56
|
+
throw error;
|
|
117
57
|
}
|
|
118
|
-
$.$
|
|
58
|
+
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
119
59
|
})($ || ($ = {}));
|
|
120
60
|
|
|
121
|
-
;
|
|
122
|
-
"use strict";
|
|
123
|
-
|
|
124
61
|
;
|
|
125
62
|
"use strict";
|
|
126
63
|
var $;
|
|
127
64
|
(function ($) {
|
|
128
|
-
|
|
129
|
-
function $
|
|
130
|
-
|
|
65
|
+
const catched = new WeakMap();
|
|
66
|
+
function $mol_fail_catch(error) {
|
|
67
|
+
if (typeof error !== 'object')
|
|
68
|
+
return false;
|
|
69
|
+
if ($mol_promise_like(error))
|
|
70
|
+
$mol_fail_hidden(error);
|
|
71
|
+
if (catched.get(error))
|
|
72
|
+
return false;
|
|
73
|
+
catched.set(error, true);
|
|
74
|
+
return true;
|
|
131
75
|
}
|
|
132
|
-
$.$
|
|
133
|
-
$.$mol_wire_affected = [];
|
|
76
|
+
$.$mol_fail_catch = $mol_fail_catch;
|
|
134
77
|
})($ || ($ = {}));
|
|
135
78
|
|
|
136
79
|
;
|
|
137
80
|
"use strict";
|
|
138
81
|
var $;
|
|
139
82
|
(function ($) {
|
|
140
|
-
$
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
$mol_dev_format_register({
|
|
148
|
-
header: (val, config = false) => {
|
|
149
|
-
if (config)
|
|
150
|
-
return null;
|
|
151
|
-
if (!val)
|
|
152
|
-
return null;
|
|
153
|
-
if ($.$mol_dev_format_head in val) {
|
|
154
|
-
try {
|
|
155
|
-
return val[$.$mol_dev_format_head]();
|
|
156
|
-
}
|
|
157
|
-
catch (error) {
|
|
158
|
-
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
if (typeof val === 'function') {
|
|
162
|
-
return $mol_dev_format_native(val);
|
|
163
|
-
}
|
|
164
|
-
if (Symbol.toStringTag in val) {
|
|
165
|
-
return $mol_dev_format_native(val);
|
|
166
|
-
}
|
|
167
|
-
return null;
|
|
168
|
-
},
|
|
169
|
-
hasBody: val => val[$.$mol_dev_format_body],
|
|
170
|
-
body: val => val[$.$mol_dev_format_body](),
|
|
171
|
-
});
|
|
172
|
-
function $mol_dev_format_native(obj) {
|
|
173
|
-
if (typeof obj === 'undefined')
|
|
174
|
-
return $.$mol_dev_format_shade('undefined');
|
|
175
|
-
return [
|
|
176
|
-
'object',
|
|
177
|
-
{
|
|
178
|
-
object: obj,
|
|
179
|
-
config: true,
|
|
180
|
-
},
|
|
181
|
-
];
|
|
182
|
-
}
|
|
183
|
-
$.$mol_dev_format_native = $mol_dev_format_native;
|
|
184
|
-
function $mol_dev_format_auto(obj) {
|
|
185
|
-
if (obj == null)
|
|
186
|
-
return $.$mol_dev_format_shade(String(obj));
|
|
187
|
-
return [
|
|
188
|
-
'object',
|
|
189
|
-
{
|
|
190
|
-
object: obj,
|
|
191
|
-
config: false,
|
|
192
|
-
},
|
|
193
|
-
];
|
|
194
|
-
}
|
|
195
|
-
$.$mol_dev_format_auto = $mol_dev_format_auto;
|
|
196
|
-
function $mol_dev_format_element(element, style, ...content) {
|
|
197
|
-
const styles = [];
|
|
198
|
-
for (let key in style)
|
|
199
|
-
styles.push(`${key} : ${style[key]}`);
|
|
200
|
-
return [
|
|
201
|
-
element,
|
|
202
|
-
{
|
|
203
|
-
style: styles.join(' ; '),
|
|
204
|
-
},
|
|
205
|
-
...content,
|
|
206
|
-
];
|
|
207
|
-
}
|
|
208
|
-
$.$mol_dev_format_element = $mol_dev_format_element;
|
|
209
|
-
function $mol_dev_format_span(style, ...content) {
|
|
210
|
-
return $mol_dev_format_element('span', {
|
|
211
|
-
...style,
|
|
212
|
-
}, ...content);
|
|
83
|
+
function $mol_fail_log(error) {
|
|
84
|
+
if ($mol_promise_like(error))
|
|
85
|
+
return false;
|
|
86
|
+
if (!$mol_fail_catch(error))
|
|
87
|
+
return false;
|
|
88
|
+
console.error(error);
|
|
89
|
+
return true;
|
|
213
90
|
}
|
|
214
|
-
$.$
|
|
215
|
-
$.$mol_dev_format_div = $mol_dev_format_element.bind(null, 'div');
|
|
216
|
-
$.$mol_dev_format_ol = $mol_dev_format_element.bind(null, 'ol');
|
|
217
|
-
$.$mol_dev_format_li = $mol_dev_format_element.bind(null, 'li');
|
|
218
|
-
$.$mol_dev_format_table = $mol_dev_format_element.bind(null, 'table');
|
|
219
|
-
$.$mol_dev_format_tr = $mol_dev_format_element.bind(null, 'tr');
|
|
220
|
-
$.$mol_dev_format_td = $mol_dev_format_element.bind(null, 'td');
|
|
221
|
-
$.$mol_dev_format_accent = $mol_dev_format_span.bind(null, {
|
|
222
|
-
'color': 'magenta',
|
|
223
|
-
});
|
|
224
|
-
$.$mol_dev_format_strong = $mol_dev_format_span.bind(null, {
|
|
225
|
-
'font-weight': 'bold',
|
|
226
|
-
});
|
|
227
|
-
$.$mol_dev_format_string = $mol_dev_format_span.bind(null, {
|
|
228
|
-
'color': 'green',
|
|
229
|
-
});
|
|
230
|
-
$.$mol_dev_format_shade = $mol_dev_format_span.bind(null, {
|
|
231
|
-
'color': 'gray',
|
|
232
|
-
});
|
|
233
|
-
$.$mol_dev_format_indent = $.$mol_dev_format_div.bind(null, {
|
|
234
|
-
'margin-left': '13px'
|
|
235
|
-
});
|
|
91
|
+
$.$mol_fail_log = $mol_fail_log;
|
|
236
92
|
})($ || ($ = {}));
|
|
237
93
|
|
|
238
94
|
;
|
|
239
95
|
"use strict";
|
|
240
|
-
var
|
|
241
|
-
(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
return
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
$mol_wire_auto(this);
|
|
261
|
-
return sub;
|
|
262
|
-
}
|
|
263
|
-
promote() {
|
|
264
|
-
if (this.cursor >= this.pub_from) {
|
|
265
|
-
$mol_fail(new Error('Circular subscription'));
|
|
266
|
-
}
|
|
267
|
-
super.promote();
|
|
268
|
-
}
|
|
269
|
-
track_next(pub) {
|
|
270
|
-
if (this.cursor < 0)
|
|
271
|
-
$mol_fail(new Error('Promo to non begun sub'));
|
|
272
|
-
if (this.cursor < this.sub_from) {
|
|
273
|
-
const next = this.data[this.cursor];
|
|
274
|
-
if (pub === undefined)
|
|
275
|
-
return next ?? null;
|
|
276
|
-
if (next === pub) {
|
|
277
|
-
this.cursor += 2;
|
|
278
|
-
return next;
|
|
279
|
-
}
|
|
280
|
-
if (next) {
|
|
281
|
-
if (this.sub_from < this.data.length) {
|
|
282
|
-
this.peer_move(this.sub_from, this.data.length);
|
|
283
|
-
}
|
|
284
|
-
this.peer_move(this.cursor, this.sub_from);
|
|
285
|
-
this.sub_from += 2;
|
|
96
|
+
var $node = new Proxy({ require }, {
|
|
97
|
+
get(target, name, wrapper) {
|
|
98
|
+
if (target[name])
|
|
99
|
+
return target[name];
|
|
100
|
+
const mod = target.require('module');
|
|
101
|
+
if (mod.builtinModules.indexOf(name) >= 0)
|
|
102
|
+
return target.require(name);
|
|
103
|
+
if (name[0] === '.')
|
|
104
|
+
return target.require(name);
|
|
105
|
+
const path = target.require('path');
|
|
106
|
+
const fs = target.require('fs');
|
|
107
|
+
let dir = path.resolve('.');
|
|
108
|
+
const suffix = `./node_modules/${name}`;
|
|
109
|
+
const $$ = $;
|
|
110
|
+
while (!fs.existsSync(path.join(dir, suffix))) {
|
|
111
|
+
const parent = path.resolve(dir, '..');
|
|
112
|
+
if (parent === dir) {
|
|
113
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
114
|
+
try {
|
|
115
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
286
116
|
}
|
|
117
|
+
catch { }
|
|
118
|
+
break;
|
|
287
119
|
}
|
|
288
120
|
else {
|
|
289
|
-
|
|
290
|
-
return null;
|
|
291
|
-
if (this.sub_from < this.data.length) {
|
|
292
|
-
this.peer_move(this.sub_from, this.data.length);
|
|
293
|
-
}
|
|
294
|
-
this.sub_from += 2;
|
|
295
|
-
}
|
|
296
|
-
this.data[this.cursor] = pub;
|
|
297
|
-
this.data[this.cursor + 1] = pub.sub_on(this, this.cursor);
|
|
298
|
-
this.cursor += 2;
|
|
299
|
-
return pub;
|
|
300
|
-
}
|
|
301
|
-
track_off(sub) {
|
|
302
|
-
$mol_wire_auto(sub);
|
|
303
|
-
if (this.cursor < 0) {
|
|
304
|
-
$mol_fail(new Error('End of non begun sub'));
|
|
305
|
-
}
|
|
306
|
-
for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
|
|
307
|
-
const pub = this.data[cursor];
|
|
308
|
-
pub.fresh();
|
|
121
|
+
dir = parent;
|
|
309
122
|
}
|
|
310
|
-
this.cursor = $mol_wire_cursor.fresh;
|
|
311
123
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
this.data[sub_pos + 1] = undefined;
|
|
315
|
-
}
|
|
316
|
-
destructor() {
|
|
317
|
-
for (let cursor = this.data.length - 2; cursor >= this.sub_from; cursor -= 2) {
|
|
318
|
-
const sub = this.data[cursor];
|
|
319
|
-
const pos = this.data[cursor + 1];
|
|
320
|
-
sub.pub_off(pos);
|
|
321
|
-
this.data.pop();
|
|
322
|
-
this.data.pop();
|
|
323
|
-
}
|
|
324
|
-
this.cursor = this.pub_from;
|
|
325
|
-
this.track_cut();
|
|
326
|
-
this.cursor = $mol_wire_cursor.final;
|
|
327
|
-
}
|
|
328
|
-
track_cut() {
|
|
329
|
-
if (this.cursor < this.pub_from) {
|
|
330
|
-
$mol_fail(new Error('Cut of non begun sub'));
|
|
331
|
-
}
|
|
332
|
-
let tail = 0;
|
|
333
|
-
for (let cursor = this.cursor; cursor < this.sub_from; cursor += 2) {
|
|
334
|
-
const pub = this.data[cursor];
|
|
335
|
-
pub?.sub_off(this.data[cursor + 1]);
|
|
336
|
-
if (this.sub_from < this.data.length) {
|
|
337
|
-
this.peer_move(this.data.length - 2, cursor);
|
|
338
|
-
this.data.pop();
|
|
339
|
-
this.data.pop();
|
|
340
|
-
}
|
|
341
|
-
else {
|
|
342
|
-
++tail;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
for (; tail; --tail) {
|
|
346
|
-
this.data.pop();
|
|
347
|
-
this.data.pop();
|
|
348
|
-
}
|
|
349
|
-
this.sub_from = this.cursor;
|
|
124
|
+
try {
|
|
125
|
+
return target.require(name);
|
|
350
126
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
|
|
360
|
-
const pub = this.data[cursor];
|
|
361
|
-
pub?.complete();
|
|
127
|
+
catch (error) {
|
|
128
|
+
if (error.code === 'ERR_REQUIRE_ESM') {
|
|
129
|
+
const module = cache.get(name);
|
|
130
|
+
if (module)
|
|
131
|
+
return module;
|
|
132
|
+
throw import(name).then(module => cache.set(name, module));
|
|
362
133
|
}
|
|
134
|
+
$.$mol_fail_log(error);
|
|
135
|
+
return null;
|
|
363
136
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
137
|
+
},
|
|
138
|
+
set(target, name, value) {
|
|
139
|
+
target[name] = value;
|
|
140
|
+
return true;
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
const cache = new Map();
|
|
144
|
+
require = (req => Object.assign(function require(name) {
|
|
145
|
+
return $node[name];
|
|
146
|
+
}, req))(require);
|
|
147
|
+
|
|
148
|
+
;
|
|
149
|
+
"use strict";
|
|
150
|
+
var $;
|
|
151
|
+
(function ($) {
|
|
152
|
+
function $mol_log3_area_lazy(event) {
|
|
153
|
+
const self = this;
|
|
154
|
+
const stack = self.$mol_log3_stack;
|
|
155
|
+
const deep = stack.length;
|
|
156
|
+
let logged = false;
|
|
157
|
+
stack.push(() => {
|
|
158
|
+
logged = true;
|
|
159
|
+
self.$mol_log3_area.call(self, event);
|
|
160
|
+
});
|
|
161
|
+
return () => {
|
|
162
|
+
if (logged)
|
|
163
|
+
self.console.groupEnd();
|
|
164
|
+
if (stack.length > deep)
|
|
165
|
+
stack.length = deep;
|
|
166
|
+
};
|
|
378
167
|
}
|
|
379
|
-
$.$
|
|
168
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
169
|
+
$.$mol_log3_stack = [];
|
|
380
170
|
})($ || ($ = {}));
|
|
381
171
|
|
|
382
172
|
;
|
|
@@ -475,533 +265,90 @@ var $;
|
|
|
475
265
|
function $mol_owning_catch(owner, having) {
|
|
476
266
|
if (!$mol_owning_allow(having))
|
|
477
267
|
return false;
|
|
478
|
-
if ($.$mol_owning_map.get(having))
|
|
479
|
-
return false;
|
|
480
|
-
$.$mol_owning_map.set(having, owner);
|
|
481
|
-
return true;
|
|
482
|
-
}
|
|
483
|
-
$.$mol_owning_catch = $mol_owning_catch;
|
|
484
|
-
})($ || ($ = {}));
|
|
485
|
-
|
|
486
|
-
;
|
|
487
|
-
"use strict";
|
|
488
|
-
var $;
|
|
489
|
-
(function ($) {
|
|
490
|
-
function $mol_fail_hidden(error) {
|
|
491
|
-
throw error;
|
|
492
|
-
}
|
|
493
|
-
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
494
|
-
})($ || ($ = {}));
|
|
495
|
-
|
|
496
|
-
;
|
|
497
|
-
"use strict";
|
|
498
|
-
|
|
499
|
-
;
|
|
500
|
-
"use strict";
|
|
501
|
-
var $;
|
|
502
|
-
(function ($) {
|
|
503
|
-
const named = new WeakSet();
|
|
504
|
-
function $mol_func_name(func) {
|
|
505
|
-
let name = func.name;
|
|
506
|
-
if (name?.length > 1)
|
|
507
|
-
return name;
|
|
508
|
-
if (named.has(func))
|
|
509
|
-
return name;
|
|
510
|
-
for (let key in this) {
|
|
511
|
-
try {
|
|
512
|
-
if (this[key] !== func)
|
|
513
|
-
continue;
|
|
514
|
-
name = key;
|
|
515
|
-
Object.defineProperty(func, 'name', { value: name });
|
|
516
|
-
break;
|
|
517
|
-
}
|
|
518
|
-
catch { }
|
|
519
|
-
}
|
|
520
|
-
named.add(func);
|
|
521
|
-
return name;
|
|
522
|
-
}
|
|
523
|
-
$.$mol_func_name = $mol_func_name;
|
|
524
|
-
function $mol_func_name_from(target, source) {
|
|
525
|
-
Object.defineProperty(target, 'name', { value: source.name });
|
|
526
|
-
return target;
|
|
527
|
-
}
|
|
528
|
-
$.$mol_func_name_from = $mol_func_name_from;
|
|
529
|
-
})($ || ($ = {}));
|
|
530
|
-
|
|
531
|
-
;
|
|
532
|
-
"use strict";
|
|
533
|
-
var $;
|
|
534
|
-
(function ($) {
|
|
535
|
-
class $mol_object2 {
|
|
536
|
-
static $ = $;
|
|
537
|
-
[Symbol.toStringTag];
|
|
538
|
-
[$mol_ambient_ref] = null;
|
|
539
|
-
get $() {
|
|
540
|
-
if (this[$mol_ambient_ref])
|
|
541
|
-
return this[$mol_ambient_ref];
|
|
542
|
-
const owner = $mol_owning_get(this);
|
|
543
|
-
return this[$mol_ambient_ref] = owner?.$ || $mol_object2.$;
|
|
544
|
-
}
|
|
545
|
-
set $(next) {
|
|
546
|
-
if (this[$mol_ambient_ref])
|
|
547
|
-
$mol_fail_hidden(new Error('Context already defined'));
|
|
548
|
-
this[$mol_ambient_ref] = next;
|
|
549
|
-
}
|
|
550
|
-
static create(init) {
|
|
551
|
-
const obj = new this;
|
|
552
|
-
if (init)
|
|
553
|
-
init(obj);
|
|
554
|
-
return obj;
|
|
555
|
-
}
|
|
556
|
-
static [Symbol.toPrimitive]() {
|
|
557
|
-
return this.toString();
|
|
558
|
-
}
|
|
559
|
-
static toString() {
|
|
560
|
-
return this[Symbol.toStringTag] || this.$.$mol_func_name(this);
|
|
561
|
-
}
|
|
562
|
-
static toJSON() {
|
|
563
|
-
return this.toString();
|
|
564
|
-
}
|
|
565
|
-
destructor() { }
|
|
566
|
-
static destructor() { }
|
|
567
|
-
toString() {
|
|
568
|
-
return this[Symbol.toStringTag] || this.constructor.name + '<>';
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
$.$mol_object2 = $mol_object2;
|
|
572
|
-
})($ || ($ = {}));
|
|
573
|
-
|
|
574
|
-
;
|
|
575
|
-
"use strict";
|
|
576
|
-
var $;
|
|
577
|
-
(function ($) {
|
|
578
|
-
class $mol_after_timeout extends $mol_object2 {
|
|
579
|
-
delay;
|
|
580
|
-
task;
|
|
581
|
-
id;
|
|
582
|
-
constructor(delay, task) {
|
|
583
|
-
super();
|
|
584
|
-
this.delay = delay;
|
|
585
|
-
this.task = task;
|
|
586
|
-
this.id = setTimeout(task, delay);
|
|
587
|
-
}
|
|
588
|
-
destructor() {
|
|
589
|
-
clearTimeout(this.id);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
$.$mol_after_timeout = $mol_after_timeout;
|
|
593
|
-
})($ || ($ = {}));
|
|
594
|
-
|
|
595
|
-
;
|
|
596
|
-
"use strict";
|
|
597
|
-
var $;
|
|
598
|
-
(function ($) {
|
|
599
|
-
class $mol_after_frame extends $mol_after_timeout {
|
|
600
|
-
task;
|
|
601
|
-
constructor(task) {
|
|
602
|
-
super(16, task);
|
|
603
|
-
this.task = task;
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
$.$mol_after_frame = $mol_after_frame;
|
|
607
|
-
})($ || ($ = {}));
|
|
608
|
-
|
|
609
|
-
;
|
|
610
|
-
"use strict";
|
|
611
|
-
var $;
|
|
612
|
-
(function ($) {
|
|
613
|
-
function $mol_promise_like(val) {
|
|
614
|
-
return val && typeof val === 'object' && 'then' in val && typeof val.then === 'function';
|
|
615
|
-
}
|
|
616
|
-
$.$mol_promise_like = $mol_promise_like;
|
|
617
|
-
})($ || ($ = {}));
|
|
618
|
-
|
|
619
|
-
;
|
|
620
|
-
"use strict";
|
|
621
|
-
var $;
|
|
622
|
-
(function ($) {
|
|
623
|
-
const handled = new WeakSet();
|
|
624
|
-
class $mol_wire_fiber extends $mol_wire_pub_sub {
|
|
625
|
-
task;
|
|
626
|
-
host;
|
|
627
|
-
static warm = true;
|
|
628
|
-
static planning = new Set();
|
|
629
|
-
static reaping = new Set();
|
|
630
|
-
static plan_task = null;
|
|
631
|
-
static plan() {
|
|
632
|
-
if (this.plan_task)
|
|
633
|
-
return;
|
|
634
|
-
this.plan_task = new $mol_after_frame(() => {
|
|
635
|
-
try {
|
|
636
|
-
this.sync();
|
|
637
|
-
}
|
|
638
|
-
finally {
|
|
639
|
-
$mol_wire_fiber.plan_task = null;
|
|
640
|
-
}
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
|
-
static sync() {
|
|
644
|
-
while (this.planning.size) {
|
|
645
|
-
for (const fiber of this.planning) {
|
|
646
|
-
this.planning.delete(fiber);
|
|
647
|
-
if (fiber.cursor >= 0)
|
|
648
|
-
continue;
|
|
649
|
-
if (fiber.cursor === $mol_wire_cursor.final)
|
|
650
|
-
continue;
|
|
651
|
-
fiber.fresh();
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
while (this.reaping.size) {
|
|
655
|
-
const fibers = this.reaping;
|
|
656
|
-
this.reaping = new Set;
|
|
657
|
-
for (const fiber of fibers) {
|
|
658
|
-
if (!fiber.sub_empty)
|
|
659
|
-
continue;
|
|
660
|
-
fiber.destructor();
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
[Symbol.toStringTag];
|
|
665
|
-
cache = undefined;
|
|
666
|
-
get args() {
|
|
667
|
-
return this.data.slice(0, this.pub_from);
|
|
668
|
-
}
|
|
669
|
-
result() {
|
|
670
|
-
if ($mol_promise_like(this.cache))
|
|
671
|
-
return;
|
|
672
|
-
if (this.cache instanceof Error)
|
|
673
|
-
return;
|
|
674
|
-
return this.cache;
|
|
675
|
-
}
|
|
676
|
-
get incompleted() {
|
|
677
|
-
return $mol_promise_like(this.cache);
|
|
678
|
-
}
|
|
679
|
-
field() {
|
|
680
|
-
return this.task.name + '<>';
|
|
681
|
-
}
|
|
682
|
-
constructor(id, task, host, args) {
|
|
683
|
-
super();
|
|
684
|
-
this.task = task;
|
|
685
|
-
this.host = host;
|
|
686
|
-
if (args)
|
|
687
|
-
this.data.push(...args);
|
|
688
|
-
this.pub_from = this.sub_from = args?.length ?? 0;
|
|
689
|
-
this[Symbol.toStringTag] = id;
|
|
690
|
-
}
|
|
691
|
-
plan() {
|
|
692
|
-
$mol_wire_fiber.planning.add(this);
|
|
693
|
-
$mol_wire_fiber.plan();
|
|
694
|
-
}
|
|
695
|
-
reap() {
|
|
696
|
-
$mol_wire_fiber.reaping.add(this);
|
|
697
|
-
$mol_wire_fiber.plan();
|
|
698
|
-
}
|
|
699
|
-
toString() {
|
|
700
|
-
return this[Symbol.toStringTag];
|
|
701
|
-
}
|
|
702
|
-
toJSON() {
|
|
703
|
-
return this[Symbol.toStringTag];
|
|
704
|
-
}
|
|
705
|
-
[$mol_dev_format_head]() {
|
|
706
|
-
const cursor = {
|
|
707
|
-
[$mol_wire_cursor.stale]: '🔴',
|
|
708
|
-
[$mol_wire_cursor.doubt]: '🟡',
|
|
709
|
-
[$mol_wire_cursor.fresh]: '🟢',
|
|
710
|
-
[$mol_wire_cursor.final]: '🔵',
|
|
711
|
-
}[this.cursor] ?? this.cursor.toString();
|
|
712
|
-
return $mol_dev_format_div({}, $mol_owning_check(this, this.cache)
|
|
713
|
-
? $mol_dev_format_auto({
|
|
714
|
-
[$mol_dev_format_head]: () => $mol_dev_format_shade(cursor),
|
|
715
|
-
[$mol_dev_format_body]: () => $mol_dev_format_native(this),
|
|
716
|
-
})
|
|
717
|
-
: $mol_dev_format_shade($mol_dev_format_native(this), cursor), $mol_dev_format_auto(this.cache));
|
|
718
|
-
}
|
|
719
|
-
get $() {
|
|
720
|
-
return (this.host ?? this.task)['$'];
|
|
721
|
-
}
|
|
722
|
-
emit(quant = $mol_wire_cursor.stale) {
|
|
723
|
-
if (this.sub_empty)
|
|
724
|
-
this.plan();
|
|
725
|
-
else
|
|
726
|
-
super.emit(quant);
|
|
727
|
-
}
|
|
728
|
-
fresh() {
|
|
729
|
-
if (this.cursor === $mol_wire_cursor.fresh)
|
|
730
|
-
return;
|
|
731
|
-
if (this.cursor === $mol_wire_cursor.final)
|
|
732
|
-
return;
|
|
733
|
-
check: if (this.cursor === $mol_wire_cursor.doubt) {
|
|
734
|
-
for (let i = this.pub_from; i < this.sub_from; i += 2) {
|
|
735
|
-
;
|
|
736
|
-
this.data[i]?.fresh();
|
|
737
|
-
if (this.cursor !== $mol_wire_cursor.doubt)
|
|
738
|
-
break check;
|
|
739
|
-
}
|
|
740
|
-
this.cursor = $mol_wire_cursor.fresh;
|
|
741
|
-
return;
|
|
742
|
-
}
|
|
743
|
-
const bu = this.track_on();
|
|
744
|
-
let result;
|
|
745
|
-
try {
|
|
746
|
-
switch (this.pub_from) {
|
|
747
|
-
case 0:
|
|
748
|
-
result = this.task.call(this.host);
|
|
749
|
-
break;
|
|
750
|
-
case 1:
|
|
751
|
-
result = this.task.call(this.host, this.data[0]);
|
|
752
|
-
break;
|
|
753
|
-
default:
|
|
754
|
-
result = this.task.call(this.host, ...this.args);
|
|
755
|
-
break;
|
|
756
|
-
}
|
|
757
|
-
if ($mol_promise_like(result) && !handled.has(result)) {
|
|
758
|
-
const put = (res) => {
|
|
759
|
-
if (this.cache === result)
|
|
760
|
-
this.put(res);
|
|
761
|
-
return res;
|
|
762
|
-
};
|
|
763
|
-
result = result.then(put, put);
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
catch (error) {
|
|
767
|
-
if (error instanceof Error || $mol_promise_like(error)) {
|
|
768
|
-
result = error;
|
|
769
|
-
}
|
|
770
|
-
else {
|
|
771
|
-
result = new Error(String(error), { cause: error });
|
|
772
|
-
}
|
|
773
|
-
if ($mol_promise_like(result) && !handled.has(result)) {
|
|
774
|
-
result = result.finally(() => {
|
|
775
|
-
if (this.cache === result)
|
|
776
|
-
this.absorb();
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
if ($mol_promise_like(result) && !handled.has(result)) {
|
|
781
|
-
result = Object.assign(result, {
|
|
782
|
-
destructor: result['destructor'] ?? (() => { })
|
|
783
|
-
});
|
|
784
|
-
handled.add(result);
|
|
785
|
-
const error = new Error(`Promise in ${this}`);
|
|
786
|
-
Object.defineProperty(result, 'stack', { get: () => error.stack });
|
|
787
|
-
}
|
|
788
|
-
if (!$mol_promise_like(result)) {
|
|
789
|
-
this.track_cut();
|
|
790
|
-
}
|
|
791
|
-
this.track_off(bu);
|
|
792
|
-
this.put(result);
|
|
793
|
-
}
|
|
794
|
-
refresh() {
|
|
795
|
-
this.cursor = $mol_wire_cursor.stale;
|
|
796
|
-
this.fresh();
|
|
797
|
-
}
|
|
798
|
-
sync() {
|
|
799
|
-
if (!$mol_wire_fiber.warm) {
|
|
800
|
-
return this.result();
|
|
801
|
-
}
|
|
802
|
-
this.promote();
|
|
803
|
-
this.fresh();
|
|
804
|
-
if (this.cache instanceof Error) {
|
|
805
|
-
return $mol_fail_hidden(this.cache);
|
|
806
|
-
}
|
|
807
|
-
if ($mol_promise_like(this.cache)) {
|
|
808
|
-
return $mol_fail_hidden(this.cache);
|
|
809
|
-
}
|
|
810
|
-
return this.cache;
|
|
811
|
-
}
|
|
812
|
-
async async() {
|
|
813
|
-
while (true) {
|
|
814
|
-
this.fresh();
|
|
815
|
-
if (this.cache instanceof Error) {
|
|
816
|
-
$mol_fail_hidden(this.cache);
|
|
817
|
-
}
|
|
818
|
-
if (!$mol_promise_like(this.cache))
|
|
819
|
-
return this.cache;
|
|
820
|
-
await Promise.race([this.cache, this.step()]);
|
|
821
|
-
if (!$mol_promise_like(this.cache))
|
|
822
|
-
return this.cache;
|
|
823
|
-
if (this.cursor === $mol_wire_cursor.final) {
|
|
824
|
-
await new Promise(() => { });
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
step() {
|
|
829
|
-
return new Promise(done => {
|
|
830
|
-
const sub = new $mol_wire_pub_sub;
|
|
831
|
-
const prev = sub.track_on();
|
|
832
|
-
sub.track_next(this);
|
|
833
|
-
sub.track_off(prev);
|
|
834
|
-
sub.absorb = () => {
|
|
835
|
-
done(null);
|
|
836
|
-
sub.destructor();
|
|
837
|
-
};
|
|
838
|
-
});
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
$.$mol_wire_fiber = $mol_wire_fiber;
|
|
842
|
-
})($ || ($ = {}));
|
|
843
|
-
|
|
844
|
-
;
|
|
845
|
-
"use strict";
|
|
846
|
-
var $;
|
|
847
|
-
(function ($) {
|
|
848
|
-
$.$mol_compare_deep_cache = new WeakMap();
|
|
849
|
-
function $mol_compare_deep(left, right) {
|
|
850
|
-
if (Object.is(left, right))
|
|
851
|
-
return true;
|
|
852
|
-
if (left === null)
|
|
853
|
-
return false;
|
|
854
|
-
if (right === null)
|
|
855
|
-
return false;
|
|
856
|
-
if (typeof left !== 'object')
|
|
857
|
-
return false;
|
|
858
|
-
if (typeof right !== 'object')
|
|
859
|
-
return false;
|
|
860
|
-
const left_proto = Reflect.getPrototypeOf(left);
|
|
861
|
-
const right_proto = Reflect.getPrototypeOf(right);
|
|
862
|
-
if (left_proto !== right_proto)
|
|
863
|
-
return false;
|
|
864
|
-
if (left instanceof Boolean)
|
|
865
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
866
|
-
if (left instanceof Number)
|
|
867
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
868
|
-
if (left instanceof String)
|
|
869
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
870
|
-
if (left instanceof Date)
|
|
871
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
872
|
-
if (left instanceof RegExp)
|
|
873
|
-
return left.source === right.source && left.flags === right.flags;
|
|
874
|
-
if (left instanceof Error)
|
|
875
|
-
return left.message === right.message && left.stack === right.stack;
|
|
876
|
-
let left_cache = $.$mol_compare_deep_cache.get(left);
|
|
877
|
-
if (left_cache) {
|
|
878
|
-
const right_cache = left_cache.get(right);
|
|
879
|
-
if (typeof right_cache === 'boolean')
|
|
880
|
-
return right_cache;
|
|
881
|
-
}
|
|
882
|
-
else {
|
|
883
|
-
left_cache = new WeakMap([[right, true]]);
|
|
884
|
-
$.$mol_compare_deep_cache.set(left, left_cache);
|
|
885
|
-
}
|
|
886
|
-
let result;
|
|
887
|
-
try {
|
|
888
|
-
if (!left_proto)
|
|
889
|
-
result = compare_pojo(left, right);
|
|
890
|
-
else if (!Reflect.getPrototypeOf(left_proto))
|
|
891
|
-
result = compare_pojo(left, right);
|
|
892
|
-
else if (Symbol.toPrimitive in left)
|
|
893
|
-
result = compare_primitive(left, right);
|
|
894
|
-
else if (Array.isArray(left))
|
|
895
|
-
result = compare_array(left, right);
|
|
896
|
-
else if (left instanceof Set)
|
|
897
|
-
result = compare_set(left, right);
|
|
898
|
-
else if (left instanceof Map)
|
|
899
|
-
result = compare_map(left, right);
|
|
900
|
-
else if (ArrayBuffer.isView(left))
|
|
901
|
-
result = compare_buffer(left, right);
|
|
902
|
-
else if (Symbol.iterator in left)
|
|
903
|
-
result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
|
|
904
|
-
else
|
|
905
|
-
result = false;
|
|
906
|
-
}
|
|
907
|
-
finally {
|
|
908
|
-
left_cache.set(right, result);
|
|
909
|
-
}
|
|
910
|
-
return result;
|
|
911
|
-
}
|
|
912
|
-
$.$mol_compare_deep = $mol_compare_deep;
|
|
913
|
-
function compare_array(left, right) {
|
|
914
|
-
const len = left.length;
|
|
915
|
-
if (len !== right.length)
|
|
916
|
-
return false;
|
|
917
|
-
for (let i = 0; i < len; ++i) {
|
|
918
|
-
if (!$mol_compare_deep(left[i], right[i]))
|
|
919
|
-
return false;
|
|
920
|
-
}
|
|
921
|
-
return true;
|
|
922
|
-
}
|
|
923
|
-
function compare_buffer(left, right) {
|
|
924
|
-
const len = left.byteLength;
|
|
925
|
-
if (len !== right.byteLength)
|
|
926
|
-
return false;
|
|
927
|
-
if (left instanceof DataView)
|
|
928
|
-
return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, left.byteOffset, left.byteLength));
|
|
929
|
-
for (let i = 0; i < len; ++i) {
|
|
930
|
-
if (left[i] !== right[i])
|
|
931
|
-
return false;
|
|
932
|
-
}
|
|
933
|
-
return true;
|
|
934
|
-
}
|
|
935
|
-
function compare_iterator(left, right) {
|
|
936
|
-
while (true) {
|
|
937
|
-
const left_next = left.next();
|
|
938
|
-
const right_next = right.next();
|
|
939
|
-
if (left_next.done !== right_next.done)
|
|
940
|
-
return false;
|
|
941
|
-
if (left_next.done)
|
|
942
|
-
break;
|
|
943
|
-
if (!$mol_compare_deep(left_next.value, right_next.value))
|
|
944
|
-
return false;
|
|
945
|
-
}
|
|
946
|
-
return true;
|
|
947
|
-
}
|
|
948
|
-
function compare_set(left, right) {
|
|
949
|
-
if (left.size !== right.size)
|
|
950
|
-
return false;
|
|
951
|
-
return compare_iterator(left.values(), right.values());
|
|
952
|
-
}
|
|
953
|
-
function compare_map(left, right) {
|
|
954
|
-
if (left.size !== right.size)
|
|
955
|
-
return false;
|
|
956
|
-
return compare_iterator(left.keys(), right.keys())
|
|
957
|
-
&& compare_iterator(left.values(), right.values());
|
|
958
|
-
}
|
|
959
|
-
function compare_pojo(left, right) {
|
|
960
|
-
const left_keys = Object.getOwnPropertyNames(left);
|
|
961
|
-
const right_keys = Object.getOwnPropertyNames(right);
|
|
962
|
-
if (!compare_array(left_keys, right_keys))
|
|
963
|
-
return false;
|
|
964
|
-
for (let key of left_keys) {
|
|
965
|
-
if (!$mol_compare_deep(left[key], right[key]))
|
|
966
|
-
return false;
|
|
967
|
-
}
|
|
968
|
-
const left_syms = Object.getOwnPropertySymbols(left);
|
|
969
|
-
const right_syms = Object.getOwnPropertySymbols(right);
|
|
970
|
-
if (!compare_array(left_syms, right_syms))
|
|
971
|
-
return false;
|
|
972
|
-
for (let key of left_syms) {
|
|
973
|
-
if (!$mol_compare_deep(left[key], right[key]))
|
|
974
|
-
return false;
|
|
975
|
-
}
|
|
268
|
+
if ($.$mol_owning_map.get(having))
|
|
269
|
+
return false;
|
|
270
|
+
$.$mol_owning_map.set(having, owner);
|
|
976
271
|
return true;
|
|
977
272
|
}
|
|
978
|
-
|
|
979
|
-
|
|
273
|
+
$.$mol_owning_catch = $mol_owning_catch;
|
|
274
|
+
})($ || ($ = {}));
|
|
275
|
+
|
|
276
|
+
;
|
|
277
|
+
"use strict";
|
|
278
|
+
|
|
279
|
+
;
|
|
280
|
+
"use strict";
|
|
281
|
+
var $;
|
|
282
|
+
(function ($) {
|
|
283
|
+
const named = new WeakSet();
|
|
284
|
+
function $mol_func_name(func) {
|
|
285
|
+
let name = func.name;
|
|
286
|
+
if (name?.length > 1)
|
|
287
|
+
return name;
|
|
288
|
+
if (named.has(func))
|
|
289
|
+
return name;
|
|
290
|
+
for (let key in this) {
|
|
291
|
+
try {
|
|
292
|
+
if (this[key] !== func)
|
|
293
|
+
continue;
|
|
294
|
+
name = key;
|
|
295
|
+
Object.defineProperty(func, 'name', { value: name });
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
catch { }
|
|
299
|
+
}
|
|
300
|
+
named.add(func);
|
|
301
|
+
return name;
|
|
302
|
+
}
|
|
303
|
+
$.$mol_func_name = $mol_func_name;
|
|
304
|
+
function $mol_func_name_from(target, source) {
|
|
305
|
+
Object.defineProperty(target, 'name', { value: source.name });
|
|
306
|
+
return target;
|
|
980
307
|
}
|
|
308
|
+
$.$mol_func_name_from = $mol_func_name_from;
|
|
981
309
|
})($ || ($ = {}));
|
|
982
310
|
|
|
983
311
|
;
|
|
984
312
|
"use strict";
|
|
985
313
|
var $;
|
|
986
314
|
(function ($) {
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
}
|
|
315
|
+
class $mol_object2 {
|
|
316
|
+
static $ = $;
|
|
317
|
+
[Symbol.toStringTag];
|
|
318
|
+
[$mol_ambient_ref] = null;
|
|
319
|
+
get $() {
|
|
320
|
+
if (this[$mol_ambient_ref])
|
|
321
|
+
return this[$mol_ambient_ref];
|
|
322
|
+
const owner = $mol_owning_get(this);
|
|
323
|
+
return this[$mol_ambient_ref] = owner?.$ || $mol_object2.$;
|
|
324
|
+
}
|
|
325
|
+
set $(next) {
|
|
326
|
+
if (this[$mol_ambient_ref])
|
|
327
|
+
$mol_fail_hidden(new Error('Context already defined'));
|
|
328
|
+
this[$mol_ambient_ref] = next;
|
|
329
|
+
}
|
|
330
|
+
static create(init) {
|
|
331
|
+
const obj = new this;
|
|
332
|
+
if (init)
|
|
333
|
+
init(obj);
|
|
334
|
+
return obj;
|
|
335
|
+
}
|
|
336
|
+
static [Symbol.toPrimitive]() {
|
|
337
|
+
return this.toString();
|
|
338
|
+
}
|
|
339
|
+
static toString() {
|
|
340
|
+
return this[Symbol.toStringTag] || this.$.$mol_func_name(this);
|
|
341
|
+
}
|
|
342
|
+
static toJSON() {
|
|
343
|
+
return this.toString();
|
|
344
|
+
}
|
|
345
|
+
destructor() { }
|
|
346
|
+
static destructor() { }
|
|
347
|
+
toString() {
|
|
348
|
+
return this[Symbol.toStringTag] || this.constructor.name + '<>';
|
|
349
|
+
}
|
|
1002
350
|
}
|
|
1003
|
-
$.$
|
|
1004
|
-
$.$mol_log3_stack = [];
|
|
351
|
+
$.$mol_object2 = $mol_object2;
|
|
1005
352
|
})($ || ($ = {}));
|
|
1006
353
|
|
|
1007
354
|
;
|
|
@@ -1497,178 +844,6 @@ var $;
|
|
|
1497
844
|
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
|
1498
845
|
})($ || ($ = {}));
|
|
1499
846
|
|
|
1500
|
-
;
|
|
1501
|
-
"use strict";
|
|
1502
|
-
var $;
|
|
1503
|
-
(function ($) {
|
|
1504
|
-
class $mol_wire_task extends $mol_wire_fiber {
|
|
1505
|
-
static getter(task) {
|
|
1506
|
-
return function $mol_wire_task_get(host, args) {
|
|
1507
|
-
const sub = $mol_wire_auto();
|
|
1508
|
-
const existen = sub?.track_next();
|
|
1509
|
-
reuse: if (existen) {
|
|
1510
|
-
if (!existen.temp)
|
|
1511
|
-
break reuse;
|
|
1512
|
-
if (existen.host !== host)
|
|
1513
|
-
break reuse;
|
|
1514
|
-
if (existen.task !== task)
|
|
1515
|
-
break reuse;
|
|
1516
|
-
if (!$mol_compare_deep(existen.args, args))
|
|
1517
|
-
break reuse;
|
|
1518
|
-
return existen;
|
|
1519
|
-
}
|
|
1520
|
-
const next = new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}<#>`, task, host, args);
|
|
1521
|
-
if (existen?.temp) {
|
|
1522
|
-
$$.$mol_log3_warn({
|
|
1523
|
-
place: '$mol_wire_task',
|
|
1524
|
-
message: `Non idempotency`,
|
|
1525
|
-
existen,
|
|
1526
|
-
next,
|
|
1527
|
-
hint: 'Ignore it',
|
|
1528
|
-
});
|
|
1529
|
-
}
|
|
1530
|
-
return next;
|
|
1531
|
-
};
|
|
1532
|
-
}
|
|
1533
|
-
get temp() {
|
|
1534
|
-
return true;
|
|
1535
|
-
}
|
|
1536
|
-
complete() {
|
|
1537
|
-
if ($mol_promise_like(this.cache))
|
|
1538
|
-
return;
|
|
1539
|
-
this.destructor();
|
|
1540
|
-
}
|
|
1541
|
-
put(next) {
|
|
1542
|
-
const prev = this.cache;
|
|
1543
|
-
this.cache = next;
|
|
1544
|
-
if ($mol_promise_like(next)) {
|
|
1545
|
-
this.cursor = $mol_wire_cursor.fresh;
|
|
1546
|
-
if (next !== prev)
|
|
1547
|
-
this.emit();
|
|
1548
|
-
return next;
|
|
1549
|
-
}
|
|
1550
|
-
this.cursor = $mol_wire_cursor.final;
|
|
1551
|
-
if (this.sub_empty)
|
|
1552
|
-
this.destructor();
|
|
1553
|
-
else if (next !== prev)
|
|
1554
|
-
this.emit();
|
|
1555
|
-
return next;
|
|
1556
|
-
}
|
|
1557
|
-
}
|
|
1558
|
-
$.$mol_wire_task = $mol_wire_task;
|
|
1559
|
-
})($ || ($ = {}));
|
|
1560
|
-
|
|
1561
|
-
;
|
|
1562
|
-
"use strict";
|
|
1563
|
-
var $;
|
|
1564
|
-
(function ($) {
|
|
1565
|
-
function $mol_wire_sync(obj) {
|
|
1566
|
-
return new Proxy(obj, {
|
|
1567
|
-
get(obj, field) {
|
|
1568
|
-
const val = obj[field];
|
|
1569
|
-
if (typeof val !== 'function')
|
|
1570
|
-
return val;
|
|
1571
|
-
const temp = $mol_wire_task.getter(val);
|
|
1572
|
-
return function $mol_wire_sync(...args) {
|
|
1573
|
-
const fiber = temp(obj, args);
|
|
1574
|
-
return fiber.sync();
|
|
1575
|
-
};
|
|
1576
|
-
},
|
|
1577
|
-
apply(obj, self, args) {
|
|
1578
|
-
const temp = $mol_wire_task.getter(obj);
|
|
1579
|
-
const fiber = temp(self, args);
|
|
1580
|
-
return fiber.sync();
|
|
1581
|
-
},
|
|
1582
|
-
});
|
|
1583
|
-
}
|
|
1584
|
-
$.$mol_wire_sync = $mol_wire_sync;
|
|
1585
|
-
})($ || ($ = {}));
|
|
1586
|
-
|
|
1587
|
-
;
|
|
1588
|
-
"use strict";
|
|
1589
|
-
var $;
|
|
1590
|
-
(function ($) {
|
|
1591
|
-
const catched = new WeakMap();
|
|
1592
|
-
function $mol_fail_catch(error) {
|
|
1593
|
-
if (typeof error !== 'object')
|
|
1594
|
-
return false;
|
|
1595
|
-
if ($mol_promise_like(error))
|
|
1596
|
-
$mol_fail_hidden(error);
|
|
1597
|
-
if (catched.get(error))
|
|
1598
|
-
return false;
|
|
1599
|
-
catched.set(error, true);
|
|
1600
|
-
return true;
|
|
1601
|
-
}
|
|
1602
|
-
$.$mol_fail_catch = $mol_fail_catch;
|
|
1603
|
-
})($ || ($ = {}));
|
|
1604
|
-
|
|
1605
|
-
;
|
|
1606
|
-
"use strict";
|
|
1607
|
-
var $;
|
|
1608
|
-
(function ($) {
|
|
1609
|
-
function $mol_fail_log(error) {
|
|
1610
|
-
if ($mol_promise_like(error))
|
|
1611
|
-
return false;
|
|
1612
|
-
if (!$mol_fail_catch(error))
|
|
1613
|
-
return false;
|
|
1614
|
-
console.error(error);
|
|
1615
|
-
return true;
|
|
1616
|
-
}
|
|
1617
|
-
$.$mol_fail_log = $mol_fail_log;
|
|
1618
|
-
})($ || ($ = {}));
|
|
1619
|
-
|
|
1620
|
-
;
|
|
1621
|
-
"use strict";
|
|
1622
|
-
var $node = new Proxy({ require }, {
|
|
1623
|
-
get(target, name, wrapper) {
|
|
1624
|
-
if (target[name])
|
|
1625
|
-
return target[name];
|
|
1626
|
-
const mod = target.require('module');
|
|
1627
|
-
if (mod.builtinModules.indexOf(name) >= 0)
|
|
1628
|
-
return target.require(name);
|
|
1629
|
-
if (name[0] === '.')
|
|
1630
|
-
return target.require(name);
|
|
1631
|
-
const path = target.require('path');
|
|
1632
|
-
const fs = target.require('fs');
|
|
1633
|
-
let dir = path.resolve('.');
|
|
1634
|
-
const suffix = `./node_modules/${name}`;
|
|
1635
|
-
const $$ = $;
|
|
1636
|
-
while (!fs.existsSync(path.join(dir, suffix))) {
|
|
1637
|
-
const parent = path.resolve(dir, '..');
|
|
1638
|
-
if (parent === dir) {
|
|
1639
|
-
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
1640
|
-
try {
|
|
1641
|
-
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
1642
|
-
}
|
|
1643
|
-
catch { }
|
|
1644
|
-
break;
|
|
1645
|
-
}
|
|
1646
|
-
else {
|
|
1647
|
-
dir = parent;
|
|
1648
|
-
}
|
|
1649
|
-
}
|
|
1650
|
-
try {
|
|
1651
|
-
return $.$mol_wire_sync(target).require(name);
|
|
1652
|
-
}
|
|
1653
|
-
catch (error) {
|
|
1654
|
-
if (error.code === 'ERR_REQUIRE_ESM') {
|
|
1655
|
-
return importSync(name);
|
|
1656
|
-
}
|
|
1657
|
-
$.$mol_fail_log(error);
|
|
1658
|
-
return null;
|
|
1659
|
-
}
|
|
1660
|
-
},
|
|
1661
|
-
set(target, name, value) {
|
|
1662
|
-
target[name] = value;
|
|
1663
|
-
return true;
|
|
1664
|
-
},
|
|
1665
|
-
});
|
|
1666
|
-
const importAsync = async (uri) => import(uri);
|
|
1667
|
-
const importSync = $.$mol_wire_sync(importAsync);
|
|
1668
|
-
require = (req => Object.assign(function require(name) {
|
|
1669
|
-
return $node[name];
|
|
1670
|
-
}, req))(require);
|
|
1671
|
-
|
|
1672
847
|
;
|
|
1673
848
|
"use strict";
|
|
1674
849
|
var $;
|
|
@@ -2062,33 +1237,6 @@ var $;
|
|
|
2062
1237
|
$.$mol_test_complete = $mol_test_complete;
|
|
2063
1238
|
})($ || ($ = {}));
|
|
2064
1239
|
|
|
2065
|
-
;
|
|
2066
|
-
"use strict";
|
|
2067
|
-
|
|
2068
|
-
;
|
|
2069
|
-
"use strict";
|
|
2070
|
-
|
|
2071
|
-
;
|
|
2072
|
-
"use strict";
|
|
2073
|
-
|
|
2074
|
-
;
|
|
2075
|
-
"use strict";
|
|
2076
|
-
var $;
|
|
2077
|
-
(function ($_1) {
|
|
2078
|
-
$mol_test({
|
|
2079
|
-
'test types'($) {
|
|
2080
|
-
class A {
|
|
2081
|
-
static a() {
|
|
2082
|
-
return Promise.resolve('');
|
|
2083
|
-
}
|
|
2084
|
-
static b() {
|
|
2085
|
-
return $mol_wire_sync(this).a();
|
|
2086
|
-
}
|
|
2087
|
-
}
|
|
2088
|
-
},
|
|
2089
|
-
});
|
|
2090
|
-
})($ || ($ = {}));
|
|
2091
|
-
|
|
2092
1240
|
;
|
|
2093
1241
|
"use strict";
|
|
2094
1242
|
var $;
|
|
@@ -2157,6 +1305,15 @@ var $;
|
|
|
2157
1305
|
;
|
|
2158
1306
|
"use strict";
|
|
2159
1307
|
|
|
1308
|
+
;
|
|
1309
|
+
"use strict";
|
|
1310
|
+
|
|
1311
|
+
;
|
|
1312
|
+
"use strict";
|
|
1313
|
+
|
|
1314
|
+
;
|
|
1315
|
+
"use strict";
|
|
1316
|
+
|
|
2160
1317
|
;
|
|
2161
1318
|
"use strict";
|
|
2162
1319
|
var $;
|
|
@@ -2665,7 +1822,146 @@ var $;
|
|
|
2665
1822
|
$mol_assert_fail(() => list.sort(), TypeError);
|
|
2666
1823
|
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
|
2667
1824
|
}
|
|
2668
|
-
});
|
|
1825
|
+
});
|
|
1826
|
+
})($ || ($ = {}));
|
|
1827
|
+
|
|
1828
|
+
;
|
|
1829
|
+
"use strict";
|
|
1830
|
+
var $;
|
|
1831
|
+
(function ($) {
|
|
1832
|
+
$.$mol_compare_deep_cache = new WeakMap();
|
|
1833
|
+
function $mol_compare_deep(left, right) {
|
|
1834
|
+
if (Object.is(left, right))
|
|
1835
|
+
return true;
|
|
1836
|
+
if (left === null)
|
|
1837
|
+
return false;
|
|
1838
|
+
if (right === null)
|
|
1839
|
+
return false;
|
|
1840
|
+
if (typeof left !== 'object')
|
|
1841
|
+
return false;
|
|
1842
|
+
if (typeof right !== 'object')
|
|
1843
|
+
return false;
|
|
1844
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
|
1845
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
|
1846
|
+
if (left_proto !== right_proto)
|
|
1847
|
+
return false;
|
|
1848
|
+
if (left instanceof Boolean)
|
|
1849
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1850
|
+
if (left instanceof Number)
|
|
1851
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1852
|
+
if (left instanceof String)
|
|
1853
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1854
|
+
if (left instanceof Date)
|
|
1855
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1856
|
+
if (left instanceof RegExp)
|
|
1857
|
+
return left.source === right.source && left.flags === right.flags;
|
|
1858
|
+
if (left instanceof Error)
|
|
1859
|
+
return left.message === right.message && left.stack === right.stack;
|
|
1860
|
+
let left_cache = $.$mol_compare_deep_cache.get(left);
|
|
1861
|
+
if (left_cache) {
|
|
1862
|
+
const right_cache = left_cache.get(right);
|
|
1863
|
+
if (typeof right_cache === 'boolean')
|
|
1864
|
+
return right_cache;
|
|
1865
|
+
}
|
|
1866
|
+
else {
|
|
1867
|
+
left_cache = new WeakMap([[right, true]]);
|
|
1868
|
+
$.$mol_compare_deep_cache.set(left, left_cache);
|
|
1869
|
+
}
|
|
1870
|
+
let result;
|
|
1871
|
+
try {
|
|
1872
|
+
if (!left_proto)
|
|
1873
|
+
result = compare_pojo(left, right);
|
|
1874
|
+
else if (!Reflect.getPrototypeOf(left_proto))
|
|
1875
|
+
result = compare_pojo(left, right);
|
|
1876
|
+
else if (Symbol.toPrimitive in left)
|
|
1877
|
+
result = compare_primitive(left, right);
|
|
1878
|
+
else if (Array.isArray(left))
|
|
1879
|
+
result = compare_array(left, right);
|
|
1880
|
+
else if (left instanceof Set)
|
|
1881
|
+
result = compare_set(left, right);
|
|
1882
|
+
else if (left instanceof Map)
|
|
1883
|
+
result = compare_map(left, right);
|
|
1884
|
+
else if (ArrayBuffer.isView(left))
|
|
1885
|
+
result = compare_buffer(left, right);
|
|
1886
|
+
else if (Symbol.iterator in left)
|
|
1887
|
+
result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
|
|
1888
|
+
else
|
|
1889
|
+
result = false;
|
|
1890
|
+
}
|
|
1891
|
+
finally {
|
|
1892
|
+
left_cache.set(right, result);
|
|
1893
|
+
}
|
|
1894
|
+
return result;
|
|
1895
|
+
}
|
|
1896
|
+
$.$mol_compare_deep = $mol_compare_deep;
|
|
1897
|
+
function compare_array(left, right) {
|
|
1898
|
+
const len = left.length;
|
|
1899
|
+
if (len !== right.length)
|
|
1900
|
+
return false;
|
|
1901
|
+
for (let i = 0; i < len; ++i) {
|
|
1902
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
|
1903
|
+
return false;
|
|
1904
|
+
}
|
|
1905
|
+
return true;
|
|
1906
|
+
}
|
|
1907
|
+
function compare_buffer(left, right) {
|
|
1908
|
+
const len = left.byteLength;
|
|
1909
|
+
if (len !== right.byteLength)
|
|
1910
|
+
return false;
|
|
1911
|
+
if (left instanceof DataView)
|
|
1912
|
+
return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, left.byteOffset, left.byteLength));
|
|
1913
|
+
for (let i = 0; i < len; ++i) {
|
|
1914
|
+
if (left[i] !== right[i])
|
|
1915
|
+
return false;
|
|
1916
|
+
}
|
|
1917
|
+
return true;
|
|
1918
|
+
}
|
|
1919
|
+
function compare_iterator(left, right) {
|
|
1920
|
+
while (true) {
|
|
1921
|
+
const left_next = left.next();
|
|
1922
|
+
const right_next = right.next();
|
|
1923
|
+
if (left_next.done !== right_next.done)
|
|
1924
|
+
return false;
|
|
1925
|
+
if (left_next.done)
|
|
1926
|
+
break;
|
|
1927
|
+
if (!$mol_compare_deep(left_next.value, right_next.value))
|
|
1928
|
+
return false;
|
|
1929
|
+
}
|
|
1930
|
+
return true;
|
|
1931
|
+
}
|
|
1932
|
+
function compare_set(left, right) {
|
|
1933
|
+
if (left.size !== right.size)
|
|
1934
|
+
return false;
|
|
1935
|
+
return compare_iterator(left.values(), right.values());
|
|
1936
|
+
}
|
|
1937
|
+
function compare_map(left, right) {
|
|
1938
|
+
if (left.size !== right.size)
|
|
1939
|
+
return false;
|
|
1940
|
+
return compare_iterator(left.keys(), right.keys())
|
|
1941
|
+
&& compare_iterator(left.values(), right.values());
|
|
1942
|
+
}
|
|
1943
|
+
function compare_pojo(left, right) {
|
|
1944
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
|
1945
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
|
1946
|
+
if (!compare_array(left_keys, right_keys))
|
|
1947
|
+
return false;
|
|
1948
|
+
for (let key of left_keys) {
|
|
1949
|
+
if (!$mol_compare_deep(left[key], right[key]))
|
|
1950
|
+
return false;
|
|
1951
|
+
}
|
|
1952
|
+
const left_syms = Object.getOwnPropertySymbols(left);
|
|
1953
|
+
const right_syms = Object.getOwnPropertySymbols(right);
|
|
1954
|
+
if (!compare_array(left_syms, right_syms))
|
|
1955
|
+
return false;
|
|
1956
|
+
for (let key of left_syms) {
|
|
1957
|
+
if (!$mol_compare_deep(left[key], right[key]))
|
|
1958
|
+
return false;
|
|
1959
|
+
}
|
|
1960
|
+
return true;
|
|
1961
|
+
}
|
|
1962
|
+
function compare_primitive(left, right) {
|
|
1963
|
+
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
1964
|
+
}
|
|
2669
1965
|
})($ || ($ = {}));
|
|
2670
1966
|
|
|
2671
1967
|
;
|
|
@@ -3237,348 +2533,6 @@ var $;
|
|
|
3237
2533
|
});
|
|
3238
2534
|
})($ || ($ = {}));
|
|
3239
2535
|
|
|
3240
|
-
;
|
|
3241
|
-
"use strict";
|
|
3242
|
-
var $;
|
|
3243
|
-
(function ($_1) {
|
|
3244
|
-
$mol_test({
|
|
3245
|
-
'Collect deps'() {
|
|
3246
|
-
const pub1 = new $mol_wire_pub;
|
|
3247
|
-
const pub2 = new $mol_wire_pub;
|
|
3248
|
-
const sub = new $mol_wire_pub_sub;
|
|
3249
|
-
const bu1 = sub.track_on();
|
|
3250
|
-
try {
|
|
3251
|
-
pub1.promote();
|
|
3252
|
-
pub2.promote();
|
|
3253
|
-
pub2.promote();
|
|
3254
|
-
}
|
|
3255
|
-
finally {
|
|
3256
|
-
sub.track_cut();
|
|
3257
|
-
sub.track_off(bu1);
|
|
3258
|
-
}
|
|
3259
|
-
pub1.emit();
|
|
3260
|
-
pub2.emit();
|
|
3261
|
-
$mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
|
|
3262
|
-
const bu2 = sub.track_on();
|
|
3263
|
-
try {
|
|
3264
|
-
pub1.promote();
|
|
3265
|
-
pub1.promote();
|
|
3266
|
-
pub2.promote();
|
|
3267
|
-
}
|
|
3268
|
-
finally {
|
|
3269
|
-
sub.track_cut();
|
|
3270
|
-
sub.track_off(bu2);
|
|
3271
|
-
}
|
|
3272
|
-
pub1.emit();
|
|
3273
|
-
pub2.emit();
|
|
3274
|
-
$mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
|
|
3275
|
-
},
|
|
3276
|
-
'cyclic detection'($) {
|
|
3277
|
-
const sub1 = new $mol_wire_pub_sub;
|
|
3278
|
-
const sub2 = new $mol_wire_pub_sub;
|
|
3279
|
-
const bu1 = sub1.track_on();
|
|
3280
|
-
try {
|
|
3281
|
-
const bu2 = sub2.track_on();
|
|
3282
|
-
try {
|
|
3283
|
-
$mol_assert_fail(() => sub1.promote(), 'Circular subscription');
|
|
3284
|
-
}
|
|
3285
|
-
finally {
|
|
3286
|
-
sub2.track_cut();
|
|
3287
|
-
sub2.track_off(bu2);
|
|
3288
|
-
}
|
|
3289
|
-
}
|
|
3290
|
-
finally {
|
|
3291
|
-
sub1.track_cut();
|
|
3292
|
-
sub1.track_off(bu1);
|
|
3293
|
-
}
|
|
3294
|
-
},
|
|
3295
|
-
});
|
|
3296
|
-
})($ || ($ = {}));
|
|
3297
|
-
|
|
3298
|
-
;
|
|
3299
|
-
"use strict";
|
|
3300
|
-
var $;
|
|
3301
|
-
(function ($) {
|
|
3302
|
-
$.$mol_after_mock_queue = [];
|
|
3303
|
-
function $mol_after_mock_warp() {
|
|
3304
|
-
const queue = $.$mol_after_mock_queue.splice(0);
|
|
3305
|
-
for (const task of queue)
|
|
3306
|
-
task();
|
|
3307
|
-
}
|
|
3308
|
-
$.$mol_after_mock_warp = $mol_after_mock_warp;
|
|
3309
|
-
class $mol_after_mock_commmon extends $mol_object2 {
|
|
3310
|
-
task;
|
|
3311
|
-
promise = Promise.resolve();
|
|
3312
|
-
cancelled = false;
|
|
3313
|
-
id;
|
|
3314
|
-
constructor(task) {
|
|
3315
|
-
super();
|
|
3316
|
-
this.task = task;
|
|
3317
|
-
$.$mol_after_mock_queue.push(task);
|
|
3318
|
-
}
|
|
3319
|
-
destructor() {
|
|
3320
|
-
const index = $.$mol_after_mock_queue.indexOf(this.task);
|
|
3321
|
-
if (index >= 0)
|
|
3322
|
-
$.$mol_after_mock_queue.splice(index, 1);
|
|
3323
|
-
}
|
|
3324
|
-
}
|
|
3325
|
-
$.$mol_after_mock_commmon = $mol_after_mock_commmon;
|
|
3326
|
-
class $mol_after_mock_timeout extends $mol_after_mock_commmon {
|
|
3327
|
-
delay;
|
|
3328
|
-
constructor(delay, task) {
|
|
3329
|
-
super(task);
|
|
3330
|
-
this.delay = delay;
|
|
3331
|
-
}
|
|
3332
|
-
}
|
|
3333
|
-
$.$mol_after_mock_timeout = $mol_after_mock_timeout;
|
|
3334
|
-
})($ || ($ = {}));
|
|
3335
|
-
|
|
3336
|
-
;
|
|
3337
|
-
"use strict";
|
|
3338
|
-
var $;
|
|
3339
|
-
(function ($_1) {
|
|
3340
|
-
$mol_test_mocks.push($ => {
|
|
3341
|
-
$.$mol_after_timeout = $mol_after_mock_timeout;
|
|
3342
|
-
});
|
|
3343
|
-
})($ || ($ = {}));
|
|
3344
|
-
|
|
3345
|
-
;
|
|
3346
|
-
"use strict";
|
|
3347
|
-
var $;
|
|
3348
|
-
(function ($_1) {
|
|
3349
|
-
$mol_test_mocks.push($ => {
|
|
3350
|
-
$.$mol_after_frame = $mol_after_mock_commmon;
|
|
3351
|
-
});
|
|
3352
|
-
})($ || ($ = {}));
|
|
3353
|
-
|
|
3354
|
-
;
|
|
3355
|
-
"use strict";
|
|
3356
|
-
var $;
|
|
3357
|
-
(function ($) {
|
|
3358
|
-
$mol_test({
|
|
3359
|
-
'Sync execution'() {
|
|
3360
|
-
class Sync extends $mol_object2 {
|
|
3361
|
-
static calc(a, b) {
|
|
3362
|
-
return a + b;
|
|
3363
|
-
}
|
|
3364
|
-
}
|
|
3365
|
-
__decorate([
|
|
3366
|
-
$mol_wire_method
|
|
3367
|
-
], Sync, "calc", null);
|
|
3368
|
-
$mol_assert_equal(Sync.calc(1, 2), 3);
|
|
3369
|
-
},
|
|
3370
|
-
async 'async <=> sync'() {
|
|
3371
|
-
class SyncAsync extends $mol_object2 {
|
|
3372
|
-
static async val(a) {
|
|
3373
|
-
return a;
|
|
3374
|
-
}
|
|
3375
|
-
static sum(a, b) {
|
|
3376
|
-
const syn = $mol_wire_sync(this);
|
|
3377
|
-
return syn.val(a) + syn.val(b);
|
|
3378
|
-
}
|
|
3379
|
-
static async calc(a, b) {
|
|
3380
|
-
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
3381
|
-
}
|
|
3382
|
-
}
|
|
3383
|
-
$mol_assert_equal(await SyncAsync.calc(1, 2), 8);
|
|
3384
|
-
},
|
|
3385
|
-
async 'Idempotence control'() {
|
|
3386
|
-
class Idempotence extends $mol_object2 {
|
|
3387
|
-
static logs_idemp = 0;
|
|
3388
|
-
static logs_unidemp = 0;
|
|
3389
|
-
static log_idemp() {
|
|
3390
|
-
this.logs_idemp += 1;
|
|
3391
|
-
}
|
|
3392
|
-
static log_unidemp() {
|
|
3393
|
-
this.logs_unidemp += 1;
|
|
3394
|
-
}
|
|
3395
|
-
static async val(a) {
|
|
3396
|
-
return a;
|
|
3397
|
-
}
|
|
3398
|
-
static sum(a, b) {
|
|
3399
|
-
this.log_idemp();
|
|
3400
|
-
this.log_unidemp();
|
|
3401
|
-
const syn = $mol_wire_sync(this);
|
|
3402
|
-
return syn.val(a) + syn.val(b);
|
|
3403
|
-
}
|
|
3404
|
-
static async calc(a, b) {
|
|
3405
|
-
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
3406
|
-
}
|
|
3407
|
-
}
|
|
3408
|
-
__decorate([
|
|
3409
|
-
$mol_wire_method
|
|
3410
|
-
], Idempotence, "log_idemp", null);
|
|
3411
|
-
$mol_assert_equal(await Idempotence.calc(1, 2), 8);
|
|
3412
|
-
$mol_assert_equal(Idempotence.logs_idemp, 1);
|
|
3413
|
-
$mol_assert_equal(Idempotence.logs_unidemp, 3);
|
|
3414
|
-
},
|
|
3415
|
-
async 'Error handling'() {
|
|
3416
|
-
class Handle extends $mol_object2 {
|
|
3417
|
-
static async sum(a, b) {
|
|
3418
|
-
$mol_fail(new Error('test error ' + (a + b)));
|
|
3419
|
-
}
|
|
3420
|
-
static check() {
|
|
3421
|
-
try {
|
|
3422
|
-
return $mol_wire_sync(Handle).sum(1, 2);
|
|
3423
|
-
}
|
|
3424
|
-
catch (error) {
|
|
3425
|
-
if ($mol_promise_like(error))
|
|
3426
|
-
$mol_fail_hidden(error);
|
|
3427
|
-
$mol_assert_equal(error.message, 'test error 3');
|
|
3428
|
-
}
|
|
3429
|
-
}
|
|
3430
|
-
}
|
|
3431
|
-
await $mol_wire_async(Handle).check();
|
|
3432
|
-
},
|
|
3433
|
-
});
|
|
3434
|
-
})($ || ($ = {}));
|
|
3435
|
-
|
|
3436
|
-
;
|
|
3437
|
-
"use strict";
|
|
3438
|
-
var $;
|
|
3439
|
-
(function ($) {
|
|
3440
|
-
function $mol_wire_method(host, field, descr) {
|
|
3441
|
-
if (!descr)
|
|
3442
|
-
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
3443
|
-
const orig = descr?.value ?? host[field];
|
|
3444
|
-
const sup = Reflect.getPrototypeOf(host);
|
|
3445
|
-
if (typeof sup[field] === 'function') {
|
|
3446
|
-
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
3447
|
-
}
|
|
3448
|
-
const temp = $mol_wire_task.getter(orig);
|
|
3449
|
-
const value = function (...args) {
|
|
3450
|
-
const fiber = temp(this ?? null, args);
|
|
3451
|
-
return fiber.sync();
|
|
3452
|
-
};
|
|
3453
|
-
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
3454
|
-
Object.assign(value, { orig });
|
|
3455
|
-
const descr2 = { ...descr, value };
|
|
3456
|
-
Reflect.defineProperty(host, field, descr2);
|
|
3457
|
-
return descr2;
|
|
3458
|
-
}
|
|
3459
|
-
$.$mol_wire_method = $mol_wire_method;
|
|
3460
|
-
})($ || ($ = {}));
|
|
3461
|
-
|
|
3462
|
-
;
|
|
3463
|
-
"use strict";
|
|
3464
|
-
var $;
|
|
3465
|
-
(function ($) {
|
|
3466
|
-
function $mol_promise() {
|
|
3467
|
-
let done;
|
|
3468
|
-
let fail;
|
|
3469
|
-
const promise = new Promise((d, f) => {
|
|
3470
|
-
done = d;
|
|
3471
|
-
fail = f;
|
|
3472
|
-
});
|
|
3473
|
-
return Object.assign(promise, {
|
|
3474
|
-
done,
|
|
3475
|
-
fail,
|
|
3476
|
-
});
|
|
3477
|
-
}
|
|
3478
|
-
$.$mol_promise = $mol_promise;
|
|
3479
|
-
})($ || ($ = {}));
|
|
3480
|
-
|
|
3481
|
-
;
|
|
3482
|
-
"use strict";
|
|
3483
|
-
var $;
|
|
3484
|
-
(function ($) {
|
|
3485
|
-
function $mol_wait_timeout_async(timeout) {
|
|
3486
|
-
const promise = $mol_promise();
|
|
3487
|
-
const task = new this.$mol_after_timeout(timeout, () => promise.done());
|
|
3488
|
-
return Object.assign(promise, {
|
|
3489
|
-
destructor: () => task.destructor()
|
|
3490
|
-
});
|
|
3491
|
-
}
|
|
3492
|
-
$.$mol_wait_timeout_async = $mol_wait_timeout_async;
|
|
3493
|
-
function $mol_wait_timeout(timeout) {
|
|
3494
|
-
return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
|
|
3495
|
-
}
|
|
3496
|
-
$.$mol_wait_timeout = $mol_wait_timeout;
|
|
3497
|
-
})($ || ($ = {}));
|
|
3498
|
-
|
|
3499
|
-
;
|
|
3500
|
-
"use strict";
|
|
3501
|
-
var $;
|
|
3502
|
-
(function ($) {
|
|
3503
|
-
function $mol_wire_async(obj) {
|
|
3504
|
-
let fiber;
|
|
3505
|
-
const temp = $mol_wire_task.getter(obj);
|
|
3506
|
-
return new Proxy(obj, {
|
|
3507
|
-
get(obj, field) {
|
|
3508
|
-
const val = obj[field];
|
|
3509
|
-
if (typeof val !== 'function')
|
|
3510
|
-
return val;
|
|
3511
|
-
let fiber;
|
|
3512
|
-
const temp = $mol_wire_task.getter(val);
|
|
3513
|
-
return function $mol_wire_async(...args) {
|
|
3514
|
-
fiber?.destructor();
|
|
3515
|
-
fiber = temp(obj, args);
|
|
3516
|
-
return fiber.async();
|
|
3517
|
-
};
|
|
3518
|
-
},
|
|
3519
|
-
apply(obj, self, args) {
|
|
3520
|
-
fiber?.destructor();
|
|
3521
|
-
fiber = temp(self, args);
|
|
3522
|
-
return fiber.async();
|
|
3523
|
-
},
|
|
3524
|
-
});
|
|
3525
|
-
}
|
|
3526
|
-
$.$mol_wire_async = $mol_wire_async;
|
|
3527
|
-
})($ || ($ = {}));
|
|
3528
|
-
|
|
3529
|
-
;
|
|
3530
|
-
"use strict";
|
|
3531
|
-
var $;
|
|
3532
|
-
(function ($_1) {
|
|
3533
|
-
$mol_test({
|
|
3534
|
-
'test types'($) {
|
|
3535
|
-
class A {
|
|
3536
|
-
static a() {
|
|
3537
|
-
return '';
|
|
3538
|
-
}
|
|
3539
|
-
static b() {
|
|
3540
|
-
return $mol_wire_async(this).a();
|
|
3541
|
-
}
|
|
3542
|
-
}
|
|
3543
|
-
},
|
|
3544
|
-
async 'Latest method calls wins'($) {
|
|
3545
|
-
class NameLogger extends $mol_object2 {
|
|
3546
|
-
static $ = $;
|
|
3547
|
-
static first = [];
|
|
3548
|
-
static last = [];
|
|
3549
|
-
static send(next) {
|
|
3550
|
-
$mol_wire_sync(this.first).push(next);
|
|
3551
|
-
this.$.$mol_wait_timeout(0);
|
|
3552
|
-
this.last.push(next);
|
|
3553
|
-
}
|
|
3554
|
-
}
|
|
3555
|
-
const name = $mol_wire_async(NameLogger).send;
|
|
3556
|
-
name('john');
|
|
3557
|
-
const promise = name('jin');
|
|
3558
|
-
$.$mol_after_mock_warp();
|
|
3559
|
-
await promise;
|
|
3560
|
-
$mol_assert_like(NameLogger.first, ['john', 'jin']);
|
|
3561
|
-
$mol_assert_like(NameLogger.last, ['jin']);
|
|
3562
|
-
},
|
|
3563
|
-
async 'Latest function calls wins'($) {
|
|
3564
|
-
const first = [];
|
|
3565
|
-
const last = [];
|
|
3566
|
-
function send_name(next) {
|
|
3567
|
-
$mol_wire_sync(first).push(next);
|
|
3568
|
-
$.$mol_wait_timeout(0);
|
|
3569
|
-
last.push(next);
|
|
3570
|
-
}
|
|
3571
|
-
const name = $mol_wire_async(send_name);
|
|
3572
|
-
name('john');
|
|
3573
|
-
const promise = name('jin');
|
|
3574
|
-
$.$mol_after_mock_warp();
|
|
3575
|
-
await promise;
|
|
3576
|
-
$mol_assert_like(first, ['john', 'jin']);
|
|
3577
|
-
$mol_assert_like(last, ['jin']);
|
|
3578
|
-
},
|
|
3579
|
-
});
|
|
3580
|
-
})($ || ($ = {}));
|
|
3581
|
-
|
|
3582
2536
|
;
|
|
3583
2537
|
"use strict";
|
|
3584
2538
|
var $;
|