mol_jsx_lib 0.0.1
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 +58 -0
- package/node.audit.js +1 -0
- package/node.d.ts +445 -0
- package/node.deps.json +1 -0
- package/node.esm.js +1879 -0
- package/node.esm.js.map +1 -0
- package/node.js +1878 -0
- package/node.js.map +1 -0
- package/node.test.js +3543 -0
- package/node.test.js.map +1 -0
- package/package.json +64 -0
- 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 +360 -0
- package/web.deps.json +1 -0
- package/web.esm.js +1386 -0
- package/web.esm.js.map +1 -0
- package/web.js +1385 -0
- package/web.js.map +1 -0
- package/web.test.js +1695 -0
- package/web.test.js.map +1 -0
package/node.esm.js
ADDED
|
@@ -0,0 +1,1879 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var exports = void 0;
|
|
3
|
+
"use strict"
|
|
4
|
+
|
|
5
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
6
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8
|
+
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;
|
|
9
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
var globalThis = globalThis || ( typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this )
|
|
13
|
+
var $ = ( typeof module === 'object' ) ? ( module['export'+'s'] = globalThis ) : globalThis
|
|
14
|
+
$.$$ = $
|
|
15
|
+
|
|
16
|
+
;
|
|
17
|
+
|
|
18
|
+
var $node = $node || {}
|
|
19
|
+
void function( module ) { var exports = module.exports = this; function require( id ) { return $node[ id.replace( /^.\// , "../" ) ] };
|
|
20
|
+
;
|
|
21
|
+
"use strict";
|
|
22
|
+
Error.stackTraceLimit = 50;
|
|
23
|
+
var $;
|
|
24
|
+
(function ($) {
|
|
25
|
+
})($ || ($ = {}));
|
|
26
|
+
module.exports = $;
|
|
27
|
+
//mam.ts
|
|
28
|
+
;
|
|
29
|
+
|
|
30
|
+
$node[ "../mam.ts" ] = $node[ "../mam.ts" ] = module.exports }.call( {} , {} )
|
|
31
|
+
;
|
|
32
|
+
"use strict";
|
|
33
|
+
var $;
|
|
34
|
+
(function ($) {
|
|
35
|
+
})($ || ($ = {}));
|
|
36
|
+
//mol/dom/context/context.ts
|
|
37
|
+
;
|
|
38
|
+
"use strict";
|
|
39
|
+
//node/node.ts
|
|
40
|
+
;
|
|
41
|
+
"use strict";
|
|
42
|
+
var $node = new Proxy({ require }, {
|
|
43
|
+
get(target, name, wrapper) {
|
|
44
|
+
if (target[name])
|
|
45
|
+
return target[name];
|
|
46
|
+
const mod = target.require('module');
|
|
47
|
+
if (mod.builtinModules.indexOf(name) >= 0)
|
|
48
|
+
return target.require(name);
|
|
49
|
+
const path = target.require('path');
|
|
50
|
+
const fs = target.require('fs');
|
|
51
|
+
let dir = path.resolve('.');
|
|
52
|
+
const suffix = `./node_modules/${name}`;
|
|
53
|
+
const $$ = $;
|
|
54
|
+
while (!fs.existsSync(path.join(dir, suffix))) {
|
|
55
|
+
const parent = path.resolve(dir, '..');
|
|
56
|
+
if (parent === dir) {
|
|
57
|
+
$$.$mol_exec('.', 'npm', 'install', name);
|
|
58
|
+
try {
|
|
59
|
+
$$.$mol_exec('.', 'npm', 'install', '@types/' + name);
|
|
60
|
+
}
|
|
61
|
+
catch { }
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
dir = parent;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return target.require(name);
|
|
69
|
+
},
|
|
70
|
+
set(target, name, value) {
|
|
71
|
+
target[name] = value;
|
|
72
|
+
return true;
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
require = (req => Object.assign(function require(name) {
|
|
76
|
+
return $node[name];
|
|
77
|
+
}, req))(require);
|
|
78
|
+
//node/node.node.ts
|
|
79
|
+
;
|
|
80
|
+
"use strict";
|
|
81
|
+
var $;
|
|
82
|
+
(function ($) {
|
|
83
|
+
function $mol_log3_area_lazy(event) {
|
|
84
|
+
const self = this;
|
|
85
|
+
const stack = self.$mol_log3_stack;
|
|
86
|
+
const deep = stack.length;
|
|
87
|
+
let logged = false;
|
|
88
|
+
stack.push(() => {
|
|
89
|
+
logged = true;
|
|
90
|
+
self.$mol_log3_area.call(self, event);
|
|
91
|
+
});
|
|
92
|
+
return () => {
|
|
93
|
+
if (logged)
|
|
94
|
+
self.console.groupEnd();
|
|
95
|
+
if (stack.length > deep)
|
|
96
|
+
stack.length = deep;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
100
|
+
$.$mol_log3_stack = [];
|
|
101
|
+
})($ || ($ = {}));
|
|
102
|
+
//mol/log3/log3.ts
|
|
103
|
+
;
|
|
104
|
+
"use strict";
|
|
105
|
+
var $;
|
|
106
|
+
(function ($) {
|
|
107
|
+
$.$mol_ambient_ref = Symbol('$mol_ambient_ref');
|
|
108
|
+
function $mol_ambient(overrides) {
|
|
109
|
+
return Object.setPrototypeOf(overrides, this || $);
|
|
110
|
+
}
|
|
111
|
+
$.$mol_ambient = $mol_ambient;
|
|
112
|
+
})($ || ($ = {}));
|
|
113
|
+
//mol/ambient/ambient.ts
|
|
114
|
+
;
|
|
115
|
+
"use strict";
|
|
116
|
+
var $;
|
|
117
|
+
(function ($) {
|
|
118
|
+
const instances = new WeakSet();
|
|
119
|
+
function $mol_delegate(proto, target) {
|
|
120
|
+
const proxy = new Proxy(proto, {
|
|
121
|
+
get: (_, field) => {
|
|
122
|
+
const obj = target();
|
|
123
|
+
let val = Reflect.get(obj, field);
|
|
124
|
+
if (typeof val === 'function') {
|
|
125
|
+
val = val.bind(obj);
|
|
126
|
+
}
|
|
127
|
+
return val;
|
|
128
|
+
},
|
|
129
|
+
has: (_, field) => Reflect.has(target(), field),
|
|
130
|
+
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
131
|
+
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
132
|
+
ownKeys: () => Reflect.ownKeys(target()),
|
|
133
|
+
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
134
|
+
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
135
|
+
isExtensible: () => Reflect.isExtensible(target()),
|
|
136
|
+
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
137
|
+
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
138
|
+
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
139
|
+
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
140
|
+
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
141
|
+
});
|
|
142
|
+
instances.add(proxy);
|
|
143
|
+
return proxy;
|
|
144
|
+
}
|
|
145
|
+
$.$mol_delegate = $mol_delegate;
|
|
146
|
+
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
147
|
+
value: (obj) => instances.has(obj),
|
|
148
|
+
});
|
|
149
|
+
})($ || ($ = {}));
|
|
150
|
+
//mol/delegate/delegate.ts
|
|
151
|
+
;
|
|
152
|
+
"use strict";
|
|
153
|
+
var $;
|
|
154
|
+
(function ($) {
|
|
155
|
+
$.$mol_owning_map = new WeakMap();
|
|
156
|
+
function $mol_owning_allow(having) {
|
|
157
|
+
try {
|
|
158
|
+
if (!having)
|
|
159
|
+
return false;
|
|
160
|
+
if (typeof having !== 'object')
|
|
161
|
+
return false;
|
|
162
|
+
if (having instanceof $mol_delegate)
|
|
163
|
+
return false;
|
|
164
|
+
if (typeof having['destructor'] !== 'function')
|
|
165
|
+
return false;
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
$.$mol_owning_allow = $mol_owning_allow;
|
|
173
|
+
function $mol_owning_get(having, Owner) {
|
|
174
|
+
if (!$mol_owning_allow(having))
|
|
175
|
+
return null;
|
|
176
|
+
while (true) {
|
|
177
|
+
const owner = $.$mol_owning_map.get(having);
|
|
178
|
+
if (!owner)
|
|
179
|
+
return owner;
|
|
180
|
+
if (!Owner)
|
|
181
|
+
return owner;
|
|
182
|
+
if (owner instanceof Owner)
|
|
183
|
+
return owner;
|
|
184
|
+
having = owner;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
$.$mol_owning_get = $mol_owning_get;
|
|
188
|
+
function $mol_owning_check(owner, having) {
|
|
189
|
+
if (!$mol_owning_allow(having))
|
|
190
|
+
return false;
|
|
191
|
+
if ($.$mol_owning_map.get(having) !== owner)
|
|
192
|
+
return false;
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
$.$mol_owning_check = $mol_owning_check;
|
|
196
|
+
function $mol_owning_catch(owner, having) {
|
|
197
|
+
if (!$mol_owning_allow(having))
|
|
198
|
+
return false;
|
|
199
|
+
if ($.$mol_owning_map.get(having))
|
|
200
|
+
return false;
|
|
201
|
+
$.$mol_owning_map.set(having, owner);
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
$.$mol_owning_catch = $mol_owning_catch;
|
|
205
|
+
})($ || ($ = {}));
|
|
206
|
+
//mol/owning/owning.ts
|
|
207
|
+
;
|
|
208
|
+
"use strict";
|
|
209
|
+
var $;
|
|
210
|
+
(function ($) {
|
|
211
|
+
function $mol_fail(error) {
|
|
212
|
+
throw error;
|
|
213
|
+
}
|
|
214
|
+
$.$mol_fail = $mol_fail;
|
|
215
|
+
})($ || ($ = {}));
|
|
216
|
+
//mol/fail/fail.ts
|
|
217
|
+
;
|
|
218
|
+
"use strict";
|
|
219
|
+
var $;
|
|
220
|
+
(function ($) {
|
|
221
|
+
function $mol_fail_hidden(error) {
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
225
|
+
})($ || ($ = {}));
|
|
226
|
+
//mol/fail/hidden/hidden.ts
|
|
227
|
+
;
|
|
228
|
+
"use strict";
|
|
229
|
+
//mol/type/writable/writable.ts
|
|
230
|
+
;
|
|
231
|
+
"use strict";
|
|
232
|
+
var $;
|
|
233
|
+
(function ($) {
|
|
234
|
+
class $mol_object2 {
|
|
235
|
+
static $ = $;
|
|
236
|
+
[$mol_ambient_ref] = null;
|
|
237
|
+
get $() {
|
|
238
|
+
if (this[$mol_ambient_ref])
|
|
239
|
+
return this[$mol_ambient_ref];
|
|
240
|
+
const owner = $mol_owning_get(this);
|
|
241
|
+
return this[$mol_ambient_ref] = owner?.$ || $mol_object2.$;
|
|
242
|
+
}
|
|
243
|
+
set $(next) {
|
|
244
|
+
if (this[$mol_ambient_ref])
|
|
245
|
+
$mol_fail_hidden(new Error('Context already defined'));
|
|
246
|
+
this[$mol_ambient_ref] = next;
|
|
247
|
+
}
|
|
248
|
+
static create(init) {
|
|
249
|
+
const obj = new this;
|
|
250
|
+
if (init)
|
|
251
|
+
init(obj);
|
|
252
|
+
return obj;
|
|
253
|
+
}
|
|
254
|
+
static [Symbol.toPrimitive]() {
|
|
255
|
+
return this.toString();
|
|
256
|
+
}
|
|
257
|
+
static toString() {
|
|
258
|
+
if (Symbol.toStringTag in this)
|
|
259
|
+
return this[Symbol.toStringTag];
|
|
260
|
+
return this.name;
|
|
261
|
+
}
|
|
262
|
+
destructor() { }
|
|
263
|
+
toString() {
|
|
264
|
+
return this[Symbol.toStringTag] || this.constructor.name + '()';
|
|
265
|
+
}
|
|
266
|
+
toJSON() {
|
|
267
|
+
return this.toString();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
$.$mol_object2 = $mol_object2;
|
|
271
|
+
})($ || ($ = {}));
|
|
272
|
+
//mol/object2/object2.ts
|
|
273
|
+
;
|
|
274
|
+
"use strict";
|
|
275
|
+
var $;
|
|
276
|
+
(function ($) {
|
|
277
|
+
function $mol_deprecated(message) {
|
|
278
|
+
return (host, field, descr) => {
|
|
279
|
+
const value = descr.value;
|
|
280
|
+
let warned = false;
|
|
281
|
+
descr.value = function $mol_deprecated_wrapper(...args) {
|
|
282
|
+
if (!warned) {
|
|
283
|
+
$$.$mol_log3_warn({
|
|
284
|
+
place: `${host.constructor.name}::${field}`,
|
|
285
|
+
message: `Deprecated`,
|
|
286
|
+
hint: message,
|
|
287
|
+
});
|
|
288
|
+
warned = true;
|
|
289
|
+
}
|
|
290
|
+
return value.call(this, ...args);
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
$.$mol_deprecated = $mol_deprecated;
|
|
295
|
+
})($ || ($ = {}));
|
|
296
|
+
//mol/deprecated/deprecated.ts
|
|
297
|
+
;
|
|
298
|
+
"use strict";
|
|
299
|
+
var $;
|
|
300
|
+
(function ($) {
|
|
301
|
+
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
302
|
+
class $mol_tree extends $mol_object2 {
|
|
303
|
+
type;
|
|
304
|
+
data;
|
|
305
|
+
sub;
|
|
306
|
+
baseUri;
|
|
307
|
+
row;
|
|
308
|
+
col;
|
|
309
|
+
length;
|
|
310
|
+
constructor(config = {}) {
|
|
311
|
+
super();
|
|
312
|
+
this.type = config.type || '';
|
|
313
|
+
if (config.value !== undefined) {
|
|
314
|
+
var sub = $mol_tree.values(config.value);
|
|
315
|
+
if (config.type || sub.length > 1) {
|
|
316
|
+
this.sub = [...sub, ...(config.sub || [])];
|
|
317
|
+
this.data = config.data || '';
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
this.data = sub[0].data;
|
|
321
|
+
this.sub = config.sub || [];
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
this.data = config.data || '';
|
|
326
|
+
this.sub = config.sub || [];
|
|
327
|
+
}
|
|
328
|
+
this.baseUri = config.baseUri || '';
|
|
329
|
+
this.row = config.row || 0;
|
|
330
|
+
this.col = config.col || 0;
|
|
331
|
+
this.length = config.length || 0;
|
|
332
|
+
}
|
|
333
|
+
static values(str, baseUri) {
|
|
334
|
+
return str.split('\n').map((data, index) => new $mol_tree({
|
|
335
|
+
data: data,
|
|
336
|
+
baseUri: baseUri,
|
|
337
|
+
row: index + 1,
|
|
338
|
+
length: data.length,
|
|
339
|
+
}));
|
|
340
|
+
}
|
|
341
|
+
clone(config = {}) {
|
|
342
|
+
return new $mol_tree({
|
|
343
|
+
type: ('type' in config) ? config.type : this.type,
|
|
344
|
+
data: ('data' in config) ? config.data : this.data,
|
|
345
|
+
sub: ('sub' in config) ? config.sub : this.sub,
|
|
346
|
+
baseUri: ('baseUri' in config) ? config.baseUri : this.baseUri,
|
|
347
|
+
row: ('row' in config) ? config.row : this.row,
|
|
348
|
+
col: ('col' in config) ? config.col : this.col,
|
|
349
|
+
length: ('length' in config) ? config.length : this.length,
|
|
350
|
+
value: config.value
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
make(config) {
|
|
354
|
+
return new $mol_tree({
|
|
355
|
+
baseUri: this.baseUri,
|
|
356
|
+
row: this.row,
|
|
357
|
+
col: this.col,
|
|
358
|
+
length: this.length,
|
|
359
|
+
...config,
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
make_data(value, sub) {
|
|
363
|
+
return this.make({ value, sub });
|
|
364
|
+
}
|
|
365
|
+
make_struct(type, sub) {
|
|
366
|
+
return this.make({ type, sub });
|
|
367
|
+
}
|
|
368
|
+
static fromString(str, baseUri) {
|
|
369
|
+
var root = new $mol_tree({ baseUri: baseUri });
|
|
370
|
+
var stack = [root];
|
|
371
|
+
var row = 0;
|
|
372
|
+
var prefix = str.replace(/^\n?(\t*)[\s\S]*/, '$1');
|
|
373
|
+
var lines = str.replace(new RegExp('^\\t{0,' + prefix.length + '}', 'mg'), '').split('\n');
|
|
374
|
+
lines.forEach(line => {
|
|
375
|
+
++row;
|
|
376
|
+
var chunks = /^(\t*)((?:[^\n\t\\ ]+ *)*)(\\[^\n]*)?(.*?)(?:$|\n)/m.exec(line);
|
|
377
|
+
if (!chunks || chunks[4])
|
|
378
|
+
return this.$.$mol_fail(new Error(`Syntax error at ${baseUri}:${row}\n${line}`));
|
|
379
|
+
var indent = chunks[1];
|
|
380
|
+
var path = chunks[2];
|
|
381
|
+
var data = chunks[3];
|
|
382
|
+
var deep = indent.length;
|
|
383
|
+
var types = path ? path.replace(/ $/, '').split(/ +/) : [];
|
|
384
|
+
if (stack.length <= deep)
|
|
385
|
+
return this.$.$mol_fail(new Error(`Too many tabs at ${baseUri}:${row}\n${line}`));
|
|
386
|
+
stack.length = deep + 1;
|
|
387
|
+
var parent = stack[deep];
|
|
388
|
+
let col = deep;
|
|
389
|
+
types.forEach(type => {
|
|
390
|
+
if (!type)
|
|
391
|
+
return this.$.$mol_fail(new Error(`Unexpected space symbol ${baseUri}:${row}\n${line}`));
|
|
392
|
+
var next = new $mol_tree({ type, baseUri, row, col, length: type.length });
|
|
393
|
+
const parent_sub = parent.sub;
|
|
394
|
+
parent_sub.push(next);
|
|
395
|
+
parent = next;
|
|
396
|
+
col += type.length + 1;
|
|
397
|
+
});
|
|
398
|
+
if (data) {
|
|
399
|
+
var next = new $mol_tree({ data: data.substring(1), baseUri, row, col, length: data.length });
|
|
400
|
+
const parent_sub = parent.sub;
|
|
401
|
+
parent_sub.push(next);
|
|
402
|
+
parent = next;
|
|
403
|
+
}
|
|
404
|
+
stack.push(parent);
|
|
405
|
+
});
|
|
406
|
+
return root;
|
|
407
|
+
}
|
|
408
|
+
static fromJSON(json, baseUri = '') {
|
|
409
|
+
switch (true) {
|
|
410
|
+
case typeof json === 'boolean':
|
|
411
|
+
case typeof json === 'number':
|
|
412
|
+
case json === null:
|
|
413
|
+
return new $mol_tree({
|
|
414
|
+
type: String(json),
|
|
415
|
+
baseUri: baseUri
|
|
416
|
+
});
|
|
417
|
+
case typeof json === 'string':
|
|
418
|
+
return new $mol_tree({
|
|
419
|
+
value: json,
|
|
420
|
+
baseUri: baseUri
|
|
421
|
+
});
|
|
422
|
+
case Array.isArray(json):
|
|
423
|
+
return new $mol_tree({
|
|
424
|
+
type: "/",
|
|
425
|
+
sub: json.map(json => $mol_tree.fromJSON(json, baseUri))
|
|
426
|
+
});
|
|
427
|
+
case json instanceof Date:
|
|
428
|
+
return new $mol_tree({
|
|
429
|
+
value: json.toISOString(),
|
|
430
|
+
baseUri: baseUri
|
|
431
|
+
});
|
|
432
|
+
default:
|
|
433
|
+
if (typeof json[$.$mol_tree_convert] === 'function') {
|
|
434
|
+
return json[$.$mol_tree_convert]();
|
|
435
|
+
}
|
|
436
|
+
if (typeof json.toJSON === 'function') {
|
|
437
|
+
return $mol_tree.fromJSON(json.toJSON());
|
|
438
|
+
}
|
|
439
|
+
if (json instanceof Error) {
|
|
440
|
+
const { name, message, stack } = json;
|
|
441
|
+
json = { ...json, name, message, stack };
|
|
442
|
+
}
|
|
443
|
+
var sub = [];
|
|
444
|
+
for (var key in json) {
|
|
445
|
+
if (json[key] === undefined)
|
|
446
|
+
continue;
|
|
447
|
+
const subsub = $mol_tree.fromJSON(json[key], baseUri);
|
|
448
|
+
if (/^[^\n\t\\ ]+$/.test(key)) {
|
|
449
|
+
var child = new $mol_tree({
|
|
450
|
+
type: key,
|
|
451
|
+
baseUri: baseUri,
|
|
452
|
+
sub: [subsub],
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
var child = new $mol_tree({
|
|
457
|
+
value: key,
|
|
458
|
+
baseUri: baseUri,
|
|
459
|
+
sub: [subsub],
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
sub.push(child);
|
|
463
|
+
}
|
|
464
|
+
return new $mol_tree({
|
|
465
|
+
type: "*",
|
|
466
|
+
sub: sub,
|
|
467
|
+
baseUri: baseUri
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
get uri() {
|
|
472
|
+
return this.baseUri + '#' + this.row + ':' + this.col;
|
|
473
|
+
}
|
|
474
|
+
toString(prefix = '') {
|
|
475
|
+
var output = '';
|
|
476
|
+
if (this.type.length) {
|
|
477
|
+
if (!prefix.length) {
|
|
478
|
+
prefix = "\t";
|
|
479
|
+
}
|
|
480
|
+
output += this.type;
|
|
481
|
+
if (this.sub.length == 1) {
|
|
482
|
+
return output + ' ' + this.sub[0].toString(prefix);
|
|
483
|
+
}
|
|
484
|
+
output += "\n";
|
|
485
|
+
}
|
|
486
|
+
else if (this.data.length || prefix.length) {
|
|
487
|
+
output += "\\" + this.data + "\n";
|
|
488
|
+
}
|
|
489
|
+
for (var child of this.sub) {
|
|
490
|
+
output += prefix;
|
|
491
|
+
output += child.toString(prefix + "\t");
|
|
492
|
+
}
|
|
493
|
+
return output;
|
|
494
|
+
}
|
|
495
|
+
toJSON() {
|
|
496
|
+
if (!this.type)
|
|
497
|
+
return this.value;
|
|
498
|
+
if (this.type === 'true')
|
|
499
|
+
return true;
|
|
500
|
+
if (this.type === 'false')
|
|
501
|
+
return false;
|
|
502
|
+
if (this.type === 'null')
|
|
503
|
+
return null;
|
|
504
|
+
if (this.type === '*') {
|
|
505
|
+
var obj = {};
|
|
506
|
+
for (var child of this.sub) {
|
|
507
|
+
if (child.type === '-')
|
|
508
|
+
continue;
|
|
509
|
+
var key = child.type || child.clone({ sub: child.sub.slice(0, child.sub.length - 1) }).value;
|
|
510
|
+
var val = child.sub[child.sub.length - 1].toJSON();
|
|
511
|
+
if (val !== undefined)
|
|
512
|
+
obj[key] = val;
|
|
513
|
+
}
|
|
514
|
+
return obj;
|
|
515
|
+
}
|
|
516
|
+
if (this.type === '/') {
|
|
517
|
+
var res = [];
|
|
518
|
+
this.sub.forEach(child => {
|
|
519
|
+
if (child.type === '-')
|
|
520
|
+
return;
|
|
521
|
+
var val = child.toJSON();
|
|
522
|
+
if (val !== undefined)
|
|
523
|
+
res.push(val);
|
|
524
|
+
});
|
|
525
|
+
return res;
|
|
526
|
+
}
|
|
527
|
+
if (this.type === 'time') {
|
|
528
|
+
return new Date(this.value);
|
|
529
|
+
}
|
|
530
|
+
const numb = Number(this.type);
|
|
531
|
+
if (!Number.isNaN(numb) || this.type === 'NaN')
|
|
532
|
+
return numb;
|
|
533
|
+
throw new Error(`Unknown type (${this.type}) at ${this.uri}`);
|
|
534
|
+
}
|
|
535
|
+
get value() {
|
|
536
|
+
var values = [];
|
|
537
|
+
for (var child of this.sub) {
|
|
538
|
+
if (child.type)
|
|
539
|
+
continue;
|
|
540
|
+
values.push(child.value);
|
|
541
|
+
}
|
|
542
|
+
return this.data + values.join("\n");
|
|
543
|
+
}
|
|
544
|
+
insert(value, ...path) {
|
|
545
|
+
if (path.length === 0)
|
|
546
|
+
return value;
|
|
547
|
+
const type = path[0];
|
|
548
|
+
if (typeof type === 'string') {
|
|
549
|
+
let replaced = false;
|
|
550
|
+
const sub = this.sub.map((item, index) => {
|
|
551
|
+
if (item.type !== type)
|
|
552
|
+
return item;
|
|
553
|
+
replaced = true;
|
|
554
|
+
return item.insert(value, ...path.slice(1));
|
|
555
|
+
});
|
|
556
|
+
if (!replaced)
|
|
557
|
+
sub.push(new $mol_tree({ type }).insert(value, ...path.slice(1)));
|
|
558
|
+
return this.clone({ sub });
|
|
559
|
+
}
|
|
560
|
+
else if (typeof type === 'number') {
|
|
561
|
+
const sub = this.sub.slice();
|
|
562
|
+
sub[type] = (sub[type] || new $mol_tree).insert(value, ...path.slice(1));
|
|
563
|
+
return this.clone({ sub });
|
|
564
|
+
}
|
|
565
|
+
else {
|
|
566
|
+
return this.clone({ sub: ((this.sub.length === 0) ? [new $mol_tree()] : this.sub).map(item => item.insert(value, ...path.slice(1))) });
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
select(...path) {
|
|
570
|
+
var next = [this];
|
|
571
|
+
for (var type of path) {
|
|
572
|
+
if (!next.length)
|
|
573
|
+
break;
|
|
574
|
+
var prev = next;
|
|
575
|
+
next = [];
|
|
576
|
+
for (var item of prev) {
|
|
577
|
+
switch (typeof (type)) {
|
|
578
|
+
case 'string':
|
|
579
|
+
for (var child of item.sub) {
|
|
580
|
+
if (!type || (child.type == type)) {
|
|
581
|
+
next.push(child);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
break;
|
|
585
|
+
case 'number':
|
|
586
|
+
if (type < item.sub.length)
|
|
587
|
+
next.push(item.sub[type]);
|
|
588
|
+
break;
|
|
589
|
+
default: next.push(...item.sub);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
return new $mol_tree({ sub: next });
|
|
594
|
+
}
|
|
595
|
+
filter(path, value) {
|
|
596
|
+
var sub = this.sub.filter(function (item) {
|
|
597
|
+
var found = item.select(...path);
|
|
598
|
+
if (value == null) {
|
|
599
|
+
return Boolean(found.sub.length);
|
|
600
|
+
}
|
|
601
|
+
else {
|
|
602
|
+
return found.sub.some(child => child.value == value);
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
return new $mol_tree({ sub: sub });
|
|
606
|
+
}
|
|
607
|
+
transform(visit, stack = []) {
|
|
608
|
+
const sub_stack = [this, ...stack];
|
|
609
|
+
return visit(sub_stack, () => this.sub.map(node => node.transform(visit, sub_stack)).filter(n => n));
|
|
610
|
+
}
|
|
611
|
+
hack(context) {
|
|
612
|
+
const sub = [].concat(...this.sub.map(child => {
|
|
613
|
+
const handle = context[child.type] || context[''];
|
|
614
|
+
if (!handle)
|
|
615
|
+
$mol_fail(child.error('Handler not defined'));
|
|
616
|
+
return handle(child, context);
|
|
617
|
+
}));
|
|
618
|
+
return this.clone({ sub });
|
|
619
|
+
}
|
|
620
|
+
error(message) {
|
|
621
|
+
return new Error(`${message}:\n${this} ${this.baseUri}:${this.row}:${this.col}`);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
__decorate([
|
|
625
|
+
$mol_deprecated('Use $mol_tree:hack')
|
|
626
|
+
], $mol_tree.prototype, "transform", null);
|
|
627
|
+
$.$mol_tree = $mol_tree;
|
|
628
|
+
})($ || ($ = {}));
|
|
629
|
+
//mol/tree/tree.ts
|
|
630
|
+
;
|
|
631
|
+
"use strict";
|
|
632
|
+
var $;
|
|
633
|
+
(function ($) {
|
|
634
|
+
function $mol_log3_node_make(level, output, type, color) {
|
|
635
|
+
return function $mol_log3_logger(event) {
|
|
636
|
+
if (!event.time)
|
|
637
|
+
event = { time: new Date().toISOString(), ...event };
|
|
638
|
+
const tree = this.$mol_tree.fromJSON(event).clone({ type });
|
|
639
|
+
let str = tree.toString();
|
|
640
|
+
if (process[output].isTTY) {
|
|
641
|
+
str = $node.colorette[color + 'Bright'](str);
|
|
642
|
+
}
|
|
643
|
+
;
|
|
644
|
+
this.console[level](str);
|
|
645
|
+
const self = this;
|
|
646
|
+
return () => self.console.groupEnd();
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
$.$mol_log3_node_make = $mol_log3_node_make;
|
|
650
|
+
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', 'blue');
|
|
651
|
+
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', 'green');
|
|
652
|
+
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', 'red');
|
|
653
|
+
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', 'yellow');
|
|
654
|
+
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', 'magenta');
|
|
655
|
+
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', 'cyan');
|
|
656
|
+
})($ || ($ = {}));
|
|
657
|
+
//mol/log3/log3.node.ts
|
|
658
|
+
;
|
|
659
|
+
"use strict";
|
|
660
|
+
var $;
|
|
661
|
+
(function ($) {
|
|
662
|
+
function $mol_env() {
|
|
663
|
+
return {};
|
|
664
|
+
}
|
|
665
|
+
$.$mol_env = $mol_env;
|
|
666
|
+
})($ || ($ = {}));
|
|
667
|
+
//mol/env/env.ts
|
|
668
|
+
;
|
|
669
|
+
"use strict";
|
|
670
|
+
var $;
|
|
671
|
+
(function ($) {
|
|
672
|
+
$.$mol_env = function $mol_env() {
|
|
673
|
+
return this.process.env;
|
|
674
|
+
};
|
|
675
|
+
})($ || ($ = {}));
|
|
676
|
+
//mol/env/env.node.ts
|
|
677
|
+
;
|
|
678
|
+
"use strict";
|
|
679
|
+
var $;
|
|
680
|
+
(function ($) {
|
|
681
|
+
function $mol_exec(dir, command, ...args) {
|
|
682
|
+
let [app, ...args0] = command.split(' ');
|
|
683
|
+
args = [...args0, ...args];
|
|
684
|
+
this.$mol_log3_come({
|
|
685
|
+
place: '$mol_exec',
|
|
686
|
+
dir: $node.path.relative('', dir),
|
|
687
|
+
message: 'Run',
|
|
688
|
+
command: `${app} ${args.join(' ')}`,
|
|
689
|
+
});
|
|
690
|
+
var res = $node['child_process'].spawnSync(app, args, {
|
|
691
|
+
cwd: $node.path.resolve(dir),
|
|
692
|
+
shell: true,
|
|
693
|
+
env: this.$mol_env(),
|
|
694
|
+
});
|
|
695
|
+
if (res.status || res.error)
|
|
696
|
+
return $mol_fail(res.error || new Error(res.stderr.toString()));
|
|
697
|
+
if (!res.stdout)
|
|
698
|
+
res.stdout = Buffer.from([]);
|
|
699
|
+
return res;
|
|
700
|
+
}
|
|
701
|
+
$.$mol_exec = $mol_exec;
|
|
702
|
+
})($ || ($ = {}));
|
|
703
|
+
//mol/exec/exec.node.ts
|
|
704
|
+
;
|
|
705
|
+
"use strict";
|
|
706
|
+
var $;
|
|
707
|
+
(function ($) {
|
|
708
|
+
$.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
|
|
709
|
+
})($ || ($ = {}));
|
|
710
|
+
//mol/dom/context/context.node.ts
|
|
711
|
+
;
|
|
712
|
+
"use strict";
|
|
713
|
+
var $;
|
|
714
|
+
(function ($) {
|
|
715
|
+
function $mol_dom_render_children(el, childNodes) {
|
|
716
|
+
const node_set = new Set(childNodes);
|
|
717
|
+
let nextNode = el.firstChild;
|
|
718
|
+
for (let view of childNodes) {
|
|
719
|
+
if (view == null)
|
|
720
|
+
continue;
|
|
721
|
+
if (view instanceof $mol_dom_context.Node) {
|
|
722
|
+
while (true) {
|
|
723
|
+
if (!nextNode) {
|
|
724
|
+
el.appendChild(view);
|
|
725
|
+
break;
|
|
726
|
+
}
|
|
727
|
+
if (nextNode == view) {
|
|
728
|
+
nextNode = nextNode.nextSibling;
|
|
729
|
+
break;
|
|
730
|
+
}
|
|
731
|
+
else {
|
|
732
|
+
if (node_set.has(nextNode)) {
|
|
733
|
+
el.insertBefore(view, nextNode);
|
|
734
|
+
break;
|
|
735
|
+
}
|
|
736
|
+
else {
|
|
737
|
+
const nn = nextNode.nextSibling;
|
|
738
|
+
el.removeChild(nextNode);
|
|
739
|
+
nextNode = nn;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
else {
|
|
745
|
+
if (nextNode && nextNode.nodeName === '#text') {
|
|
746
|
+
const str = String(view);
|
|
747
|
+
if (nextNode.nodeValue !== str)
|
|
748
|
+
nextNode.nodeValue = str;
|
|
749
|
+
nextNode = nextNode.nextSibling;
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
|
753
|
+
el.insertBefore(textNode, nextNode);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
while (nextNode) {
|
|
758
|
+
const currNode = nextNode;
|
|
759
|
+
nextNode = currNode.nextSibling;
|
|
760
|
+
el.removeChild(currNode);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
$.$mol_dom_render_children = $mol_dom_render_children;
|
|
764
|
+
})($ || ($ = {}));
|
|
765
|
+
//mol/dom/render/children/children.ts
|
|
766
|
+
;
|
|
767
|
+
"use strict";
|
|
768
|
+
//mol/type/partial/deep/deep.ts
|
|
769
|
+
;
|
|
770
|
+
"use strict";
|
|
771
|
+
var $;
|
|
772
|
+
(function ($) {
|
|
773
|
+
$.$mol_jsx_prefix = '';
|
|
774
|
+
$.$mol_jsx_booked = null;
|
|
775
|
+
$.$mol_jsx_document = {
|
|
776
|
+
getElementById: () => null,
|
|
777
|
+
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
|
778
|
+
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
779
|
+
};
|
|
780
|
+
$.$mol_jsx_frag = '';
|
|
781
|
+
function $mol_jsx(Elem, props, ...childNodes) {
|
|
782
|
+
const id = props && props.id || '';
|
|
783
|
+
if (Elem && $.$mol_jsx_booked) {
|
|
784
|
+
if ($.$mol_jsx_booked.has(id)) {
|
|
785
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
|
|
786
|
+
}
|
|
787
|
+
else {
|
|
788
|
+
$.$mol_jsx_booked.add(id);
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
const guid = $.$mol_jsx_prefix + id;
|
|
792
|
+
let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
|
|
793
|
+
if (typeof Elem !== 'string') {
|
|
794
|
+
if ('prototype' in Elem) {
|
|
795
|
+
const view = node && node[Elem] || new Elem;
|
|
796
|
+
Object.assign(view, props);
|
|
797
|
+
view[Symbol.toStringTag] = guid;
|
|
798
|
+
view.childNodes = childNodes;
|
|
799
|
+
if (!view.ownerDocument)
|
|
800
|
+
view.ownerDocument = $.$mol_jsx_document;
|
|
801
|
+
node = view.valueOf();
|
|
802
|
+
node[Elem] = view;
|
|
803
|
+
return node;
|
|
804
|
+
}
|
|
805
|
+
else {
|
|
806
|
+
const prefix = $.$mol_jsx_prefix;
|
|
807
|
+
const booked = $.$mol_jsx_booked;
|
|
808
|
+
try {
|
|
809
|
+
$.$mol_jsx_prefix = guid;
|
|
810
|
+
$.$mol_jsx_booked = new Set;
|
|
811
|
+
return Elem(props, ...childNodes);
|
|
812
|
+
}
|
|
813
|
+
finally {
|
|
814
|
+
$.$mol_jsx_prefix = prefix;
|
|
815
|
+
$.$mol_jsx_booked = booked;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
if (!node) {
|
|
820
|
+
node = Elem
|
|
821
|
+
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
822
|
+
: $.$mol_jsx_document.createDocumentFragment();
|
|
823
|
+
}
|
|
824
|
+
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
825
|
+
if (!Elem)
|
|
826
|
+
return node;
|
|
827
|
+
for (const key in props) {
|
|
828
|
+
if (typeof props[key] === 'string') {
|
|
829
|
+
;
|
|
830
|
+
node.setAttribute(key, props[key]);
|
|
831
|
+
}
|
|
832
|
+
else if (props[key] &&
|
|
833
|
+
typeof props[key] === 'object' &&
|
|
834
|
+
Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
|
|
835
|
+
if (typeof node[key] === 'object') {
|
|
836
|
+
Object.assign(node[key], props[key]);
|
|
837
|
+
continue;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
else {
|
|
841
|
+
node[key] = props[key];
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
if (guid)
|
|
845
|
+
node.id = guid;
|
|
846
|
+
return node;
|
|
847
|
+
}
|
|
848
|
+
$.$mol_jsx = $mol_jsx;
|
|
849
|
+
})($ || ($ = {}));
|
|
850
|
+
//mol/jsx/jsx.ts
|
|
851
|
+
;
|
|
852
|
+
"use strict";
|
|
853
|
+
var $;
|
|
854
|
+
(function ($) {
|
|
855
|
+
function $mol_jsx_attach(next, action) {
|
|
856
|
+
const prev = $mol_jsx_document;
|
|
857
|
+
try {
|
|
858
|
+
$mol_jsx_document = next;
|
|
859
|
+
return action();
|
|
860
|
+
}
|
|
861
|
+
finally {
|
|
862
|
+
$mol_jsx_document = prev;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
$.$mol_jsx_attach = $mol_jsx_attach;
|
|
866
|
+
})($ || ($ = {}));
|
|
867
|
+
//mol/jsx/attach/attach.ts
|
|
868
|
+
;
|
|
869
|
+
"use strict";
|
|
870
|
+
var $;
|
|
871
|
+
(function ($) {
|
|
872
|
+
let $mol_wire_cursor;
|
|
873
|
+
(function ($mol_wire_cursor) {
|
|
874
|
+
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
|
875
|
+
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
876
|
+
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
877
|
+
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
878
|
+
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
879
|
+
})($ || ($ = {}));
|
|
880
|
+
//mol/wire/cursor/cursor.ts
|
|
881
|
+
;
|
|
882
|
+
"use strict";
|
|
883
|
+
var $;
|
|
884
|
+
(function ($) {
|
|
885
|
+
class $mol_wire_pub extends Object {
|
|
886
|
+
data = [];
|
|
887
|
+
static get [Symbol.species]() {
|
|
888
|
+
return Array;
|
|
889
|
+
}
|
|
890
|
+
sub_from = 0;
|
|
891
|
+
get sub_list() {
|
|
892
|
+
const res = [];
|
|
893
|
+
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
894
|
+
res.push(this.data[i]);
|
|
895
|
+
}
|
|
896
|
+
return res;
|
|
897
|
+
}
|
|
898
|
+
get sub_empty() {
|
|
899
|
+
return this.sub_from === this.data.length;
|
|
900
|
+
}
|
|
901
|
+
sub_on(sub, pub_pos) {
|
|
902
|
+
const pos = this.data.length;
|
|
903
|
+
this.data.push(sub, pub_pos);
|
|
904
|
+
return pos;
|
|
905
|
+
}
|
|
906
|
+
sub_off(sub_pos) {
|
|
907
|
+
if (!(sub_pos < this.data.length)) {
|
|
908
|
+
$mol_fail(new Error(`Wrong pos ${sub_pos}`));
|
|
909
|
+
}
|
|
910
|
+
const end = this.data.length - 2;
|
|
911
|
+
if (sub_pos !== end) {
|
|
912
|
+
this.peer_move(end, sub_pos);
|
|
913
|
+
}
|
|
914
|
+
this.data.pop();
|
|
915
|
+
this.data.pop();
|
|
916
|
+
if (this.data.length === this.sub_from)
|
|
917
|
+
this.reap();
|
|
918
|
+
}
|
|
919
|
+
reap() { }
|
|
920
|
+
promote() {
|
|
921
|
+
$mol_wire_auto()?.track_next(this);
|
|
922
|
+
}
|
|
923
|
+
refresh() { }
|
|
924
|
+
complete() { }
|
|
925
|
+
emit(quant = $mol_wire_cursor.stale) {
|
|
926
|
+
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
927
|
+
;
|
|
928
|
+
this.data[i].absorb(quant);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
peer_move(from_pos, to_pos) {
|
|
932
|
+
const peer = this.data[from_pos];
|
|
933
|
+
const self_pos = this.data[from_pos + 1];
|
|
934
|
+
this.data[to_pos] = peer;
|
|
935
|
+
this.data[to_pos + 1] = self_pos;
|
|
936
|
+
peer.peer_repos(self_pos, to_pos);
|
|
937
|
+
}
|
|
938
|
+
peer_repos(peer_pos, self_pos) {
|
|
939
|
+
this.data[peer_pos + 1] = self_pos;
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
$.$mol_wire_pub = $mol_wire_pub;
|
|
943
|
+
})($ || ($ = {}));
|
|
944
|
+
//mol/wire/pub/pub.ts
|
|
945
|
+
;
|
|
946
|
+
"use strict";
|
|
947
|
+
//mol/wire/sub/sub.ts
|
|
948
|
+
;
|
|
949
|
+
"use strict";
|
|
950
|
+
var $;
|
|
951
|
+
(function ($) {
|
|
952
|
+
let auto = null;
|
|
953
|
+
function $mol_wire_auto(next = auto) {
|
|
954
|
+
return auto = next;
|
|
955
|
+
}
|
|
956
|
+
$.$mol_wire_auto = $mol_wire_auto;
|
|
957
|
+
$.$mol_wire_affected = [];
|
|
958
|
+
})($ || ($ = {}));
|
|
959
|
+
//mol/wire/wire.ts
|
|
960
|
+
;
|
|
961
|
+
"use strict";
|
|
962
|
+
var $;
|
|
963
|
+
(function ($) {
|
|
964
|
+
$['devtoolsFormatters'] = $['devtoolsFormatters'] || [];
|
|
965
|
+
function $mol_dev_format_register(config) {
|
|
966
|
+
$['devtoolsFormatters'].push(config);
|
|
967
|
+
}
|
|
968
|
+
$.$mol_dev_format_register = $mol_dev_format_register;
|
|
969
|
+
$.$mol_dev_format_head = Symbol('$mol_dev_format_head');
|
|
970
|
+
$.$mol_dev_format_body = Symbol('$mol_dev_format_body');
|
|
971
|
+
$mol_dev_format_register({
|
|
972
|
+
header: (val, config = false) => {
|
|
973
|
+
if (config)
|
|
974
|
+
return null;
|
|
975
|
+
if (!val)
|
|
976
|
+
return null;
|
|
977
|
+
if ($.$mol_dev_format_head in val) {
|
|
978
|
+
return val[$.$mol_dev_format_head]();
|
|
979
|
+
}
|
|
980
|
+
if (typeof val === 'function') {
|
|
981
|
+
return $mol_dev_format_native(val);
|
|
982
|
+
}
|
|
983
|
+
return null;
|
|
984
|
+
},
|
|
985
|
+
hasBody: val => val[$.$mol_dev_format_body],
|
|
986
|
+
body: val => val[$.$mol_dev_format_body](),
|
|
987
|
+
});
|
|
988
|
+
function $mol_dev_format_native(obj) {
|
|
989
|
+
if (typeof obj === 'undefined')
|
|
990
|
+
return $.$mol_dev_format_shade('undefined');
|
|
991
|
+
if (typeof obj !== 'object' && typeof obj !== 'function')
|
|
992
|
+
return obj;
|
|
993
|
+
return [
|
|
994
|
+
'object',
|
|
995
|
+
{
|
|
996
|
+
object: obj,
|
|
997
|
+
config: true,
|
|
998
|
+
},
|
|
999
|
+
];
|
|
1000
|
+
}
|
|
1001
|
+
$.$mol_dev_format_native = $mol_dev_format_native;
|
|
1002
|
+
function $mol_dev_format_auto(obj) {
|
|
1003
|
+
if (obj == null)
|
|
1004
|
+
return $.$mol_dev_format_shade(String(obj));
|
|
1005
|
+
if (typeof obj === 'object' && $.$mol_dev_format_head in obj) {
|
|
1006
|
+
return obj[$.$mol_dev_format_head]();
|
|
1007
|
+
}
|
|
1008
|
+
return [
|
|
1009
|
+
'object',
|
|
1010
|
+
{
|
|
1011
|
+
object: obj,
|
|
1012
|
+
config: false,
|
|
1013
|
+
},
|
|
1014
|
+
];
|
|
1015
|
+
}
|
|
1016
|
+
$.$mol_dev_format_auto = $mol_dev_format_auto;
|
|
1017
|
+
function $mol_dev_format_element(element, style, ...content) {
|
|
1018
|
+
const styles = [];
|
|
1019
|
+
for (let key in style)
|
|
1020
|
+
styles.push(`${key} : ${style[key]}`);
|
|
1021
|
+
return [
|
|
1022
|
+
element,
|
|
1023
|
+
{
|
|
1024
|
+
style: styles.join(' ; '),
|
|
1025
|
+
},
|
|
1026
|
+
...content,
|
|
1027
|
+
];
|
|
1028
|
+
}
|
|
1029
|
+
$.$mol_dev_format_element = $mol_dev_format_element;
|
|
1030
|
+
function $mol_dev_format_span(style, ...content) {
|
|
1031
|
+
return $mol_dev_format_element('span', {
|
|
1032
|
+
'vertical-align': '8%',
|
|
1033
|
+
...style,
|
|
1034
|
+
}, ...content);
|
|
1035
|
+
}
|
|
1036
|
+
$.$mol_dev_format_span = $mol_dev_format_span;
|
|
1037
|
+
$.$mol_dev_format_div = $mol_dev_format_element.bind(null, 'div');
|
|
1038
|
+
$.$mol_dev_format_ol = $mol_dev_format_element.bind(null, 'ol');
|
|
1039
|
+
$.$mol_dev_format_li = $mol_dev_format_element.bind(null, 'li');
|
|
1040
|
+
$.$mol_dev_format_table = $mol_dev_format_element.bind(null, 'table');
|
|
1041
|
+
$.$mol_dev_format_tr = $mol_dev_format_element.bind(null, 'tr');
|
|
1042
|
+
$.$mol_dev_format_td = $mol_dev_format_element.bind(null, 'td');
|
|
1043
|
+
$.$mol_dev_format_accent = $mol_dev_format_span.bind(null, {
|
|
1044
|
+
'color': 'magenta',
|
|
1045
|
+
});
|
|
1046
|
+
$.$mol_dev_format_strong = $mol_dev_format_span.bind(null, {
|
|
1047
|
+
'font-weight': 'bold',
|
|
1048
|
+
});
|
|
1049
|
+
$.$mol_dev_format_string = $mol_dev_format_span.bind(null, {
|
|
1050
|
+
'color': 'green',
|
|
1051
|
+
});
|
|
1052
|
+
$.$mol_dev_format_shade = $mol_dev_format_span.bind(null, {
|
|
1053
|
+
'color': 'gray',
|
|
1054
|
+
});
|
|
1055
|
+
$.$mol_dev_format_indent = $.$mol_dev_format_div.bind(null, {
|
|
1056
|
+
'margin-left': '13px'
|
|
1057
|
+
});
|
|
1058
|
+
})($ || ($ = {}));
|
|
1059
|
+
//mol/dev/format/format.ts
|
|
1060
|
+
;
|
|
1061
|
+
"use strict";
|
|
1062
|
+
var $;
|
|
1063
|
+
(function ($) {
|
|
1064
|
+
class $mol_wire_pub_sub extends $mol_wire_pub {
|
|
1065
|
+
pub_from = 0;
|
|
1066
|
+
cursor = $mol_wire_cursor.stale;
|
|
1067
|
+
get pub_list() {
|
|
1068
|
+
const res = [];
|
|
1069
|
+
const max = this.cursor >= 0 ? this.cursor : this.sub_from;
|
|
1070
|
+
for (let i = this.pub_from; i < max; i += 2) {
|
|
1071
|
+
res.push(this.data[i]);
|
|
1072
|
+
}
|
|
1073
|
+
return res;
|
|
1074
|
+
}
|
|
1075
|
+
track_on() {
|
|
1076
|
+
this.cursor = this.pub_from;
|
|
1077
|
+
const sub = $mol_wire_auto();
|
|
1078
|
+
$mol_wire_auto(this);
|
|
1079
|
+
return sub;
|
|
1080
|
+
}
|
|
1081
|
+
promote() {
|
|
1082
|
+
if (this.cursor >= this.pub_from) {
|
|
1083
|
+
$mol_fail(new Error('Circular subscription'));
|
|
1084
|
+
}
|
|
1085
|
+
super.promote();
|
|
1086
|
+
}
|
|
1087
|
+
track_next(pub) {
|
|
1088
|
+
if (this.cursor < 0)
|
|
1089
|
+
$mol_fail(new Error('Promo to non begun sub'));
|
|
1090
|
+
if (this.cursor < this.sub_from) {
|
|
1091
|
+
const next = this.data[this.cursor];
|
|
1092
|
+
if (pub === undefined)
|
|
1093
|
+
return next ?? null;
|
|
1094
|
+
if (next === pub) {
|
|
1095
|
+
this.cursor += 2;
|
|
1096
|
+
return next;
|
|
1097
|
+
}
|
|
1098
|
+
if (next) {
|
|
1099
|
+
if (this.sub_from < this.data.length) {
|
|
1100
|
+
this.peer_move(this.sub_from, this.data.length);
|
|
1101
|
+
}
|
|
1102
|
+
this.peer_move(this.cursor, this.sub_from);
|
|
1103
|
+
this.sub_from += 2;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
else {
|
|
1107
|
+
if (pub === undefined)
|
|
1108
|
+
return null;
|
|
1109
|
+
if (this.sub_from < this.data.length) {
|
|
1110
|
+
this.peer_move(this.sub_from, this.data.length);
|
|
1111
|
+
}
|
|
1112
|
+
this.sub_from += 2;
|
|
1113
|
+
}
|
|
1114
|
+
this.data[this.cursor] = pub;
|
|
1115
|
+
this.data[this.cursor + 1] = pub.sub_on(this, this.cursor);
|
|
1116
|
+
this.cursor += 2;
|
|
1117
|
+
return pub;
|
|
1118
|
+
}
|
|
1119
|
+
track_off(sub) {
|
|
1120
|
+
$mol_wire_auto(sub);
|
|
1121
|
+
if (this.cursor < 0) {
|
|
1122
|
+
$mol_fail(new Error('End of non begun sub'));
|
|
1123
|
+
}
|
|
1124
|
+
for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
|
|
1125
|
+
const pub = this.data[cursor];
|
|
1126
|
+
pub.refresh();
|
|
1127
|
+
}
|
|
1128
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
1129
|
+
}
|
|
1130
|
+
pub_off(sub_pos) {
|
|
1131
|
+
this.data[sub_pos] = undefined;
|
|
1132
|
+
this.data[sub_pos + 1] = undefined;
|
|
1133
|
+
}
|
|
1134
|
+
destructor() {
|
|
1135
|
+
for (let cursor = this.data.length - 2; cursor >= this.sub_from; cursor -= 2) {
|
|
1136
|
+
const sub = this.data[cursor];
|
|
1137
|
+
const pos = this.data[cursor + 1];
|
|
1138
|
+
sub.pub_off(pos);
|
|
1139
|
+
this.data.pop();
|
|
1140
|
+
this.data.pop();
|
|
1141
|
+
}
|
|
1142
|
+
this.cursor = this.pub_from;
|
|
1143
|
+
this.track_cut();
|
|
1144
|
+
this.cursor = $mol_wire_cursor.final;
|
|
1145
|
+
}
|
|
1146
|
+
track_cut() {
|
|
1147
|
+
if (this.cursor < this.pub_from) {
|
|
1148
|
+
$mol_fail(new Error('Cut of non begun sub'));
|
|
1149
|
+
}
|
|
1150
|
+
let tail = 0;
|
|
1151
|
+
for (let cursor = this.cursor; cursor < this.sub_from; cursor += 2) {
|
|
1152
|
+
const pub = this.data[cursor];
|
|
1153
|
+
pub?.sub_off(this.data[cursor + 1]);
|
|
1154
|
+
if (this.sub_from < this.data.length) {
|
|
1155
|
+
this.peer_move(this.data.length - 2, cursor);
|
|
1156
|
+
this.data.pop();
|
|
1157
|
+
this.data.pop();
|
|
1158
|
+
}
|
|
1159
|
+
else {
|
|
1160
|
+
++tail;
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
for (; tail; --tail) {
|
|
1164
|
+
this.data.pop();
|
|
1165
|
+
this.data.pop();
|
|
1166
|
+
}
|
|
1167
|
+
this.sub_from = this.cursor;
|
|
1168
|
+
}
|
|
1169
|
+
complete() { }
|
|
1170
|
+
complete_pubs() {
|
|
1171
|
+
const limit = this.cursor < 0 ? this.sub_from : this.cursor;
|
|
1172
|
+
for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
|
|
1173
|
+
const pub = this.data[cursor];
|
|
1174
|
+
pub?.complete();
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
absorb(quant = $mol_wire_cursor.stale) {
|
|
1178
|
+
if (this.cursor === $mol_wire_cursor.final)
|
|
1179
|
+
return;
|
|
1180
|
+
if (this.cursor >= quant)
|
|
1181
|
+
return;
|
|
1182
|
+
this.cursor = quant;
|
|
1183
|
+
this.emit($mol_wire_cursor.doubt);
|
|
1184
|
+
}
|
|
1185
|
+
[$mol_dev_format_head]() {
|
|
1186
|
+
return $mol_dev_format_native(this);
|
|
1187
|
+
}
|
|
1188
|
+
get pub_empty() {
|
|
1189
|
+
return this.sub_from === this.pub_from;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
$.$mol_wire_pub_sub = $mol_wire_pub_sub;
|
|
1193
|
+
})($ || ($ = {}));
|
|
1194
|
+
//mol/wire/pub/sub/sub.ts
|
|
1195
|
+
;
|
|
1196
|
+
"use strict";
|
|
1197
|
+
var $;
|
|
1198
|
+
(function ($) {
|
|
1199
|
+
class $mol_after_timeout extends $mol_object2 {
|
|
1200
|
+
delay;
|
|
1201
|
+
task;
|
|
1202
|
+
id;
|
|
1203
|
+
constructor(delay, task) {
|
|
1204
|
+
super();
|
|
1205
|
+
this.delay = delay;
|
|
1206
|
+
this.task = task;
|
|
1207
|
+
this.id = setTimeout(task, delay);
|
|
1208
|
+
}
|
|
1209
|
+
destructor() {
|
|
1210
|
+
clearTimeout(this.id);
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
$.$mol_after_timeout = $mol_after_timeout;
|
|
1214
|
+
})($ || ($ = {}));
|
|
1215
|
+
//mol/after/timeout/timeout.ts
|
|
1216
|
+
;
|
|
1217
|
+
"use strict";
|
|
1218
|
+
var $;
|
|
1219
|
+
(function ($) {
|
|
1220
|
+
class $mol_after_frame extends $mol_after_timeout {
|
|
1221
|
+
task;
|
|
1222
|
+
constructor(task) {
|
|
1223
|
+
super(16, task);
|
|
1224
|
+
this.task = task;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
$.$mol_after_frame = $mol_after_frame;
|
|
1228
|
+
})($ || ($ = {}));
|
|
1229
|
+
//mol/after/frame/frame.node.ts
|
|
1230
|
+
;
|
|
1231
|
+
"use strict";
|
|
1232
|
+
var $;
|
|
1233
|
+
(function ($) {
|
|
1234
|
+
const handled = new WeakSet();
|
|
1235
|
+
class $mol_wire_fiber extends $mol_wire_pub_sub {
|
|
1236
|
+
task;
|
|
1237
|
+
host;
|
|
1238
|
+
static warm = true;
|
|
1239
|
+
static planning = new Set();
|
|
1240
|
+
static reaping = new Set();
|
|
1241
|
+
static plan_task = null;
|
|
1242
|
+
static plan() {
|
|
1243
|
+
if (this.plan_task)
|
|
1244
|
+
return;
|
|
1245
|
+
this.plan_task = new $mol_after_frame(() => {
|
|
1246
|
+
try {
|
|
1247
|
+
this.sync();
|
|
1248
|
+
}
|
|
1249
|
+
finally {
|
|
1250
|
+
$mol_wire_fiber.plan_task = null;
|
|
1251
|
+
}
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
static sync() {
|
|
1255
|
+
while (this.planning.size) {
|
|
1256
|
+
const fibers = this.planning;
|
|
1257
|
+
this.planning = new Set;
|
|
1258
|
+
for (const fiber of fibers) {
|
|
1259
|
+
fiber.refresh();
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
while (this.reaping.size) {
|
|
1263
|
+
const fibers = this.reaping;
|
|
1264
|
+
this.reaping = new Set;
|
|
1265
|
+
for (const fiber of fibers) {
|
|
1266
|
+
if (!fiber.sub_empty)
|
|
1267
|
+
continue;
|
|
1268
|
+
fiber.destructor();
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
cache = undefined;
|
|
1273
|
+
get args() {
|
|
1274
|
+
return this.data.slice(0, this.pub_from);
|
|
1275
|
+
}
|
|
1276
|
+
result() {
|
|
1277
|
+
if (this.cache instanceof Promise)
|
|
1278
|
+
return;
|
|
1279
|
+
if (this.cache instanceof Error)
|
|
1280
|
+
return;
|
|
1281
|
+
return this.cache;
|
|
1282
|
+
}
|
|
1283
|
+
field() {
|
|
1284
|
+
return this.task.name + '()';
|
|
1285
|
+
}
|
|
1286
|
+
constructor(id, task, host, ...args) {
|
|
1287
|
+
super();
|
|
1288
|
+
this.task = task;
|
|
1289
|
+
this.host = host;
|
|
1290
|
+
this.data.push(...args);
|
|
1291
|
+
this.pub_from = this.sub_from = args.length;
|
|
1292
|
+
this[Symbol.toStringTag] = id;
|
|
1293
|
+
}
|
|
1294
|
+
plan() {
|
|
1295
|
+
$mol_wire_fiber.planning.add(this);
|
|
1296
|
+
$mol_wire_fiber.plan();
|
|
1297
|
+
}
|
|
1298
|
+
reap() {
|
|
1299
|
+
$mol_wire_fiber.reaping.add(this);
|
|
1300
|
+
$mol_wire_fiber.plan();
|
|
1301
|
+
}
|
|
1302
|
+
toString() {
|
|
1303
|
+
return this[Symbol.toStringTag];
|
|
1304
|
+
}
|
|
1305
|
+
toJSON() {
|
|
1306
|
+
return this[Symbol.toStringTag];
|
|
1307
|
+
}
|
|
1308
|
+
[$mol_dev_format_head]() {
|
|
1309
|
+
const cursor = {
|
|
1310
|
+
[-1]: '🔴',
|
|
1311
|
+
[-2]: '🟡',
|
|
1312
|
+
[-3]: '🟢',
|
|
1313
|
+
[-4]: '🔵',
|
|
1314
|
+
}[this.cursor] ?? this.cursor.toString();
|
|
1315
|
+
return $mol_dev_format_div({}, $mol_dev_format_native(this), $mol_dev_format_shade(cursor + ' '), $mol_dev_format_auto(this.cache));
|
|
1316
|
+
}
|
|
1317
|
+
get $() {
|
|
1318
|
+
return (this.host ?? this.task)['$'];
|
|
1319
|
+
}
|
|
1320
|
+
emit(quant = $mol_wire_cursor.stale) {
|
|
1321
|
+
if (this.sub_empty)
|
|
1322
|
+
this.plan();
|
|
1323
|
+
else
|
|
1324
|
+
super.emit(quant);
|
|
1325
|
+
}
|
|
1326
|
+
refresh() {
|
|
1327
|
+
if (this.cursor === $mol_wire_cursor.fresh)
|
|
1328
|
+
return;
|
|
1329
|
+
if (this.cursor === $mol_wire_cursor.final)
|
|
1330
|
+
return;
|
|
1331
|
+
check: if (this.cursor === $mol_wire_cursor.doubt) {
|
|
1332
|
+
for (let i = this.pub_from; i < this.sub_from; i += 2) {
|
|
1333
|
+
;
|
|
1334
|
+
this.data[i]?.refresh();
|
|
1335
|
+
if (this.cursor !== $mol_wire_cursor.doubt)
|
|
1336
|
+
break check;
|
|
1337
|
+
}
|
|
1338
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
1339
|
+
return;
|
|
1340
|
+
}
|
|
1341
|
+
const bu = this.track_on();
|
|
1342
|
+
let result;
|
|
1343
|
+
try {
|
|
1344
|
+
switch (this.pub_from) {
|
|
1345
|
+
case 0:
|
|
1346
|
+
result = this.task.call(this.host);
|
|
1347
|
+
break;
|
|
1348
|
+
case 1:
|
|
1349
|
+
result = this.task.call(this.host, this.data[0]);
|
|
1350
|
+
break;
|
|
1351
|
+
default:
|
|
1352
|
+
result = this.task.call(this.host, ...this.data.slice(0, this.pub_from));
|
|
1353
|
+
break;
|
|
1354
|
+
}
|
|
1355
|
+
if (result instanceof Promise) {
|
|
1356
|
+
const put = (res) => {
|
|
1357
|
+
if (this.cache === result)
|
|
1358
|
+
this.put(res);
|
|
1359
|
+
return res;
|
|
1360
|
+
};
|
|
1361
|
+
result = Object.assign(result.then(put, put), {
|
|
1362
|
+
destructor: result['destructor']
|
|
1363
|
+
});
|
|
1364
|
+
handled.add(result);
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
catch (error) {
|
|
1368
|
+
if (error instanceof Error || error instanceof Promise) {
|
|
1369
|
+
result = error;
|
|
1370
|
+
}
|
|
1371
|
+
else {
|
|
1372
|
+
result = new Error(String(error), { cause: error });
|
|
1373
|
+
}
|
|
1374
|
+
if (result instanceof Promise && !handled.has(result)) {
|
|
1375
|
+
result = Object.assign(result.finally(() => {
|
|
1376
|
+
if (this.cache === result)
|
|
1377
|
+
this.absorb();
|
|
1378
|
+
}), {
|
|
1379
|
+
destructor: result['destructor']
|
|
1380
|
+
});
|
|
1381
|
+
handled.add(result);
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
if (!(result instanceof Promise)) {
|
|
1385
|
+
this.track_cut();
|
|
1386
|
+
}
|
|
1387
|
+
this.track_off(bu);
|
|
1388
|
+
this.put(result);
|
|
1389
|
+
}
|
|
1390
|
+
sync() {
|
|
1391
|
+
if (!$mol_wire_fiber.warm) {
|
|
1392
|
+
return this.result();
|
|
1393
|
+
}
|
|
1394
|
+
this.promote();
|
|
1395
|
+
this.refresh();
|
|
1396
|
+
if (this.cache instanceof Error) {
|
|
1397
|
+
return $mol_fail_hidden(this.cache);
|
|
1398
|
+
}
|
|
1399
|
+
if (this.cache instanceof Promise) {
|
|
1400
|
+
return $mol_fail_hidden(this.cache);
|
|
1401
|
+
}
|
|
1402
|
+
return this.cache;
|
|
1403
|
+
}
|
|
1404
|
+
async async() {
|
|
1405
|
+
while (true) {
|
|
1406
|
+
this.refresh();
|
|
1407
|
+
if (this.cache instanceof Error) {
|
|
1408
|
+
$mol_fail_hidden(this.cache);
|
|
1409
|
+
}
|
|
1410
|
+
if (!(this.cache instanceof Promise))
|
|
1411
|
+
return this.cache;
|
|
1412
|
+
await this.cache;
|
|
1413
|
+
if (this.cursor === $mol_wire_cursor.final) {
|
|
1414
|
+
await new Promise(() => { });
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
$.$mol_wire_fiber = $mol_wire_fiber;
|
|
1420
|
+
})($ || ($ = {}));
|
|
1421
|
+
//mol/wire/fiber/fiber.ts
|
|
1422
|
+
;
|
|
1423
|
+
"use strict";
|
|
1424
|
+
var $;
|
|
1425
|
+
(function ($) {
|
|
1426
|
+
function $mol_guid(length = 8, exists = () => false) {
|
|
1427
|
+
for (;;) {
|
|
1428
|
+
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
1429
|
+
if (exists(id))
|
|
1430
|
+
continue;
|
|
1431
|
+
return id;
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
$.$mol_guid = $mol_guid;
|
|
1435
|
+
})($ || ($ = {}));
|
|
1436
|
+
//mol/guid/guid.ts
|
|
1437
|
+
;
|
|
1438
|
+
"use strict";
|
|
1439
|
+
var $;
|
|
1440
|
+
(function ($) {
|
|
1441
|
+
$.$mol_key_store = new WeakMap();
|
|
1442
|
+
function $mol_key(value) {
|
|
1443
|
+
if (!value)
|
|
1444
|
+
return JSON.stringify(value);
|
|
1445
|
+
if (typeof value !== 'object' && typeof value !== 'function')
|
|
1446
|
+
return JSON.stringify(value);
|
|
1447
|
+
return JSON.stringify(value, (field, value) => {
|
|
1448
|
+
if (!value)
|
|
1449
|
+
return value;
|
|
1450
|
+
if (typeof value !== 'object' && typeof value !== 'function')
|
|
1451
|
+
return value;
|
|
1452
|
+
if (Array.isArray(value))
|
|
1453
|
+
return value;
|
|
1454
|
+
const proto = Reflect.getPrototypeOf(value);
|
|
1455
|
+
if (!proto)
|
|
1456
|
+
return value;
|
|
1457
|
+
if (Reflect.getPrototypeOf(proto) === null)
|
|
1458
|
+
return value;
|
|
1459
|
+
if ('toJSON' in value)
|
|
1460
|
+
return value;
|
|
1461
|
+
if (value instanceof RegExp)
|
|
1462
|
+
return value.toString();
|
|
1463
|
+
let key = $.$mol_key_store.get(value);
|
|
1464
|
+
if (key)
|
|
1465
|
+
return key;
|
|
1466
|
+
key = $mol_guid();
|
|
1467
|
+
$.$mol_key_store.set(value, key);
|
|
1468
|
+
return key;
|
|
1469
|
+
});
|
|
1470
|
+
}
|
|
1471
|
+
$.$mol_key = $mol_key;
|
|
1472
|
+
})($ || ($ = {}));
|
|
1473
|
+
//mol/key/key.ts
|
|
1474
|
+
;
|
|
1475
|
+
"use strict";
|
|
1476
|
+
var $;
|
|
1477
|
+
(function ($) {
|
|
1478
|
+
$.$mol_compare_deep_cache = new WeakMap();
|
|
1479
|
+
function $mol_compare_deep(left, right) {
|
|
1480
|
+
if (Object.is(left, right))
|
|
1481
|
+
return true;
|
|
1482
|
+
if (left === null)
|
|
1483
|
+
return false;
|
|
1484
|
+
if (right === null)
|
|
1485
|
+
return false;
|
|
1486
|
+
if (typeof left !== 'object')
|
|
1487
|
+
return false;
|
|
1488
|
+
if (typeof right !== 'object')
|
|
1489
|
+
return false;
|
|
1490
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
|
1491
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
|
1492
|
+
if (left_proto !== right_proto)
|
|
1493
|
+
return false;
|
|
1494
|
+
if (left instanceof Boolean)
|
|
1495
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1496
|
+
if (left instanceof Number)
|
|
1497
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1498
|
+
if (left instanceof String)
|
|
1499
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1500
|
+
if (left instanceof Date)
|
|
1501
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1502
|
+
if (left instanceof RegExp)
|
|
1503
|
+
return left.source === right['source'] && left.flags === right['flags'];
|
|
1504
|
+
let left_cache = $.$mol_compare_deep_cache.get(left);
|
|
1505
|
+
if (left_cache) {
|
|
1506
|
+
const right_cache = left_cache.get(right);
|
|
1507
|
+
if (typeof right_cache === 'boolean')
|
|
1508
|
+
return right_cache;
|
|
1509
|
+
}
|
|
1510
|
+
else {
|
|
1511
|
+
left_cache = new WeakMap([[right, true]]);
|
|
1512
|
+
$.$mol_compare_deep_cache.set(left, left_cache);
|
|
1513
|
+
}
|
|
1514
|
+
let result;
|
|
1515
|
+
try {
|
|
1516
|
+
if (left_proto && !Reflect.getPrototypeOf(left_proto))
|
|
1517
|
+
result = compare_pojo(left, right);
|
|
1518
|
+
else if (Array.isArray(left))
|
|
1519
|
+
result = compare_array(left, right);
|
|
1520
|
+
else if (left instanceof Set)
|
|
1521
|
+
result = compare_set(left, right);
|
|
1522
|
+
else if (left instanceof Map)
|
|
1523
|
+
result = compare_map(left, right);
|
|
1524
|
+
else if (left instanceof Error)
|
|
1525
|
+
result = left.stack === right.stack;
|
|
1526
|
+
else if (ArrayBuffer.isView(left))
|
|
1527
|
+
result = compare_buffer(left, right);
|
|
1528
|
+
else if (Symbol.toPrimitive in left)
|
|
1529
|
+
result = compare_primitive(left, right);
|
|
1530
|
+
else
|
|
1531
|
+
result = false;
|
|
1532
|
+
}
|
|
1533
|
+
finally {
|
|
1534
|
+
left_cache.set(right, result);
|
|
1535
|
+
}
|
|
1536
|
+
return result;
|
|
1537
|
+
}
|
|
1538
|
+
$.$mol_compare_deep = $mol_compare_deep;
|
|
1539
|
+
function compare_array(left, right) {
|
|
1540
|
+
const len = left.length;
|
|
1541
|
+
if (len !== right.length)
|
|
1542
|
+
return false;
|
|
1543
|
+
for (let i = 0; i < len; ++i) {
|
|
1544
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
|
1545
|
+
return false;
|
|
1546
|
+
}
|
|
1547
|
+
return true;
|
|
1548
|
+
}
|
|
1549
|
+
function compare_buffer(left, right) {
|
|
1550
|
+
const len = left.byteLength;
|
|
1551
|
+
if (len !== right.byteLength)
|
|
1552
|
+
return false;
|
|
1553
|
+
for (let i = 0; i < len; ++i) {
|
|
1554
|
+
if (left[i] !== right[i])
|
|
1555
|
+
return false;
|
|
1556
|
+
}
|
|
1557
|
+
return true;
|
|
1558
|
+
}
|
|
1559
|
+
function compare_iterator(left, right, compare) {
|
|
1560
|
+
while (true) {
|
|
1561
|
+
const left_next = left.next();
|
|
1562
|
+
const right_next = right.next();
|
|
1563
|
+
if (left_next.done !== right_next.done)
|
|
1564
|
+
return false;
|
|
1565
|
+
if (left_next.done)
|
|
1566
|
+
break;
|
|
1567
|
+
if (!compare(left_next.value, right_next.value))
|
|
1568
|
+
return false;
|
|
1569
|
+
}
|
|
1570
|
+
return true;
|
|
1571
|
+
}
|
|
1572
|
+
function compare_set(left, right) {
|
|
1573
|
+
if (left.size !== right.size)
|
|
1574
|
+
return false;
|
|
1575
|
+
return compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
1576
|
+
}
|
|
1577
|
+
function compare_map(left, right) {
|
|
1578
|
+
if (left.size !== right.size)
|
|
1579
|
+
return false;
|
|
1580
|
+
return compare_iterator(left.keys(), right.keys(), Object.is)
|
|
1581
|
+
&& compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
1582
|
+
}
|
|
1583
|
+
function compare_pojo(left, right) {
|
|
1584
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
|
1585
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
|
1586
|
+
if (left_keys.length !== right_keys.length)
|
|
1587
|
+
return false;
|
|
1588
|
+
for (let key of left_keys) {
|
|
1589
|
+
if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
|
|
1590
|
+
return false;
|
|
1591
|
+
}
|
|
1592
|
+
return true;
|
|
1593
|
+
}
|
|
1594
|
+
function compare_primitive(left, right) {
|
|
1595
|
+
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
1596
|
+
}
|
|
1597
|
+
})($ || ($ = {}));
|
|
1598
|
+
//mol/compare/deep/deep.ts
|
|
1599
|
+
;
|
|
1600
|
+
"use strict";
|
|
1601
|
+
var $;
|
|
1602
|
+
(function ($) {
|
|
1603
|
+
class $mol_wire_task extends $mol_wire_fiber {
|
|
1604
|
+
static getter(task) {
|
|
1605
|
+
return function $mol_wire_task_get(host, args) {
|
|
1606
|
+
const existen = $mol_wire_auto()?.track_next();
|
|
1607
|
+
reuse: if (existen) {
|
|
1608
|
+
if (!(existen instanceof $mol_wire_task))
|
|
1609
|
+
break reuse;
|
|
1610
|
+
if (existen.host !== host)
|
|
1611
|
+
break reuse;
|
|
1612
|
+
if (existen.task !== task)
|
|
1613
|
+
break reuse;
|
|
1614
|
+
if (!$mol_compare_deep(existen.args, args))
|
|
1615
|
+
break reuse;
|
|
1616
|
+
return existen;
|
|
1617
|
+
}
|
|
1618
|
+
return new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, ...args);
|
|
1619
|
+
};
|
|
1620
|
+
}
|
|
1621
|
+
complete() {
|
|
1622
|
+
if (this.sub_empty)
|
|
1623
|
+
this.destructor();
|
|
1624
|
+
}
|
|
1625
|
+
put(next) {
|
|
1626
|
+
const prev = this.cache;
|
|
1627
|
+
this.cache = next;
|
|
1628
|
+
if (next instanceof Promise) {
|
|
1629
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
1630
|
+
if (next !== prev)
|
|
1631
|
+
this.emit();
|
|
1632
|
+
return next;
|
|
1633
|
+
}
|
|
1634
|
+
this.cursor = $mol_wire_cursor.final;
|
|
1635
|
+
if (this.sub_empty)
|
|
1636
|
+
this.destructor();
|
|
1637
|
+
else if (next !== prev)
|
|
1638
|
+
this.emit();
|
|
1639
|
+
return next;
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
$.$mol_wire_task = $mol_wire_task;
|
|
1643
|
+
})($ || ($ = {}));
|
|
1644
|
+
//mol/wire/task/task.ts
|
|
1645
|
+
;
|
|
1646
|
+
"use strict";
|
|
1647
|
+
var $;
|
|
1648
|
+
(function ($) {
|
|
1649
|
+
function $mol_wire_method(host, field, descr) {
|
|
1650
|
+
if (!descr)
|
|
1651
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
1652
|
+
const orig = descr?.value ?? host[field];
|
|
1653
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
1654
|
+
if (typeof sup[field] === 'function') {
|
|
1655
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1656
|
+
}
|
|
1657
|
+
const temp = $mol_wire_task.getter(orig);
|
|
1658
|
+
const value = function (...args) {
|
|
1659
|
+
const fiber = temp(this ?? null, args);
|
|
1660
|
+
return fiber.sync();
|
|
1661
|
+
};
|
|
1662
|
+
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
1663
|
+
Object.assign(value, { orig });
|
|
1664
|
+
const descr2 = { ...descr, value };
|
|
1665
|
+
Reflect.defineProperty(host, field, descr2);
|
|
1666
|
+
return descr2;
|
|
1667
|
+
}
|
|
1668
|
+
$.$mol_wire_method = $mol_wire_method;
|
|
1669
|
+
})($ || ($ = {}));
|
|
1670
|
+
//mol/wire/method/method.ts
|
|
1671
|
+
;
|
|
1672
|
+
"use strict";
|
|
1673
|
+
var $;
|
|
1674
|
+
(function ($) {
|
|
1675
|
+
class $mol_wire_atom extends $mol_wire_fiber {
|
|
1676
|
+
static getter(task, keys) {
|
|
1677
|
+
const field = task.name + '()';
|
|
1678
|
+
if (keys) {
|
|
1679
|
+
return function $mol_wire_atom_get(host, args) {
|
|
1680
|
+
let dict, key, fiber;
|
|
1681
|
+
key = `${host?.[Symbol.toStringTag] ?? host}.${task.name}(${args.map(v => $mol_key(v)).join(',')})`;
|
|
1682
|
+
dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
1683
|
+
if (dict) {
|
|
1684
|
+
const existen = dict.get(key);
|
|
1685
|
+
if (existen)
|
|
1686
|
+
return existen;
|
|
1687
|
+
}
|
|
1688
|
+
else {
|
|
1689
|
+
dict = (host ?? task)[field] = new Map();
|
|
1690
|
+
}
|
|
1691
|
+
fiber = new $mol_wire_atom(key, task, host, ...args);
|
|
1692
|
+
dict.set(key, fiber);
|
|
1693
|
+
return fiber;
|
|
1694
|
+
};
|
|
1695
|
+
}
|
|
1696
|
+
else {
|
|
1697
|
+
return function $mol_wire_atom_get(host, args) {
|
|
1698
|
+
const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
1699
|
+
if (existen)
|
|
1700
|
+
return existen;
|
|
1701
|
+
const key = `${host?.[Symbol.toStringTag] ?? host}.${field}`;
|
|
1702
|
+
const fiber = new $mol_wire_atom(key, task, host, ...args);
|
|
1703
|
+
(host ?? task)[field] = fiber;
|
|
1704
|
+
return fiber;
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
recall(...args) {
|
|
1709
|
+
if (this.cursor > $mol_wire_cursor.fresh) {
|
|
1710
|
+
try {
|
|
1711
|
+
this.once();
|
|
1712
|
+
}
|
|
1713
|
+
catch (error) {
|
|
1714
|
+
if (error instanceof Promise)
|
|
1715
|
+
$mol_fail_hidden(error);
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
return this.put(this.task.call(this.host, ...args));
|
|
1719
|
+
}
|
|
1720
|
+
once() {
|
|
1721
|
+
return this.sync();
|
|
1722
|
+
}
|
|
1723
|
+
destructor() {
|
|
1724
|
+
super.destructor();
|
|
1725
|
+
const prev = this.cache;
|
|
1726
|
+
if ($mol_owning_check(this, prev)) {
|
|
1727
|
+
prev.destructor();
|
|
1728
|
+
}
|
|
1729
|
+
if (this.pub_from === 0) {
|
|
1730
|
+
;
|
|
1731
|
+
(this.host ?? this.task)[this.field()] = null;
|
|
1732
|
+
}
|
|
1733
|
+
else {
|
|
1734
|
+
;
|
|
1735
|
+
(this.host ?? this.task)[this.field()].delete(this[Symbol.toStringTag]);
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
put(next) {
|
|
1739
|
+
const prev = this.cache;
|
|
1740
|
+
if (next !== prev) {
|
|
1741
|
+
if ($mol_owning_check(this, prev)) {
|
|
1742
|
+
prev.destructor();
|
|
1743
|
+
}
|
|
1744
|
+
this.cache = next;
|
|
1745
|
+
if ($mol_owning_catch(this, next)) {
|
|
1746
|
+
try {
|
|
1747
|
+
next[Symbol.toStringTag] = this[Symbol.toStringTag];
|
|
1748
|
+
}
|
|
1749
|
+
catch { }
|
|
1750
|
+
}
|
|
1751
|
+
if (this.sub_from < this.data.length) {
|
|
1752
|
+
if (!$mol_compare_deep(prev, next)) {
|
|
1753
|
+
this.emit();
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
1758
|
+
if (next instanceof Promise)
|
|
1759
|
+
return next;
|
|
1760
|
+
this.complete_pubs();
|
|
1761
|
+
return next;
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
__decorate([
|
|
1765
|
+
$mol_wire_method
|
|
1766
|
+
], $mol_wire_atom.prototype, "recall", null);
|
|
1767
|
+
__decorate([
|
|
1768
|
+
$mol_wire_method
|
|
1769
|
+
], $mol_wire_atom.prototype, "once", null);
|
|
1770
|
+
$.$mol_wire_atom = $mol_wire_atom;
|
|
1771
|
+
})($ || ($ = {}));
|
|
1772
|
+
//mol/wire/atom/atom.ts
|
|
1773
|
+
;
|
|
1774
|
+
"use strict";
|
|
1775
|
+
var $;
|
|
1776
|
+
(function ($) {
|
|
1777
|
+
function $mol_wire_mem(keys) {
|
|
1778
|
+
const wrap = $mol_wire_mem_func(keys);
|
|
1779
|
+
return (host, field, descr) => {
|
|
1780
|
+
if (!descr)
|
|
1781
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
1782
|
+
const orig = descr?.value ?? host[field];
|
|
1783
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
1784
|
+
if (typeof sup[field] === 'function') {
|
|
1785
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1786
|
+
}
|
|
1787
|
+
const descr2 = {
|
|
1788
|
+
...descr,
|
|
1789
|
+
value: wrap(orig)
|
|
1790
|
+
};
|
|
1791
|
+
Reflect.defineProperty(host, field, descr2);
|
|
1792
|
+
return descr2;
|
|
1793
|
+
};
|
|
1794
|
+
}
|
|
1795
|
+
$.$mol_wire_mem = $mol_wire_mem;
|
|
1796
|
+
function $mol_wire_mem_func(keys) {
|
|
1797
|
+
return (func) => {
|
|
1798
|
+
const persist = $mol_wire_atom.getter(func, keys);
|
|
1799
|
+
const wrapper = function (...args) {
|
|
1800
|
+
let atom = persist(this, args.slice(0, keys));
|
|
1801
|
+
if (args.length <= keys || args[keys] === undefined) {
|
|
1802
|
+
if (!$mol_wire_fiber.warm)
|
|
1803
|
+
return atom.sync();
|
|
1804
|
+
if ($mol_wire_auto() instanceof $mol_wire_task) {
|
|
1805
|
+
return atom.once();
|
|
1806
|
+
}
|
|
1807
|
+
else {
|
|
1808
|
+
return atom.sync();
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
return atom.recall(...args);
|
|
1812
|
+
};
|
|
1813
|
+
Object.defineProperty(wrapper, 'name', { value: func.name + ' ' });
|
|
1814
|
+
Object.assign(wrapper, { orig: func });
|
|
1815
|
+
return wrapper;
|
|
1816
|
+
};
|
|
1817
|
+
}
|
|
1818
|
+
$.$mol_wire_mem_func = $mol_wire_mem_func;
|
|
1819
|
+
})($ || ($ = {}));
|
|
1820
|
+
//mol/wire/mem/mem.ts
|
|
1821
|
+
;
|
|
1822
|
+
"use strict";
|
|
1823
|
+
var $;
|
|
1824
|
+
(function ($) {
|
|
1825
|
+
$.$mol_mem = $mol_wire_mem(0);
|
|
1826
|
+
$.$mol_mem_key = $mol_wire_mem(1);
|
|
1827
|
+
$.$mol_mem_key2 = $mol_wire_mem(2);
|
|
1828
|
+
$.$mol_mem_key3 = $mol_wire_mem(3);
|
|
1829
|
+
})($ || ($ = {}));
|
|
1830
|
+
//mol/mem/mem.ts
|
|
1831
|
+
;
|
|
1832
|
+
"use strict";
|
|
1833
|
+
var $;
|
|
1834
|
+
(function ($) {
|
|
1835
|
+
class $mol_jsx_view extends $mol_object2 {
|
|
1836
|
+
static of(node) {
|
|
1837
|
+
return node[this];
|
|
1838
|
+
}
|
|
1839
|
+
attributes;
|
|
1840
|
+
ownerDocument;
|
|
1841
|
+
get childNodes() {
|
|
1842
|
+
return this._kids();
|
|
1843
|
+
}
|
|
1844
|
+
set childNodes(next) {
|
|
1845
|
+
this._kids(next);
|
|
1846
|
+
}
|
|
1847
|
+
_kids(next = []) { return next; }
|
|
1848
|
+
valueOf() {
|
|
1849
|
+
const prefix = $mol_jsx_prefix;
|
|
1850
|
+
const booked = $mol_jsx_booked;
|
|
1851
|
+
const document = $mol_jsx_document;
|
|
1852
|
+
try {
|
|
1853
|
+
$mol_jsx_prefix = this[Symbol.toStringTag];
|
|
1854
|
+
$mol_jsx_booked = new Set;
|
|
1855
|
+
$mol_jsx_document = this.ownerDocument;
|
|
1856
|
+
return this.render();
|
|
1857
|
+
}
|
|
1858
|
+
finally {
|
|
1859
|
+
$mol_jsx_prefix = prefix;
|
|
1860
|
+
$mol_jsx_booked = booked;
|
|
1861
|
+
$mol_jsx_document = document;
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
render() {
|
|
1865
|
+
return $mol_fail(new Error(`render() isn't implemented`));
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
__decorate([
|
|
1869
|
+
$mol_mem
|
|
1870
|
+
], $mol_jsx_view.prototype, "_kids", null);
|
|
1871
|
+
__decorate([
|
|
1872
|
+
$mol_mem
|
|
1873
|
+
], $mol_jsx_view.prototype, "valueOf", null);
|
|
1874
|
+
$.$mol_jsx_view = $mol_jsx_view;
|
|
1875
|
+
})($ || ($ = {}));
|
|
1876
|
+
//mol/jsx/view/view.tsx
|
|
1877
|
+
;
|
|
1878
|
+
export default $
|
|
1879
|
+
//# sourceMappingURL=node.esm.js.map
|