@xpell/core 2.0.2 → 2.0.3
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/FPSCalc.d.ts +18 -0
- package/dist/XDataModule.d.ts +12 -0
- package/dist/XUtils.d.ts +93 -18
- package/dist/xpell-core.cjs.js +3 -2
- package/dist/xpell-core.es.js +706 -354
- package/docs/AGENTS.md +2 -2
- package/package.json +1 -1
package/dist/xpell-core.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var B = (o) => {
|
|
2
2
|
throw TypeError(o);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var f = (o, e, t) => (
|
|
4
|
+
var z = (o, e, t) => e.has(o) || B("Cannot " + t);
|
|
5
|
+
var f = (o, e, t) => (z(o, e, "read from private field"), t ? t.call(o) : e.get(o)), J = (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), V = (o, e, t, s) => (z(o, e, "write to private field"), s ? s.call(o, t) : e.set(o, t), t);
|
|
6
6
|
class Y {
|
|
7
7
|
/**
|
|
8
8
|
* Create ignore list for parser to ignore spell words
|
|
@@ -11,8 +11,8 @@ class Y {
|
|
|
11
11
|
*/
|
|
12
12
|
createIgnoreList(e, t) {
|
|
13
13
|
if (!e) return t;
|
|
14
|
-
const s = e.split(",").map((
|
|
15
|
-
for (const
|
|
14
|
+
const s = e.split(",").map((r) => r.trim()).filter(Boolean);
|
|
15
|
+
for (const r of s) t[r] = "";
|
|
16
16
|
return t;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
@@ -33,12 +33,12 @@ class Y {
|
|
|
33
33
|
const c = Array.from(i, (a) => a.toString(16).padStart(2, "0"));
|
|
34
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
|
-
const s = "0123456789abcdef".split(""),
|
|
37
|
-
let
|
|
38
|
-
|
|
36
|
+
const s = "0123456789abcdef".split(""), r = [];
|
|
37
|
+
let n;
|
|
38
|
+
r[8] = r[13] = r[18] = r[23] = "-", r[14] = "4";
|
|
39
39
|
for (let i = 0; i < 36; i++)
|
|
40
|
-
|
|
41
|
-
return
|
|
40
|
+
r[i] || (n = (0 | Math.random() * 16) >>> 0, r[i] = s[i === 19 ? n & 3 | 8 : n & 15]);
|
|
41
|
+
return r.join("");
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* Merge defaults into data object (mutates data)
|
|
@@ -49,10 +49,20 @@ class Y {
|
|
|
49
49
|
mergeDefaultsWithData(e, t, s = !1) {
|
|
50
50
|
if (!e) return t;
|
|
51
51
|
e._id || (e._id = e.id ?? this.guid());
|
|
52
|
-
for (const
|
|
53
|
-
(!(
|
|
52
|
+
for (const r of Object.keys(t))
|
|
53
|
+
(!(r in e) || s) && (e[r] = t[r]);
|
|
54
54
|
return e;
|
|
55
55
|
}
|
|
56
|
+
deepMergeDefaults(e, t) {
|
|
57
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
58
|
+
return structuredClone(t);
|
|
59
|
+
const s = structuredClone(t);
|
|
60
|
+
for (const r of Object.keys(e)) {
|
|
61
|
+
const n = e[r], i = t?.[r];
|
|
62
|
+
n && typeof n == "object" && !Array.isArray(n) && i && typeof i == "object" && !Array.isArray(i) ? s[r] = this.deepMergeDefaults(n, i) : s[r] = n;
|
|
63
|
+
}
|
|
64
|
+
return s;
|
|
65
|
+
}
|
|
56
66
|
/**
|
|
57
67
|
* Encode string to Base64 (UTF-8 safe, cross-platform)
|
|
58
68
|
*/
|
|
@@ -61,7 +71,7 @@ class Y {
|
|
|
61
71
|
if (typeof t.btoa == "function") {
|
|
62
72
|
const s = encodeURIComponent(String(e)).replace(
|
|
63
73
|
/%([0-9A-F]{2})/g,
|
|
64
|
-
(
|
|
74
|
+
(r, n) => String.fromCharCode(parseInt(n, 16))
|
|
65
75
|
);
|
|
66
76
|
return t.btoa(s);
|
|
67
77
|
}
|
|
@@ -75,8 +85,8 @@ class Y {
|
|
|
75
85
|
decode(e) {
|
|
76
86
|
const t = globalThis;
|
|
77
87
|
if (typeof t.atob == "function") {
|
|
78
|
-
const s = t.atob(String(e)),
|
|
79
|
-
return decodeURIComponent(
|
|
88
|
+
const s = t.atob(String(e)), r = Array.prototype.map.call(s, (n) => "%" + n.charCodeAt(0).toString(16).padStart(2, "0")).join("");
|
|
89
|
+
return decodeURIComponent(r);
|
|
80
90
|
}
|
|
81
91
|
if (t.Buffer && typeof t.Buffer.from == "function")
|
|
82
92
|
return t.Buffer.from(String(e), "base64").toString("utf8");
|
|
@@ -103,12 +113,12 @@ class Y {
|
|
|
103
113
|
createDefaultScheduler(e) {
|
|
104
114
|
const t = globalThis;
|
|
105
115
|
if (typeof t.requestAnimationFrame == "function")
|
|
106
|
-
return (
|
|
116
|
+
return (n) => t.requestAnimationFrame(n);
|
|
107
117
|
const s = typeof e == "number" && isFinite(e) && e > 0 ? e : 60;
|
|
108
118
|
if (typeof t.setImmediate == "function" && (!e || e >= 60))
|
|
109
|
-
return (
|
|
110
|
-
const
|
|
111
|
-
return (
|
|
119
|
+
return (n) => t.setImmediate(n);
|
|
120
|
+
const r = Math.max(1, Math.round(1e3 / s));
|
|
121
|
+
return (n) => t.setTimeout(n, r);
|
|
112
122
|
}
|
|
113
123
|
to_iso_now() {
|
|
114
124
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -116,11 +126,28 @@ class Y {
|
|
|
116
126
|
is_plain_object(e) {
|
|
117
127
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
118
128
|
}
|
|
129
|
+
ensure_object(e, t) {
|
|
130
|
+
if (!this.is_plain_object(e))
|
|
131
|
+
throw new Error(`Invalid '${t}'`);
|
|
132
|
+
return e;
|
|
133
|
+
}
|
|
119
134
|
ensure_string(e, t) {
|
|
120
135
|
if (typeof e != "string" || !e.trim())
|
|
121
136
|
throw new Error(`Invalid '${t}'`);
|
|
122
137
|
return e.trim();
|
|
123
138
|
}
|
|
139
|
+
ensure_boolean(e, t) {
|
|
140
|
+
if (typeof e == "boolean") return e;
|
|
141
|
+
if (e === "true") return !0;
|
|
142
|
+
if (e === "false") return !1;
|
|
143
|
+
throw new Error(`Invalid '${t}'`);
|
|
144
|
+
}
|
|
145
|
+
ensure_number(e, t) {
|
|
146
|
+
const s = Number(e);
|
|
147
|
+
if (isNaN(s))
|
|
148
|
+
throw new Error(`Invalid '${t}'`);
|
|
149
|
+
return s;
|
|
150
|
+
}
|
|
124
151
|
ensure_params(e) {
|
|
125
152
|
return this.is_plain_object(e) ? e : {};
|
|
126
153
|
}
|
|
@@ -130,9 +157,9 @@ class Y {
|
|
|
130
157
|
*/
|
|
131
158
|
addIfNotNull(e, t, s) {
|
|
132
159
|
if (!(!e || !t || !Array.isArray(s)))
|
|
133
|
-
for (const
|
|
134
|
-
const
|
|
135
|
-
|
|
160
|
+
for (const r of s) {
|
|
161
|
+
const n = e[r];
|
|
162
|
+
n != null && (t[r] = n);
|
|
136
163
|
}
|
|
137
164
|
}
|
|
138
165
|
/**
|
|
@@ -175,21 +202,252 @@ class Y {
|
|
|
175
202
|
calculateExpiration(e) {
|
|
176
203
|
const s = String(e ?? "").trim().match(/^(\d+)([hdy])$/);
|
|
177
204
|
if (!s) throw new Error("Invalid expiration format. Use: 1h | 2d | 3y");
|
|
178
|
-
const
|
|
205
|
+
const r = Number.parseInt(s[1], 10), n = s[2], i = Date.now();
|
|
179
206
|
let c = 0;
|
|
180
|
-
switch (
|
|
207
|
+
switch (n) {
|
|
181
208
|
case "h":
|
|
182
|
-
c =
|
|
209
|
+
c = r * 60 * 60 * 1e3;
|
|
183
210
|
break;
|
|
184
211
|
case "d":
|
|
185
|
-
c =
|
|
212
|
+
c = r * 24 * 60 * 60 * 1e3;
|
|
186
213
|
break;
|
|
187
214
|
case "y":
|
|
188
|
-
c =
|
|
215
|
+
c = r * 365 * 24 * 60 * 60 * 1e3;
|
|
189
216
|
break;
|
|
190
217
|
}
|
|
191
218
|
return i + c;
|
|
192
219
|
}
|
|
220
|
+
// ============================================================================
|
|
221
|
+
// AI / Runtime Primitive Helpers
|
|
222
|
+
// ============================================================================
|
|
223
|
+
normalize_prompt(e) {
|
|
224
|
+
return String(e ?? "").normalize("NFKC").replace(/\s+/g, " ").trim();
|
|
225
|
+
}
|
|
226
|
+
normalize_prompt_key(e) {
|
|
227
|
+
return this.normalize_prompt(e).toLowerCase().replace(/[_/]+/g, " ");
|
|
228
|
+
}
|
|
229
|
+
is_non_empty_string(e) {
|
|
230
|
+
return typeof e == "string" && e.trim().length > 0;
|
|
231
|
+
}
|
|
232
|
+
has_value(e) {
|
|
233
|
+
return e == null ? !1 : Array.isArray(e) ? e.length > 0 : typeof e == "object" ? Object.keys(e).length > 0 : !0;
|
|
234
|
+
}
|
|
235
|
+
ensure_array(e) {
|
|
236
|
+
return Array.isArray(e) ? e : e == null ? [] : [e];
|
|
237
|
+
}
|
|
238
|
+
to_record(e) {
|
|
239
|
+
return this.is_plain_object(e) ? e : {};
|
|
240
|
+
}
|
|
241
|
+
safe_json_parse(e, t) {
|
|
242
|
+
if (typeof e != "string") return t;
|
|
243
|
+
try {
|
|
244
|
+
return JSON.parse(e);
|
|
245
|
+
} catch {
|
|
246
|
+
return t;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
safe_json_stringify(e, t = "{}") {
|
|
250
|
+
try {
|
|
251
|
+
return JSON.stringify(e);
|
|
252
|
+
} catch {
|
|
253
|
+
return t;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
clone_json(e) {
|
|
257
|
+
return this.safe_json_parse(
|
|
258
|
+
this.safe_json_stringify(e, "null"),
|
|
259
|
+
e
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
get_path(e, t, s) {
|
|
263
|
+
const r = Array.isArray(t) ? t : String(t ?? "").split(".").filter(Boolean);
|
|
264
|
+
let n = e;
|
|
265
|
+
for (const i of r) {
|
|
266
|
+
if (n == null) return s;
|
|
267
|
+
n = n[i];
|
|
268
|
+
}
|
|
269
|
+
return n === void 0 ? s : n;
|
|
270
|
+
}
|
|
271
|
+
set_path(e, t, s) {
|
|
272
|
+
const r = Array.isArray(t) ? t : String(t ?? "").split(".").filter(Boolean);
|
|
273
|
+
if (!r.length) return e;
|
|
274
|
+
let n = e;
|
|
275
|
+
for (let i = 0; i < r.length - 1; i++) {
|
|
276
|
+
const c = r[i];
|
|
277
|
+
this.is_plain_object(n[c]) || (n[c] = {}), n = n[c];
|
|
278
|
+
}
|
|
279
|
+
return n[r[r.length - 1]] = s, e;
|
|
280
|
+
}
|
|
281
|
+
pick_defined(e, t) {
|
|
282
|
+
const s = {};
|
|
283
|
+
if (!this.is_plain_object(e) || !Array.isArray(t)) return s;
|
|
284
|
+
for (const r of t) {
|
|
285
|
+
const n = e[r];
|
|
286
|
+
n != null && (s[r] = n);
|
|
287
|
+
}
|
|
288
|
+
return s;
|
|
289
|
+
}
|
|
290
|
+
omit_undefined(e) {
|
|
291
|
+
const t = {};
|
|
292
|
+
if (!this.is_plain_object(e)) return t;
|
|
293
|
+
for (const [s, r] of Object.entries(e))
|
|
294
|
+
r !== void 0 && (t[s] = r);
|
|
295
|
+
return t;
|
|
296
|
+
}
|
|
297
|
+
escape_regexp(e) {
|
|
298
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
299
|
+
}
|
|
300
|
+
matches_keyword(e, t) {
|
|
301
|
+
const s = /^[a-z0-9]+$/.test(t) ? "s?" : "";
|
|
302
|
+
return new RegExp(
|
|
303
|
+
`(^|[^a-z0-9])${this.escape_regexp(t)}${s}($|[^a-z0-9])`
|
|
304
|
+
).test(e);
|
|
305
|
+
}
|
|
306
|
+
match_keywords(e, t) {
|
|
307
|
+
return t.filter((s) => this.matches_keyword(e, s));
|
|
308
|
+
}
|
|
309
|
+
contains_keyword(e, t) {
|
|
310
|
+
return this.match_keywords(e, t).length > 0;
|
|
311
|
+
}
|
|
312
|
+
read_optional_string(e, t) {
|
|
313
|
+
if (e != null) {
|
|
314
|
+
if (typeof e != "string" || e.trim().length === 0)
|
|
315
|
+
throw new Error(`Invalid '${t}': expected non-empty string`);
|
|
316
|
+
return e.trim();
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
read_optional_boolean(e, t) {
|
|
320
|
+
if (e != null) {
|
|
321
|
+
if (typeof e != "boolean")
|
|
322
|
+
throw new Error(`Invalid '${t}': expected boolean`);
|
|
323
|
+
return e;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
read_optional_number(e, t) {
|
|
327
|
+
if (e != null) {
|
|
328
|
+
if (typeof e != "number" || !isFinite(e))
|
|
329
|
+
throw new Error(`Invalid '${t}': expected finite number`);
|
|
330
|
+
return e;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
read_optional_object(e, t) {
|
|
334
|
+
if (e != null) {
|
|
335
|
+
if (!this.is_plain_object(e))
|
|
336
|
+
throw new Error(`Invalid '${t}': expected plain object`);
|
|
337
|
+
return e;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Returns unique string values while preserving insertion order.
|
|
342
|
+
*
|
|
343
|
+
* Example:
|
|
344
|
+
* ["a", "b", "a"] -> ["a", "b"]
|
|
345
|
+
*/
|
|
346
|
+
unique_strings(e) {
|
|
347
|
+
return Array.from(new Set(e));
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Normalizes IDs (trim + lowercase) and removes duplicates.
|
|
351
|
+
*
|
|
352
|
+
* Example:
|
|
353
|
+
* [" User ", "user", "ADMIN"] -> ["user", "admin"]
|
|
354
|
+
*/
|
|
355
|
+
unique_normalized_ids(e) {
|
|
356
|
+
return Array.from(
|
|
357
|
+
new Set(
|
|
358
|
+
e.map((t) => t.trim().toLowerCase()).filter((t) => t.length > 0)
|
|
359
|
+
)
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Truncates long text while preserving the beginning.
|
|
364
|
+
* Appends a truncation marker when the text exceeds max_chars.
|
|
365
|
+
*/
|
|
366
|
+
truncate_text(e, t) {
|
|
367
|
+
return e.length <= t ? e : `${e.slice(0, Math.max(0, t - 18))}
|
|
368
|
+
...[truncated]`;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Serializes a value as formatted JSON and truncates the result
|
|
372
|
+
* when it exceeds the specified character limit.
|
|
373
|
+
*/
|
|
374
|
+
compact_json(e, t = 5e3) {
|
|
375
|
+
return this.truncate_text(
|
|
376
|
+
JSON.stringify(e, null, 2),
|
|
377
|
+
t
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Serializes a value as compact single-line JSON and truncates
|
|
382
|
+
* the result when it exceeds the specified character limit.
|
|
383
|
+
*/
|
|
384
|
+
compact_inline_json(e, t = 5e3) {
|
|
385
|
+
return this.truncate_text(
|
|
386
|
+
JSON.stringify(e),
|
|
387
|
+
t
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Safe version of compact_inline_json().
|
|
392
|
+
* Returns an empty string when serialization fails.
|
|
393
|
+
*/
|
|
394
|
+
safe_compact_inline_json(e, t = 5e3) {
|
|
395
|
+
try {
|
|
396
|
+
return this.compact_inline_json(e, t);
|
|
397
|
+
} catch {
|
|
398
|
+
return "";
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Returns the first max_items items from an array.
|
|
403
|
+
* Returns an empty array for non-array values.
|
|
404
|
+
*/
|
|
405
|
+
compact_array(e, t = 20) {
|
|
406
|
+
return Array.isArray(e) ? e.slice(0, t) : [];
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Normalizes arbitrary text into a stable identifier.
|
|
410
|
+
*
|
|
411
|
+
* Example:
|
|
412
|
+
* "User Profile" -> "user-profile"
|
|
413
|
+
* "user_profile" -> "user-profile"
|
|
414
|
+
*/
|
|
415
|
+
normalize_id(e) {
|
|
416
|
+
if (typeof e != "string") return;
|
|
417
|
+
const t = e.toLowerCase().trim().replace(/[_\s]+/gu, "-").replace(/[^a-z0-9-]+/gu, "-").replace(/-+/gu, "-").replace(/^-|-$/gu, "");
|
|
418
|
+
return t.length > 0 ? t : void 0;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Normalizes an array of identifiers and removes duplicates.
|
|
422
|
+
*
|
|
423
|
+
* Example:
|
|
424
|
+
* ["User Profile", "user-profile"]
|
|
425
|
+
* -> ["user-profile"]
|
|
426
|
+
*/
|
|
427
|
+
normalize_id_array(e) {
|
|
428
|
+
return Array.isArray(e) ? e.map((t) => this.normalize_id(t)).filter((t) => typeof t == "string").filter((t, s, r) => r.indexOf(t) === s) : [];
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* @deprecated Use normalize_id_array().
|
|
432
|
+
*/
|
|
433
|
+
normalize_string_array(e) {
|
|
434
|
+
return this.normalize_id_array(e);
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Returns only plain object items from an array.
|
|
438
|
+
* Non-object values, nulls, and arrays are ignored.
|
|
439
|
+
*/
|
|
440
|
+
ensure_object_array(e) {
|
|
441
|
+
return Array.isArray(e) ? e.filter(
|
|
442
|
+
(t) => this.is_plain_object(t)
|
|
443
|
+
) : [];
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* @deprecated Use ensure_object_array().
|
|
447
|
+
*/
|
|
448
|
+
read_object_array(e) {
|
|
449
|
+
return this.ensure_object_array(e);
|
|
450
|
+
}
|
|
193
451
|
}
|
|
194
452
|
const Z = new Y(), u = Z;
|
|
195
453
|
class ee {
|
|
@@ -198,15 +456,15 @@ class ee {
|
|
|
198
456
|
#t = 0;
|
|
199
457
|
// EMA of ms/frame
|
|
200
458
|
#s = 0;
|
|
201
|
-
#n;
|
|
202
|
-
// weight of new samples (0..1)
|
|
203
459
|
#r;
|
|
460
|
+
// weight of new samples (0..1)
|
|
461
|
+
#n;
|
|
204
462
|
// minimum integer change to update displayed fps
|
|
205
463
|
constructor(e = 0.05, t = 1) {
|
|
206
464
|
const s = Number(e);
|
|
207
|
-
this.#
|
|
208
|
-
const
|
|
209
|
-
this.#
|
|
465
|
+
this.#r = Number.isFinite(s) ? Math.min(1, Math.max(1e-3, s)) : 0.05;
|
|
466
|
+
const r = Number(t);
|
|
467
|
+
this.#n = Number.isFinite(r) ? Math.max(0, Math.floor(r)) : 1;
|
|
210
468
|
}
|
|
211
469
|
now() {
|
|
212
470
|
const e = globalThis.performance;
|
|
@@ -218,11 +476,11 @@ class ee {
|
|
|
218
476
|
return this.#s = e, this.#e;
|
|
219
477
|
const t = e - this.#s;
|
|
220
478
|
if (this.#s = e, !Number.isFinite(t) || t <= 0) return this.#e;
|
|
221
|
-
this.#t === 0 ? this.#t = t : this.#t = (1 - this.#
|
|
479
|
+
this.#t === 0 ? this.#t = t : this.#t = (1 - this.#r) * this.#t + this.#r * t;
|
|
222
480
|
const s = 1e3 / this.#t;
|
|
223
481
|
if (!Number.isFinite(s) || s <= 0) return this.#e;
|
|
224
|
-
const
|
|
225
|
-
return this.#e !== 0 && this.#
|
|
482
|
+
const r = Math.round(s);
|
|
483
|
+
return this.#e !== 0 && this.#n > 0 && Math.abs(r - this.#e) < this.#n ? this.#e : (this.#e = r, this.#e);
|
|
226
484
|
}
|
|
227
485
|
reset() {
|
|
228
486
|
this.#e = 0, this.#t = 0, this.#s = 0;
|
|
@@ -252,11 +510,11 @@ class te {
|
|
|
252
510
|
!this._enabled || !this._debug || console.debug(this._dt(), e, ...t);
|
|
253
511
|
}
|
|
254
512
|
}
|
|
255
|
-
const
|
|
513
|
+
const h = new te(), Q = typeof process < "u" && !!process?.env && process.env.NODE_ENV === "production";
|
|
256
514
|
Q || console.info(
|
|
257
515
|
"[Xpell] _xlog is redirected to console in development mode. Tip: enable 'Show timestamps' in DevTools → Console for timed logs."
|
|
258
516
|
);
|
|
259
|
-
const
|
|
517
|
+
const x = Q ? h : console;
|
|
260
518
|
class se {
|
|
261
519
|
constructor() {
|
|
262
520
|
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 = {};
|
|
@@ -269,10 +527,10 @@ class se {
|
|
|
269
527
|
get _o() {
|
|
270
528
|
return !this._compat_writes && !this._warn_legacy_writes ? this._objects : (this._o_proxy || (this._o_proxy = new Proxy(this._objects, {
|
|
271
529
|
set: (e, t, s) => {
|
|
272
|
-
const
|
|
530
|
+
const r = String(t);
|
|
273
531
|
return this._warn_legacy_writes && console.warn(
|
|
274
|
-
`[XData] Legacy write: _o["${
|
|
275
|
-
), this._compat_writes ? this.set(
|
|
532
|
+
`[XData] Legacy write: _o["${r}"] = ... ; prefer XData.set("${r}", value).`
|
|
533
|
+
), this._compat_writes ? this.set(r, s, { source: "legacy:_o" }) : e[r] = s, !0;
|
|
276
534
|
},
|
|
277
535
|
deleteProperty: (e, t) => {
|
|
278
536
|
const s = String(t);
|
|
@@ -288,13 +546,13 @@ class se {
|
|
|
288
546
|
}
|
|
289
547
|
/** Preferred write API */
|
|
290
548
|
set(e, t, s) {
|
|
291
|
-
const
|
|
292
|
-
this._objects[e] = t, this._emit({ key: e, value: t, prev:
|
|
549
|
+
const r = this._objects[e];
|
|
550
|
+
this._objects[e] = t, this._emit({ key: e, value: t, prev: r, ts: Date.now(), op: "set", meta: s });
|
|
293
551
|
}
|
|
294
552
|
/** Shallow merge helper (nice for state objects) */
|
|
295
553
|
patch(e, t, s) {
|
|
296
|
-
const
|
|
297
|
-
this._objects[e] = i, this._emit({ key: e, value: i, prev:
|
|
554
|
+
const r = this._objects[e], i = { ...r && typeof r == "object" ? r : {}, ...t };
|
|
555
|
+
this._objects[e] = i, this._emit({ key: e, value: i, prev: r, ts: Date.now(), op: "patch", meta: s });
|
|
298
556
|
}
|
|
299
557
|
/** In-place mutation notifier */
|
|
300
558
|
touch(e, t) {
|
|
@@ -339,8 +597,8 @@ class se {
|
|
|
339
597
|
for (const s of this._any_listeners) s(e);
|
|
340
598
|
}
|
|
341
599
|
}
|
|
342
|
-
const
|
|
343
|
-
class
|
|
600
|
+
const v = new se(), m = v;
|
|
601
|
+
class N {
|
|
344
602
|
constructor(e) {
|
|
345
603
|
e && Object.keys(e).forEach((t) => {
|
|
346
604
|
this[t] = e[t];
|
|
@@ -360,17 +618,17 @@ class R {
|
|
|
360
618
|
return this._params?.hasOwnProperty(t) ? this._params[t] : this._params?.hasOwnProperty(e) ? this._params[e] : s;
|
|
361
619
|
}
|
|
362
620
|
}
|
|
363
|
-
const
|
|
621
|
+
const E = {
|
|
364
622
|
type: "_type",
|
|
365
623
|
children: "_children"
|
|
366
|
-
},
|
|
624
|
+
}, j = class j {
|
|
367
625
|
/**
|
|
368
626
|
* Adds HTML-Xpell Mapping item
|
|
369
627
|
* @param htmlElement HTML element to change from
|
|
370
628
|
* @param xpellElement Xpell element to change to
|
|
371
629
|
*/
|
|
372
630
|
static addHtml2XpellMapItem(e, t) {
|
|
373
|
-
|
|
631
|
+
j.html2XMap.elements[e] = t;
|
|
374
632
|
}
|
|
375
633
|
/**
|
|
376
634
|
* convert text command to Xpell json command
|
|
@@ -378,60 +636,60 @@ const A = {
|
|
|
378
636
|
*/
|
|
379
637
|
static parse(e, t) {
|
|
380
638
|
const s = e.split(" ");
|
|
381
|
-
let
|
|
382
|
-
if (t ? (
|
|
383
|
-
for (let
|
|
384
|
-
const i = s[
|
|
639
|
+
let r = new N();
|
|
640
|
+
if (t ? (r._module = t, r._op = s[0]) : (r._module = s[0], r._op = s[1]), r._params = {}, s.length > 1)
|
|
641
|
+
for (let n = 2; n < s.length; ++n) {
|
|
642
|
+
const i = s[n];
|
|
385
643
|
if (i.indexOf(":") > -1) {
|
|
386
644
|
const a = i.split(":");
|
|
387
|
-
|
|
645
|
+
r._params[a[0]] = a[1];
|
|
388
646
|
} else
|
|
389
|
-
|
|
647
|
+
r._params[n - 1] = s[n];
|
|
390
648
|
}
|
|
391
|
-
return
|
|
649
|
+
return r;
|
|
392
650
|
}
|
|
393
651
|
static replaceSpacesInQuotes(e, t = "_%20_") {
|
|
394
|
-
return e.replace(/(['"])(.*?)\1/g, (s,
|
|
395
|
-
const i = String(
|
|
396
|
-
return `${
|
|
652
|
+
return e.replace(/(['"])(.*?)\1/g, (s, r, n) => {
|
|
653
|
+
const i = String(n).replace(/\s/g, t);
|
|
654
|
+
return `${r}${i}${r}`;
|
|
397
655
|
});
|
|
398
656
|
}
|
|
399
657
|
static parseObjectCommand(e, t) {
|
|
400
|
-
e =
|
|
401
|
-
const s = e.trim().split(/\s+/),
|
|
402
|
-
if (!
|
|
403
|
-
let
|
|
404
|
-
if (s[0]?.startsWith("#") && (
|
|
658
|
+
e = j.replaceSpacesInQuotes(e);
|
|
659
|
+
const s = e.trim().split(/\s+/), r = t || s.shift();
|
|
660
|
+
if (!r) throw new Error("Missing module name");
|
|
661
|
+
let n;
|
|
662
|
+
if (s[0]?.startsWith("#") && (n = s.shift().slice(1), !n))
|
|
405
663
|
throw new Error("Invalid object selector '#'. Use '#<id>'");
|
|
406
664
|
const i = s.shift();
|
|
407
665
|
if (!i) throw new Error("Missing operation");
|
|
408
666
|
const c = {};
|
|
409
667
|
let a = null, _ = null;
|
|
410
|
-
if (s.forEach((
|
|
668
|
+
if (s.forEach((l) => {
|
|
411
669
|
if (_) {
|
|
412
|
-
if (_ += ` ${
|
|
413
|
-
const
|
|
414
|
-
c[a] =
|
|
670
|
+
if (_ += ` ${l}`, l.endsWith(_[0])) {
|
|
671
|
+
const d = _.slice(1, -1).replace(/_%20_/g, " ");
|
|
672
|
+
c[a] = d, _ = null;
|
|
415
673
|
}
|
|
416
674
|
return;
|
|
417
675
|
}
|
|
418
|
-
if (
|
|
419
|
-
if (_ =
|
|
420
|
-
const
|
|
421
|
-
c[a] =
|
|
676
|
+
if (l.startsWith('"') || l.startsWith("'")) {
|
|
677
|
+
if (_ = l, l.endsWith(l[0]) && l.length > 1) {
|
|
678
|
+
const d = l.slice(1, -1).replace(/_%20_/g, " ");
|
|
679
|
+
c[a] = d, _ = null;
|
|
422
680
|
}
|
|
423
681
|
return;
|
|
424
682
|
}
|
|
425
|
-
if (
|
|
426
|
-
const
|
|
427
|
-
c[
|
|
683
|
+
if (l.includes(":")) {
|
|
684
|
+
const d = l.split(":"), y = d[0], g = d.slice(1).join(":").replace(/_%20_/g, " ");
|
|
685
|
+
c[y] = g, a = null;
|
|
428
686
|
return;
|
|
429
687
|
}
|
|
430
|
-
a =
|
|
688
|
+
a = l.replace(/_%20_/g, " ");
|
|
431
689
|
}), _) throw new Error("Unclosed quoted parameter value");
|
|
432
690
|
return {
|
|
433
|
-
_module:
|
|
434
|
-
_object:
|
|
691
|
+
_module: r,
|
|
692
|
+
_object: n,
|
|
435
693
|
_op: i,
|
|
436
694
|
_params: c
|
|
437
695
|
};
|
|
@@ -443,7 +701,7 @@ const A = {
|
|
|
443
701
|
*/
|
|
444
702
|
static xmlString2Xpell(e) {
|
|
445
703
|
const s = new DOMParser().parseFromString(e, "text/xml");
|
|
446
|
-
return s.childNodes.length > 0 ?
|
|
704
|
+
return s.childNodes.length > 0 ? j.xml2Xpell(s.childNodes[0]) : {};
|
|
447
705
|
}
|
|
448
706
|
/**
|
|
449
707
|
* Converts XML/HTML Document to Xpell JSON
|
|
@@ -452,25 +710,25 @@ const A = {
|
|
|
452
710
|
* @returns {} Xpell JSON
|
|
453
711
|
*/
|
|
454
712
|
static xml2Xpell(e, t) {
|
|
455
|
-
const s =
|
|
456
|
-
let
|
|
457
|
-
|
|
458
|
-
const
|
|
713
|
+
const s = j.html2XMap;
|
|
714
|
+
let r = {};
|
|
715
|
+
r._children = [];
|
|
716
|
+
const n = e.nodeName, i = e.nodeName;
|
|
459
717
|
let c = t;
|
|
460
|
-
if (t ? (
|
|
718
|
+
if (t ? (r[E.type] = "xhtml", r._html_ns = "http://www.w3.org/2000/svg") : r._type = s.elements[n] ? s.elements[n] : n, e.attributes)
|
|
461
719
|
for (let a = 0; a < e.attributes.length; ++a) {
|
|
462
|
-
const _ = e.attributes[a],
|
|
463
|
-
|
|
720
|
+
const _ = e.attributes[a], l = s.attributes[_.name] ? s.attributes[_.name] : _.name;
|
|
721
|
+
r[l] = _.value;
|
|
464
722
|
}
|
|
465
|
-
if (e?.firstChild?.nodeValue && (
|
|
723
|
+
if (e?.firstChild?.nodeValue && (r.text = e?.firstChild.nodeValue.trim()), r[E.type] == "xhtml" ? r._html_tag = i : r[E.type] == "svg" && (c = !0, r._html_ns = "http://www.w3.org/2000/svg"), e?.childNodes.length > 0)
|
|
466
724
|
for (let a = 0; a < e.childNodes.length; ++a) {
|
|
467
725
|
const _ = e.childNodes[a];
|
|
468
|
-
_.nodeName.startsWith("#") ||
|
|
726
|
+
_.nodeName.startsWith("#") || r[E.children].push(j.xml2Xpell(_, c));
|
|
469
727
|
}
|
|
470
|
-
return
|
|
728
|
+
return r;
|
|
471
729
|
}
|
|
472
730
|
};
|
|
473
|
-
|
|
731
|
+
j.html2XMap = {
|
|
474
732
|
elements: {
|
|
475
733
|
div: "view",
|
|
476
734
|
a: "link",
|
|
@@ -500,8 +758,8 @@ y.html2XMap = {
|
|
|
500
758
|
id: "_id"
|
|
501
759
|
}
|
|
502
760
|
};
|
|
503
|
-
let
|
|
504
|
-
class
|
|
761
|
+
let O = j;
|
|
762
|
+
class re {
|
|
505
763
|
#e;
|
|
506
764
|
#t;
|
|
507
765
|
#s;
|
|
@@ -569,7 +827,7 @@ class ne {
|
|
|
569
827
|
* @param xObject XObject to maintain
|
|
570
828
|
*/
|
|
571
829
|
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) :
|
|
830
|
+
e && e._id ? (this.#t[e._id] = e, (!e._name || e._name.length == 0) && (e._name = e._id), this.#s[e._name] = e._id) : h.log("unable to add object");
|
|
573
831
|
}
|
|
574
832
|
/**
|
|
575
833
|
* Remove XObject from the manager
|
|
@@ -604,7 +862,7 @@ class ne {
|
|
|
604
862
|
return this.#s[e] ? this.getObject(this.#s[e]) : null;
|
|
605
863
|
}
|
|
606
864
|
}
|
|
607
|
-
class
|
|
865
|
+
class pe {
|
|
608
866
|
constructor() {
|
|
609
867
|
this._log_rules = {
|
|
610
868
|
register: !1,
|
|
@@ -619,16 +877,16 @@ class fe {
|
|
|
619
877
|
* - Canonical: on(name, cb, { _once, _owner, _tag })
|
|
620
878
|
* - Legacy: on(name, cb, { _once }, owner)
|
|
621
879
|
*/
|
|
622
|
-
on(e, t, s = {},
|
|
880
|
+
on(e, t, s = {}, r) {
|
|
623
881
|
this._events[e] || (this._events[e] = []);
|
|
624
|
-
const
|
|
882
|
+
const n = s?._owner ?? r, i = u.guid(), c = {
|
|
625
883
|
_id: i,
|
|
626
884
|
_callback: t,
|
|
627
885
|
_options: s,
|
|
628
|
-
_owner:
|
|
886
|
+
_owner: n,
|
|
629
887
|
_tag: s?._tag
|
|
630
888
|
};
|
|
631
|
-
return this._events[e].push(c), this._listener_index[i] = e, this._log_rules.register &&
|
|
889
|
+
return this._events[e].push(c), this._listener_index[i] = e, this._log_rules.register && x.log("XEM Register", e, i), i;
|
|
632
890
|
}
|
|
633
891
|
/**
|
|
634
892
|
* Register a listener that will be removed after first fire.
|
|
@@ -642,17 +900,17 @@ class fe {
|
|
|
642
900
|
async fire(e, t) {
|
|
643
901
|
const s = this._events[e];
|
|
644
902
|
if (!s || s.length === 0) return;
|
|
645
|
-
this._log_rules.fire &&
|
|
646
|
-
const
|
|
647
|
-
for (const i of
|
|
903
|
+
this._log_rules.fire && x.log("XEM Fire", e, t);
|
|
904
|
+
const r = s.slice(), n = [];
|
|
905
|
+
for (const i of r) {
|
|
648
906
|
try {
|
|
649
907
|
i && i._callback && i._callback(t);
|
|
650
908
|
} catch (c) {
|
|
651
|
-
|
|
909
|
+
x.error(c);
|
|
652
910
|
}
|
|
653
|
-
i?._options?._once &&
|
|
911
|
+
i?._options?._once && n.push(i._id);
|
|
654
912
|
}
|
|
655
|
-
for (const i of
|
|
913
|
+
for (const i of n) this.remove(i);
|
|
656
914
|
}
|
|
657
915
|
/**
|
|
658
916
|
* Remove a listener by id.
|
|
@@ -662,10 +920,10 @@ class fe {
|
|
|
662
920
|
if (!t) return;
|
|
663
921
|
const s = this._events[t];
|
|
664
922
|
if (s && s.length) {
|
|
665
|
-
const
|
|
666
|
-
|
|
923
|
+
const r = s.findIndex((n) => n?._id === e);
|
|
924
|
+
r >= 0 && s.splice(r, 1), s.length === 0 && delete this._events[t];
|
|
667
925
|
}
|
|
668
|
-
delete this._listener_index[e], this._log_rules.remove &&
|
|
926
|
+
delete this._listener_index[e], this._log_rules.remove && x.log("XEM Remove", t, e);
|
|
669
927
|
}
|
|
670
928
|
/**
|
|
671
929
|
* Remove all listeners for a given owner reference.
|
|
@@ -674,8 +932,8 @@ class fe {
|
|
|
674
932
|
if (!e) return;
|
|
675
933
|
const t = [];
|
|
676
934
|
for (const s of Object.values(this._events))
|
|
677
|
-
for (const
|
|
678
|
-
(
|
|
935
|
+
for (const r of s)
|
|
936
|
+
(r?._owner ?? r?._options?._owner) === e && t.push(r._id);
|
|
679
937
|
t.forEach((s) => this.remove(s));
|
|
680
938
|
}
|
|
681
939
|
/**
|
|
@@ -685,16 +943,16 @@ class fe {
|
|
|
685
943
|
this._events = {}, this._listener_index = {};
|
|
686
944
|
}
|
|
687
945
|
}
|
|
688
|
-
let
|
|
689
|
-
function
|
|
690
|
-
|
|
946
|
+
let R;
|
|
947
|
+
function fe(o) {
|
|
948
|
+
R = o;
|
|
691
949
|
}
|
|
692
|
-
function
|
|
693
|
-
if (!
|
|
950
|
+
function X() {
|
|
951
|
+
if (!R)
|
|
694
952
|
throw new Error("XEventManager not set");
|
|
695
|
-
return
|
|
953
|
+
return R;
|
|
696
954
|
}
|
|
697
|
-
const
|
|
955
|
+
const ne = [
|
|
698
956
|
"_nano_commands",
|
|
699
957
|
"_cache_cmd_txt",
|
|
700
958
|
"_cache_jcmd",
|
|
@@ -703,21 +961,21 @@ const re = [
|
|
|
703
961
|
"_parent",
|
|
704
962
|
"_children"
|
|
705
963
|
];
|
|
706
|
-
function
|
|
707
|
-
return
|
|
964
|
+
function $(o) {
|
|
965
|
+
return ne.includes(o);
|
|
708
966
|
}
|
|
709
967
|
function K(o) {
|
|
710
968
|
if (!o || typeof o != "object" || Array.isArray(o)) return !1;
|
|
711
969
|
const e = Object.getPrototypeOf(o);
|
|
712
970
|
return e === Object.prototype || e === null;
|
|
713
971
|
}
|
|
714
|
-
function
|
|
972
|
+
function b(o, e) {
|
|
715
973
|
return o._skill = e, o.getSkill = () => e, o;
|
|
716
974
|
}
|
|
717
975
|
const G = {
|
|
718
|
-
info:
|
|
976
|
+
info: b(
|
|
719
977
|
(o, e) => {
|
|
720
|
-
|
|
978
|
+
h.log("XObject id " + e?._id);
|
|
721
979
|
},
|
|
722
980
|
{
|
|
723
981
|
_name: "info",
|
|
@@ -725,9 +983,9 @@ const G = {
|
|
|
725
983
|
_description: "Logs the current object's id."
|
|
726
984
|
}
|
|
727
985
|
),
|
|
728
|
-
log:
|
|
986
|
+
log: b(
|
|
729
987
|
(o, e) => {
|
|
730
|
-
o._params && o._params[1] ?
|
|
988
|
+
o._params && o._params[1] ? h.log(o._params[1]) : h.log(e);
|
|
731
989
|
},
|
|
732
990
|
{
|
|
733
991
|
_name: "log",
|
|
@@ -738,12 +996,12 @@ const G = {
|
|
|
738
996
|
}
|
|
739
997
|
}
|
|
740
998
|
),
|
|
741
|
-
fire:
|
|
999
|
+
fire: b(
|
|
742
1000
|
(o, e) => {
|
|
743
|
-
o._params && o._params[1] ?
|
|
1001
|
+
o._params && o._params[1] ? X().fire(
|
|
744
1002
|
String(o._params[1]),
|
|
745
1003
|
o._params[2]
|
|
746
|
-
) : o._params && o._params.event &&
|
|
1004
|
+
) : o._params && o._params.event && X().fire(
|
|
747
1005
|
String(o._params.event),
|
|
748
1006
|
o._params.data
|
|
749
1007
|
);
|
|
@@ -769,7 +1027,7 @@ const G = {
|
|
|
769
1027
|
}
|
|
770
1028
|
}
|
|
771
1029
|
),
|
|
772
|
-
noop:
|
|
1030
|
+
noop: b(
|
|
773
1031
|
() => {
|
|
774
1032
|
},
|
|
775
1033
|
{
|
|
@@ -778,12 +1036,12 @@ const G = {
|
|
|
778
1036
|
_description: "No-op command. Useful as a placeholder in sequences."
|
|
779
1037
|
}
|
|
780
1038
|
),
|
|
781
|
-
"set-field":
|
|
1039
|
+
"set-field": b(
|
|
782
1040
|
(o, e) => {
|
|
783
1041
|
const t = o._params?.name, s = o._params?.value;
|
|
784
1042
|
if (!(!e || typeof t != "string" || t.length === 0)) {
|
|
785
|
-
if (
|
|
786
|
-
|
|
1043
|
+
if ($(t)) {
|
|
1044
|
+
h.error(`set-field denied for protected field: ${t}`);
|
|
787
1045
|
return;
|
|
788
1046
|
}
|
|
789
1047
|
e[t] = s;
|
|
@@ -806,12 +1064,12 @@ const G = {
|
|
|
806
1064
|
}
|
|
807
1065
|
}
|
|
808
1066
|
),
|
|
809
|
-
"delete-field":
|
|
1067
|
+
"delete-field": b(
|
|
810
1068
|
(o, e) => {
|
|
811
1069
|
const t = o._params?.name;
|
|
812
1070
|
if (!(!e || typeof t != "string" || t.length === 0)) {
|
|
813
|
-
if (
|
|
814
|
-
|
|
1071
|
+
if ($(t)) {
|
|
1072
|
+
h.error(`delete-field denied for protected field: ${t}`);
|
|
815
1073
|
return;
|
|
816
1074
|
}
|
|
817
1075
|
delete e[t];
|
|
@@ -826,12 +1084,12 @@ const G = {
|
|
|
826
1084
|
}
|
|
827
1085
|
}
|
|
828
1086
|
),
|
|
829
|
-
"toggle-field":
|
|
1087
|
+
"toggle-field": b(
|
|
830
1088
|
(o, e) => {
|
|
831
1089
|
const t = o._params?.name;
|
|
832
1090
|
if (!e || typeof t != "string" || t.length === 0) return;
|
|
833
|
-
if (
|
|
834
|
-
|
|
1091
|
+
if ($(t)) {
|
|
1092
|
+
h.error(`toggle-field denied for protected field: ${t}`);
|
|
835
1093
|
return;
|
|
836
1094
|
}
|
|
837
1095
|
const s = e[t];
|
|
@@ -846,20 +1104,20 @@ const G = {
|
|
|
846
1104
|
}
|
|
847
1105
|
}
|
|
848
1106
|
),
|
|
849
|
-
merge:
|
|
1107
|
+
merge: b(
|
|
850
1108
|
(o, e) => {
|
|
851
1109
|
const t = o._params?.name, s = o._params?.value;
|
|
852
1110
|
if (!e || typeof t != "string" || t.length === 0) return;
|
|
853
|
-
if (
|
|
854
|
-
|
|
1111
|
+
if ($(t)) {
|
|
1112
|
+
h.error(`merge denied for protected field: ${t}`);
|
|
855
1113
|
return;
|
|
856
1114
|
}
|
|
857
1115
|
if (!K(s)) {
|
|
858
|
-
|
|
1116
|
+
h.error("merge expects _params.value as a plain object");
|
|
859
1117
|
return;
|
|
860
1118
|
}
|
|
861
|
-
const
|
|
862
|
-
K(
|
|
1119
|
+
const r = e[t];
|
|
1120
|
+
K(r) || (e[t] = {}), Object.assign(e[t], s);
|
|
863
1121
|
},
|
|
864
1122
|
{
|
|
865
1123
|
_name: "merge",
|
|
@@ -871,12 +1129,12 @@ const G = {
|
|
|
871
1129
|
}
|
|
872
1130
|
}
|
|
873
1131
|
),
|
|
874
|
-
"run-seq":
|
|
1132
|
+
"run-seq": b(
|
|
875
1133
|
async (o, e) => {
|
|
876
1134
|
if (!e) return;
|
|
877
1135
|
const t = o._params?.seq;
|
|
878
1136
|
if (!Array.isArray(t)) {
|
|
879
|
-
|
|
1137
|
+
h.error("run-seq expects _params.seq as an array");
|
|
880
1138
|
return;
|
|
881
1139
|
}
|
|
882
1140
|
for (const s of t) {
|
|
@@ -885,9 +1143,9 @@ const G = {
|
|
|
885
1143
|
continue;
|
|
886
1144
|
}
|
|
887
1145
|
if (s && typeof s == "object" && s._op) {
|
|
888
|
-
const
|
|
889
|
-
if (!(
|
|
890
|
-
|
|
1146
|
+
const r = s._object;
|
|
1147
|
+
if (!(r == null || r === "this" || r === e._id)) {
|
|
1148
|
+
h.error("run-seq rejected non-self _object target");
|
|
891
1149
|
return;
|
|
892
1150
|
}
|
|
893
1151
|
const i = {
|
|
@@ -897,7 +1155,7 @@ const G = {
|
|
|
897
1155
|
await e.execute(i);
|
|
898
1156
|
continue;
|
|
899
1157
|
}
|
|
900
|
-
|
|
1158
|
+
h.error(
|
|
901
1159
|
"run-seq skipped invalid step; expected string or object with _op"
|
|
902
1160
|
);
|
|
903
1161
|
}
|
|
@@ -993,7 +1251,7 @@ const U = {
|
|
|
993
1251
|
"Runtime methods include parse, append, run, execute, bindDataSource, unbindDataSource, toXData, dispose, and removeChild.",
|
|
994
1252
|
"Most prompts should use this skill as a compact dependency summary, not full context."
|
|
995
1253
|
]
|
|
996
|
-
},
|
|
1254
|
+
}, P = { _children: "child nodes" }, A = class A {
|
|
997
1255
|
/**
|
|
998
1256
|
* XObject constructor is creating the object and adding all the data keys to the XObject instance
|
|
999
1257
|
* @param data constructor input data (object)
|
|
@@ -1022,11 +1280,11 @@ const U = {
|
|
|
1022
1280
|
"_debug"
|
|
1023
1281
|
],
|
|
1024
1282
|
_instance_xporters: {}
|
|
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(
|
|
1283
|
+
}, 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(A, (r) => r.toXData()), this._xem_options = {
|
|
1026
1284
|
// _instance:_xem
|
|
1027
1285
|
// _object: this
|
|
1028
1286
|
// _support_html: true
|
|
1029
|
-
}, !s && e && this.parse(e,
|
|
1287
|
+
}, !s && e && this.parse(e, P);
|
|
1030
1288
|
}
|
|
1031
1289
|
static getOwnSkill() {
|
|
1032
1290
|
const e = this, t = e._skill ?? U;
|
|
@@ -1064,8 +1322,8 @@ const U = {
|
|
|
1064
1322
|
return "canonical";
|
|
1065
1323
|
}
|
|
1066
1324
|
static generateArtifact(e = {}) {
|
|
1067
|
-
const t = this.getOwnSkill?.(), s = t?._canonical_examples?.[0],
|
|
1068
|
-
return this.applyArtifactIntent(
|
|
1325
|
+
const t = this.getOwnSkill?.(), s = t?._canonical_examples?.[0], r = s ? this.cloneArtifact(s) : { _type: this._xtype ?? t?._id ?? "object" };
|
|
1326
|
+
return this.applyArtifactIntent(r, e);
|
|
1069
1327
|
}
|
|
1070
1328
|
static cloneArtifact(e) {
|
|
1071
1329
|
return typeof structuredClone == "function" ? structuredClone(e) : JSON.parse(JSON.stringify(e));
|
|
@@ -1085,7 +1343,7 @@ const U = {
|
|
|
1085
1343
|
};
|
|
1086
1344
|
}
|
|
1087
1345
|
log(e, ...t) {
|
|
1088
|
-
this._debug && e &&
|
|
1346
|
+
this._debug && e && h.log(this._type + "->" + this._id + "]", e, ...t);
|
|
1089
1347
|
}
|
|
1090
1348
|
/**
|
|
1091
1349
|
* Initialize the XObject
|
|
@@ -1094,7 +1352,7 @@ const U = {
|
|
|
1094
1352
|
* @deprecated - use parse method instead
|
|
1095
1353
|
*/
|
|
1096
1354
|
init(e, t) {
|
|
1097
|
-
!t && e && this.parse(e,
|
|
1355
|
+
!t && e && this.parse(e, P);
|
|
1098
1356
|
}
|
|
1099
1357
|
parseEvents(e) {
|
|
1100
1358
|
if (!this._event_parsed) {
|
|
@@ -1109,10 +1367,10 @@ const U = {
|
|
|
1109
1367
|
}
|
|
1110
1368
|
addEventListener(e, t, s) {
|
|
1111
1369
|
s || (s = this._xem_options);
|
|
1112
|
-
const
|
|
1370
|
+
const r = async (i) => {
|
|
1113
1371
|
await this.checkAndRunInternalFunction(t, i);
|
|
1114
|
-
},
|
|
1115
|
-
return this._event_listeners_ids[e] || (this._event_listeners_ids[e] = []), this._event_listeners_ids[e].push(
|
|
1372
|
+
}, n = X().on(e, r, s, this);
|
|
1373
|
+
return this._event_listeners_ids[e] || (this._event_listeners_ids[e] = []), this._event_listeners_ids[e].push(n), n;
|
|
1116
1374
|
}
|
|
1117
1375
|
removeEventListener(e) {
|
|
1118
1376
|
const t = this._event_listeners_ids;
|
|
@@ -1120,9 +1378,9 @@ const U = {
|
|
|
1120
1378
|
this._event_listeners_ids = {};
|
|
1121
1379
|
return;
|
|
1122
1380
|
}
|
|
1123
|
-
(Array.isArray(t[e]) ? [...t[e]] : []).forEach((
|
|
1381
|
+
(Array.isArray(t[e]) ? [...t[e]] : []).forEach((r) => {
|
|
1124
1382
|
try {
|
|
1125
|
-
|
|
1383
|
+
X().remove(r);
|
|
1126
1384
|
} catch {
|
|
1127
1385
|
}
|
|
1128
1386
|
}), delete t[e];
|
|
@@ -1133,9 +1391,9 @@ const U = {
|
|
|
1133
1391
|
this._event_listeners_ids = {};
|
|
1134
1392
|
return;
|
|
1135
1393
|
}
|
|
1136
|
-
(e ? [e] : Object.keys(t)).forEach((
|
|
1394
|
+
(e ? [e] : Object.keys(t)).forEach((r) => {
|
|
1137
1395
|
try {
|
|
1138
|
-
this.removeEventListener(
|
|
1396
|
+
this.removeEventListener(r);
|
|
1139
1397
|
} catch {
|
|
1140
1398
|
}
|
|
1141
1399
|
});
|
|
@@ -1183,9 +1441,9 @@ const U = {
|
|
|
1183
1441
|
* @param data data to parse
|
|
1184
1442
|
* @param ignore - lis of words to ignore in the parse process
|
|
1185
1443
|
*/
|
|
1186
|
-
parse(e, t =
|
|
1187
|
-
Object.keys(e).forEach((
|
|
1188
|
-
!t.hasOwnProperty(
|
|
1444
|
+
parse(e, t = P) {
|
|
1445
|
+
Object.keys(e).forEach((r) => {
|
|
1446
|
+
!t.hasOwnProperty(r) && e.hasOwnProperty(r) && (this[r] = e[r]);
|
|
1189
1447
|
});
|
|
1190
1448
|
}
|
|
1191
1449
|
/**
|
|
@@ -1199,8 +1457,8 @@ const U = {
|
|
|
1199
1457
|
* }
|
|
1200
1458
|
*/
|
|
1201
1459
|
parseFieldsFromXDataObject(e, t) {
|
|
1202
|
-
Object.keys(t).forEach((
|
|
1203
|
-
e.hasOwnProperty(
|
|
1460
|
+
Object.keys(t).forEach((r) => {
|
|
1461
|
+
e.hasOwnProperty(r) ? this[r] = e[r] : this[r] = t[r];
|
|
1204
1462
|
});
|
|
1205
1463
|
}
|
|
1206
1464
|
/**
|
|
@@ -1210,12 +1468,12 @@ const U = {
|
|
|
1210
1468
|
* @param checkNonXParams - also check non Xpell fields (fields that not starting with "_" sign)
|
|
1211
1469
|
*/
|
|
1212
1470
|
parseFields(e, t, s) {
|
|
1213
|
-
t.forEach((
|
|
1214
|
-
if (e.hasOwnProperty(
|
|
1215
|
-
this[
|
|
1216
|
-
else if (s &&
|
|
1217
|
-
const
|
|
1218
|
-
e.hasOwnProperty(
|
|
1471
|
+
t.forEach((r) => {
|
|
1472
|
+
if (e.hasOwnProperty(r))
|
|
1473
|
+
this[r] = e[r];
|
|
1474
|
+
else if (s && r.startsWith("_")) {
|
|
1475
|
+
const n = r.substring(1);
|
|
1476
|
+
e.hasOwnProperty(n) && (this[r] = e[n], this[n] = e[n]);
|
|
1219
1477
|
}
|
|
1220
1478
|
});
|
|
1221
1479
|
}
|
|
@@ -1233,41 +1491,91 @@ const U = {
|
|
|
1233
1491
|
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);
|
|
1234
1492
|
}
|
|
1235
1493
|
async runCmd(e) {
|
|
1236
|
-
const t = e instanceof
|
|
1494
|
+
const t = e instanceof N ? e : new N(e);
|
|
1237
1495
|
await this.execute(t);
|
|
1238
1496
|
}
|
|
1239
1497
|
async checkAndRunInternalFunction(e, ...t) {
|
|
1240
1498
|
const s = (i, c) => {
|
|
1241
1499
|
const a = c.split(".");
|
|
1242
1500
|
let _ = i;
|
|
1243
|
-
for (const
|
|
1501
|
+
for (const l of a) {
|
|
1244
1502
|
if (_ == null) return;
|
|
1245
|
-
_ = _[
|
|
1503
|
+
_ = _[l];
|
|
1246
1504
|
}
|
|
1247
1505
|
return _;
|
|
1248
|
-
},
|
|
1249
|
-
if (typeof i == "string")
|
|
1250
|
-
|
|
1506
|
+
}, r = (i, c, a) => {
|
|
1507
|
+
if (typeof i == "string") {
|
|
1508
|
+
if (i === "$prev") return c;
|
|
1509
|
+
if (i.startsWith("$prev."))
|
|
1510
|
+
return s(
|
|
1511
|
+
c,
|
|
1512
|
+
i.slice(6)
|
|
1513
|
+
);
|
|
1514
|
+
if (i === "$event") return t[0];
|
|
1515
|
+
if (i.startsWith("$event."))
|
|
1516
|
+
return s(
|
|
1517
|
+
t[0],
|
|
1518
|
+
i.slice(7)
|
|
1519
|
+
);
|
|
1520
|
+
if (i === "$data") return t[0];
|
|
1521
|
+
if (i.startsWith("$data."))
|
|
1522
|
+
return s(
|
|
1523
|
+
t[0],
|
|
1524
|
+
i.slice(6)
|
|
1525
|
+
);
|
|
1526
|
+
if (i.startsWith("$xdata:") || i.startsWith("$xdata.")) {
|
|
1527
|
+
const l = (i.startsWith("$xdata:"), i.slice(7)).split(".");
|
|
1528
|
+
for (let d = l.length; d > 0; d--) {
|
|
1529
|
+
const y = l.slice(0, d).join(".");
|
|
1530
|
+
if (v.has(y)) {
|
|
1531
|
+
const g = v.get(y), w = l.slice(d).join(".");
|
|
1532
|
+
return w ? u.get_path(g, w) : g;
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
return;
|
|
1536
|
+
}
|
|
1537
|
+
if (i.startsWith("$") && a && typeof a == "object") {
|
|
1538
|
+
const _ = i.slice(1), l = _.indexOf("."), d = l === -1 ? _ : _.slice(0, l), y = l === -1 ? "" : _.slice(l + 1);
|
|
1539
|
+
if (Object.prototype.hasOwnProperty.call(
|
|
1540
|
+
a,
|
|
1541
|
+
d
|
|
1542
|
+
)) {
|
|
1543
|
+
const g = a[d];
|
|
1544
|
+
return y ? s(g, y) : g;
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
return i;
|
|
1548
|
+
}
|
|
1251
1549
|
if (Array.isArray(i))
|
|
1252
|
-
return i.map(
|
|
1550
|
+
return i.map(
|
|
1551
|
+
(_) => r(
|
|
1552
|
+
_,
|
|
1553
|
+
c,
|
|
1554
|
+
a
|
|
1555
|
+
)
|
|
1556
|
+
);
|
|
1253
1557
|
if (i && typeof i == "object") {
|
|
1254
|
-
const
|
|
1255
|
-
for (const
|
|
1256
|
-
|
|
1257
|
-
|
|
1558
|
+
const _ = {};
|
|
1559
|
+
for (const l of Object.keys(i))
|
|
1560
|
+
_[l] = r(
|
|
1561
|
+
i[l],
|
|
1562
|
+
c,
|
|
1563
|
+
a
|
|
1564
|
+
);
|
|
1565
|
+
return _;
|
|
1258
1566
|
}
|
|
1259
1567
|
return i;
|
|
1260
|
-
},
|
|
1568
|
+
}, n = async (i, c) => {
|
|
1261
1569
|
if (Array.isArray(i)) {
|
|
1262
1570
|
let a;
|
|
1263
1571
|
for (const _ of i)
|
|
1264
|
-
a = await
|
|
1572
|
+
a = await n(_, a);
|
|
1265
1573
|
return a;
|
|
1266
1574
|
}
|
|
1267
1575
|
if (typeof i == "function")
|
|
1268
1576
|
return await i(this, ...t);
|
|
1269
1577
|
if (typeof i == "string") {
|
|
1270
|
-
const a =
|
|
1578
|
+
const a = O.parseObjectCommand(
|
|
1271
1579
|
`${this._id} ${i}`
|
|
1272
1580
|
);
|
|
1273
1581
|
if (t.length > 0) {
|
|
@@ -1278,72 +1586,73 @@ const U = {
|
|
|
1278
1586
|
return await this.execute(a);
|
|
1279
1587
|
}
|
|
1280
1588
|
if (i && typeof i == "object" && Array.isArray(i._commands)) {
|
|
1281
|
-
const a = i, _ = typeof a._mode == "string" ? a._mode : "sequence",
|
|
1589
|
+
const a = i, _ = typeof a._mode == "string" ? a._mode : "sequence", l = a._stop_on_error !== !1, d = a._commands;
|
|
1282
1590
|
if (_ === "parallel") {
|
|
1283
|
-
const
|
|
1284
|
-
|
|
1285
|
-
(
|
|
1591
|
+
const g = await Promise.allSettled(
|
|
1592
|
+
d.map(
|
|
1593
|
+
(M) => n(M, c)
|
|
1286
1594
|
)
|
|
1287
|
-
),
|
|
1288
|
-
(
|
|
1595
|
+
), w = g.find(
|
|
1596
|
+
(M) => M.status === "rejected"
|
|
1289
1597
|
);
|
|
1290
|
-
if (
|
|
1291
|
-
throw
|
|
1292
|
-
return
|
|
1598
|
+
if (w && l)
|
|
1599
|
+
throw w.reason;
|
|
1600
|
+
return g;
|
|
1293
1601
|
}
|
|
1294
|
-
let
|
|
1295
|
-
for (const
|
|
1602
|
+
let y = c;
|
|
1603
|
+
for (const g of d)
|
|
1296
1604
|
try {
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
_ === "chain" ?
|
|
1605
|
+
y = await n(
|
|
1606
|
+
g,
|
|
1607
|
+
_ === "chain" ? y : c
|
|
1300
1608
|
);
|
|
1301
|
-
} catch (
|
|
1302
|
-
if (
|
|
1609
|
+
} catch (w) {
|
|
1610
|
+
if (h.error(
|
|
1303
1611
|
this._type + "->" + this._id + "] command sequence failed",
|
|
1304
|
-
|
|
1305
|
-
),
|
|
1306
|
-
throw
|
|
1612
|
+
w
|
|
1613
|
+
), l)
|
|
1614
|
+
throw w;
|
|
1307
1615
|
}
|
|
1308
|
-
return
|
|
1616
|
+
return y;
|
|
1309
1617
|
}
|
|
1310
1618
|
if (i && typeof i == "object" && i._op) {
|
|
1311
1619
|
const a = i;
|
|
1312
1620
|
if ((a._object === void 0 || a._object === null || a._object === "this" ? this._id : a._object) !== this._id) {
|
|
1313
|
-
|
|
1621
|
+
h.error(
|
|
1314
1622
|
"XObject JSON handler target not supported; expected _object omitted/'this'/" + this._id
|
|
1315
1623
|
);
|
|
1316
1624
|
return;
|
|
1317
1625
|
}
|
|
1318
|
-
const
|
|
1626
|
+
const l = {
|
|
1319
1627
|
...a,
|
|
1320
1628
|
_params: a._params ? { ...a._params } : {}
|
|
1321
1629
|
};
|
|
1322
1630
|
if (t.length > 0) {
|
|
1323
|
-
const
|
|
1631
|
+
const d = t[0];
|
|
1324
1632
|
Object.prototype.hasOwnProperty.call(
|
|
1325
|
-
|
|
1633
|
+
l._params,
|
|
1326
1634
|
"data"
|
|
1327
|
-
) || (
|
|
1328
|
-
|
|
1635
|
+
) || (l._params.data = d), Object.prototype.hasOwnProperty.call(
|
|
1636
|
+
l._params,
|
|
1329
1637
|
"_event"
|
|
1330
|
-
) || (
|
|
1638
|
+
) || (l._params._event = d);
|
|
1331
1639
|
}
|
|
1332
|
-
return
|
|
1333
|
-
|
|
1334
|
-
c
|
|
1335
|
-
|
|
1640
|
+
return l._params = r(
|
|
1641
|
+
l._params,
|
|
1642
|
+
c,
|
|
1643
|
+
this._context
|
|
1644
|
+
), this._debug && h.log(
|
|
1336
1645
|
this._type + "->" + this._id + "]",
|
|
1337
1646
|
"JSON handler executed locally",
|
|
1338
|
-
|
|
1339
|
-
), await this.execute(
|
|
1647
|
+
l
|
|
1648
|
+
), await this.execute(l);
|
|
1340
1649
|
}
|
|
1341
|
-
|
|
1650
|
+
h.error(
|
|
1342
1651
|
this._type + "->" + this._id + "] invalid handler in checkAndRunInternalFunction",
|
|
1343
1652
|
i
|
|
1344
1653
|
);
|
|
1345
1654
|
};
|
|
1346
|
-
return await
|
|
1655
|
+
return await n(e);
|
|
1347
1656
|
}
|
|
1348
1657
|
/**
|
|
1349
1658
|
* Triggers when the object is being mounted to other element
|
|
@@ -1365,7 +1674,7 @@ const U = {
|
|
|
1365
1674
|
const e = this._data_source;
|
|
1366
1675
|
if (typeof e != "string" || e.length === 0) return;
|
|
1367
1676
|
const t = this._type ?? this.constructor.name, s = this._id ?? "no-id";
|
|
1368
|
-
|
|
1677
|
+
v.delete(e, { source: `${t}#${s}.emptyDataSource` });
|
|
1369
1678
|
}
|
|
1370
1679
|
/**
|
|
1371
1680
|
* Triggers when new data is being received from the data source
|
|
@@ -1406,7 +1715,7 @@ const U = {
|
|
|
1406
1715
|
* @param cache - cache last command to prevent multiple parsing on the same command
|
|
1407
1716
|
*/
|
|
1408
1717
|
async run(e, t = !0) {
|
|
1409
|
-
let s = this._cache_cmd_txt && this._cache_cmd_txt == e ? this._cache_jcmd :
|
|
1718
|
+
let s = this._cache_cmd_txt && this._cache_cmd_txt == e ? this._cache_jcmd : O.parseObjectCommand(e);
|
|
1410
1719
|
t && (this._cache_cmd_txt = e, this._cache_jcmd = s), await this.execute(s);
|
|
1411
1720
|
}
|
|
1412
1721
|
/**
|
|
@@ -1423,40 +1732,40 @@ const U = {
|
|
|
1423
1732
|
async execute(e) {
|
|
1424
1733
|
const t = e?._op, s = typeof t == "string" && t.startsWith("_") && t.length > 1 ? t.slice(1) : t;
|
|
1425
1734
|
if (!s) {
|
|
1426
|
-
|
|
1735
|
+
h.error(this._id + " missing _op in command");
|
|
1427
1736
|
return;
|
|
1428
1737
|
}
|
|
1429
|
-
const
|
|
1430
|
-
if (
|
|
1738
|
+
const r = e?._module;
|
|
1739
|
+
if (r)
|
|
1431
1740
|
try {
|
|
1432
1741
|
return await oe().execute({
|
|
1433
1742
|
...e,
|
|
1434
|
-
_module:
|
|
1743
|
+
_module: r,
|
|
1435
1744
|
_op: s
|
|
1436
1745
|
});
|
|
1437
|
-
} catch (
|
|
1438
|
-
|
|
1439
|
-
this._id + " module execution failed: " +
|
|
1746
|
+
} catch (n) {
|
|
1747
|
+
h.error(
|
|
1748
|
+
this._id + " module execution failed: " + r + "." + s + " " + n
|
|
1440
1749
|
);
|
|
1441
1750
|
return;
|
|
1442
1751
|
}
|
|
1443
1752
|
if (this._nano_commands[s])
|
|
1444
1753
|
try {
|
|
1445
|
-
const
|
|
1754
|
+
const n = {
|
|
1446
1755
|
...e,
|
|
1447
1756
|
_op: s
|
|
1448
1757
|
};
|
|
1449
1758
|
return await this._nano_commands[s](
|
|
1450
|
-
|
|
1759
|
+
n,
|
|
1451
1760
|
this
|
|
1452
1761
|
);
|
|
1453
|
-
} catch (
|
|
1454
|
-
|
|
1455
|
-
this._id + " has error with command name " + s + " " +
|
|
1762
|
+
} catch (n) {
|
|
1763
|
+
h.error(
|
|
1764
|
+
this._id + " has error with command name " + s + " " + n
|
|
1456
1765
|
);
|
|
1457
1766
|
return;
|
|
1458
1767
|
}
|
|
1459
|
-
|
|
1768
|
+
h.error(this._id + " has no command name " + s);
|
|
1460
1769
|
}
|
|
1461
1770
|
/**
|
|
1462
1771
|
* Return an IXObjectData JSON representation of the XObject
|
|
@@ -1470,11 +1779,11 @@ const U = {
|
|
|
1470
1779
|
if (typeof s == "function")
|
|
1471
1780
|
return;
|
|
1472
1781
|
if (typeof s == "object") {
|
|
1473
|
-
const
|
|
1474
|
-
let
|
|
1475
|
-
|
|
1476
|
-
this._xporter._instance_xporters[i], s instanceof this._xporter._instance_xporters[i].cls && (e[t] = this._xporter._instance_xporters[i].handler(s),
|
|
1477
|
-
}),
|
|
1782
|
+
const r = Object.keys(this._xporter._instance_xporters);
|
|
1783
|
+
let n = !0;
|
|
1784
|
+
r.forEach((i) => {
|
|
1785
|
+
this._xporter._instance_xporters[i], s instanceof this._xporter._instance_xporters[i].cls && (e[t] = this._xporter._instance_xporters[i].handler(s), n = !1);
|
|
1786
|
+
}), n && (e[t] = s);
|
|
1478
1787
|
} else
|
|
1479
1788
|
e[t] = s;
|
|
1480
1789
|
}
|
|
@@ -1495,10 +1804,10 @@ const U = {
|
|
|
1495
1804
|
});
|
|
1496
1805
|
}
|
|
1497
1806
|
bindDataSource(e, t) {
|
|
1498
|
-
const s = t?.initial ?? !0,
|
|
1499
|
-
typeof
|
|
1500
|
-
await this.onData(
|
|
1501
|
-
}), s &&
|
|
1807
|
+
const s = t?.initial ?? !0, r = e ?? this._data_source;
|
|
1808
|
+
typeof r != "string" || r.length === 0 || this._process_data && (this._xd_bound_key === r && this._xd_unsub || (this.unbindDataSource(), this._data_source = r, this._xd_bound_key = r, this._type ?? this.constructor.name, this._id, this._xd_unsub = v.on(r, async (n) => {
|
|
1809
|
+
await this.onData(n.value);
|
|
1810
|
+
}), s && v.has(r) && this.onData(v.get(r))));
|
|
1502
1811
|
}
|
|
1503
1812
|
unbindDataSource() {
|
|
1504
1813
|
this._xd_unsub?.(), this._xd_unsub = void 0, this._xd_bound_key = void 0;
|
|
@@ -1536,8 +1845,8 @@ const U = {
|
|
|
1536
1845
|
this.append(e);
|
|
1537
1846
|
}
|
|
1538
1847
|
};
|
|
1539
|
-
|
|
1540
|
-
let C =
|
|
1848
|
+
A._xtype = "object", A._skill = U;
|
|
1849
|
+
let C = A;
|
|
1541
1850
|
class me {
|
|
1542
1851
|
/**
|
|
1543
1852
|
* Get all registered object in this ObjectPack
|
|
@@ -1549,7 +1858,7 @@ class me {
|
|
|
1549
1858
|
};
|
|
1550
1859
|
}
|
|
1551
1860
|
}
|
|
1552
|
-
const ae = "engine:module:num-of-objects:",
|
|
1861
|
+
const ae = "engine:module:num-of-objects:", W = {
|
|
1553
1862
|
_id: "xmodule",
|
|
1554
1863
|
_title: "XModule Runtime Contract",
|
|
1555
1864
|
_version: "1.0.0",
|
|
@@ -1564,14 +1873,14 @@ const ae = "engine:module:num-of-objects:", q = {
|
|
|
1564
1873
|
"Do not mutate another module's objects directly."
|
|
1565
1874
|
]
|
|
1566
1875
|
};
|
|
1567
|
-
var
|
|
1568
|
-
const
|
|
1876
|
+
var p;
|
|
1877
|
+
const I = class I {
|
|
1569
1878
|
constructor(e) {
|
|
1570
|
-
|
|
1879
|
+
J(this, p);
|
|
1571
1880
|
this._loaded = !1, this._loading = !1, this._log_rules = {
|
|
1572
1881
|
createObject: !1,
|
|
1573
1882
|
removeObject: !1
|
|
1574
|
-
},
|
|
1883
|
+
}, V(this, p, new re()), this._name = e._name, this._id = u.guid();
|
|
1575
1884
|
}
|
|
1576
1885
|
static getOwnSkillBase() {
|
|
1577
1886
|
return {
|
|
@@ -1579,7 +1888,7 @@ const M = class M {
|
|
|
1579
1888
|
};
|
|
1580
1889
|
}
|
|
1581
1890
|
getOwnSkill() {
|
|
1582
|
-
const t = this.constructor._skill ??
|
|
1891
|
+
const t = this.constructor._skill ?? W;
|
|
1583
1892
|
return {
|
|
1584
1893
|
...t,
|
|
1585
1894
|
_exports: {
|
|
@@ -1600,23 +1909,23 @@ const M = class M {
|
|
|
1600
1909
|
}
|
|
1601
1910
|
getObjectSkills() {
|
|
1602
1911
|
const e = [], t = /* @__PURE__ */ new Set();
|
|
1603
|
-
for (const s of Object.values(f(this,
|
|
1912
|
+
for (const s of Object.values(f(this, p).getObjectClasses())) {
|
|
1604
1913
|
if (typeof s.getOwnSkill != "function") continue;
|
|
1605
|
-
const
|
|
1606
|
-
|
|
1914
|
+
const r = s.getOwnSkill();
|
|
1915
|
+
r?._id && (t.has(r._id) || (t.add(r._id), e.push(r)));
|
|
1607
1916
|
}
|
|
1608
1917
|
return e;
|
|
1609
1918
|
}
|
|
1610
1919
|
getCommandSkills() {
|
|
1611
1920
|
const e = Object.getPrototypeOf(this), s = this.constructor._ops ?? {};
|
|
1612
1921
|
return Object.getOwnPropertyNames(e).filter(
|
|
1613
|
-
(
|
|
1614
|
-
).map((
|
|
1615
|
-
const
|
|
1616
|
-
return s[
|
|
1617
|
-
_name:
|
|
1922
|
+
(r) => r.startsWith("_") && !r.startsWith("__") && typeof this[r] == "function"
|
|
1923
|
+
).map((r) => {
|
|
1924
|
+
const n = r.slice(1).replaceAll("_", "-");
|
|
1925
|
+
return s[n] ?? {
|
|
1926
|
+
_name: n,
|
|
1618
1927
|
_scope: "module",
|
|
1619
|
-
_description: `Runtime module command: ${
|
|
1928
|
+
_description: `Runtime module command: ${n}`
|
|
1620
1929
|
};
|
|
1621
1930
|
});
|
|
1622
1931
|
}
|
|
@@ -1624,7 +1933,7 @@ const M = class M {
|
|
|
1624
1933
|
if (!(this._loaded || this._loading)) {
|
|
1625
1934
|
this._loading = !0;
|
|
1626
1935
|
try {
|
|
1627
|
-
await this.onLoad(), this._loaded = !0,
|
|
1936
|
+
await this.onLoad(), this._loaded = !0, h.log("Module " + this._name + " loaded");
|
|
1628
1937
|
} finally {
|
|
1629
1938
|
this._loading = !1;
|
|
1630
1939
|
}
|
|
@@ -1638,22 +1947,22 @@ const M = class M {
|
|
|
1638
1947
|
* @return {XObject|*}
|
|
1639
1948
|
*/
|
|
1640
1949
|
create(e) {
|
|
1641
|
-
e._debug &&
|
|
1950
|
+
e._debug && h.log("Creating object with data", e);
|
|
1642
1951
|
let t;
|
|
1643
1952
|
if (e.hasOwnProperty("_type")) {
|
|
1644
|
-
e._debug &&
|
|
1645
|
-
const s = String(e._type),
|
|
1646
|
-
if (!
|
|
1953
|
+
e._debug && h.log("Object type is", e._type, this.hasObject(e._type) ? "found" : "not found", "in module", this._name);
|
|
1954
|
+
const s = String(e._type), r = f(this, p).getObjectClass(s);
|
|
1955
|
+
if (!r)
|
|
1647
1956
|
throw `Xpell object '${s}' not found in module '${this._name}'`;
|
|
1648
|
-
typeof
|
|
1957
|
+
typeof r == "function" && r.hasOwnProperty("defaults") && u.mergeDefaultsWithData(
|
|
1649
1958
|
e,
|
|
1650
|
-
|
|
1651
|
-
), t = new
|
|
1959
|
+
r.defaults
|
|
1960
|
+
), t = new r(e);
|
|
1652
1961
|
} else
|
|
1653
1962
|
t = new C(e);
|
|
1654
|
-
return f(this,
|
|
1655
|
-
const
|
|
1656
|
-
t.append(
|
|
1963
|
+
return f(this, p).addObject(t), e._children && e._children.forEach((s) => {
|
|
1964
|
+
const r = this.create(s);
|
|
1965
|
+
t.append(r);
|
|
1657
1966
|
}), t.onCreate(), t;
|
|
1658
1967
|
}
|
|
1659
1968
|
/**
|
|
@@ -1661,15 +1970,15 @@ const M = class M {
|
|
|
1661
1970
|
* @param objectId op
|
|
1662
1971
|
*/
|
|
1663
1972
|
remove(e) {
|
|
1664
|
-
const t = f(this,
|
|
1973
|
+
const t = f(this, p).getObject(e);
|
|
1665
1974
|
if (!t) return;
|
|
1666
|
-
const s = [],
|
|
1667
|
-
|
|
1975
|
+
const s = [], r = (n) => {
|
|
1976
|
+
n?._id && (s.push(n._id), (n._children ?? []).forEach((i) => r(i)));
|
|
1668
1977
|
};
|
|
1669
|
-
|
|
1978
|
+
r(t), typeof t.dispose == "function" && t.dispose(), s.reverse().forEach((n) => f(this, p).removeObject(n));
|
|
1670
1979
|
}
|
|
1671
1980
|
_info(e) {
|
|
1672
|
-
|
|
1981
|
+
h.log("module info");
|
|
1673
1982
|
}
|
|
1674
1983
|
//xpell interpreter
|
|
1675
1984
|
/**
|
|
@@ -1682,7 +1991,7 @@ const M = class M {
|
|
|
1682
1991
|
if (e) {
|
|
1683
1992
|
let t = e.trim();
|
|
1684
1993
|
t.startsWith(this._name) || (t = this._name + " " + t);
|
|
1685
|
-
let s =
|
|
1994
|
+
let s = O.parse(t);
|
|
1686
1995
|
return await this.execute(s);
|
|
1687
1996
|
} else
|
|
1688
1997
|
throw "Unable to parse Xpell Command";
|
|
@@ -1698,12 +2007,12 @@ const M = class M {
|
|
|
1698
2007
|
throw new Error(`Invalid XCommand: missing _op (module: ${this._name})`);
|
|
1699
2008
|
const t = e._object;
|
|
1700
2009
|
if (t) {
|
|
1701
|
-
const c = f(this,
|
|
2010
|
+
const c = f(this, p).getObject(t);
|
|
1702
2011
|
if (!c)
|
|
1703
2012
|
throw new Error(`Module '${this._name}' cant find object id: ${t}`);
|
|
1704
2013
|
return await c.execute(e);
|
|
1705
2014
|
}
|
|
1706
|
-
const s = e._op,
|
|
2015
|
+
const s = e._op, n = "_" + (s.startsWith("_") && s.length > 1 ? s.slice(1) : s).replaceAll("-", "_"), i = this[n];
|
|
1707
2016
|
if (typeof i == "function")
|
|
1708
2017
|
return await i.call(this, e);
|
|
1709
2018
|
throw new Error(`Module '${this._name}' cant find op: ${e._op}`);
|
|
@@ -1714,10 +2023,10 @@ const M = class M {
|
|
|
1714
2023
|
* @param frameNumber Current frame number
|
|
1715
2024
|
*/
|
|
1716
2025
|
async onFrame(e) {
|
|
1717
|
-
const t = f(this,
|
|
1718
|
-
s.forEach((
|
|
1719
|
-
const
|
|
1720
|
-
|
|
2026
|
+
const t = f(this, p)._objects, s = Object.keys(t);
|
|
2027
|
+
s.forEach((r) => {
|
|
2028
|
+
const n = t[r];
|
|
2029
|
+
n && n.onFrame && typeof n.onFrame == "function" && n?.onFrame(e);
|
|
1721
2030
|
}), m.set(ae + this._id, s.length, {
|
|
1722
2031
|
source: "xmodule"
|
|
1723
2032
|
});
|
|
@@ -1733,10 +2042,10 @@ const M = class M {
|
|
|
1733
2042
|
* getObject directly on the module instead of om.getObject
|
|
1734
2043
|
*/
|
|
1735
2044
|
get om() {
|
|
1736
|
-
return f(this,
|
|
2045
|
+
return f(this, p);
|
|
1737
2046
|
}
|
|
1738
2047
|
get _object_manager() {
|
|
1739
|
-
return f(this,
|
|
2048
|
+
return f(this, p);
|
|
1740
2049
|
}
|
|
1741
2050
|
/**
|
|
1742
2051
|
* Returns the XObject instance from the module Object Manager
|
|
@@ -1744,10 +2053,10 @@ const M = class M {
|
|
|
1744
2053
|
* @returns XObject
|
|
1745
2054
|
*/
|
|
1746
2055
|
getObject(e) {
|
|
1747
|
-
return f(this,
|
|
2056
|
+
return f(this, p).getObject(e);
|
|
1748
2057
|
}
|
|
1749
2058
|
hasObject(e) {
|
|
1750
|
-
return f(this,
|
|
2059
|
+
return f(this, p).hasObjectClass(e);
|
|
1751
2060
|
}
|
|
1752
2061
|
/**
|
|
1753
2062
|
* Returns the XObject instance from the module Object Manager
|
|
@@ -1755,7 +2064,7 @@ const M = class M {
|
|
|
1755
2064
|
* xmodule._o["object-id"] is equivalent to xmodule.getObject("object-id")
|
|
1756
2065
|
*/
|
|
1757
2066
|
get _o() {
|
|
1758
|
-
return f(this,
|
|
2067
|
+
return f(this, p)._objects;
|
|
1759
2068
|
}
|
|
1760
2069
|
/**
|
|
1761
2070
|
* Imports external object pack to the engine
|
|
@@ -1763,7 +2072,7 @@ const M = class M {
|
|
|
1763
2072
|
* @param {XObjects} xObjectPack
|
|
1764
2073
|
*/
|
|
1765
2074
|
importObjectPack(e) {
|
|
1766
|
-
f(this,
|
|
2075
|
+
f(this, p).registerObjects(e.getObjects());
|
|
1767
2076
|
}
|
|
1768
2077
|
/**
|
|
1769
2078
|
* Imports external object pack to the engine
|
|
@@ -1780,7 +2089,7 @@ const M = class M {
|
|
|
1780
2089
|
* @param xObject
|
|
1781
2090
|
*/
|
|
1782
2091
|
importObject(e, t) {
|
|
1783
|
-
f(this,
|
|
2092
|
+
f(this, p).registerObject(e, t);
|
|
1784
2093
|
}
|
|
1785
2094
|
// In XModule
|
|
1786
2095
|
async _help(e) {
|
|
@@ -1800,7 +2109,7 @@ const M = class M {
|
|
|
1800
2109
|
};
|
|
1801
2110
|
}
|
|
1802
2111
|
};
|
|
1803
|
-
|
|
2112
|
+
p = new WeakMap(), I._skill = W, I._ops = {
|
|
1804
2113
|
help: {
|
|
1805
2114
|
_name: "help",
|
|
1806
2115
|
_scope: "module",
|
|
@@ -1812,7 +2121,7 @@ d = new WeakMap(), M._skill = q, M._ops = {
|
|
|
1812
2121
|
_description: "Log basic module information."
|
|
1813
2122
|
}
|
|
1814
2123
|
};
|
|
1815
|
-
let
|
|
2124
|
+
let F = I;
|
|
1816
2125
|
const ce = {
|
|
1817
2126
|
_id: "xdata",
|
|
1818
2127
|
_title: "XData Runtime State Contract",
|
|
@@ -1832,9 +2141,9 @@ const ce = {
|
|
|
1832
2141
|
_data_source: "XData key used by XObject/XUIObject for reactive data binding.",
|
|
1833
2142
|
"$xdata.key": "Runtime payload reference to an XData value."
|
|
1834
2143
|
}
|
|
1835
|
-
},
|
|
2144
|
+
}, S = class S extends F {
|
|
1836
2145
|
constructor() {
|
|
1837
|
-
super({ _name:
|
|
2146
|
+
super({ _name: S._name });
|
|
1838
2147
|
}
|
|
1839
2148
|
async _get(e) {
|
|
1840
2149
|
const t = u.ensure_params(e?._params), s = u.ensure_string(t.key, "key");
|
|
@@ -1845,7 +2154,7 @@ const ce = {
|
|
|
1845
2154
|
}
|
|
1846
2155
|
async _set(e) {
|
|
1847
2156
|
const t = u.ensure_params(e?._params), s = u.ensure_string(t.key, "key");
|
|
1848
|
-
return t._debug &&
|
|
2157
|
+
return t._debug && x.log("XD SET", { key: s, value: t.value }), m.set(s, t.value, {
|
|
1849
2158
|
source: t.source ?? "xd:set"
|
|
1850
2159
|
}), {
|
|
1851
2160
|
_ok: !0,
|
|
@@ -1888,8 +2197,41 @@ const ce = {
|
|
|
1888
2197
|
_result: m.has(s)
|
|
1889
2198
|
};
|
|
1890
2199
|
}
|
|
2200
|
+
async _get_path(e) {
|
|
2201
|
+
const t = u.ensure_params(e?._params), s = u.ensure_string(t.key, "key"), r = u.ensure_string(t.path, "path"), n = m.get(s);
|
|
2202
|
+
return {
|
|
2203
|
+
_ok: !0,
|
|
2204
|
+
_result: u.get_path(
|
|
2205
|
+
n,
|
|
2206
|
+
r,
|
|
2207
|
+
t.fallback
|
|
2208
|
+
)
|
|
2209
|
+
};
|
|
2210
|
+
}
|
|
2211
|
+
async _log(e) {
|
|
2212
|
+
const t = u.ensure_params(e?._params), s = u.ensure_string(t.key, "key"), r = m.get(s), n = u.read_optional_string(
|
|
2213
|
+
t.path,
|
|
2214
|
+
"path"
|
|
2215
|
+
), i = n ? u.get_path(
|
|
2216
|
+
r,
|
|
2217
|
+
n,
|
|
2218
|
+
t.fallback
|
|
2219
|
+
) : r;
|
|
2220
|
+
return x.log("XDATA LOG", {
|
|
2221
|
+
key: s,
|
|
2222
|
+
path: n,
|
|
2223
|
+
value: i
|
|
2224
|
+
}), {
|
|
2225
|
+
_ok: !0,
|
|
2226
|
+
_result: {
|
|
2227
|
+
key: s,
|
|
2228
|
+
path: n,
|
|
2229
|
+
value: i
|
|
2230
|
+
}
|
|
2231
|
+
};
|
|
2232
|
+
}
|
|
1891
2233
|
};
|
|
1892
|
-
|
|
2234
|
+
S._name = "xd", S._skill = ce, S._ops = {
|
|
1893
2235
|
get: {
|
|
1894
2236
|
_name: "get",
|
|
1895
2237
|
_scope: "module",
|
|
@@ -1943,9 +2285,19 @@ k._name = "xd", k._skill = ce, k._ops = {
|
|
|
1943
2285
|
_params: {
|
|
1944
2286
|
key: "XData key."
|
|
1945
2287
|
}
|
|
2288
|
+
},
|
|
2289
|
+
get_path: {
|
|
2290
|
+
_name: "get_path",
|
|
2291
|
+
_scope: "module",
|
|
2292
|
+
_description: "Get nested value from an XData value.",
|
|
2293
|
+
_params: {
|
|
2294
|
+
key: "XData key.",
|
|
2295
|
+
path: "Nested path inside the stored value.",
|
|
2296
|
+
fallback: "Optional fallback value."
|
|
2297
|
+
}
|
|
1946
2298
|
}
|
|
1947
2299
|
};
|
|
1948
|
-
let
|
|
2300
|
+
let q = S;
|
|
1949
2301
|
const _e = {
|
|
1950
2302
|
_id: "xem",
|
|
1951
2303
|
_title: "XEventManager Runtime Event Bus",
|
|
@@ -1971,16 +2323,16 @@ const _e = {
|
|
|
1971
2323
|
"XEM is process-wide and listener order should not be assumed.",
|
|
1972
2324
|
"Event payloads should be JSON/data-only."
|
|
1973
2325
|
]
|
|
1974
|
-
},
|
|
2326
|
+
}, D = class D extends F {
|
|
1975
2327
|
constructor() {
|
|
1976
|
-
super({ _name:
|
|
2328
|
+
super({ _name: D._name });
|
|
1977
2329
|
}
|
|
1978
2330
|
async _fire(e) {
|
|
1979
|
-
const t = u.ensure_params(e?._params), s = u.ensure_string(t.event, "event"),
|
|
1980
|
-
t._debug &&
|
|
2331
|
+
const t = u.ensure_params(e?._params), s = u.ensure_string(t.event, "event"), r = t.data;
|
|
2332
|
+
t._debug && x.log("xem fire 🔥 ", s, r), await X().fire(s, r);
|
|
1981
2333
|
}
|
|
1982
2334
|
};
|
|
1983
|
-
|
|
2335
|
+
D._name = "xem", D._skill = _e, D._ops = {
|
|
1984
2336
|
fire: {
|
|
1985
2337
|
_name: "fire",
|
|
1986
2338
|
_scope: "module",
|
|
@@ -2002,51 +2354,51 @@ O._name = "xem", O._skill = _e, O._ops = {
|
|
|
2002
2354
|
}
|
|
2003
2355
|
}
|
|
2004
2356
|
};
|
|
2005
|
-
let
|
|
2357
|
+
let T = D;
|
|
2006
2358
|
class ge {
|
|
2007
2359
|
/* -------------------------------------------------- */
|
|
2008
2360
|
/* core helpers */
|
|
2009
2361
|
/* -------------------------------------------------- */
|
|
2010
2362
|
static get(e, t, s) {
|
|
2011
|
-
const
|
|
2012
|
-
return
|
|
2363
|
+
const n = (e?._params ?? e)?.[t];
|
|
2364
|
+
return n !== void 0 ? n : s;
|
|
2013
2365
|
}
|
|
2014
2366
|
static has(e, t) {
|
|
2015
2367
|
return (e?._params ?? e)[t] !== void 0;
|
|
2016
2368
|
}
|
|
2017
2369
|
static str(e, ...t) {
|
|
2018
2370
|
const s = e?._params ?? e;
|
|
2019
|
-
for (const
|
|
2020
|
-
const
|
|
2021
|
-
if (
|
|
2022
|
-
return String(
|
|
2371
|
+
for (const r of t) {
|
|
2372
|
+
const n = s?.[r];
|
|
2373
|
+
if (n != null)
|
|
2374
|
+
return String(n);
|
|
2023
2375
|
}
|
|
2024
2376
|
}
|
|
2025
2377
|
/* -------------------------------------------------- */
|
|
2026
2378
|
/* typed params */
|
|
2027
2379
|
/* -------------------------------------------------- */
|
|
2028
2380
|
static bool(e, t, s = !1) {
|
|
2029
|
-
const
|
|
2030
|
-
if (typeof
|
|
2031
|
-
if (typeof
|
|
2032
|
-
if (typeof
|
|
2033
|
-
const i =
|
|
2381
|
+
const r = e?._params ?? e, n = this.get(r, t, s);
|
|
2382
|
+
if (typeof n == "boolean") return n;
|
|
2383
|
+
if (typeof n == "number") return n !== 0;
|
|
2384
|
+
if (typeof n == "string") {
|
|
2385
|
+
const i = n.toLowerCase();
|
|
2034
2386
|
if (["1", "true", "yes", "on"].includes(i)) return !0;
|
|
2035
2387
|
if (["0", "false", "no", "off"].includes(i)) return !1;
|
|
2036
2388
|
}
|
|
2037
|
-
return !!
|
|
2389
|
+
return !!n;
|
|
2038
2390
|
}
|
|
2039
2391
|
static int(e, t, s = 0) {
|
|
2040
|
-
const
|
|
2392
|
+
const r = e?._params ?? e, n = this.get(r, t, s), i = parseInt(String(n), 10);
|
|
2041
2393
|
return Number.isFinite(i) ? i : s;
|
|
2042
2394
|
}
|
|
2043
2395
|
static json(e, t, s) {
|
|
2044
|
-
const
|
|
2045
|
-
if (
|
|
2046
|
-
if (typeof
|
|
2047
|
-
if (typeof
|
|
2396
|
+
const r = e?._params ?? e, n = this.get(r, t, s);
|
|
2397
|
+
if (n == null) return s;
|
|
2398
|
+
if (typeof n == "object") return n;
|
|
2399
|
+
if (typeof n == "string")
|
|
2048
2400
|
try {
|
|
2049
|
-
return JSON.parse(
|
|
2401
|
+
return JSON.parse(n);
|
|
2050
2402
|
} catch {
|
|
2051
2403
|
return s;
|
|
2052
2404
|
}
|
|
@@ -2076,7 +2428,7 @@ class H extends Error {
|
|
|
2076
2428
|
};
|
|
2077
2429
|
}
|
|
2078
2430
|
}
|
|
2079
|
-
class
|
|
2431
|
+
class k {
|
|
2080
2432
|
constructor(e) {
|
|
2081
2433
|
this._ok = !1, this._ts = Date.now(), this._pt = 0, e && this.setXData(e);
|
|
2082
2434
|
}
|
|
@@ -2084,14 +2436,14 @@ class b {
|
|
|
2084
2436
|
// Factories
|
|
2085
2437
|
// ---------------------------------------------------------------------------
|
|
2086
2438
|
static create(e) {
|
|
2087
|
-
return new
|
|
2439
|
+
return new k(e);
|
|
2088
2440
|
}
|
|
2089
2441
|
static ok(e) {
|
|
2090
|
-
return new
|
|
2442
|
+
return new k({ _ok: !0, _result: e });
|
|
2091
2443
|
}
|
|
2092
2444
|
static error(e) {
|
|
2093
2445
|
if (e instanceof H)
|
|
2094
|
-
return new
|
|
2446
|
+
return new k({
|
|
2095
2447
|
_ok: !1,
|
|
2096
2448
|
_result: e.toXData()
|
|
2097
2449
|
});
|
|
@@ -2100,7 +2452,7 @@ class b {
|
|
|
2100
2452
|
e?.message ?? String(e),
|
|
2101
2453
|
{ _cause: e }
|
|
2102
2454
|
);
|
|
2103
|
-
return new
|
|
2455
|
+
return new k({
|
|
2104
2456
|
_ok: !1,
|
|
2105
2457
|
_result: t.toXData()
|
|
2106
2458
|
});
|
|
@@ -2133,12 +2485,12 @@ class b {
|
|
|
2133
2485
|
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));
|
|
2134
2486
|
}
|
|
2135
2487
|
}
|
|
2136
|
-
class ye extends
|
|
2488
|
+
class ye extends k {
|
|
2137
2489
|
constructor(e) {
|
|
2138
|
-
super(
|
|
2490
|
+
super(k.error(e).toXData());
|
|
2139
2491
|
}
|
|
2140
2492
|
}
|
|
2141
|
-
class be extends
|
|
2493
|
+
class be extends k {
|
|
2142
2494
|
constructor(e) {
|
|
2143
2495
|
super({ _ok: !0, _result: e });
|
|
2144
2496
|
}
|
|
@@ -2146,20 +2498,20 @@ class be extends b {
|
|
|
2146
2498
|
const le = "engine:frame-number", he = "engine:fps";
|
|
2147
2499
|
class ue {
|
|
2148
2500
|
constructor(e) {
|
|
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 =
|
|
2501
|
+
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 = O, this._modules = {}, h._enabled = !1, ie(this);
|
|
2150
2502
|
}
|
|
2151
2503
|
/**
|
|
2152
2504
|
* @deprecated use _verbose instead
|
|
2153
2505
|
* Enable Xpell logs to console
|
|
2154
2506
|
*/
|
|
2155
2507
|
set verbose(e) {
|
|
2156
|
-
|
|
2508
|
+
h._enabled = e;
|
|
2157
2509
|
}
|
|
2158
2510
|
/**
|
|
2159
2511
|
* Enable Xpell logs to console
|
|
2160
2512
|
*/
|
|
2161
2513
|
set _verbose(e) {
|
|
2162
|
-
|
|
2514
|
+
h._enabled = e;
|
|
2163
2515
|
}
|
|
2164
2516
|
/**
|
|
2165
2517
|
* Logs message to console using Xpell logger
|
|
@@ -2169,7 +2521,7 @@ class ue {
|
|
|
2169
2521
|
* @param optionalParams
|
|
2170
2522
|
*/
|
|
2171
2523
|
log(e, ...t) {
|
|
2172
|
-
|
|
2524
|
+
h.log(e, ...t);
|
|
2173
2525
|
}
|
|
2174
2526
|
/**
|
|
2175
2527
|
* Delay the execution of the next command
|
|
@@ -2186,7 +2538,7 @@ class ue {
|
|
|
2186
2538
|
* Use loadModuleAsync() for deterministic startup.
|
|
2187
2539
|
*/
|
|
2188
2540
|
addModule(e) {
|
|
2189
|
-
return this._modules.hasOwnProperty(e._name) ? (
|
|
2541
|
+
return this._modules.hasOwnProperty(e._name) ? (h.log("Module " + e._name + " already loaded"), !1) : (this._modules[e._name] = e, !0);
|
|
2190
2542
|
}
|
|
2191
2543
|
/**
|
|
2192
2544
|
* Loads Xpell module into the engine
|
|
@@ -2213,7 +2565,7 @@ class ue {
|
|
|
2213
2565
|
* Display information about the Xpell engine to the console
|
|
2214
2566
|
*/
|
|
2215
2567
|
info() {
|
|
2216
|
-
|
|
2568
|
+
h.log(`Xpell information:
|
|
2217
2569
|
- Engine Id: ` + this._engine_id + `
|
|
2218
2570
|
- Version ` + this._version);
|
|
2219
2571
|
}
|
|
@@ -2223,7 +2575,7 @@ class ue {
|
|
|
2223
2575
|
*/
|
|
2224
2576
|
run(e) {
|
|
2225
2577
|
if (e?.length > 2) {
|
|
2226
|
-
let t =
|
|
2578
|
+
let t = O.parse(e);
|
|
2227
2579
|
return this.execute(t);
|
|
2228
2580
|
} else
|
|
2229
2581
|
throw "Unable to parse Xpell command";
|
|
@@ -2262,11 +2614,11 @@ class ue {
|
|
|
2262
2614
|
* Start Xpell engine for web browsers using requestAnimationFrame
|
|
2263
2615
|
*/
|
|
2264
2616
|
start() {
|
|
2265
|
-
|
|
2617
|
+
h.log("Loading Xpell core modules...[xd, xem]"), this.loadModule(new q()), this.loadModule(new T()), h.log("Starting Xpell"), this.onFrame();
|
|
2266
2618
|
}
|
|
2267
2619
|
getCoreSkills() {
|
|
2268
2620
|
return [
|
|
2269
|
-
|
|
2621
|
+
W,
|
|
2270
2622
|
U
|
|
2271
2623
|
];
|
|
2272
2624
|
}
|
|
@@ -2292,36 +2644,36 @@ class ue {
|
|
|
2292
2644
|
}
|
|
2293
2645
|
const we = new ue();
|
|
2294
2646
|
export {
|
|
2295
|
-
|
|
2647
|
+
N as XCommand,
|
|
2296
2648
|
he as XD_FPS,
|
|
2297
2649
|
le as XD_FRAME_NUMBER,
|
|
2298
|
-
|
|
2299
|
-
|
|
2650
|
+
v as XData,
|
|
2651
|
+
q as XDataModule,
|
|
2300
2652
|
H as XError,
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2653
|
+
T as XEventManagerModule,
|
|
2654
|
+
h as XLogger,
|
|
2655
|
+
F as XModule,
|
|
2304
2656
|
C as XObject,
|
|
2305
|
-
|
|
2657
|
+
re as XObjectManager,
|
|
2306
2658
|
me as XObjectPack,
|
|
2307
2659
|
ge as XParams,
|
|
2308
|
-
|
|
2309
|
-
|
|
2660
|
+
O as XParser,
|
|
2661
|
+
k as XResponse,
|
|
2310
2662
|
ye as XResponseError,
|
|
2311
2663
|
be as XResponseOK,
|
|
2312
2664
|
Z as XUtils,
|
|
2313
2665
|
we as Xpell,
|
|
2314
2666
|
ue as XpellEngine,
|
|
2315
2667
|
se as _XData,
|
|
2316
|
-
|
|
2668
|
+
pe as _XEventManager,
|
|
2317
2669
|
te as _XLogger,
|
|
2318
2670
|
Y as _XUtils,
|
|
2319
2671
|
we as _x,
|
|
2320
2672
|
m as _xd,
|
|
2321
|
-
|
|
2673
|
+
h as _xlog,
|
|
2322
2674
|
u as _xu,
|
|
2323
|
-
|
|
2675
|
+
b as createNanoCommandWithSkill,
|
|
2324
2676
|
we as default,
|
|
2325
|
-
|
|
2326
|
-
|
|
2677
|
+
X as getXEventManager,
|
|
2678
|
+
fe as setXEventManager
|
|
2327
2679
|
};
|