@safe-engine/pixi 1.0.2 → 7.0.2

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.
Files changed (48) hide show
  1. package/.github/workflows/npm-publish.yml +35 -0
  2. package/README.md +4 -4
  3. package/dist/app.d.ts +3 -2
  4. package/dist/app.d.ts.map +1 -1
  5. package/dist/app.js +41 -81
  6. package/dist/components/GUIComponent.d.ts +15 -14
  7. package/dist/components/GUIComponent.d.ts.map +1 -1
  8. package/dist/components/GUIComponent.js +68 -138
  9. package/dist/components/NodeComp.d.ts +6 -5
  10. package/dist/components/NodeComp.d.ts.map +1 -1
  11. package/dist/components/NodeComp.js +223 -305
  12. package/dist/components/RenderComponent.d.ts +8 -7
  13. package/dist/components/RenderComponent.d.ts.map +1 -1
  14. package/dist/components/RenderComponent.js +25 -56
  15. package/dist/core/Color.js +1 -1
  16. package/dist/core/LoadingBar.d.ts +9 -1
  17. package/dist/core/LoadingBar.d.ts.map +1 -1
  18. package/dist/core/LoadingBar.js +50 -46
  19. package/dist/core/Size.js +3 -6
  20. package/dist/core/Vec2.d.ts +20 -0
  21. package/dist/core/Vec2.d.ts.map +1 -0
  22. package/dist/core/Vec2.js +70 -0
  23. package/dist/helper/html-text-parser.js +34 -34
  24. package/dist/helper/utils.d.ts +1 -1
  25. package/dist/helper/utils.d.ts.map +1 -1
  26. package/dist/helper/utils.js +20 -24
  27. package/dist/index.d.ts +4 -6
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +4 -18
  30. package/dist/systems/GUISystem.d.ts +2 -2
  31. package/dist/systems/GUISystem.d.ts.map +1 -1
  32. package/dist/systems/GUISystem.js +39 -40
  33. package/dist/systems/RenderSystem.d.ts +0 -1
  34. package/dist/systems/RenderSystem.d.ts.map +1 -1
  35. package/dist/systems/RenderSystem.js +24 -35
  36. package/package.json +5 -4
  37. package/src/app.ts +53 -0
  38. package/src/components/GUIComponent.ts +141 -0
  39. package/src/components/NodeComp.ts +416 -0
  40. package/src/components/RenderComponent.ts +66 -0
  41. package/src/core/Color.ts +3 -0
  42. package/src/core/LoadingBar.ts +63 -0
  43. package/src/core/Size.ts +21 -0
  44. package/src/helper/html-text-parser.ts +364 -0
  45. package/src/index.ts +7 -0
  46. package/src/systems/GUISystem.ts +80 -0
  47. package/src/systems/RenderSystem.ts +70 -0
  48. package/tsconfig.json +24 -0
@@ -1,56 +1,34 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.MaskRender = exports.GraphicsRender = exports.SpriteRender = exports.NodeRender = void 0;
19
- var pixi_js_1 = require("pixi.js");
20
- var decorator_1 = require("../core/decorator");
21
- var LoadingBar_1 = require("../core/LoadingBar");
22
- var NodeRender = /** @class */ (function (_super) {
23
- __extends(NodeRender, _super);
24
- function NodeRender() {
25
- return _super !== null && _super.apply(this, arguments) || this;
26
- }
27
- return NodeRender;
28
- }(decorator_1.ComponentX));
4
+ const core_1 = require("@safe-engine/core");
5
+ const pixi_js_1 = require("pixi.js");
6
+ const LoadingBar_1 = require("../core/LoadingBar");
7
+ class NodeRender extends core_1.ComponentX {
8
+ }
29
9
  exports.NodeRender = NodeRender;
30
- var SpriteRender = /** @class */ (function (_super) {
31
- __extends(SpriteRender, _super);
32
- function SpriteRender() {
33
- var _this = _super !== null && _super.apply(this, arguments) || this;
34
- _this.fillType = LoadingBar_1.LoadingBarMode.BAR;
35
- _this.fillRange = 1;
36
- return _this;
10
+ class SpriteRender extends core_1.ComponentX {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.fillType = LoadingBar_1.LoadingBarMode.BAR;
14
+ this.fillRange = 1;
37
15
  }
38
16
  // set fillStart(val: number) {
39
17
  // if (this.node.instance instanceof cc.ProgressTimer) {
40
18
  // this.node.instance.setMidpoint(cc.v2(val, val));
41
19
  // }
42
20
  // }
43
- SpriteRender.prototype.setFillRange = function (val) {
21
+ setFillRange(val) {
44
22
  if (this.loadingBar) {
45
23
  this.loadingBar.progress = val;
46
24
  }
47
- };
48
- SpriteRender.prototype.getSpriteFrame = function () {
25
+ }
26
+ getSpriteFrame() {
49
27
  return this.spriteFrame;
50
- };
51
- SpriteRender.prototype.setSpriteFrame = function (frame) {
28
+ }
29
+ setSpriteFrame(frame) {
52
30
  this.spriteFrame = frame;
53
- var sprite = this.node.instance;
31
+ const sprite = this.node.instance;
54
32
  // if (this.node.instance instanceof cc.Sprite) {
55
33
  sprite.texture = pixi_js_1.Texture.from(frame);
56
34
  // sprite.texture.rotate = 8
@@ -65,25 +43,16 @@ var SpriteRender = /** @class */ (function (_super) {
65
43
  // } else if (this.node.instance instanceof ccui.Button) {
66
44
  // this.node.instance.loadTextureNormal(frame);
67
45
  // }
68
- };
69
- return SpriteRender;
70
- }(decorator_1.ComponentX));
46
+ }
47
+ }
71
48
  exports.SpriteRender = SpriteRender;
72
- var GraphicsRender = /** @class */ (function (_super) {
73
- __extends(GraphicsRender, _super);
74
- function GraphicsRender() {
75
- var _this = _super !== null && _super.apply(this, arguments) || this;
76
- _this.lineWidth = 2;
77
- return _this;
49
+ class GraphicsRender extends core_1.ComponentX {
50
+ constructor() {
51
+ super(...arguments);
52
+ this.lineWidth = 2;
78
53
  }
79
- return GraphicsRender;
80
- }(decorator_1.ComponentX));
54
+ }
81
55
  exports.GraphicsRender = GraphicsRender;
82
- var MaskRender = /** @class */ (function (_super) {
83
- __extends(MaskRender, _super);
84
- function MaskRender() {
85
- return _super !== null && _super.apply(this, arguments) || this;
86
- }
87
- return MaskRender;
88
- }(decorator_1.ComponentX));
56
+ class MaskRender extends core_1.ComponentX {
57
+ }
89
58
  exports.MaskRender = MaskRender;
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Color4B = Color4B;
4
4
  function Color4B(r, g, b, a) {
5
- return ({ r: r, g: g, b: b, a: a });
5
+ return ({ r, g, b, a });
6
6
  }
@@ -1,4 +1,4 @@
1
- import { Graphics, Point, Sprite } from 'pixi.js';
1
+ import { Container, Graphics, Point, Sprite } from 'pixi.js';
2
2
  export declare enum LoadingBarMode {
3
3
  BAR = 0,
4
4
  RADIAL = 1
@@ -10,4 +10,12 @@ export declare class LoadingBar extends Graphics {
10
10
  constructor(mode: LoadingBarMode, spriteComp: Sprite);
11
11
  set progress(val: number);
12
12
  }
13
+ export declare class ProgressTimer extends Container {
14
+ graphics: Graphics;
15
+ spriteComp: Sprite;
16
+ mode: LoadingBarMode;
17
+ fillCenter: Point;
18
+ constructor(mode: LoadingBarMode, spriteFrame: string);
19
+ set progress(val: number);
20
+ }
13
21
  //# sourceMappingURL=LoadingBar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LoadingBar.d.ts","sourceRoot":"","sources":["../../src/core/LoadingBar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEjD,oBAAY,cAAc;IACxB,GAAG,IAAA;IACH,MAAM,IAAA;CACP;AAED,qBAAa,UAAW,SAAQ,QAAQ;IACtC,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,cAAc,CAAA;IACpB,UAAU,QAAsB;gBACpB,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM;IAUpD,IAAI,QAAQ,CAAC,GAAG,EAAE,MAAM,EAUvB;CACF"}
1
+ {"version":3,"file":"LoadingBar.d.ts","sourceRoot":"","sources":["../../src/core/LoadingBar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAW,MAAM,SAAS,CAAA;AAErE,oBAAY,cAAc;IACxB,GAAG,IAAA;IACH,MAAM,IAAA;CACP;AAED,qBAAa,UAAW,SAAQ,QAAQ;IACtC,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,cAAc,CAAA;IACpB,UAAU,QAAsB;gBACpB,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM;IAUpD,IAAI,QAAQ,CAAC,GAAG,EAAE,MAAM,EAUvB;CACF;AAED,qBAAa,aAAc,SAAQ,SAAS;IAC1C,QAAQ,EAAE,QAAQ,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,cAAc,CAAA;IACpB,UAAU,QAAsB;gBACpB,IAAI,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM;IAerD,IAAI,QAAQ,CAAC,GAAG,EAAE,MAAM,EAOvB;CACF"}
@@ -1,55 +1,59 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.LoadingBar = exports.LoadingBarMode = void 0;
19
- var pixi_js_1 = require("pixi.js");
3
+ exports.ProgressTimer = exports.LoadingBar = exports.LoadingBarMode = void 0;
4
+ const pixi_js_1 = require("pixi.js");
20
5
  var LoadingBarMode;
21
6
  (function (LoadingBarMode) {
22
7
  LoadingBarMode[LoadingBarMode["BAR"] = 0] = "BAR";
23
8
  LoadingBarMode[LoadingBarMode["RADIAL"] = 1] = "RADIAL";
24
9
  })(LoadingBarMode || (exports.LoadingBarMode = LoadingBarMode = {}));
25
- var LoadingBar = /** @class */ (function (_super) {
26
- __extends(LoadingBar, _super);
27
- function LoadingBar(mode, spriteComp) {
28
- var _this = _super.call(this) || this;
29
- _this.fillCenter = new pixi_js_1.Point(0.5, 0.5);
30
- _this.spriteComp = spriteComp;
31
- _this.mode = mode || LoadingBarMode.BAR;
32
- _this.beginFill(0xffffff);
33
- _this.drawRect(0, 0, spriteComp.width, spriteComp.height);
34
- spriteComp.mask = _this;
35
- spriteComp.addChild(_this);
36
- return _this;
10
+ class LoadingBar extends pixi_js_1.Graphics {
11
+ constructor(mode, spriteComp) {
12
+ super();
13
+ this.fillCenter = new pixi_js_1.Point(0.5, 0.5);
14
+ this.spriteComp = spriteComp;
15
+ this.mode = mode || LoadingBarMode.BAR;
16
+ this.beginFill(0xffffff);
17
+ this.drawRect(0, 0, spriteComp.width, spriteComp.height);
18
+ spriteComp.mask = this;
19
+ spriteComp.addChild(this);
37
20
  }
38
- Object.defineProperty(LoadingBar.prototype, "progress", {
39
- set: function (val) {
40
- this.clear();
41
- this.beginFill(0xffffff);
42
- if (this.mode === LoadingBarMode.BAR) {
43
- var spriteComp = this.spriteComp;
44
- this.drawRect(0, 0, spriteComp.width * val, spriteComp.height);
45
- // console.log('new length', spriteComp.width)
46
- this.x = -spriteComp.width * 0.5;
47
- this.y = -spriteComp.height * 0.5;
48
- }
49
- },
50
- enumerable: false,
51
- configurable: true
52
- });
53
- return LoadingBar;
54
- }(pixi_js_1.Graphics));
21
+ set progress(val) {
22
+ this.clear();
23
+ this.beginFill(0xffffff);
24
+ if (this.mode === LoadingBarMode.BAR) {
25
+ const spriteComp = this.spriteComp;
26
+ this.drawRect(0, 0, spriteComp.width * val, spriteComp.height);
27
+ // console.log('new length', spriteComp.width)
28
+ this.x = -spriteComp.width * 0.5;
29
+ this.y = -spriteComp.height * 0.5;
30
+ }
31
+ }
32
+ }
55
33
  exports.LoadingBar = LoadingBar;
34
+ class ProgressTimer extends pixi_js_1.Container {
35
+ constructor(mode, spriteFrame) {
36
+ super();
37
+ this.fillCenter = new pixi_js_1.Point(0.5, 0.5);
38
+ const texture = pixi_js_1.Texture.from(spriteFrame);
39
+ this.spriteComp = pixi_js_1.Sprite.from(texture);
40
+ this.graphics = new pixi_js_1.Graphics();
41
+ this.mode = mode || LoadingBarMode.BAR;
42
+ this.graphics.beginFill(0xffffff);
43
+ this.graphics.drawRect(0, 0, this.spriteComp.width, this.spriteComp.height);
44
+ this.spriteComp.mask = this.graphics;
45
+ this.addChild(this.graphics);
46
+ this.addChild(this.spriteComp);
47
+ // this.graphics.x = -this.spriteComp.width * this.fillCenter.x
48
+ // this.graphics.y = -this.spriteComp.height * this.fillCenter.y
49
+ }
50
+ set progress(val) {
51
+ this.graphics.clear();
52
+ if (this.mode === LoadingBarMode.BAR) {
53
+ this.graphics.beginFill(0xffffff);
54
+ this.graphics.drawRect(0, 0, this.spriteComp.width * val, this.spriteComp.height);
55
+ // console.log('new length', this.width)
56
+ }
57
+ }
58
+ }
59
+ exports.ProgressTimer = ProgressTimer;
package/dist/core/Size.js CHANGED
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Size = Size;
4
- var _Size = /** @class */ (function () {
5
- function _Size(width, height) {
6
- if (width === void 0) { width = 0; }
7
- if (height === void 0) { height = 0; }
4
+ class _Size {
5
+ constructor(width = 0, height = 0) {
8
6
  if (!(this instanceof _Size)) {
9
7
  return new _Size(width, height);
10
8
  }
@@ -15,8 +13,7 @@ var _Size = /** @class */ (function () {
15
13
  this.width = width;
16
14
  this.height = height;
17
15
  }
18
- return _Size;
19
- }());
16
+ }
20
17
  function Size(x, y) {
21
18
  return new _Size(x, y);
22
19
  }
@@ -0,0 +1,20 @@
1
+ import { Point } from 'pixi.js';
2
+ declare class _Vec2 extends Point {
3
+ x: number;
4
+ y: number;
5
+ static ZERO: any;
6
+ equals(other: Point): boolean;
7
+ addSelf(value: Point): Point;
8
+ cross(other: Vec2): number;
9
+ signAngle(other: Vec2): number;
10
+ lengthSqr(): number;
11
+ dot(other: Vec2): number;
12
+ angle(other: Vec2): number;
13
+ }
14
+ export type Vec2 = _Vec2;
15
+ export declare function Vec2(x?: number, y?: number): Vec2;
16
+ export declare namespace Vec2 {
17
+ var ZERO: Readonly<_Vec2>;
18
+ }
19
+ export {};
20
+ //# sourceMappingURL=Vec2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Vec2.d.ts","sourceRoot":"","sources":["../../src/core/Vec2.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,cAAM,KAAM,SAAQ,KAAK;IACvB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,MAAM,CAAC,IAAI,MAAA;IAEX,MAAM,CAAC,KAAK,EAAE,KAAK;IAInB,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK;IAOrB,KAAK,CAAC,KAAK,EAAE,IAAI;IAGjB,SAAS,CAAC,KAAK,EAAE,IAAI;IAIrB,SAAS;IAGT,GAAG,CAAC,KAAK,EAAE,IAAI;IAGf,KAAK,CAAC,KAAK,EAAE,IAAI;CAczB;AACD,MAAM,MAAM,IAAI,GAAG,KAAK,CAAA;AACxB,wBAAgB,IAAI,CAAC,CAAC,SAAI,EAAE,CAAC,SAAI,GAAG,IAAI,CAEvC;yBAFe,IAAI"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.Vec2 = Vec2;
22
+ var clamp_1 = __importDefault(require("lodash/clamp"));
23
+ var pixi_js_1 = require("pixi.js");
24
+ var _Vec2 = /** @class */ (function (_super) {
25
+ __extends(_Vec2, _super);
26
+ function _Vec2() {
27
+ return _super !== null && _super.apply(this, arguments) || this;
28
+ }
29
+ _Vec2.prototype.equals = function (other) {
30
+ return this.x === other.x && this.y === other.y;
31
+ };
32
+ _Vec2.prototype.addSelf = function (value) {
33
+ var nor = value.add(new pixi_js_1.Point(this.x, this.y));
34
+ this.x = nor.x;
35
+ this.y = nor.y;
36
+ return nor;
37
+ };
38
+ _Vec2.prototype.cross = function (other) {
39
+ return this.x * other.y - this.y * other.x;
40
+ };
41
+ _Vec2.prototype.signAngle = function (other) {
42
+ var angle = this.angle(other);
43
+ return this.cross(other) < 0 ? -angle : angle;
44
+ };
45
+ _Vec2.prototype.lengthSqr = function () {
46
+ return this.x * this.x + this.y * this.y;
47
+ };
48
+ _Vec2.prototype.dot = function (other) {
49
+ return this.x * other.x + this.y * other.y;
50
+ };
51
+ _Vec2.prototype.angle = function (other) {
52
+ var magSqr1 = this.lengthSqr();
53
+ var magSqr2 = other.lengthSqr();
54
+ if (magSqr1 === 0 || magSqr2 === 0) {
55
+ console.warn('Cant get angle between zero vector');
56
+ return 0.0;
57
+ }
58
+ var dot = this.dot(other);
59
+ var theta = dot / Math.sqrt(magSqr1 * magSqr2);
60
+ theta = (0, clamp_1.default)(theta, -1.0, 1.0);
61
+ return Math.acos(theta);
62
+ };
63
+ return _Vec2;
64
+ }(pixi_js_1.Point));
65
+ function Vec2(x, y) {
66
+ if (x === void 0) { x = 0; }
67
+ if (y === void 0) { y = 0; }
68
+ return new _Vec2(x, y);
69
+ }
70
+ Vec2.ZERO = Object.freeze(Vec2(0, 0));
@@ -29,12 +29,12 @@
29
29
  ****************************************************************************/
30
30
  Object.defineProperty(exports, "__esModule", { value: true });
31
31
  exports.HtmlTextParser = void 0;
32
- var eventRegx = /^(click)(\s)*=|(param)(\s)*=/;
33
- var imageAttrReg = /(\s)*src(\s)*=|(\s)*height(\s)*=|(\s)*width(\s)*=|(\s)*align(\s)*=|(\s)*offset(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;
32
+ const eventRegx = /^(click)(\s)*=|(param)(\s)*=/;
33
+ const imageAttrReg = /(\s)*src(\s)*=|(\s)*height(\s)*=|(\s)*width(\s)*=|(\s)*align(\s)*=|(\s)*offset(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;
34
34
  /**
35
35
  * A utils class for parsing HTML texts. The parsed results will be an object array.
36
36
  */
37
- var HtmlTextParser = function () {
37
+ const HtmlTextParser = function () {
38
38
  this._parsedObject = {};
39
39
  this._specialSymbolArray = [];
40
40
  this._specialSymbolArray.push([/&lt;/g, '<']);
@@ -53,14 +53,14 @@ exports.HtmlTextParser.prototype = {
53
53
  return this._resultObjectArray;
54
54
  }
55
55
  this._stack = [];
56
- var startIndex = 0;
57
- var length = htmlString.length;
56
+ let startIndex = 0;
57
+ const length = htmlString.length;
58
58
  while (startIndex < length) {
59
- var tagEndIndex = htmlString.indexOf('>', startIndex);
60
- var tagBeginIndex = -1;
59
+ let tagEndIndex = htmlString.indexOf('>', startIndex);
60
+ let tagBeginIndex = -1;
61
61
  if (tagEndIndex >= 0) {
62
62
  tagBeginIndex = htmlString.lastIndexOf('<', tagEndIndex);
63
- var noTagBegin = tagBeginIndex < startIndex - 1;
63
+ const noTagBegin = tagBeginIndex < startIndex - 1;
64
64
  if (noTagBegin) {
65
65
  tagBeginIndex = htmlString.indexOf('<', tagEndIndex + 1);
66
66
  tagEndIndex = htmlString.indexOf('>', tagBeginIndex + 1);
@@ -72,8 +72,8 @@ exports.HtmlTextParser.prototype = {
72
72
  startIndex = length;
73
73
  }
74
74
  else {
75
- var newStr = htmlString.substring(startIndex, tagBeginIndex);
76
- var tagStr = htmlString.substring(tagBeginIndex + 1, tagEndIndex);
75
+ let newStr = htmlString.substring(startIndex, tagBeginIndex);
76
+ const tagStr = htmlString.substring(tagBeginIndex + 1, tagEndIndex);
77
77
  if (tagStr === '')
78
78
  newStr = htmlString.substring(startIndex, tagEndIndex + 1);
79
79
  this._processResult(newStr);
@@ -94,12 +94,12 @@ exports.HtmlTextParser.prototype = {
94
94
  },
95
95
  _attributeToObject: function (attribute) {
96
96
  attribute = attribute.trim();
97
- var obj = {};
98
- var header = attribute.match(/^(color|size)(\s)*=/);
99
- var tagName;
100
- var nextSpace;
101
- var eventObj;
102
- var eventHanlderString;
97
+ const obj = {};
98
+ let header = attribute.match(/^(color|size)(\s)*=/);
99
+ let tagName;
100
+ let nextSpace;
101
+ let eventObj;
102
+ let eventHanlderString;
103
103
  if (header) {
104
104
  tagName = header[0];
105
105
  attribute = attribute.substring(tagName.length).trim();
@@ -144,7 +144,7 @@ exports.HtmlTextParser.prototype = {
144
144
  header = attribute.match(imageAttrReg);
145
145
  var tagValue;
146
146
  var remainingArgument;
147
- var isValidImageTag = false;
147
+ let isValidImageTag = false;
148
148
  while (header) {
149
149
  //skip the invalid tags at first
150
150
  attribute = attribute.substring(attribute.indexOf(header[0]));
@@ -188,7 +188,7 @@ exports.HtmlTextParser.prototype = {
188
188
  obj.imageOffset = tagValue;
189
189
  }
190
190
  else if (tagName === 'click') {
191
- obj.event = this._processEventHandler("".concat(tagName, "=").concat(tagValue));
191
+ obj.event = this._processEventHandler(`${tagName}=${tagValue}`);
192
192
  }
193
193
  if (obj.event && tagName === 'param') {
194
194
  obj.event.param = tagValue.replace(/^\"|\"$/g, '');
@@ -204,9 +204,9 @@ exports.HtmlTextParser.prototype = {
204
204
  header = attribute.match(/^(outline(\s)*[^>]*)/);
205
205
  if (header) {
206
206
  attribute = header[0].substring('outline'.length).trim();
207
- var defaultOutlineObject = { color: '#ffffff', width: 1 };
207
+ const defaultOutlineObject = { color: '#ffffff', width: 1 };
208
208
  if (attribute) {
209
- var outlineAttrReg = /(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;
209
+ const outlineAttrReg = /(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;
210
210
  header = attribute.match(outlineAttrReg);
211
211
  var tagValue;
212
212
  while (header) {
@@ -226,7 +226,7 @@ exports.HtmlTextParser.prototype = {
226
226
  tagName = tagName.toLocaleLowerCase();
227
227
  attribute = remainingArgument.substring(nextSpace).trim();
228
228
  if (tagName === 'click') {
229
- obj.event = this._processEventHandler("".concat(tagName, "=").concat(tagValue));
229
+ obj.event = this._processEventHandler(`${tagName}=${tagValue}`);
230
230
  }
231
231
  else if (tagName === 'color') {
232
232
  defaultOutlineObject.color = tagValue;
@@ -266,13 +266,13 @@ exports.HtmlTextParser.prototype = {
266
266
  return obj;
267
267
  },
268
268
  _processEventHandler: function (eventString) {
269
- var index = 0;
270
- var obj = {};
271
- var eventNames = eventString.match(eventRegx);
272
- var isValidTag = false;
269
+ let index = 0;
270
+ const obj = {};
271
+ let eventNames = eventString.match(eventRegx);
272
+ let isValidTag = false;
273
273
  while (eventNames) {
274
- var eventName = eventNames[0];
275
- var eventValue = '';
274
+ let eventName = eventNames[0];
275
+ let eventValue = '';
276
276
  isValidTag = false;
277
277
  eventString = eventString.substring(eventName.length).trim();
278
278
  if (eventString.charAt(0) === '"') {
@@ -293,7 +293,7 @@ exports.HtmlTextParser.prototype = {
293
293
  }
294
294
  else {
295
295
  //skip the invalid attribute value
296
- var match = eventString.match(/(\S)+/);
296
+ const match = eventString.match(/(\S)+/);
297
297
  if (match) {
298
298
  eventValue = match[0];
299
299
  }
@@ -312,7 +312,7 @@ exports.HtmlTextParser.prototype = {
312
312
  return obj;
313
313
  },
314
314
  _addToStack: function (attribute) {
315
- var obj = this._attributeToObject(attribute);
315
+ const obj = this._attributeToObject(attribute);
316
316
  if (this._stack.length === 0) {
317
317
  this._stack.push(obj);
318
318
  }
@@ -321,8 +321,8 @@ exports.HtmlTextParser.prototype = {
321
321
  return;
322
322
  }
323
323
  //for nested tags
324
- var previousTagObj = this._stack[this._stack.length - 1];
325
- for (var key in previousTagObj) {
324
+ const previousTagObj = this._stack[this._stack.length - 1];
325
+ for (const key in previousTagObj) {
326
326
  if (!obj[key]) {
327
327
  obj[key] = previousTagObj[key];
328
328
  }
@@ -343,9 +343,9 @@ exports.HtmlTextParser.prototype = {
343
343
  }
344
344
  },
345
345
  _escapeSpecialSymbol: function (str) {
346
- for (var i = 0; i < this._specialSymbolArray.length; ++i) {
347
- var key = this._specialSymbolArray[i][0];
348
- var value = this._specialSymbolArray[i][1];
346
+ for (let i = 0; i < this._specialSymbolArray.length; ++i) {
347
+ const key = this._specialSymbolArray[i][0];
348
+ const value = this._specialSymbolArray[i][1];
349
349
  str = str.replace(key, value);
350
350
  }
351
351
  return str;
@@ -1,5 +1,5 @@
1
+ import { ComponentX } from '@safe-engine/core';
1
2
  import { Constructor, EntityManager, EventManager, EventReceive } from 'entityx-ts';
2
- import { ComponentX } from '..';
3
3
  export declare function registerSystem<T extends ComponentX>(component: Constructor<T>): {
4
4
  new (): {
5
5
  configure(event_manager: EventManager): void;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/helper/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAGvD,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,UAAU,EAAY,MAAM,IAAI,CAAA;AAGzC,wBAAgB,cAAc,CAAC,CAAC,SAAS,UAAU,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;;iCAKjD,YAAY;0CAKH,YAAY,CAAC,CAAC,CAAC;yBAMhC,aAAa,UAAU,YAAY,MAAM,MAAM;;EAenE;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAE3E"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/helper/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,mBAAmB,CAAA;AACzD,OAAO,EACL,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAGvD,MAAM,YAAY,CAAA;AAInB,wBAAgB,cAAc,CAAC,CAAC,SAAS,UAAU,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;;iCAKjD,YAAY;0CAKH,YAAY,CAAC,CAAC,CAAC;yBAMhC,aAAa,UAAU,YAAY,MAAM,MAAM;;EAenE;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAE3E"}
@@ -2,41 +2,37 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.registerSystem = registerSystem;
4
4
  exports.instantiate = instantiate;
5
- var entityx_ts_1 = require("entityx-ts");
6
- var __1 = require("..");
7
- var gworld_1 = require("../gworld");
5
+ const core_1 = require("@safe-engine/core");
6
+ const entityx_ts_1 = require("entityx-ts");
7
+ const __1 = require("..");
8
8
  function registerSystem(component) {
9
- if (gworld_1.GameWorld.Instance.systems.isRegistered("".concat(component.name, "System"))) {
9
+ if (core_1.GameWorld.Instance.systems.isRegistered(`${component.name}System`)) {
10
10
  return;
11
11
  }
12
- var NewSystem = /** @class */ (function () {
13
- function NewSystem() {
14
- }
15
- NewSystem.prototype.configure = function (event_manager) {
12
+ class NewSystem {
13
+ configure(event_manager) {
16
14
  console.log('configure registerSystem', component.name);
17
15
  event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, component, this.receiveComponentAddedEvent.bind(this));
18
- };
19
- NewSystem.prototype.receiveComponentAddedEvent = function (event) {
20
- var ett = event.entity;
21
- var newComp = ett.getComponent(component);
16
+ }
17
+ receiveComponentAddedEvent(event) {
18
+ const ett = event.entity;
19
+ const newComp = ett.getComponent(component);
22
20
  newComp.node = ett.getComponent(__1.NodeComp);
23
- };
24
- NewSystem.prototype.update = function (entities, events, dt) {
25
- for (var _i = 0, _a = entities.entities_with_components(component); _i < _a.length; _i++) {
26
- var entt = _a[_i];
27
- var comp = entt.getComponent(component);
21
+ }
22
+ update(entities, events, dt) {
23
+ for (const entt of entities.entities_with_components(component)) {
24
+ const comp = entt.getComponent(component);
28
25
  // console.log('comp', comp.constructor.name, typeof comp['update'] === 'function')
29
26
  if (comp.node.active && typeof comp['update'] === 'function') {
30
27
  comp['update'](dt);
31
28
  }
32
29
  }
33
- };
34
- return NewSystem;
35
- }());
36
- Object.defineProperty(NewSystem, 'name', { value: "".concat(component.name, "System") });
37
- gworld_1.GameWorld.Instance.systems.add(NewSystem);
38
- gworld_1.GameWorld.Instance.systems.configureOnce(NewSystem);
39
- gworld_1.GameWorld.Instance.listUpdate.push(NewSystem);
30
+ }
31
+ }
32
+ Object.defineProperty(NewSystem, 'name', { value: `${component.name}System` });
33
+ core_1.GameWorld.Instance.systems.add(NewSystem);
34
+ core_1.GameWorld.Instance.systems.configureOnce(NewSystem);
35
+ core_1.GameWorld.Instance.listUpdate.push(NewSystem);
40
36
  return NewSystem;
41
37
  }
42
38
  function instantiate(ComponentType, data) {
package/dist/index.d.ts CHANGED
@@ -1,10 +1,8 @@
1
- export { addGameCanvasTo, app, initWorld, setupResolution } from './app';
1
+ export * from './app';
2
2
  export * from './components/GUIComponent';
3
- export { NodeComp } from './components/NodeComp';
3
+ export * from './components/NodeComp';
4
4
  export * from './components/RenderComponent';
5
- export { ComponentX, NoRenderComponentX } from './core/decorator';
6
- export { SceneComponent } from './core/Scene';
7
5
  export * from './core/Size';
8
- export { GameWorld } from './gworld';
9
- export { instantiate, registerSystem } from './helper/utils';
6
+ export * from './systems/GUISystem';
7
+ export * from './systems/RenderSystem';
10
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,SAAS,EAAC,eAAe,EAAE,MAAM,OAAO,CAAA;AACvE,cAAc,2BAA2B,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,cAAc,8BAA8B,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACpC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAA;AACrB,cAAc,2BAA2B,CAAA;AACzC,cAAc,uBAAuB,CAAA;AACrC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA"}