@eva/eva.js 2.0.0-beta.9 → 2.0.1-beta.0

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.
@@ -2,7 +2,6 @@ import EventEmitter from 'eventemitter3';
2
2
  import { isObject, isEqual } from 'lodash-es';
3
3
  import { type, step } from '@eva/inspector-decorator';
4
4
  import { Assets } from 'pixi.js';
5
- import { AbstractLoadStrategy, AudioLoadStrategy, ImageLoadStrategy, XhrResponseType, MediaElementLoadStrategy, VideoLoadStrategy, Loader, Resource as Resource$1, ResourceType, ResourceState } from 'resource-loader';
6
5
 
7
6
  function getComponentName(component) {
8
7
  if (component instanceof Component) {
@@ -864,7 +863,7 @@ class Game extends EventEmitter {
864
863
  }
865
864
  init({ systems, frameRate = 60, autoStart = true, needScene = true } = {}) {
866
865
  return __awaiter(this, void 0, void 0, function* () {
867
- if (window.__EVA_INSPECTOR_ENV__) {
866
+ if (typeof window !== 'undefined' && window.__EVA_INSPECTOR_ENV__) {
868
867
  window.__EVA_GAME_INSTANCE__ = this;
869
868
  }
870
869
  this.ticker = new Ticker$1({ autoStart: false, frameRate });
@@ -1116,19 +1115,6 @@ class Progress extends EventEmitter {
1116
1115
  }
1117
1116
  }
1118
1117
 
1119
- const resourceLoader = {
1120
- AbstractLoadStrategy,
1121
- AudioLoadStrategy,
1122
- ImageLoadStrategy,
1123
- XhrResponseType,
1124
- MediaElementLoadStrategy,
1125
- VideoLoadStrategy,
1126
- Loader,
1127
- Resource: Resource$1,
1128
- ResourceType,
1129
- ResourceState,
1130
- };
1131
-
1132
1118
  var LOAD_EVENT;
1133
1119
  (function (LOAD_EVENT) {
1134
1120
  LOAD_EVENT["START"] = "start";
@@ -1236,6 +1222,7 @@ class Resource extends EventEmitter {
1236
1222
  resource.data = {};
1237
1223
  resource.complete = false;
1238
1224
  resource.instance = undefined;
1225
+ delete this.resourcesMap[name];
1239
1226
  });
1240
1227
  }
1241
1228
  registerResourceType(type, value = type) {
@@ -1255,7 +1242,7 @@ class Resource extends EventEmitter {
1255
1242
  if (!unLoadNames.length)
1256
1243
  return;
1257
1244
  const resolves = {};
1258
- unLoadNames.forEach(name => {
1245
+ unLoadNames.forEach((name) => __awaiter(this, void 0, void 0, function* () {
1259
1246
  var _a;
1260
1247
  this.promiseMap[name] = new Promise(r => (resolves[name] = r));
1261
1248
  const res = this.resourcesMap[name];
@@ -1270,23 +1257,55 @@ class Resource extends EventEmitter {
1270
1257
  }
1271
1258
  else {
1272
1259
  let url = (_a = res.src[key]) === null || _a === void 0 ? void 0 : _a.url;
1260
+ console.log(url);
1273
1261
  if (typeof url === 'string' && url.startsWith('//')) {
1274
- url = `${window.location.protocol}${res.src[key].url}`;
1262
+ url = `https:${res.src[key].url}`;
1275
1263
  }
1276
1264
  if (key === 'atlas') {
1265
+ const loadImagePromise = Assets.load(res.src['image'].url).catch(e => {
1266
+ this.onError({
1267
+ preload,
1268
+ errMsg: e.message,
1269
+ resource: {
1270
+ metadata: { key, name, resolves },
1271
+ },
1272
+ });
1273
+ });
1277
1274
  Assets.add({
1278
1275
  alias: url,
1279
1276
  src: url,
1280
1277
  data: {
1281
- resolve: () => Assets.load(res.src['image'].url),
1278
+ resolve: () => loadImagePromise,
1279
+ imageTexture: yield loadImagePromise,
1282
1280
  },
1283
1281
  });
1284
1282
  }
1285
1283
  else {
1286
- Assets.add({
1284
+ const options = {
1287
1285
  alias: url,
1288
1286
  src: url,
1289
- });
1287
+ };
1288
+ if (res.type === RESOURCE_TYPE.SPRITE || res.type === RESOURCE_TYPE.SPRITE_ANIMATION) {
1289
+ if (res.src[key].type === 'json') {
1290
+ try {
1291
+ const data = yield Assets.load(res.src['image'].url);
1292
+ options.data = {
1293
+ texture: data,
1294
+ };
1295
+ }
1296
+ catch (e) {
1297
+ console.log('>>>E', e);
1298
+ this.onError({
1299
+ preload,
1300
+ errMsg: e.message,
1301
+ resource: {
1302
+ metadata: { key, name, resolves },
1303
+ },
1304
+ });
1305
+ }
1306
+ }
1307
+ }
1308
+ Assets.add(options);
1290
1309
  }
1291
1310
  Assets.load(url)
1292
1311
  .then(data => {
@@ -1310,7 +1329,7 @@ class Resource extends EventEmitter {
1310
1329
  });
1311
1330
  }
1312
1331
  }
1313
- });
1332
+ }));
1314
1333
  }
1315
1334
  doComplete(name, resolve, preload = false) {
1316
1335
  return __awaiter(this, void 0, void 0, function* () {
@@ -1379,8 +1398,8 @@ const decorators = {
1379
1398
  IDEProp,
1380
1399
  componentObserver,
1381
1400
  };
1382
- const version = '2.0.0-beta.9';
1401
+ const version = '2.0.0';
1383
1402
  console.log(`Eva.js version: ${version}`);
1384
1403
  const RESOURCE_TYPE_STRATEGY = {};
1385
1404
 
1386
- export { Component$1 as Component, Game$1 as Game, GameObject$1 as GameObject, IDEProp, LOAD_EVENT, LOAD_SCENE_MODE, ObserverType as OBSERVER_TYPE, RESOURCE_TYPE, RESOURCE_TYPE_STRATEGY, Scene$1 as Scene, System$1 as System, Transform$1 as Transform, componentObserver, decorators, resource, resourceLoader, version };
1405
+ export { Component$1 as Component, Game$1 as Game, GameObject$1 as GameObject, IDEProp, LOAD_EVENT, LOAD_SCENE_MODE, ObserverType as OBSERVER_TYPE, RESOURCE_TYPE, RESOURCE_TYPE_STRATEGY, Scene$1 as Scene, System$1 as System, Transform$1 as Transform, componentObserver, decorators, resource, version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/eva.js",
3
- "version": "2.0.0-beta.9",
3
+ "version": "2.0.1-beta.0",
4
4
  "description": "@eva/eva.js",
5
5
  "main": "index.js",
6
6
  "module": "dist/eva.js.esm.js",