@xpell/core 2.0.1 → 2.0.2
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/dist/XObject.d.ts +24 -1
- package/dist/Xpell.d.ts +1 -1
- package/dist/xpell-core.cjs.js +2 -2
- package/dist/xpell-core.es.js +407 -382
- package/docs/AGENTS.md +10 -0
- package/package.json +2 -2
- package/docs/Codex.md +0 -138
- package/docs/Codex_Skills/SKILL.md +0 -184
- package/docs/Codex_Skills/SKILL_API_MAP.md +0 -122
- package/docs/Codex_Skills/SKILL_CHECKLIST.md +0 -18
package/dist/xpell-core.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
1
|
+
var B = (o) => {
|
|
2
2
|
throw TypeError(o);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
class
|
|
4
|
+
var J = (o, e, t) => e.has(o) || B("Cannot " + t);
|
|
5
|
+
var f = (o, e, t) => (J(o, e, "read from private field"), t ? t.call(o) : e.get(o)), V = (o, e, t) => e.has(o) ? B("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), z = (o, e, t, s) => (J(o, e, "write to private field"), s ? s.call(o, t) : e.set(o, t), t);
|
|
6
|
+
class Y {
|
|
7
7
|
/**
|
|
8
8
|
* Create ignore list for parser to ignore spell words
|
|
9
9
|
* @param list - comma-separated list of words
|
|
@@ -30,8 +30,8 @@ class Q {
|
|
|
30
30
|
if (t && typeof t.getRandomValues == "function") {
|
|
31
31
|
const i = new Uint8Array(16);
|
|
32
32
|
t.getRandomValues(i), i[6] = i[6] & 15 | 64, i[8] = i[8] & 63 | 128;
|
|
33
|
-
const
|
|
34
|
-
return
|
|
33
|
+
const c = Array.from(i, (a) => a.toString(16).padStart(2, "0"));
|
|
34
|
+
return c.slice(0, 4).join("") + "-" + c.slice(4, 6).join("") + "-" + c.slice(6, 8).join("") + "-" + c.slice(8, 10).join("") + "-" + c.slice(10, 16).join("");
|
|
35
35
|
}
|
|
36
36
|
const s = "0123456789abcdef".split(""), n = [];
|
|
37
37
|
let r;
|
|
@@ -176,23 +176,23 @@ class Q {
|
|
|
176
176
|
const s = String(e ?? "").trim().match(/^(\d+)([hdy])$/);
|
|
177
177
|
if (!s) throw new Error("Invalid expiration format. Use: 1h | 2d | 3y");
|
|
178
178
|
const n = Number.parseInt(s[1], 10), r = s[2], i = Date.now();
|
|
179
|
-
let
|
|
179
|
+
let c = 0;
|
|
180
180
|
switch (r) {
|
|
181
181
|
case "h":
|
|
182
|
-
|
|
182
|
+
c = n * 60 * 60 * 1e3;
|
|
183
183
|
break;
|
|
184
184
|
case "d":
|
|
185
|
-
|
|
185
|
+
c = n * 24 * 60 * 60 * 1e3;
|
|
186
186
|
break;
|
|
187
187
|
case "y":
|
|
188
|
-
|
|
188
|
+
c = n * 365 * 24 * 60 * 60 * 1e3;
|
|
189
189
|
break;
|
|
190
190
|
}
|
|
191
|
-
return i +
|
|
191
|
+
return i + c;
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
-
const
|
|
195
|
-
class
|
|
194
|
+
const Z = new Y(), u = Z;
|
|
195
|
+
class ee {
|
|
196
196
|
#e = 0;
|
|
197
197
|
// displayed fps (stable)
|
|
198
198
|
#t = 0;
|
|
@@ -228,7 +228,7 @@ class Y {
|
|
|
228
228
|
this.#e = 0, this.#t = 0, this.#s = 0;
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
class
|
|
231
|
+
class te {
|
|
232
232
|
constructor(e) {
|
|
233
233
|
this._enabled = !0, this._show_date = !1, this._show_time = !0, this._debug = !1, e && this.configure(e);
|
|
234
234
|
}
|
|
@@ -252,12 +252,12 @@ class Z {
|
|
|
252
252
|
!this._enabled || !this._debug || console.debug(this._dt(), e, ...t);
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
|
-
const
|
|
256
|
-
|
|
255
|
+
const l = new te(), Q = typeof process < "u" && !!process?.env && process.env.NODE_ENV === "production";
|
|
256
|
+
Q || console.info(
|
|
257
257
|
"[Xpell] _xlog is redirected to console in development mode. Tip: enable 'Show timestamps' in DevTools → Console for timed logs."
|
|
258
258
|
);
|
|
259
|
-
const
|
|
260
|
-
class
|
|
259
|
+
const v = Q ? l : console;
|
|
260
|
+
class se {
|
|
261
261
|
constructor() {
|
|
262
262
|
this._objects = {}, this._listeners = /* @__PURE__ */ new Map(), this._any_listeners = /* @__PURE__ */ new Set(), this._compat_writes = !0, this._warn_legacy_writes = !0, this._verbose = !1, this._compat_legacy_keys = !0, this._o_proxy = null, this._objects = {};
|
|
263
263
|
}
|
|
@@ -339,8 +339,8 @@ class ee {
|
|
|
339
339
|
for (const s of this._any_listeners) s(e);
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
|
-
const
|
|
343
|
-
class
|
|
342
|
+
const D = new se(), m = D;
|
|
343
|
+
class R {
|
|
344
344
|
constructor(e) {
|
|
345
345
|
e && Object.keys(e).forEach((t) => {
|
|
346
346
|
this[t] = e[t];
|
|
@@ -360,17 +360,17 @@ class I {
|
|
|
360
360
|
return this._params?.hasOwnProperty(t) ? this._params[t] : this._params?.hasOwnProperty(e) ? this._params[e] : s;
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
|
-
const
|
|
363
|
+
const A = {
|
|
364
364
|
type: "_type",
|
|
365
365
|
children: "_children"
|
|
366
|
-
},
|
|
366
|
+
}, y = class y {
|
|
367
367
|
/**
|
|
368
368
|
* Adds HTML-Xpell Mapping item
|
|
369
369
|
* @param htmlElement HTML element to change from
|
|
370
370
|
* @param xpellElement Xpell element to change to
|
|
371
371
|
*/
|
|
372
372
|
static addHtml2XpellMapItem(e, t) {
|
|
373
|
-
|
|
373
|
+
y.html2XMap.elements[e] = t;
|
|
374
374
|
}
|
|
375
375
|
/**
|
|
376
376
|
* convert text command to Xpell json command
|
|
@@ -378,13 +378,13 @@ const X = {
|
|
|
378
378
|
*/
|
|
379
379
|
static parse(e, t) {
|
|
380
380
|
const s = e.split(" ");
|
|
381
|
-
let n = new
|
|
381
|
+
let n = new R();
|
|
382
382
|
if (t ? (n._module = t, n._op = s[0]) : (n._module = s[0], n._op = s[1]), n._params = {}, s.length > 1)
|
|
383
383
|
for (let r = 2; r < s.length; ++r) {
|
|
384
384
|
const i = s[r];
|
|
385
385
|
if (i.indexOf(":") > -1) {
|
|
386
|
-
const
|
|
387
|
-
n._params[
|
|
386
|
+
const a = i.split(":");
|
|
387
|
+
n._params[a[0]] = a[1];
|
|
388
388
|
} else
|
|
389
389
|
n._params[r - 1] = s[r];
|
|
390
390
|
}
|
|
@@ -397,7 +397,7 @@ const X = {
|
|
|
397
397
|
});
|
|
398
398
|
}
|
|
399
399
|
static parseObjectCommand(e, t) {
|
|
400
|
-
e =
|
|
400
|
+
e = y.replaceSpacesInQuotes(e);
|
|
401
401
|
const s = e.trim().split(/\s+/), n = t || s.shift();
|
|
402
402
|
if (!n) throw new Error("Missing module name");
|
|
403
403
|
let r;
|
|
@@ -405,35 +405,35 @@ const X = {
|
|
|
405
405
|
throw new Error("Invalid object selector '#'. Use '#<id>'");
|
|
406
406
|
const i = s.shift();
|
|
407
407
|
if (!i) throw new Error("Missing operation");
|
|
408
|
-
const
|
|
409
|
-
let
|
|
410
|
-
if (s.forEach((
|
|
411
|
-
if (
|
|
412
|
-
if (
|
|
413
|
-
const
|
|
414
|
-
a
|
|
408
|
+
const c = {};
|
|
409
|
+
let a = null, _ = null;
|
|
410
|
+
if (s.forEach((h) => {
|
|
411
|
+
if (_) {
|
|
412
|
+
if (_ += ` ${h}`, h.endsWith(_[0])) {
|
|
413
|
+
const p = _.slice(1, -1).replace(/_%20_/g, " ");
|
|
414
|
+
c[a] = p, _ = null;
|
|
415
415
|
}
|
|
416
416
|
return;
|
|
417
417
|
}
|
|
418
|
-
if (
|
|
419
|
-
if (
|
|
420
|
-
const
|
|
421
|
-
a
|
|
418
|
+
if (h.startsWith('"') || h.startsWith("'")) {
|
|
419
|
+
if (_ = h, h.endsWith(h[0]) && h.length > 1) {
|
|
420
|
+
const p = h.slice(1, -1).replace(/_%20_/g, " ");
|
|
421
|
+
c[a] = p, _ = null;
|
|
422
422
|
}
|
|
423
423
|
return;
|
|
424
424
|
}
|
|
425
|
-
if (
|
|
426
|
-
const
|
|
427
|
-
|
|
425
|
+
if (h.includes(":")) {
|
|
426
|
+
const p = h.split(":"), x = p[0], j = p.slice(1).join(":").replace(/_%20_/g, " ");
|
|
427
|
+
c[x] = j, a = null;
|
|
428
428
|
return;
|
|
429
429
|
}
|
|
430
|
-
|
|
431
|
-
}),
|
|
430
|
+
a = h.replace(/_%20_/g, " ");
|
|
431
|
+
}), _) throw new Error("Unclosed quoted parameter value");
|
|
432
432
|
return {
|
|
433
433
|
_module: n,
|
|
434
434
|
_object: r,
|
|
435
435
|
_op: i,
|
|
436
|
-
_params:
|
|
436
|
+
_params: c
|
|
437
437
|
};
|
|
438
438
|
}
|
|
439
439
|
/**
|
|
@@ -443,7 +443,7 @@ const X = {
|
|
|
443
443
|
*/
|
|
444
444
|
static xmlString2Xpell(e) {
|
|
445
445
|
const s = new DOMParser().parseFromString(e, "text/xml");
|
|
446
|
-
return s.childNodes.length > 0 ?
|
|
446
|
+
return s.childNodes.length > 0 ? y.xml2Xpell(s.childNodes[0]) : {};
|
|
447
447
|
}
|
|
448
448
|
/**
|
|
449
449
|
* Converts XML/HTML Document to Xpell JSON
|
|
@@ -452,25 +452,25 @@ const X = {
|
|
|
452
452
|
* @returns {} Xpell JSON
|
|
453
453
|
*/
|
|
454
454
|
static xml2Xpell(e, t) {
|
|
455
|
-
const s =
|
|
455
|
+
const s = y.html2XMap;
|
|
456
456
|
let n = {};
|
|
457
457
|
n._children = [];
|
|
458
458
|
const r = e.nodeName, i = e.nodeName;
|
|
459
|
-
let
|
|
460
|
-
if (t ? (n[
|
|
461
|
-
for (let
|
|
462
|
-
const
|
|
463
|
-
n[
|
|
459
|
+
let c = t;
|
|
460
|
+
if (t ? (n[A.type] = "xhtml", n._html_ns = "http://www.w3.org/2000/svg") : n._type = s.elements[r] ? s.elements[r] : r, e.attributes)
|
|
461
|
+
for (let a = 0; a < e.attributes.length; ++a) {
|
|
462
|
+
const _ = e.attributes[a], h = s.attributes[_.name] ? s.attributes[_.name] : _.name;
|
|
463
|
+
n[h] = _.value;
|
|
464
464
|
}
|
|
465
|
-
if (e?.firstChild?.nodeValue && (n.text = e?.firstChild.nodeValue.trim()), n[
|
|
466
|
-
for (let
|
|
467
|
-
const
|
|
468
|
-
|
|
465
|
+
if (e?.firstChild?.nodeValue && (n.text = e?.firstChild.nodeValue.trim()), n[A.type] == "xhtml" ? n._html_tag = i : n[A.type] == "svg" && (c = !0, n._html_ns = "http://www.w3.org/2000/svg"), e?.childNodes.length > 0)
|
|
466
|
+
for (let a = 0; a < e.childNodes.length; ++a) {
|
|
467
|
+
const _ = e.childNodes[a];
|
|
468
|
+
_.nodeName.startsWith("#") || n[A.children].push(y.xml2Xpell(_, c));
|
|
469
469
|
}
|
|
470
470
|
return n;
|
|
471
471
|
}
|
|
472
472
|
};
|
|
473
|
-
|
|
473
|
+
y.html2XMap = {
|
|
474
474
|
elements: {
|
|
475
475
|
div: "view",
|
|
476
476
|
a: "link",
|
|
@@ -500,8 +500,8 @@ b.html2XMap = {
|
|
|
500
500
|
id: "_id"
|
|
501
501
|
}
|
|
502
502
|
};
|
|
503
|
-
let w =
|
|
504
|
-
class
|
|
503
|
+
let w = y;
|
|
504
|
+
class ne {
|
|
505
505
|
#e;
|
|
506
506
|
#t;
|
|
507
507
|
#s;
|
|
@@ -569,7 +569,7 @@ class te {
|
|
|
569
569
|
* @param xObject XObject to maintain
|
|
570
570
|
*/
|
|
571
571
|
addObject(e) {
|
|
572
|
-
e && e._id ? (this.#t[e._id] = e, (!e._name || e._name.length == 0) && (e._name = e._id), this.#s[e._name] = e._id) :
|
|
572
|
+
e && e._id ? (this.#t[e._id] = e, (!e._name || e._name.length == 0) && (e._name = e._id), this.#s[e._name] = e._id) : l.log("unable to add object");
|
|
573
573
|
}
|
|
574
574
|
/**
|
|
575
575
|
* Remove XObject from the manager
|
|
@@ -604,7 +604,7 @@ class te {
|
|
|
604
604
|
return this.#s[e] ? this.getObject(this.#s[e]) : null;
|
|
605
605
|
}
|
|
606
606
|
}
|
|
607
|
-
class
|
|
607
|
+
class fe {
|
|
608
608
|
constructor() {
|
|
609
609
|
this._log_rules = {
|
|
610
610
|
register: !1,
|
|
@@ -621,14 +621,14 @@ class ue {
|
|
|
621
621
|
*/
|
|
622
622
|
on(e, t, s = {}, n) {
|
|
623
623
|
this._events[e] || (this._events[e] = []);
|
|
624
|
-
const r = s?._owner ?? n, i =
|
|
624
|
+
const r = s?._owner ?? n, i = u.guid(), c = {
|
|
625
625
|
_id: i,
|
|
626
626
|
_callback: t,
|
|
627
627
|
_options: s,
|
|
628
628
|
_owner: r,
|
|
629
629
|
_tag: s?._tag
|
|
630
630
|
};
|
|
631
|
-
return this._events[e].push(
|
|
631
|
+
return this._events[e].push(c), this._listener_index[i] = e, this._log_rules.register && v.log("XEM Register", e, i), i;
|
|
632
632
|
}
|
|
633
633
|
/**
|
|
634
634
|
* Register a listener that will be removed after first fire.
|
|
@@ -642,13 +642,13 @@ class ue {
|
|
|
642
642
|
async fire(e, t) {
|
|
643
643
|
const s = this._events[e];
|
|
644
644
|
if (!s || s.length === 0) return;
|
|
645
|
-
this._log_rules.fire &&
|
|
645
|
+
this._log_rules.fire && v.log("XEM Fire", e, t);
|
|
646
646
|
const n = s.slice(), r = [];
|
|
647
647
|
for (const i of n) {
|
|
648
648
|
try {
|
|
649
649
|
i && i._callback && i._callback(t);
|
|
650
|
-
} catch (
|
|
651
|
-
|
|
650
|
+
} catch (c) {
|
|
651
|
+
v.error(c);
|
|
652
652
|
}
|
|
653
653
|
i?._options?._once && r.push(i._id);
|
|
654
654
|
}
|
|
@@ -665,7 +665,7 @@ class ue {
|
|
|
665
665
|
const n = s.findIndex((r) => r?._id === e);
|
|
666
666
|
n >= 0 && s.splice(n, 1), s.length === 0 && delete this._events[t];
|
|
667
667
|
}
|
|
668
|
-
delete this._listener_index[e], this._log_rules.remove &&
|
|
668
|
+
delete this._listener_index[e], this._log_rules.remove && v.log("XEM Remove", t, e);
|
|
669
669
|
}
|
|
670
670
|
/**
|
|
671
671
|
* Remove all listeners for a given owner reference.
|
|
@@ -685,16 +685,16 @@ class ue {
|
|
|
685
685
|
this._events = {}, this._listener_index = {};
|
|
686
686
|
}
|
|
687
687
|
}
|
|
688
|
-
let
|
|
689
|
-
function
|
|
690
|
-
|
|
688
|
+
let N;
|
|
689
|
+
function pe(o) {
|
|
690
|
+
N = o;
|
|
691
691
|
}
|
|
692
|
-
function
|
|
693
|
-
if (!
|
|
692
|
+
function E() {
|
|
693
|
+
if (!N)
|
|
694
694
|
throw new Error("XEventManager not set");
|
|
695
|
-
return
|
|
695
|
+
return N;
|
|
696
696
|
}
|
|
697
|
-
const
|
|
697
|
+
const re = [
|
|
698
698
|
"_nano_commands",
|
|
699
699
|
"_cache_cmd_txt",
|
|
700
700
|
"_cache_jcmd",
|
|
@@ -703,10 +703,10 @@ const se = [
|
|
|
703
703
|
"_parent",
|
|
704
704
|
"_children"
|
|
705
705
|
];
|
|
706
|
-
function
|
|
707
|
-
return
|
|
706
|
+
function F(o) {
|
|
707
|
+
return re.includes(o);
|
|
708
708
|
}
|
|
709
|
-
function
|
|
709
|
+
function K(o) {
|
|
710
710
|
if (!o || typeof o != "object" || Array.isArray(o)) return !1;
|
|
711
711
|
const e = Object.getPrototypeOf(o);
|
|
712
712
|
return e === Object.prototype || e === null;
|
|
@@ -714,10 +714,10 @@ function J(o) {
|
|
|
714
714
|
function g(o, e) {
|
|
715
715
|
return o._skill = e, o.getSkill = () => e, o;
|
|
716
716
|
}
|
|
717
|
-
const
|
|
717
|
+
const G = {
|
|
718
718
|
info: g(
|
|
719
719
|
(o, e) => {
|
|
720
|
-
|
|
720
|
+
l.log("XObject id " + e?._id);
|
|
721
721
|
},
|
|
722
722
|
{
|
|
723
723
|
_name: "info",
|
|
@@ -727,7 +727,7 @@ const V = {
|
|
|
727
727
|
),
|
|
728
728
|
log: g(
|
|
729
729
|
(o, e) => {
|
|
730
|
-
o._params && o._params[1] ?
|
|
730
|
+
o._params && o._params[1] ? l.log(o._params[1]) : l.log(e);
|
|
731
731
|
},
|
|
732
732
|
{
|
|
733
733
|
_name: "log",
|
|
@@ -740,10 +740,10 @@ const V = {
|
|
|
740
740
|
),
|
|
741
741
|
fire: g(
|
|
742
742
|
(o, e) => {
|
|
743
|
-
o._params && o._params[1] ?
|
|
743
|
+
o._params && o._params[1] ? E().fire(
|
|
744
744
|
String(o._params[1]),
|
|
745
745
|
o._params[2]
|
|
746
|
-
) : o._params && o._params.event &&
|
|
746
|
+
) : o._params && o._params.event && E().fire(
|
|
747
747
|
String(o._params.event),
|
|
748
748
|
o._params.data
|
|
749
749
|
);
|
|
@@ -782,8 +782,8 @@ const V = {
|
|
|
782
782
|
(o, e) => {
|
|
783
783
|
const t = o._params?.name, s = o._params?.value;
|
|
784
784
|
if (!(!e || typeof t != "string" || t.length === 0)) {
|
|
785
|
-
if (
|
|
786
|
-
|
|
785
|
+
if (F(t)) {
|
|
786
|
+
l.error(`set-field denied for protected field: ${t}`);
|
|
787
787
|
return;
|
|
788
788
|
}
|
|
789
789
|
e[t] = s;
|
|
@@ -810,8 +810,8 @@ const V = {
|
|
|
810
810
|
(o, e) => {
|
|
811
811
|
const t = o._params?.name;
|
|
812
812
|
if (!(!e || typeof t != "string" || t.length === 0)) {
|
|
813
|
-
if (
|
|
814
|
-
|
|
813
|
+
if (F(t)) {
|
|
814
|
+
l.error(`delete-field denied for protected field: ${t}`);
|
|
815
815
|
return;
|
|
816
816
|
}
|
|
817
817
|
delete e[t];
|
|
@@ -830,8 +830,8 @@ const V = {
|
|
|
830
830
|
(o, e) => {
|
|
831
831
|
const t = o._params?.name;
|
|
832
832
|
if (!e || typeof t != "string" || t.length === 0) return;
|
|
833
|
-
if (
|
|
834
|
-
|
|
833
|
+
if (F(t)) {
|
|
834
|
+
l.error(`toggle-field denied for protected field: ${t}`);
|
|
835
835
|
return;
|
|
836
836
|
}
|
|
837
837
|
const s = e[t];
|
|
@@ -850,16 +850,16 @@ const V = {
|
|
|
850
850
|
(o, e) => {
|
|
851
851
|
const t = o._params?.name, s = o._params?.value;
|
|
852
852
|
if (!e || typeof t != "string" || t.length === 0) return;
|
|
853
|
-
if (
|
|
854
|
-
|
|
853
|
+
if (F(t)) {
|
|
854
|
+
l.error(`merge denied for protected field: ${t}`);
|
|
855
855
|
return;
|
|
856
856
|
}
|
|
857
|
-
if (!
|
|
858
|
-
|
|
857
|
+
if (!K(s)) {
|
|
858
|
+
l.error("merge expects _params.value as a plain object");
|
|
859
859
|
return;
|
|
860
860
|
}
|
|
861
861
|
const n = e[t];
|
|
862
|
-
|
|
862
|
+
K(n) || (e[t] = {}), Object.assign(e[t], s);
|
|
863
863
|
},
|
|
864
864
|
{
|
|
865
865
|
_name: "merge",
|
|
@@ -876,7 +876,7 @@ const V = {
|
|
|
876
876
|
if (!e) return;
|
|
877
877
|
const t = o._params?.seq;
|
|
878
878
|
if (!Array.isArray(t)) {
|
|
879
|
-
|
|
879
|
+
l.error("run-seq expects _params.seq as an array");
|
|
880
880
|
return;
|
|
881
881
|
}
|
|
882
882
|
for (const s of t) {
|
|
@@ -887,7 +887,7 @@ const V = {
|
|
|
887
887
|
if (s && typeof s == "object" && s._op) {
|
|
888
888
|
const n = s._object;
|
|
889
889
|
if (!(n == null || n === "this" || n === e._id)) {
|
|
890
|
-
|
|
890
|
+
l.error("run-seq rejected non-self _object target");
|
|
891
891
|
return;
|
|
892
892
|
}
|
|
893
893
|
const i = {
|
|
@@ -897,7 +897,7 @@ const V = {
|
|
|
897
897
|
await e.execute(i);
|
|
898
898
|
continue;
|
|
899
899
|
}
|
|
900
|
-
|
|
900
|
+
l.error(
|
|
901
901
|
"run-seq skipped invalid step; expected string or object with _op"
|
|
902
902
|
);
|
|
903
903
|
}
|
|
@@ -932,16 +932,16 @@ const V = {
|
|
|
932
932
|
}
|
|
933
933
|
)
|
|
934
934
|
};
|
|
935
|
-
let
|
|
936
|
-
function
|
|
937
|
-
|
|
935
|
+
let L;
|
|
936
|
+
function ie(o) {
|
|
937
|
+
L = o;
|
|
938
938
|
}
|
|
939
|
-
function
|
|
940
|
-
if (
|
|
939
|
+
function oe() {
|
|
940
|
+
if (!L)
|
|
941
941
|
throw new Error("XRuntime not set");
|
|
942
|
-
return
|
|
942
|
+
return L;
|
|
943
943
|
}
|
|
944
|
-
const
|
|
944
|
+
const U = {
|
|
945
945
|
_id: "xobject",
|
|
946
946
|
_title: "XObject Core Runtime Contract",
|
|
947
947
|
_version: "1.0.0",
|
|
@@ -993,7 +993,7 @@ const R = {
|
|
|
993
993
|
"Runtime methods include parse, append, run, execute, bindDataSource, unbindDataSource, toXData, dispose, and removeChild.",
|
|
994
994
|
"Most prompts should use this skill as a compact dependency summary, not full context."
|
|
995
995
|
]
|
|
996
|
-
},
|
|
996
|
+
}, $ = { _children: "child nodes" }, X = class X {
|
|
997
997
|
/**
|
|
998
998
|
* XObject constructor is creating the object and adding all the data keys to the XObject instance
|
|
999
999
|
* @param data constructor input data (object)
|
|
@@ -1022,14 +1022,14 @@ const R = {
|
|
|
1022
1022
|
"_debug"
|
|
1023
1023
|
],
|
|
1024
1024
|
_instance_xporters: {}
|
|
1025
|
-
}, t &&
|
|
1025
|
+
}, t && u.mergeDefaultsWithData(e, t), this._id = e && e._id ? e._id : "xo-" + u.guid(), this._type = "object", this._children = [], this._nano_commands = {}, this.addNanoCommandPack(G), e && e.hasOwnProperty("_nano_commands") && e._nano_commands && (this.addNanoCommandPack(e._nano_commands), delete e._nano_commands), this.addXporterDataIgnoreFields(["_nano_commands"]), this.addXporterInstanceXporter(X, (n) => n.toXData()), this._xem_options = {
|
|
1026
1026
|
// _instance:_xem
|
|
1027
1027
|
// _object: this
|
|
1028
1028
|
// _support_html: true
|
|
1029
|
-
}, !s && e && this.parse(e,
|
|
1029
|
+
}, !s && e && this.parse(e, $);
|
|
1030
1030
|
}
|
|
1031
1031
|
static getOwnSkill() {
|
|
1032
|
-
const e = this, t = e._skill ??
|
|
1032
|
+
const e = this, t = e._skill ?? U;
|
|
1033
1033
|
return {
|
|
1034
1034
|
...t,
|
|
1035
1035
|
_exports: {
|
|
@@ -1044,7 +1044,7 @@ const R = {
|
|
|
1044
1044
|
}
|
|
1045
1045
|
static getOwnNanoCommands() {
|
|
1046
1046
|
return {
|
|
1047
|
-
...
|
|
1047
|
+
...G
|
|
1048
1048
|
};
|
|
1049
1049
|
}
|
|
1050
1050
|
static getNanoCommands() {
|
|
@@ -1060,8 +1060,32 @@ const R = {
|
|
|
1060
1060
|
(t) => t.getSkill?.() ?? t._skill
|
|
1061
1061
|
).filter(Boolean) : [];
|
|
1062
1062
|
}
|
|
1063
|
+
static getArtifactStrategy() {
|
|
1064
|
+
return "canonical";
|
|
1065
|
+
}
|
|
1066
|
+
static generateArtifact(e = {}) {
|
|
1067
|
+
const t = this.getOwnSkill?.(), s = t?._canonical_examples?.[0], n = s ? this.cloneArtifact(s) : { _type: this._xtype ?? t?._id ?? "object" };
|
|
1068
|
+
return this.applyArtifactIntent(n, e);
|
|
1069
|
+
}
|
|
1070
|
+
static cloneArtifact(e) {
|
|
1071
|
+
return typeof structuredClone == "function" ? structuredClone(e) : JSON.parse(JSON.stringify(e));
|
|
1072
|
+
}
|
|
1073
|
+
static applyArtifactIntent(e, t = {}) {
|
|
1074
|
+
const s = e;
|
|
1075
|
+
return t._id && (s._id = t._id), t._label && ("_label" in s ? s._label = t._label : "_text" in s ? s._text = t._label : "_title" in s && (s._title = t._label)), t._text && "_text" in s && (s._text = t._text), t._title && "_title" in s && (s._title = t._title), t._description && "_description" in s && (s._description = t._description), t._variant && "_variant" in s && (s._variant = t._variant), t._tone && "_tone" in s && (s._tone = t._tone), t._size && "_size" in s && (s._size = t._size), t._density && "_density" in s && (s._density = t._density), t._elevation && "_elevation" in s && (s._elevation = t._elevation), t.class && (s.class = t.class), t._placeholder && ("placeholder" in s ? s.placeholder = t._placeholder : "_placeholder" in s && (s._placeholder = t._placeholder)), t._data_output && "_data_output" in s && (s._data_output = t._data_output), Array.isArray(t._children) && (s._children = t._children), Array.isArray(t._actions) && (s._actions = t._actions), Array.isArray(t._items) && (s._items = t._items), t._flow_id && (s._flow = {
|
|
1076
|
+
_id: t._flow_id,
|
|
1077
|
+
_payload: t._payload ?? {}
|
|
1078
|
+
}), t._flow_event && (s._flow_event = t._flow_event), s;
|
|
1079
|
+
}
|
|
1080
|
+
static validateArtifact(e) {
|
|
1081
|
+
const t = [];
|
|
1082
|
+
return (!e || typeof e != "object") && t.push("artifact must be an object"), e._type || t.push("artifact requires _type"), {
|
|
1083
|
+
_ok: t.length === 0,
|
|
1084
|
+
_errors: t
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1063
1087
|
log(e, ...t) {
|
|
1064
|
-
this._debug && e &&
|
|
1088
|
+
this._debug && e && l.log(this._type + "->" + this._id + "]", e, ...t);
|
|
1065
1089
|
}
|
|
1066
1090
|
/**
|
|
1067
1091
|
* Initialize the XObject
|
|
@@ -1070,7 +1094,7 @@ const R = {
|
|
|
1070
1094
|
* @deprecated - use parse method instead
|
|
1071
1095
|
*/
|
|
1072
1096
|
init(e, t) {
|
|
1073
|
-
!t && e && this.parse(e,
|
|
1097
|
+
!t && e && this.parse(e, $);
|
|
1074
1098
|
}
|
|
1075
1099
|
parseEvents(e) {
|
|
1076
1100
|
if (!this._event_parsed) {
|
|
@@ -1087,17 +1111,34 @@ const R = {
|
|
|
1087
1111
|
s || (s = this._xem_options);
|
|
1088
1112
|
const n = async (i) => {
|
|
1089
1113
|
await this.checkAndRunInternalFunction(t, i);
|
|
1090
|
-
}, r =
|
|
1114
|
+
}, r = E().on(e, n, s, this);
|
|
1091
1115
|
return this._event_listeners_ids[e] || (this._event_listeners_ids[e] = []), this._event_listeners_ids[e].push(r), r;
|
|
1092
1116
|
}
|
|
1093
1117
|
removeEventListener(e) {
|
|
1094
|
-
const t = this._event_listeners_ids
|
|
1095
|
-
t
|
|
1096
|
-
|
|
1097
|
-
|
|
1118
|
+
const t = this._event_listeners_ids;
|
|
1119
|
+
if (!t || typeof t != "object" || Array.isArray(t)) {
|
|
1120
|
+
this._event_listeners_ids = {};
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
(Array.isArray(t[e]) ? [...t[e]] : []).forEach((n) => {
|
|
1124
|
+
try {
|
|
1125
|
+
E().remove(n);
|
|
1126
|
+
} catch {
|
|
1127
|
+
}
|
|
1128
|
+
}), delete t[e];
|
|
1098
1129
|
}
|
|
1099
|
-
removeAllEventListeners() {
|
|
1100
|
-
|
|
1130
|
+
removeAllEventListeners(e) {
|
|
1131
|
+
const t = this._event_listeners_ids;
|
|
1132
|
+
if (!t || typeof t != "object" || Array.isArray(t)) {
|
|
1133
|
+
this._event_listeners_ids = {};
|
|
1134
|
+
return;
|
|
1135
|
+
}
|
|
1136
|
+
(e ? [e] : Object.keys(t)).forEach((n) => {
|
|
1137
|
+
try {
|
|
1138
|
+
this.removeEventListener(n);
|
|
1139
|
+
} catch {
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1101
1142
|
}
|
|
1102
1143
|
/**
|
|
1103
1144
|
* Append a child XObject to this XObject
|
|
@@ -1131,7 +1172,7 @@ const R = {
|
|
|
1131
1172
|
* @param <XDataInstanceXporter> ie - the instance exporter object
|
|
1132
1173
|
*/
|
|
1133
1174
|
addXporterInstanceXporter(e, t) {
|
|
1134
|
-
const s =
|
|
1175
|
+
const s = u.guid();
|
|
1135
1176
|
this._xporter._instance_xporters[s] = {
|
|
1136
1177
|
cls: e,
|
|
1137
1178
|
handler: t
|
|
@@ -1142,7 +1183,7 @@ const R = {
|
|
|
1142
1183
|
* @param data data to parse
|
|
1143
1184
|
* @param ignore - lis of words to ignore in the parse process
|
|
1144
1185
|
*/
|
|
1145
|
-
parse(e, t =
|
|
1186
|
+
parse(e, t = $) {
|
|
1146
1187
|
Object.keys(e).forEach((n) => {
|
|
1147
1188
|
!t.hasOwnProperty(n) && e.hasOwnProperty(n) && (this[n] = e[n]);
|
|
1148
1189
|
});
|
|
@@ -1192,137 +1233,117 @@ const R = {
|
|
|
1192
1233
|
this._on_create ? this.checkAndRunInternalFunction(this._on_create) : this._on && this._on.create ? this.checkAndRunInternalFunction(this._on.create) : this._once && this._once.create && this.checkAndRunInternalFunction(this._once.create);
|
|
1193
1234
|
}
|
|
1194
1235
|
async runCmd(e) {
|
|
1195
|
-
const t = e instanceof
|
|
1236
|
+
const t = e instanceof R ? e : new R(e);
|
|
1196
1237
|
await this.execute(t);
|
|
1197
1238
|
}
|
|
1198
1239
|
async checkAndRunInternalFunction(e, ...t) {
|
|
1199
|
-
const s = (
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
for (const _ of i) {
|
|
1206
|
-
if (a == null) return;
|
|
1207
|
-
a = a[_];
|
|
1208
|
-
}
|
|
1209
|
-
return a;
|
|
1210
|
-
}
|
|
1211
|
-
if (r === "$data") return t[0];
|
|
1212
|
-
if (r.startsWith("$data.")) {
|
|
1213
|
-
const i = r.slice(6).split(".");
|
|
1214
|
-
let a = t[0];
|
|
1215
|
-
for (const _ of i) {
|
|
1216
|
-
if (a == null) return;
|
|
1217
|
-
a = a[_];
|
|
1218
|
-
}
|
|
1219
|
-
return a;
|
|
1220
|
-
}
|
|
1221
|
-
return r;
|
|
1240
|
+
const s = (i, c) => {
|
|
1241
|
+
const a = c.split(".");
|
|
1242
|
+
let _ = i;
|
|
1243
|
+
for (const h of a) {
|
|
1244
|
+
if (_ == null) return;
|
|
1245
|
+
_ = _[h];
|
|
1222
1246
|
}
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
if (
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1247
|
+
return _;
|
|
1248
|
+
}, n = (i, c) => {
|
|
1249
|
+
if (typeof i == "string")
|
|
1250
|
+
return i === "$prev" ? c : i.startsWith("$prev.") ? s(c, i.slice(6)) : i === "$event" ? t[0] : i.startsWith("$event.") ? s(t[0], i.slice(7)) : i === "$data" ? t[0] : i.startsWith("$data.") ? s(t[0], i.slice(6)) : i;
|
|
1251
|
+
if (Array.isArray(i))
|
|
1252
|
+
return i.map((a) => n(a, c));
|
|
1253
|
+
if (i && typeof i == "object") {
|
|
1254
|
+
const a = {};
|
|
1255
|
+
for (const _ of Object.keys(i))
|
|
1256
|
+
a[_] = n(i[_], c);
|
|
1257
|
+
return a;
|
|
1230
1258
|
}
|
|
1231
|
-
return
|
|
1232
|
-
},
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1259
|
+
return i;
|
|
1260
|
+
}, r = async (i, c) => {
|
|
1261
|
+
if (Array.isArray(i)) {
|
|
1262
|
+
let a;
|
|
1263
|
+
for (const _ of i)
|
|
1264
|
+
a = await r(_, a);
|
|
1265
|
+
return a;
|
|
1237
1266
|
}
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
let r;
|
|
1244
|
-
for (const i of e)
|
|
1245
|
-
r = await n(
|
|
1246
|
-
i,
|
|
1247
|
-
r
|
|
1248
|
-
);
|
|
1249
|
-
return r;
|
|
1250
|
-
}
|
|
1251
|
-
if (typeof e == "function")
|
|
1252
|
-
return await e(this, ...t);
|
|
1253
|
-
if (typeof e == "string") {
|
|
1254
|
-
const r = w.parseObjectCommand(
|
|
1255
|
-
`${this._id} ${e}`
|
|
1256
|
-
);
|
|
1257
|
-
if (t.length > 0) {
|
|
1258
|
-
r._params = r._params || {};
|
|
1259
|
-
const i = t[0];
|
|
1260
|
-
r._params._event = i, !r._params.data && !i?.target && (r._params.data = i);
|
|
1261
|
-
}
|
|
1262
|
-
return await this.execute(r);
|
|
1263
|
-
}
|
|
1264
|
-
if (e && typeof e == "object" && Array.isArray(e._commands)) {
|
|
1265
|
-
const r = e, i = typeof r._mode == "string" ? r._mode : "sequence", a = r._stop_on_error !== !1, _ = r._commands;
|
|
1266
|
-
if (i === "parallel") {
|
|
1267
|
-
const u = await Promise.allSettled(
|
|
1268
|
-
_.map(
|
|
1269
|
-
(O) => n(O)
|
|
1270
|
-
)
|
|
1271
|
-
), m = u.find(
|
|
1272
|
-
(O) => O.status === "rejected"
|
|
1267
|
+
if (typeof i == "function")
|
|
1268
|
+
return await i(this, ...t);
|
|
1269
|
+
if (typeof i == "string") {
|
|
1270
|
+
const a = w.parseObjectCommand(
|
|
1271
|
+
`${this._id} ${i}`
|
|
1273
1272
|
);
|
|
1274
|
-
if (
|
|
1275
|
-
|
|
1276
|
-
|
|
1273
|
+
if (t.length > 0) {
|
|
1274
|
+
a._params = a._params || {};
|
|
1275
|
+
const _ = t[0];
|
|
1276
|
+
a._params._event = _, !a._params.data && !_?.target && (a._params.data = _);
|
|
1277
|
+
}
|
|
1278
|
+
return await this.execute(a);
|
|
1277
1279
|
}
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1280
|
+
if (i && typeof i == "object" && Array.isArray(i._commands)) {
|
|
1281
|
+
const a = i, _ = typeof a._mode == "string" ? a._mode : "sequence", h = a._stop_on_error !== !1, p = a._commands;
|
|
1282
|
+
if (_ === "parallel") {
|
|
1283
|
+
const j = await Promise.allSettled(
|
|
1284
|
+
p.map(
|
|
1285
|
+
(P) => r(P, c)
|
|
1286
|
+
)
|
|
1287
|
+
), S = j.find(
|
|
1288
|
+
(P) => P.status === "rejected"
|
|
1284
1289
|
);
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
m
|
|
1289
|
-
), a)
|
|
1290
|
-
throw m;
|
|
1290
|
+
if (S && h)
|
|
1291
|
+
throw S.reason;
|
|
1292
|
+
return j;
|
|
1291
1293
|
}
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1294
|
+
let x = c;
|
|
1295
|
+
for (const j of p)
|
|
1296
|
+
try {
|
|
1297
|
+
x = await r(
|
|
1298
|
+
j,
|
|
1299
|
+
_ === "chain" ? x : c
|
|
1300
|
+
);
|
|
1301
|
+
} catch (S) {
|
|
1302
|
+
if (l.error(
|
|
1303
|
+
this._type + "->" + this._id + "] command sequence failed",
|
|
1304
|
+
S
|
|
1305
|
+
), h)
|
|
1306
|
+
throw S;
|
|
1307
|
+
}
|
|
1308
|
+
return x;
|
|
1301
1309
|
}
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
a._params
|
|
1313
|
-
|
|
1314
|
-
|
|
1310
|
+
if (i && typeof i == "object" && i._op) {
|
|
1311
|
+
const a = i;
|
|
1312
|
+
if ((a._object === void 0 || a._object === null || a._object === "this" ? this._id : a._object) !== this._id) {
|
|
1313
|
+
l.error(
|
|
1314
|
+
"XObject JSON handler target not supported; expected _object omitted/'this'/" + this._id
|
|
1315
|
+
);
|
|
1316
|
+
return;
|
|
1317
|
+
}
|
|
1318
|
+
const h = {
|
|
1319
|
+
...a,
|
|
1320
|
+
_params: a._params ? { ...a._params } : {}
|
|
1321
|
+
};
|
|
1322
|
+
if (t.length > 0) {
|
|
1323
|
+
const p = t[0];
|
|
1324
|
+
Object.prototype.hasOwnProperty.call(
|
|
1325
|
+
h._params,
|
|
1326
|
+
"data"
|
|
1327
|
+
) || (h._params.data = p), Object.prototype.hasOwnProperty.call(
|
|
1328
|
+
h._params,
|
|
1329
|
+
"_event"
|
|
1330
|
+
) || (h._params._event = p);
|
|
1331
|
+
}
|
|
1332
|
+
return h._params = n(
|
|
1333
|
+
h._params,
|
|
1334
|
+
c
|
|
1335
|
+
), this._debug && l.log(
|
|
1336
|
+
this._type + "->" + this._id + "]",
|
|
1337
|
+
"JSON handler executed locally",
|
|
1338
|
+
h
|
|
1339
|
+
), await this.execute(h);
|
|
1315
1340
|
}
|
|
1316
|
-
|
|
1317
|
-
this._type + "->" + this._id + "]",
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
c.error(
|
|
1323
|
-
this._type + "->" + this._id + "] invalid handler in checkAndRunInternalFunction",
|
|
1324
|
-
e
|
|
1325
|
-
);
|
|
1341
|
+
l.error(
|
|
1342
|
+
this._type + "->" + this._id + "] invalid handler in checkAndRunInternalFunction",
|
|
1343
|
+
i
|
|
1344
|
+
);
|
|
1345
|
+
};
|
|
1346
|
+
return await r(e);
|
|
1326
1347
|
}
|
|
1327
1348
|
/**
|
|
1328
1349
|
* Triggers when the object is being mounted to other element
|
|
@@ -1344,7 +1365,7 @@ const R = {
|
|
|
1344
1365
|
const e = this._data_source;
|
|
1345
1366
|
if (typeof e != "string" || e.length === 0) return;
|
|
1346
1367
|
const t = this._type ?? this.constructor.name, s = this._id ?? "no-id";
|
|
1347
|
-
|
|
1368
|
+
D.delete(e, { source: `${t}#${s}.emptyDataSource` });
|
|
1348
1369
|
}
|
|
1349
1370
|
/**
|
|
1350
1371
|
* Triggers when new data is being received from the data source
|
|
@@ -1400,37 +1421,42 @@ const R = {
|
|
|
1400
1421
|
*
|
|
1401
1422
|
*/
|
|
1402
1423
|
async execute(e) {
|
|
1403
|
-
const t = e?._op;
|
|
1404
|
-
if (!
|
|
1405
|
-
|
|
1424
|
+
const t = e?._op, s = typeof t == "string" && t.startsWith("_") && t.length > 1 ? t.slice(1) : t;
|
|
1425
|
+
if (!s) {
|
|
1426
|
+
l.error(this._id + " missing _op in command");
|
|
1406
1427
|
return;
|
|
1407
1428
|
}
|
|
1408
|
-
const
|
|
1409
|
-
if (
|
|
1429
|
+
const n = e?._module;
|
|
1430
|
+
if (n)
|
|
1410
1431
|
try {
|
|
1411
|
-
return await
|
|
1432
|
+
return await oe().execute({
|
|
1412
1433
|
...e,
|
|
1413
|
-
_module:
|
|
1434
|
+
_module: n,
|
|
1435
|
+
_op: s
|
|
1414
1436
|
});
|
|
1415
|
-
} catch (
|
|
1416
|
-
|
|
1417
|
-
this._id + " module execution failed: " +
|
|
1437
|
+
} catch (r) {
|
|
1438
|
+
l.error(
|
|
1439
|
+
this._id + " module execution failed: " + n + "." + s + " " + r
|
|
1418
1440
|
);
|
|
1419
1441
|
return;
|
|
1420
1442
|
}
|
|
1421
|
-
if (this._nano_commands[
|
|
1443
|
+
if (this._nano_commands[s])
|
|
1422
1444
|
try {
|
|
1423
|
-
|
|
1424
|
-
e,
|
|
1445
|
+
const r = {
|
|
1446
|
+
...e,
|
|
1447
|
+
_op: s
|
|
1448
|
+
};
|
|
1449
|
+
return await this._nano_commands[s](
|
|
1450
|
+
r,
|
|
1425
1451
|
this
|
|
1426
1452
|
);
|
|
1427
|
-
} catch (
|
|
1428
|
-
|
|
1429
|
-
this._id + " has error with command name " +
|
|
1453
|
+
} catch (r) {
|
|
1454
|
+
l.error(
|
|
1455
|
+
this._id + " has error with command name " + s + " " + r
|
|
1430
1456
|
);
|
|
1431
1457
|
return;
|
|
1432
1458
|
}
|
|
1433
|
-
|
|
1459
|
+
l.error(this._id + " has no command name " + s);
|
|
1434
1460
|
}
|
|
1435
1461
|
/**
|
|
1436
1462
|
* Return an IXObjectData JSON representation of the XObject
|
|
@@ -1470,9 +1496,9 @@ const R = {
|
|
|
1470
1496
|
}
|
|
1471
1497
|
bindDataSource(e, t) {
|
|
1472
1498
|
const s = t?.initial ?? !0, n = e ?? this._data_source;
|
|
1473
|
-
typeof n != "string" || n.length === 0 || this._process_data && (this._xd_bound_key === n && this._xd_unsub || (this.unbindDataSource(), this._data_source = n, this._xd_bound_key = n, this._type ?? this.constructor.name, this._id, this._xd_unsub =
|
|
1499
|
+
typeof n != "string" || n.length === 0 || this._process_data && (this._xd_bound_key === n && this._xd_unsub || (this.unbindDataSource(), this._data_source = n, this._xd_bound_key = n, this._type ?? this.constructor.name, this._id, this._xd_unsub = D.on(n, async (r) => {
|
|
1474
1500
|
await this.onData(r.value);
|
|
1475
|
-
}), s &&
|
|
1501
|
+
}), s && D.has(n) && this.onData(D.get(n))));
|
|
1476
1502
|
}
|
|
1477
1503
|
unbindDataSource() {
|
|
1478
1504
|
this._xd_unsub?.(), this._xd_unsub = void 0, this._xd_bound_key = void 0;
|
|
@@ -1510,20 +1536,20 @@ const R = {
|
|
|
1510
1536
|
this.append(e);
|
|
1511
1537
|
}
|
|
1512
1538
|
};
|
|
1513
|
-
|
|
1514
|
-
let
|
|
1515
|
-
class
|
|
1539
|
+
X._xtype = "object", X._skill = U;
|
|
1540
|
+
let C = X;
|
|
1541
|
+
class me {
|
|
1516
1542
|
/**
|
|
1517
1543
|
* Get all registered object in this ObjectPack
|
|
1518
1544
|
* @returns XObject dictionary
|
|
1519
1545
|
*/
|
|
1520
1546
|
static getObjects() {
|
|
1521
1547
|
return {
|
|
1522
|
-
object:
|
|
1548
|
+
object: C
|
|
1523
1549
|
};
|
|
1524
1550
|
}
|
|
1525
1551
|
}
|
|
1526
|
-
const
|
|
1552
|
+
const ae = "engine:module:num-of-objects:", q = {
|
|
1527
1553
|
_id: "xmodule",
|
|
1528
1554
|
_title: "XModule Runtime Contract",
|
|
1529
1555
|
_version: "1.0.0",
|
|
@@ -1539,13 +1565,13 @@ const ie = "engine:module:num-of-objects:", N = {
|
|
|
1539
1565
|
]
|
|
1540
1566
|
};
|
|
1541
1567
|
var d;
|
|
1542
|
-
const
|
|
1568
|
+
const M = class M {
|
|
1543
1569
|
constructor(e) {
|
|
1544
|
-
|
|
1570
|
+
V(this, d);
|
|
1545
1571
|
this._loaded = !1, this._loading = !1, this._log_rules = {
|
|
1546
1572
|
createObject: !1,
|
|
1547
1573
|
removeObject: !1
|
|
1548
|
-
},
|
|
1574
|
+
}, z(this, d, new ne()), this._name = e._name, this._id = u.guid();
|
|
1549
1575
|
}
|
|
1550
1576
|
static getOwnSkillBase() {
|
|
1551
1577
|
return {
|
|
@@ -1553,7 +1579,7 @@ const C = class C {
|
|
|
1553
1579
|
};
|
|
1554
1580
|
}
|
|
1555
1581
|
getOwnSkill() {
|
|
1556
|
-
const t = this.constructor._skill ??
|
|
1582
|
+
const t = this.constructor._skill ?? q;
|
|
1557
1583
|
return {
|
|
1558
1584
|
...t,
|
|
1559
1585
|
_exports: {
|
|
@@ -1574,7 +1600,7 @@ const C = class C {
|
|
|
1574
1600
|
}
|
|
1575
1601
|
getObjectSkills() {
|
|
1576
1602
|
const e = [], t = /* @__PURE__ */ new Set();
|
|
1577
|
-
for (const s of Object.values(
|
|
1603
|
+
for (const s of Object.values(f(this, d).getObjectClasses())) {
|
|
1578
1604
|
if (typeof s.getOwnSkill != "function") continue;
|
|
1579
1605
|
const n = s.getOwnSkill();
|
|
1580
1606
|
n?._id && (t.has(n._id) || (t.add(n._id), e.push(n)));
|
|
@@ -1598,7 +1624,7 @@ const C = class C {
|
|
|
1598
1624
|
if (!(this._loaded || this._loading)) {
|
|
1599
1625
|
this._loading = !0;
|
|
1600
1626
|
try {
|
|
1601
|
-
await this.onLoad(), this._loaded = !0,
|
|
1627
|
+
await this.onLoad(), this._loaded = !0, l.log("Module " + this._name + " loaded");
|
|
1602
1628
|
} finally {
|
|
1603
1629
|
this._loading = !1;
|
|
1604
1630
|
}
|
|
@@ -1612,20 +1638,20 @@ const C = class C {
|
|
|
1612
1638
|
* @return {XObject|*}
|
|
1613
1639
|
*/
|
|
1614
1640
|
create(e) {
|
|
1615
|
-
e._debug &&
|
|
1641
|
+
e._debug && l.log("Creating object with data", e);
|
|
1616
1642
|
let t;
|
|
1617
1643
|
if (e.hasOwnProperty("_type")) {
|
|
1618
|
-
e._debug &&
|
|
1619
|
-
const s = String(e._type), n =
|
|
1644
|
+
e._debug && l.log("Object type is", e._type, this.hasObject(e._type) ? "found" : "not found", "in module", this._name);
|
|
1645
|
+
const s = String(e._type), n = f(this, d).getObjectClass(s);
|
|
1620
1646
|
if (!n)
|
|
1621
1647
|
throw `Xpell object '${s}' not found in module '${this._name}'`;
|
|
1622
|
-
typeof n == "function" && n.hasOwnProperty("defaults") &&
|
|
1648
|
+
typeof n == "function" && n.hasOwnProperty("defaults") && u.mergeDefaultsWithData(
|
|
1623
1649
|
e,
|
|
1624
1650
|
n.defaults
|
|
1625
1651
|
), t = new n(e);
|
|
1626
1652
|
} else
|
|
1627
|
-
t = new
|
|
1628
|
-
return
|
|
1653
|
+
t = new C(e);
|
|
1654
|
+
return f(this, d).addObject(t), e._children && e._children.forEach((s) => {
|
|
1629
1655
|
const n = this.create(s);
|
|
1630
1656
|
t.append(n);
|
|
1631
1657
|
}), t.onCreate(), t;
|
|
@@ -1635,15 +1661,15 @@ const C = class C {
|
|
|
1635
1661
|
* @param objectId op
|
|
1636
1662
|
*/
|
|
1637
1663
|
remove(e) {
|
|
1638
|
-
const t =
|
|
1664
|
+
const t = f(this, d).getObject(e);
|
|
1639
1665
|
if (!t) return;
|
|
1640
1666
|
const s = [], n = (r) => {
|
|
1641
1667
|
r?._id && (s.push(r._id), (r._children ?? []).forEach((i) => n(i)));
|
|
1642
1668
|
};
|
|
1643
|
-
n(t), typeof t.dispose == "function" && t.dispose(), s.reverse().forEach((r) =>
|
|
1669
|
+
n(t), typeof t.dispose == "function" && t.dispose(), s.reverse().forEach((r) => f(this, d).removeObject(r));
|
|
1644
1670
|
}
|
|
1645
1671
|
_info(e) {
|
|
1646
|
-
|
|
1672
|
+
l.log("module info");
|
|
1647
1673
|
}
|
|
1648
1674
|
//xpell interpreter
|
|
1649
1675
|
/**
|
|
@@ -1672,14 +1698,14 @@ const C = class C {
|
|
|
1672
1698
|
throw new Error(`Invalid XCommand: missing _op (module: ${this._name})`);
|
|
1673
1699
|
const t = e._object;
|
|
1674
1700
|
if (t) {
|
|
1675
|
-
const
|
|
1676
|
-
if (!
|
|
1701
|
+
const c = f(this, d).getObject(t);
|
|
1702
|
+
if (!c)
|
|
1677
1703
|
throw new Error(`Module '${this._name}' cant find object id: ${t}`);
|
|
1678
|
-
return await
|
|
1704
|
+
return await c.execute(e);
|
|
1679
1705
|
}
|
|
1680
|
-
const s = "_" +
|
|
1681
|
-
if (typeof
|
|
1682
|
-
return await
|
|
1706
|
+
const s = e._op, r = "_" + (s.startsWith("_") && s.length > 1 ? s.slice(1) : s).replaceAll("-", "_"), i = this[r];
|
|
1707
|
+
if (typeof i == "function")
|
|
1708
|
+
return await i.call(this, e);
|
|
1683
1709
|
throw new Error(`Module '${this._name}' cant find op: ${e._op}`);
|
|
1684
1710
|
}
|
|
1685
1711
|
/**
|
|
@@ -1688,11 +1714,11 @@ const C = class C {
|
|
|
1688
1714
|
* @param frameNumber Current frame number
|
|
1689
1715
|
*/
|
|
1690
1716
|
async onFrame(e) {
|
|
1691
|
-
const t =
|
|
1717
|
+
const t = f(this, d)._objects, s = Object.keys(t);
|
|
1692
1718
|
s.forEach((n) => {
|
|
1693
1719
|
const r = t[n];
|
|
1694
1720
|
r && r.onFrame && typeof r.onFrame == "function" && r?.onFrame(e);
|
|
1695
|
-
}),
|
|
1721
|
+
}), m.set(ae + this._id, s.length, {
|
|
1696
1722
|
source: "xmodule"
|
|
1697
1723
|
});
|
|
1698
1724
|
}
|
|
@@ -1707,10 +1733,10 @@ const C = class C {
|
|
|
1707
1733
|
* getObject directly on the module instead of om.getObject
|
|
1708
1734
|
*/
|
|
1709
1735
|
get om() {
|
|
1710
|
-
return
|
|
1736
|
+
return f(this, d);
|
|
1711
1737
|
}
|
|
1712
1738
|
get _object_manager() {
|
|
1713
|
-
return
|
|
1739
|
+
return f(this, d);
|
|
1714
1740
|
}
|
|
1715
1741
|
/**
|
|
1716
1742
|
* Returns the XObject instance from the module Object Manager
|
|
@@ -1718,10 +1744,10 @@ const C = class C {
|
|
|
1718
1744
|
* @returns XObject
|
|
1719
1745
|
*/
|
|
1720
1746
|
getObject(e) {
|
|
1721
|
-
return
|
|
1747
|
+
return f(this, d).getObject(e);
|
|
1722
1748
|
}
|
|
1723
1749
|
hasObject(e) {
|
|
1724
|
-
return
|
|
1750
|
+
return f(this, d).hasObjectClass(e);
|
|
1725
1751
|
}
|
|
1726
1752
|
/**
|
|
1727
1753
|
* Returns the XObject instance from the module Object Manager
|
|
@@ -1729,7 +1755,7 @@ const C = class C {
|
|
|
1729
1755
|
* xmodule._o["object-id"] is equivalent to xmodule.getObject("object-id")
|
|
1730
1756
|
*/
|
|
1731
1757
|
get _o() {
|
|
1732
|
-
return
|
|
1758
|
+
return f(this, d)._objects;
|
|
1733
1759
|
}
|
|
1734
1760
|
/**
|
|
1735
1761
|
* Imports external object pack to the engine
|
|
@@ -1737,7 +1763,7 @@ const C = class C {
|
|
|
1737
1763
|
* @param {XObjects} xObjectPack
|
|
1738
1764
|
*/
|
|
1739
1765
|
importObjectPack(e) {
|
|
1740
|
-
|
|
1766
|
+
f(this, d).registerObjects(e.getObjects());
|
|
1741
1767
|
}
|
|
1742
1768
|
/**
|
|
1743
1769
|
* Imports external object pack to the engine
|
|
@@ -1754,7 +1780,7 @@ const C = class C {
|
|
|
1754
1780
|
* @param xObject
|
|
1755
1781
|
*/
|
|
1756
1782
|
importObject(e, t) {
|
|
1757
|
-
|
|
1783
|
+
f(this, d).registerObject(e, t);
|
|
1758
1784
|
}
|
|
1759
1785
|
// In XModule
|
|
1760
1786
|
async _help(e) {
|
|
@@ -1774,7 +1800,7 @@ const C = class C {
|
|
|
1774
1800
|
};
|
|
1775
1801
|
}
|
|
1776
1802
|
};
|
|
1777
|
-
d = new WeakMap(),
|
|
1803
|
+
d = new WeakMap(), M._skill = q, M._ops = {
|
|
1778
1804
|
help: {
|
|
1779
1805
|
_name: "help",
|
|
1780
1806
|
_scope: "module",
|
|
@@ -1786,8 +1812,8 @@ d = new WeakMap(), C._skill = N, C._ops = {
|
|
|
1786
1812
|
_description: "Log basic module information."
|
|
1787
1813
|
}
|
|
1788
1814
|
};
|
|
1789
|
-
let
|
|
1790
|
-
const
|
|
1815
|
+
let I = M;
|
|
1816
|
+
const ce = {
|
|
1791
1817
|
_id: "xdata",
|
|
1792
1818
|
_title: "XData Runtime State Contract",
|
|
1793
1819
|
_version: "1.0.0",
|
|
@@ -1806,20 +1832,20 @@ const oe = {
|
|
|
1806
1832
|
_data_source: "XData key used by XObject/XUIObject for reactive data binding.",
|
|
1807
1833
|
"$xdata.key": "Runtime payload reference to an XData value."
|
|
1808
1834
|
}
|
|
1809
|
-
},
|
|
1835
|
+
}, k = class k extends I {
|
|
1810
1836
|
constructor() {
|
|
1811
|
-
super({ _name:
|
|
1837
|
+
super({ _name: k._name });
|
|
1812
1838
|
}
|
|
1813
1839
|
async _get(e) {
|
|
1814
|
-
const t =
|
|
1840
|
+
const t = u.ensure_params(e?._params), s = u.ensure_string(t.key, "key");
|
|
1815
1841
|
return {
|
|
1816
1842
|
_ok: !0,
|
|
1817
|
-
_result:
|
|
1843
|
+
_result: m.get(s)
|
|
1818
1844
|
};
|
|
1819
1845
|
}
|
|
1820
1846
|
async _set(e) {
|
|
1821
|
-
const t =
|
|
1822
|
-
return t._debug &&
|
|
1847
|
+
const t = u.ensure_params(e?._params), s = u.ensure_string(t.key, "key");
|
|
1848
|
+
return t._debug && v.log("XD SET", { key: s, value: t.value }), m.set(s, t.value, {
|
|
1823
1849
|
source: t.source ?? "xd:set"
|
|
1824
1850
|
}), {
|
|
1825
1851
|
_ok: !0,
|
|
@@ -1827,10 +1853,10 @@ const oe = {
|
|
|
1827
1853
|
};
|
|
1828
1854
|
}
|
|
1829
1855
|
async _patch(e) {
|
|
1830
|
-
const t =
|
|
1831
|
-
if (!
|
|
1856
|
+
const t = u.ensure_params(e?._params), s = u.ensure_string(t.key, "key");
|
|
1857
|
+
if (!u.is_plain_object(t.value))
|
|
1832
1858
|
throw new Error("xd patch expects value as plain object");
|
|
1833
|
-
return
|
|
1859
|
+
return m.patch(s, t.value, {
|
|
1834
1860
|
source: t.source ?? "xd:patch"
|
|
1835
1861
|
}), {
|
|
1836
1862
|
_ok: !0,
|
|
@@ -1838,8 +1864,8 @@ const oe = {
|
|
|
1838
1864
|
};
|
|
1839
1865
|
}
|
|
1840
1866
|
async _delete(e) {
|
|
1841
|
-
const t =
|
|
1842
|
-
return
|
|
1867
|
+
const t = u.ensure_params(e?._params), s = u.ensure_string(t.key, "key");
|
|
1868
|
+
return m.delete(s, {
|
|
1843
1869
|
source: t.source ?? "xd:delete"
|
|
1844
1870
|
}), {
|
|
1845
1871
|
_ok: !0,
|
|
@@ -1847,8 +1873,8 @@ const oe = {
|
|
|
1847
1873
|
};
|
|
1848
1874
|
}
|
|
1849
1875
|
async _touch(e) {
|
|
1850
|
-
const t =
|
|
1851
|
-
return
|
|
1876
|
+
const t = u.ensure_params(e?._params), s = u.ensure_string(t.key, "key");
|
|
1877
|
+
return m.touch(s, {
|
|
1852
1878
|
source: t.source ?? "xd:touch"
|
|
1853
1879
|
}), {
|
|
1854
1880
|
_ok: !0,
|
|
@@ -1856,14 +1882,14 @@ const oe = {
|
|
|
1856
1882
|
};
|
|
1857
1883
|
}
|
|
1858
1884
|
async _has(e) {
|
|
1859
|
-
const t =
|
|
1885
|
+
const t = u.ensure_params(e?._params), s = u.ensure_string(t.key, "key");
|
|
1860
1886
|
return {
|
|
1861
1887
|
_ok: !0,
|
|
1862
|
-
_result:
|
|
1888
|
+
_result: m.has(s)
|
|
1863
1889
|
};
|
|
1864
1890
|
}
|
|
1865
1891
|
};
|
|
1866
|
-
|
|
1892
|
+
k._name = "xd", k._skill = ce, k._ops = {
|
|
1867
1893
|
get: {
|
|
1868
1894
|
_name: "get",
|
|
1869
1895
|
_scope: "module",
|
|
@@ -1919,8 +1945,8 @@ v._name = "xd", v._skill = oe, v._ops = {
|
|
|
1919
1945
|
}
|
|
1920
1946
|
}
|
|
1921
1947
|
};
|
|
1922
|
-
let
|
|
1923
|
-
const
|
|
1948
|
+
let T = k;
|
|
1949
|
+
const _e = {
|
|
1924
1950
|
_id: "xem",
|
|
1925
1951
|
_title: "XEventManager Runtime Event Bus",
|
|
1926
1952
|
_version: "1.0.0",
|
|
@@ -1945,16 +1971,16 @@ const ae = {
|
|
|
1945
1971
|
"XEM is process-wide and listener order should not be assumed.",
|
|
1946
1972
|
"Event payloads should be JSON/data-only."
|
|
1947
1973
|
]
|
|
1948
|
-
},
|
|
1974
|
+
}, O = class O extends I {
|
|
1949
1975
|
constructor() {
|
|
1950
|
-
super({ _name:
|
|
1976
|
+
super({ _name: O._name });
|
|
1951
1977
|
}
|
|
1952
1978
|
async _fire(e) {
|
|
1953
|
-
const t =
|
|
1954
|
-
t._debug &&
|
|
1979
|
+
const t = u.ensure_params(e?._params), s = u.ensure_string(t.event, "event"), n = t.data;
|
|
1980
|
+
t._debug && v.log("xem fire 🔥 ", s, n), await E().fire(s, n);
|
|
1955
1981
|
}
|
|
1956
1982
|
};
|
|
1957
|
-
|
|
1983
|
+
O._name = "xem", O._skill = _e, O._ops = {
|
|
1958
1984
|
fire: {
|
|
1959
1985
|
_name: "fire",
|
|
1960
1986
|
_scope: "module",
|
|
@@ -1976,21 +2002,20 @@ k._name = "xem", k._skill = ae, k._ops = {
|
|
|
1976
2002
|
}
|
|
1977
2003
|
}
|
|
1978
2004
|
};
|
|
1979
|
-
let
|
|
1980
|
-
class
|
|
2005
|
+
let W = O;
|
|
2006
|
+
class ge {
|
|
1981
2007
|
/* -------------------------------------------------- */
|
|
1982
2008
|
/* core helpers */
|
|
1983
2009
|
/* -------------------------------------------------- */
|
|
1984
2010
|
static get(e, t, s) {
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
return n !== void 0 ? n : s;
|
|
2011
|
+
const r = (e?._params ?? e)?.[t];
|
|
2012
|
+
return r !== void 0 ? r : s;
|
|
1988
2013
|
}
|
|
1989
2014
|
static has(e, t) {
|
|
1990
|
-
return (e?._params
|
|
2015
|
+
return (e?._params ?? e)[t] !== void 0;
|
|
1991
2016
|
}
|
|
1992
2017
|
static str(e, ...t) {
|
|
1993
|
-
const s = e?._params
|
|
2018
|
+
const s = e?._params ?? e;
|
|
1994
2019
|
for (const n of t) {
|
|
1995
2020
|
const r = s?.[n];
|
|
1996
2021
|
if (r != null)
|
|
@@ -2001,7 +2026,7 @@ class me {
|
|
|
2001
2026
|
/* typed params */
|
|
2002
2027
|
/* -------------------------------------------------- */
|
|
2003
2028
|
static bool(e, t, s = !1) {
|
|
2004
|
-
const n = e?._params
|
|
2029
|
+
const n = e?._params ?? e, r = this.get(n, t, s);
|
|
2005
2030
|
if (typeof r == "boolean") return r;
|
|
2006
2031
|
if (typeof r == "number") return r !== 0;
|
|
2007
2032
|
if (typeof r == "string") {
|
|
@@ -2012,11 +2037,11 @@ class me {
|
|
|
2012
2037
|
return !!r;
|
|
2013
2038
|
}
|
|
2014
2039
|
static int(e, t, s = 0) {
|
|
2015
|
-
const n = e?._params
|
|
2040
|
+
const n = e?._params ?? e, r = this.get(n, t, s), i = parseInt(String(r), 10);
|
|
2016
2041
|
return Number.isFinite(i) ? i : s;
|
|
2017
2042
|
}
|
|
2018
2043
|
static json(e, t, s) {
|
|
2019
|
-
const n = e?._params
|
|
2044
|
+
const n = e?._params ?? e, r = this.get(n, t, s);
|
|
2020
2045
|
if (r == null) return s;
|
|
2021
2046
|
if (typeof r == "object") return r;
|
|
2022
2047
|
if (typeof r == "string")
|
|
@@ -2028,7 +2053,7 @@ class me {
|
|
|
2028
2053
|
return s;
|
|
2029
2054
|
}
|
|
2030
2055
|
}
|
|
2031
|
-
class
|
|
2056
|
+
class H extends Error {
|
|
2032
2057
|
constructor(e, t, s) {
|
|
2033
2058
|
super(t), this.name = "XError", this._code = e, this._level = s?._level ?? "error", this._meta = s?._meta, this._cause = s?._cause;
|
|
2034
2059
|
}
|
|
@@ -2051,7 +2076,7 @@ class K extends Error {
|
|
|
2051
2076
|
};
|
|
2052
2077
|
}
|
|
2053
2078
|
}
|
|
2054
|
-
class
|
|
2079
|
+
class b {
|
|
2055
2080
|
constructor(e) {
|
|
2056
2081
|
this._ok = !1, this._ts = Date.now(), this._pt = 0, e && this.setXData(e);
|
|
2057
2082
|
}
|
|
@@ -2059,23 +2084,23 @@ class y {
|
|
|
2059
2084
|
// Factories
|
|
2060
2085
|
// ---------------------------------------------------------------------------
|
|
2061
2086
|
static create(e) {
|
|
2062
|
-
return new
|
|
2087
|
+
return new b(e);
|
|
2063
2088
|
}
|
|
2064
2089
|
static ok(e) {
|
|
2065
|
-
return new
|
|
2090
|
+
return new b({ _ok: !0, _result: e });
|
|
2066
2091
|
}
|
|
2067
2092
|
static error(e) {
|
|
2068
|
-
if (e instanceof
|
|
2069
|
-
return new
|
|
2093
|
+
if (e instanceof H)
|
|
2094
|
+
return new b({
|
|
2070
2095
|
_ok: !1,
|
|
2071
2096
|
_result: e.toXData()
|
|
2072
2097
|
});
|
|
2073
|
-
const t = new
|
|
2098
|
+
const t = new H(
|
|
2074
2099
|
"E_INTERNAL",
|
|
2075
2100
|
e?.message ?? String(e),
|
|
2076
2101
|
{ _cause: e }
|
|
2077
2102
|
);
|
|
2078
|
-
return new
|
|
2103
|
+
return new b({
|
|
2079
2104
|
_ok: !1,
|
|
2080
2105
|
_result: t.toXData()
|
|
2081
2106
|
});
|
|
@@ -2108,33 +2133,33 @@ class y {
|
|
|
2108
2133
|
e && ("_ok" in e && (this._ok = !!e._ok), "_ts" in e && typeof e._ts == "number" && (this._ts = e._ts), "_pt" in e && typeof e._pt == "number" && (this._pt = e._pt), "_result" in e && (this._result = e._result));
|
|
2109
2134
|
}
|
|
2110
2135
|
}
|
|
2111
|
-
class
|
|
2136
|
+
class ye extends b {
|
|
2112
2137
|
constructor(e) {
|
|
2113
|
-
super(
|
|
2138
|
+
super(b.error(e).toXData());
|
|
2114
2139
|
}
|
|
2115
2140
|
}
|
|
2116
|
-
class
|
|
2141
|
+
class be extends b {
|
|
2117
2142
|
constructor(e) {
|
|
2118
2143
|
super({ _ok: !0, _result: e });
|
|
2119
2144
|
}
|
|
2120
2145
|
}
|
|
2121
|
-
const
|
|
2122
|
-
class
|
|
2146
|
+
const le = "engine:frame-number", he = "engine:fps";
|
|
2147
|
+
class ue {
|
|
2123
2148
|
constructor(e) {
|
|
2124
|
-
this._log_rules = {}, this._modules = {}, this._schedule_frame = e?._schedule_frame ??
|
|
2149
|
+
this._log_rules = {}, this._modules = {}, this._schedule_frame = e?._schedule_frame ?? u.createDefaultScheduler(e?._target_fps), this._version = "0.0.1", this._engine_id = u.guid(), this._frame_number = 0, this._fps_calc = new ee(), this.parser = w, this._modules = {}, l._enabled = !1, ie(this);
|
|
2125
2150
|
}
|
|
2126
2151
|
/**
|
|
2127
2152
|
* @deprecated use _verbose instead
|
|
2128
2153
|
* Enable Xpell logs to console
|
|
2129
2154
|
*/
|
|
2130
2155
|
set verbose(e) {
|
|
2131
|
-
|
|
2156
|
+
l._enabled = e;
|
|
2132
2157
|
}
|
|
2133
2158
|
/**
|
|
2134
2159
|
* Enable Xpell logs to console
|
|
2135
2160
|
*/
|
|
2136
2161
|
set _verbose(e) {
|
|
2137
|
-
|
|
2162
|
+
l._enabled = e;
|
|
2138
2163
|
}
|
|
2139
2164
|
/**
|
|
2140
2165
|
* Logs message to console using Xpell logger
|
|
@@ -2144,7 +2169,7 @@ class le {
|
|
|
2144
2169
|
* @param optionalParams
|
|
2145
2170
|
*/
|
|
2146
2171
|
log(e, ...t) {
|
|
2147
|
-
|
|
2172
|
+
l.log(e, ...t);
|
|
2148
2173
|
}
|
|
2149
2174
|
/**
|
|
2150
2175
|
* Delay the execution of the next command
|
|
@@ -2161,7 +2186,7 @@ class le {
|
|
|
2161
2186
|
* Use loadModuleAsync() for deterministic startup.
|
|
2162
2187
|
*/
|
|
2163
2188
|
addModule(e) {
|
|
2164
|
-
return this._modules.hasOwnProperty(e._name) ? (
|
|
2189
|
+
return this._modules.hasOwnProperty(e._name) ? (l.log("Module " + e._name + " already loaded"), !1) : (this._modules[e._name] = e, !0);
|
|
2165
2190
|
}
|
|
2166
2191
|
/**
|
|
2167
2192
|
* Loads Xpell module into the engine
|
|
@@ -2188,7 +2213,7 @@ class le {
|
|
|
2188
2213
|
* Display information about the Xpell engine to the console
|
|
2189
2214
|
*/
|
|
2190
2215
|
info() {
|
|
2191
|
-
|
|
2216
|
+
l.log(`Xpell information:
|
|
2192
2217
|
- Engine Id: ` + this._engine_id + `
|
|
2193
2218
|
- Version ` + this._version);
|
|
2194
2219
|
}
|
|
@@ -2223,7 +2248,7 @@ class le {
|
|
|
2223
2248
|
s?.onFrame && typeof s.onFrame == "function" && s.onFrame(this._frame_number);
|
|
2224
2249
|
}
|
|
2225
2250
|
const e = this._fps_calc.calc();
|
|
2226
|
-
|
|
2251
|
+
m.set(le, this._frame_number, { source: "engine" }), m.set(he, e, { source: "engine" }), m._compat_legacy_keys && (m.set("frame-number", this._frame_number, { source: "engine:legacy" }), m.set("fps", e, { source: "engine:legacy" })), this._schedule_frame(() => this.onFrame());
|
|
2227
2252
|
}
|
|
2228
2253
|
/**
|
|
2229
2254
|
* Gets Xpell module by name
|
|
@@ -2237,12 +2262,12 @@ class le {
|
|
|
2237
2262
|
* Start Xpell engine for web browsers using requestAnimationFrame
|
|
2238
2263
|
*/
|
|
2239
2264
|
start() {
|
|
2240
|
-
|
|
2265
|
+
l.log("Loading Xpell core modules...[xd, xem]"), this.loadModule(new T()), this.loadModule(new W()), l.log("Starting Xpell"), this.onFrame();
|
|
2241
2266
|
}
|
|
2242
2267
|
getCoreSkills() {
|
|
2243
2268
|
return [
|
|
2244
|
-
|
|
2245
|
-
|
|
2269
|
+
q,
|
|
2270
|
+
U
|
|
2246
2271
|
];
|
|
2247
2272
|
}
|
|
2248
2273
|
getModuleSkills() {
|
|
@@ -2265,38 +2290,38 @@ class le {
|
|
|
2265
2290
|
};
|
|
2266
2291
|
}
|
|
2267
2292
|
}
|
|
2268
|
-
const
|
|
2293
|
+
const we = new ue();
|
|
2269
2294
|
export {
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2295
|
+
R as XCommand,
|
|
2296
|
+
he as XD_FPS,
|
|
2297
|
+
le as XD_FRAME_NUMBER,
|
|
2298
|
+
D as XData,
|
|
2299
|
+
T as XDataModule,
|
|
2300
|
+
H as XError,
|
|
2301
|
+
W as XEventManagerModule,
|
|
2302
|
+
l as XLogger,
|
|
2303
|
+
I as XModule,
|
|
2304
|
+
C as XObject,
|
|
2305
|
+
ne as XObjectManager,
|
|
2306
|
+
me as XObjectPack,
|
|
2307
|
+
ge as XParams,
|
|
2283
2308
|
w as XParser,
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2309
|
+
b as XResponse,
|
|
2310
|
+
ye as XResponseError,
|
|
2311
|
+
be as XResponseOK,
|
|
2312
|
+
Z as XUtils,
|
|
2313
|
+
we as Xpell,
|
|
2314
|
+
ue as XpellEngine,
|
|
2315
|
+
se as _XData,
|
|
2316
|
+
fe as _XEventManager,
|
|
2317
|
+
te as _XLogger,
|
|
2318
|
+
Y as _XUtils,
|
|
2319
|
+
we as _x,
|
|
2320
|
+
m as _xd,
|
|
2321
|
+
l as _xlog,
|
|
2322
|
+
u as _xu,
|
|
2298
2323
|
g as createNanoCommandWithSkill,
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2324
|
+
we as default,
|
|
2325
|
+
E as getXEventManager,
|
|
2326
|
+
pe as setXEventManager
|
|
2302
2327
|
};
|