canvasengine 2.0.0-beta.58 → 2.0.0-beta.59
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/engine/reactive.d.ts.map +1 -1
- package/dist/index.global.js +1 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +98 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Sprite.ts +38 -7
- package/src/engine/reactive.ts +99 -26
package/dist/index.js
CHANGED
|
@@ -3307,56 +3307,105 @@ function H(e, t) {
|
|
|
3307
3307
|
if (!i) throw Error(`attach in ${e.tag} is undefined or null, add a component`);
|
|
3308
3308
|
n && V(n), n = i, await l(e, i), t(void 0);
|
|
3309
3309
|
}));
|
|
3310
|
-
}) : e.props.children.push(e.props.attach)), e.props.children) for (let t
|
|
3310
|
+
}) : e.props.children.push(e.props.attach)), e.props.children) for (let t = 0; t < e.props.children.length; t++) {
|
|
3311
|
+
let n = e.props.children[t];
|
|
3312
|
+
n && await l(e, n, t);
|
|
3313
|
+
}
|
|
3311
3314
|
}
|
|
3312
|
-
async function l(e, t) {
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
+
async function l(e, t, n) {
|
|
3316
|
+
fn(t) && (t = await t);
|
|
3317
|
+
let r = e.__childGroups ??= [], a = n ?? (e.props.children ? e.props.children.indexOf(t) : -1), o = {
|
|
3318
|
+
order: a >= 0 ? a : r.length,
|
|
3319
|
+
mounted: /* @__PURE__ */ new Map()
|
|
3320
|
+
};
|
|
3321
|
+
r.push(o);
|
|
3322
|
+
let u = (t) => {
|
|
3323
|
+
let n = e.componentInstance?.children;
|
|
3324
|
+
if (!t || !n) return;
|
|
3325
|
+
let r = n.indexOf(t.componentInstance);
|
|
3326
|
+
return r >= 0 ? r : void 0;
|
|
3327
|
+
}, d = () => {
|
|
3328
|
+
let e = r.filter((e) => e !== o && e.order > o.order).sort((e, t) => e.order - t.order);
|
|
3329
|
+
for (let t of e) for (let e of t.mounted.values()) {
|
|
3330
|
+
let t = u(e);
|
|
3331
|
+
if (t !== void 0) return t;
|
|
3332
|
+
}
|
|
3333
|
+
}, f = (e, t) => {
|
|
3334
|
+
for (let n = e + 1; n < t.length; n++) {
|
|
3335
|
+
let e = u(o.mounted.get(t[n]));
|
|
3336
|
+
if (e !== void 0) return e;
|
|
3337
|
+
}
|
|
3338
|
+
return d();
|
|
3339
|
+
};
|
|
3340
|
+
if (t instanceof w) {
|
|
3341
|
+
let n = o.mounted, r = () => ({
|
|
3342
|
+
tag: "fragment",
|
|
3343
|
+
props: { children: [] },
|
|
3344
|
+
componentInstance: {},
|
|
3345
|
+
propSubscriptions: [],
|
|
3346
|
+
effectSubscriptions: [],
|
|
3347
|
+
effectMounts: [],
|
|
3348
|
+
effectUnmounts: [],
|
|
3349
|
+
propObservables: {},
|
|
3350
|
+
parent: e,
|
|
3351
|
+
directives: {},
|
|
3352
|
+
destroy() {
|
|
3353
|
+
V(this);
|
|
3354
|
+
},
|
|
3355
|
+
allElements: new it(),
|
|
3356
|
+
isFrozen: !1
|
|
3357
|
+
}), a = (t, r, i) => {
|
|
3315
3358
|
if (n.has(t)) return;
|
|
3316
|
-
let
|
|
3317
|
-
n.set(t,
|
|
3318
|
-
},
|
|
3359
|
+
let a = ka(e, t);
|
|
3360
|
+
n.set(t, a), s(e, a, f(r, i)), c(a);
|
|
3361
|
+
}, u = (e) => {
|
|
3319
3362
|
n.forEach((t, r) => {
|
|
3320
3363
|
e.has(r) || (n.delete(r), t !== r && V(t));
|
|
3321
3364
|
});
|
|
3322
|
-
},
|
|
3323
|
-
if (
|
|
3324
|
-
|
|
3365
|
+
}, d = (e, t, i, o) => {
|
|
3366
|
+
if (e instanceof w) {
|
|
3367
|
+
if (t.add(e), !n.has(e)) {
|
|
3368
|
+
let t = r();
|
|
3369
|
+
n.set(e, t), l(t, e);
|
|
3370
|
+
}
|
|
3325
3371
|
return;
|
|
3326
3372
|
}
|
|
3327
|
-
if (Array.isArray(
|
|
3328
|
-
|
|
3373
|
+
if (Array.isArray(e)) {
|
|
3374
|
+
e.forEach((e) => d(e, t, i, o));
|
|
3329
3375
|
return;
|
|
3330
3376
|
}
|
|
3331
|
-
R(
|
|
3332
|
-
},
|
|
3377
|
+
R(e) && (t.add(e), a(e, i, o));
|
|
3378
|
+
}, p = t.subscribe((t) => {
|
|
3333
3379
|
if (t && typeof t == "object" && "elements" in t) {
|
|
3334
|
-
let { elements: n, prev: r } = t, i = n.filter((e) => e !== null),
|
|
3380
|
+
let { elements: n, prev: r } = t, i = n.filter((e) => e !== null), a = /* @__PURE__ */ new Set();
|
|
3335
3381
|
if (r) {
|
|
3336
3382
|
i.forEach((t) => {
|
|
3337
|
-
|
|
3338
|
-
}), a
|
|
3383
|
+
d(t, a, e.props.children.indexOf(r.props.key) + 1, i);
|
|
3384
|
+
}), u(a);
|
|
3339
3385
|
return;
|
|
3340
3386
|
}
|
|
3341
3387
|
i.forEach((e, t) => {
|
|
3342
|
-
|
|
3343
|
-
}), a
|
|
3388
|
+
d(e, a, t, i);
|
|
3389
|
+
}), u(a);
|
|
3344
3390
|
} else if (R(t)) {
|
|
3345
3391
|
let n = ka(e, t);
|
|
3346
|
-
s(e, n), c(n);
|
|
3347
|
-
} else Array.isArray(t)
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
});
|
|
3392
|
+
o.mounted.set(t, n), s(e, n, f(0, [t])), c(n);
|
|
3393
|
+
} else if (Array.isArray(t)) {
|
|
3394
|
+
let e = /* @__PURE__ */ new Set();
|
|
3395
|
+
t.forEach((n, r) => {
|
|
3396
|
+
d(n, e, r, t);
|
|
3397
|
+
}), u(e);
|
|
3398
|
+
}
|
|
3354
3399
|
i.next(void 0);
|
|
3355
3400
|
});
|
|
3356
|
-
|
|
3401
|
+
p.add(() => {
|
|
3402
|
+
n.forEach((e) => {
|
|
3403
|
+
V(e);
|
|
3404
|
+
}), n.clear();
|
|
3405
|
+
}), e.effectSubscriptions.push(p);
|
|
3357
3406
|
} else if (R(t)) {
|
|
3358
3407
|
let n = ka(e, t);
|
|
3359
|
-
s(e, n), await c(n);
|
|
3408
|
+
o.mounted.set(t, n), s(e, n, f(0, [t])), await c(n);
|
|
3360
3409
|
}
|
|
3361
3410
|
}
|
|
3362
3411
|
return r;
|
|
@@ -6481,7 +6530,9 @@ var bs = console.log, xs = /* @__PURE__ */ function(e) {
|
|
|
6481
6530
|
});
|
|
6482
6531
|
L(() => {
|
|
6483
6532
|
let e = o();
|
|
6484
|
-
|
|
6533
|
+
if (!this.isMounted) return;
|
|
6534
|
+
let t = this.getMovementAnimationName(e);
|
|
6535
|
+
t && (this.sheetCurrentAnimation = t, this.spritesheet && this.play(this.sheetCurrentAnimation, [this.sheetParams]));
|
|
6485
6536
|
}), super.onMount(e);
|
|
6486
6537
|
}
|
|
6487
6538
|
async onUpdate(e) {
|
|
@@ -6536,6 +6587,18 @@ var bs = console.log, xs = /* @__PURE__ */ function(e) {
|
|
|
6536
6587
|
isPlaying(e) {
|
|
6537
6588
|
return e ? this.currentAnimation == null ? !1 : this.currentAnimation.name == e : !!this.currentAnimation;
|
|
6538
6589
|
}
|
|
6590
|
+
getFirstAnimationName() {
|
|
6591
|
+
return this.animations.keys().next().value;
|
|
6592
|
+
}
|
|
6593
|
+
getPlayableAnimationName(e) {
|
|
6594
|
+
return e && this.has(e) ? e : this.getFirstAnimationName();
|
|
6595
|
+
}
|
|
6596
|
+
getMovementAnimationName(e) {
|
|
6597
|
+
let t = e ? xs.Walk : xs.Stand;
|
|
6598
|
+
if (this.has(t)) return t;
|
|
6599
|
+
if (this.sheetCurrentAnimation && this.has(this.sheetCurrentAnimation)) return this.sheetCurrentAnimation;
|
|
6600
|
+
if (this.currentAnimation?.name && this.has(this.currentAnimation.name)) return this.currentAnimation.name;
|
|
6601
|
+
}
|
|
6539
6602
|
stop() {
|
|
6540
6603
|
this.currentAnimation = null;
|
|
6541
6604
|
}
|
|
@@ -6562,7 +6625,11 @@ var bs = console.log, xs = /* @__PURE__ */ function(e) {
|
|
|
6562
6625
|
}), this.update({ deltaRatio: 1 });
|
|
6563
6626
|
}
|
|
6564
6627
|
async resetAnimations() {
|
|
6565
|
-
this.stop(), this.animations.clear(), this.currentAnimation = null, this.currentAnimationContainer = null, this.time = 0, this.frameIndex = 0, this.removeChildren(), this.spritesheet
|
|
6628
|
+
if (this.stop(), this.animations.clear(), this.currentAnimation = null, this.currentAnimationContainer = null, this.time = 0, this.frameIndex = 0, this.removeChildren(), this.spritesheet) {
|
|
6629
|
+
await this.createAnimations();
|
|
6630
|
+
let e = this.getPlayableAnimationName(this.sheetCurrentAnimation);
|
|
6631
|
+
e && (this.sheetCurrentAnimation = e, this.play(e, [this.sheetParams]));
|
|
6632
|
+
}
|
|
6566
6633
|
}
|
|
6567
6634
|
update({ deltaRatio: e }) {
|
|
6568
6635
|
let t = this.getElement();
|