@meta2d/core 1.1.21 → 1.1.22

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/src/core.js CHANGED
@@ -1696,6 +1696,9 @@ export class Meta2d {
1696
1696
  }
1697
1697
  if (index !== -1 && index !== undefined) {
1698
1698
  const animate = deepClone(pen.animations[index]);
1699
+ if (!animate.animateCycle) {
1700
+ animate.animateCycle = 0;
1701
+ }
1699
1702
  animate.animateName = animate.name;
1700
1703
  delete animate.name;
1701
1704
  animate.currentAnimation = index;
@@ -3173,6 +3176,9 @@ export class Meta2d {
3173
3176
  }
3174
3177
  }
3175
3178
  penNetwork(pen) {
3179
+ if (!pen.apiUrl) {
3180
+ return;
3181
+ }
3176
3182
  const penNetwork = {
3177
3183
  url: pen.apiUrl,
3178
3184
  method: pen.apiMethod,
@@ -3268,8 +3274,8 @@ export class Meta2d {
3268
3274
  }
3269
3275
  async requestHttp(_req) {
3270
3276
  let req = deepClone(_req);
3271
- const net = this.store.data.networks.filter((item) => item.protocol === 'http')[req.index];
3272
- if (net.preJs) {
3277
+ const net = this.store.data.networks?.filter((item) => item.protocol === 'http')[req.index];
3278
+ if (net?.preJs) {
3273
3279
  if (!net.preFn) {
3274
3280
  const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
3275
3281
  net.preFn = new AsyncFunction('network', net.preJs);
@@ -3912,11 +3918,9 @@ export class Meta2d {
3912
3918
  }
3913
3919
  event.actions.forEach((action) => {
3914
3920
  if (action.timeout) {
3915
- let timer = setTimeout(() => {
3921
+ setTimeout(() => {
3916
3922
  if (this.events[action.action]) {
3917
3923
  this.events[action.action](pen, action);
3918
- clearTimeout(timer);
3919
- timer = null;
3920
3924
  }
3921
3925
  }, action.timeout);
3922
3926
  }
@@ -3962,11 +3966,9 @@ export class Meta2d {
3962
3966
  if (indexArr.includes(index)) {
3963
3967
  trigger.actions?.forEach((event) => {
3964
3968
  if (event.timeout) {
3965
- let timer = setTimeout(() => {
3969
+ setTimeout(() => {
3966
3970
  if (this.events[event.action]) {
3967
3971
  this.events[event.action](pen, event);
3968
- clearTimeout(timer);
3969
- timer = null;
3970
3972
  }
3971
3973
  }, event.timeout);
3972
3974
  }
@@ -4005,11 +4007,9 @@ export class Meta2d {
4005
4007
  if (indexArr.includes(index)) {
4006
4008
  trigger.actions?.forEach((event) => {
4007
4009
  if (event.timeout) {
4008
- let timer = setTimeout(() => {
4010
+ setTimeout(() => {
4009
4011
  if (this.events[event.action]) {
4010
4012
  this.events[event.action](pen, event);
4011
- clearTimeout(timer);
4012
- timer = null;
4013
4013
  }
4014
4014
  }, event.timeout);
4015
4015
  }
@@ -4044,11 +4044,9 @@ export class Meta2d {
4044
4044
  if (flag) {
4045
4045
  state.actions?.forEach((event) => {
4046
4046
  if (event.timeout) {
4047
- let timer = setTimeout(() => {
4047
+ setTimeout(() => {
4048
4048
  if (this.events[event.action]) {
4049
4049
  this.events[event.action](pen, event);
4050
- clearTimeout(timer);
4051
- timer = null;
4052
4050
  }
4053
4051
  }, event.timeout);
4054
4052
  }
@@ -4087,7 +4085,14 @@ export class Meta2d {
4087
4085
  }
4088
4086
  if (flag) {
4089
4087
  item.event.actions.forEach((action) => {
4090
- this.events[action.action](item.pen, action, data);
4088
+ if (action.timeout) {
4089
+ setTimeout(() => {
4090
+ this.events[action.action](item.pen, action, data);
4091
+ }, action.timeout);
4092
+ }
4093
+ else {
4094
+ this.events[action.action](item.pen, action, data);
4095
+ }
4091
4096
  });
4092
4097
  }
4093
4098
  });