@eva/eva.js 2.0.0-beta.8 → 2.0.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";
@@ -1255,7 +1241,7 @@ class Resource extends EventEmitter {
1255
1241
  if (!unLoadNames.length)
1256
1242
  return;
1257
1243
  const resolves = {};
1258
- unLoadNames.forEach(name => {
1244
+ unLoadNames.forEach((name) => __awaiter(this, void 0, void 0, function* () {
1259
1245
  var _a;
1260
1246
  this.promiseMap[name] = new Promise(r => (resolves[name] = r));
1261
1247
  const res = this.resourcesMap[name];
@@ -1270,23 +1256,55 @@ class Resource extends EventEmitter {
1270
1256
  }
1271
1257
  else {
1272
1258
  let url = (_a = res.src[key]) === null || _a === void 0 ? void 0 : _a.url;
1259
+ console.log(url);
1273
1260
  if (typeof url === 'string' && url.startsWith('//')) {
1274
- url = `${window.location.protocol}${res.src[key].url}`;
1261
+ url = `https:${res.src[key].url}`;
1275
1262
  }
1276
1263
  if (key === 'atlas') {
1264
+ const loadImagePromise = Assets.load(res.src['image'].url).catch(e => {
1265
+ this.onError({
1266
+ preload,
1267
+ errMsg: e.message,
1268
+ resource: {
1269
+ metadata: { key, name, resolves },
1270
+ },
1271
+ });
1272
+ });
1277
1273
  Assets.add({
1278
1274
  alias: url,
1279
1275
  src: url,
1280
1276
  data: {
1281
- resolve: () => Assets.load(res.src['image'].url),
1277
+ resolve: () => loadImagePromise,
1278
+ imageTexture: yield loadImagePromise,
1282
1279
  },
1283
1280
  });
1284
1281
  }
1285
1282
  else {
1286
- Assets.add({
1283
+ const options = {
1287
1284
  alias: url,
1288
1285
  src: url,
1289
- });
1286
+ };
1287
+ if (res.type === RESOURCE_TYPE.SPRITE || res.type === RESOURCE_TYPE.SPRITE_ANIMATION) {
1288
+ if (res.src[key].type === 'json') {
1289
+ try {
1290
+ const data = yield Assets.load(res.src['image'].url);
1291
+ options.data = {
1292
+ texture: data,
1293
+ };
1294
+ }
1295
+ catch (e) {
1296
+ console.log('>>>E', e);
1297
+ this.onError({
1298
+ preload,
1299
+ errMsg: e.message,
1300
+ resource: {
1301
+ metadata: { key, name, resolves },
1302
+ },
1303
+ });
1304
+ }
1305
+ }
1306
+ }
1307
+ Assets.add(options);
1290
1308
  }
1291
1309
  Assets.load(url)
1292
1310
  .then(data => {
@@ -1310,7 +1328,7 @@ class Resource extends EventEmitter {
1310
1328
  });
1311
1329
  }
1312
1330
  }
1313
- });
1331
+ }));
1314
1332
  }
1315
1333
  doComplete(name, resolve, preload = false) {
1316
1334
  return __awaiter(this, void 0, void 0, function* () {
@@ -1379,8 +1397,8 @@ const decorators = {
1379
1397
  IDEProp,
1380
1398
  componentObserver,
1381
1399
  };
1382
- const version = '2.0.0-beta.8';
1400
+ const version = '2.0.0-beta.22';
1383
1401
  console.log(`Eva.js version: ${version}`);
1384
1402
  const RESOURCE_TYPE_STRATEGY = {};
1385
1403
 
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 };
1404
+ 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.8",
3
+ "version": "2.0.0",
4
4
  "description": "@eva/eva.js",
5
5
  "main": "index.js",
6
6
  "module": "dist/eva.js.esm.js",