@urso/core 0.7.96-dev → 0.7.97

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.
@@ -149,12 +149,11 @@ object-assign
149
149
  */
150
150
 
151
151
  /*!
152
- * GSAP 3.12.5
152
+ * GSAP 3.14.2
153
153
  * https://gsap.com
154
154
  *
155
- * @license Copyright 2008-2024, GreenSock. All rights reserved.
156
- * Subject to the terms at https://gsap.com/standard-license or for
157
- * Club GSAP members, the agreement issued with that membership.
155
+ * @license Copyright 2008-2025, GreenSock. All rights reserved.
156
+ * Subject to the terms at https://gsap.com/standard-license
158
157
  * @author: Jack Doyle, jack@greensock.com
159
158
  */
160
159
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urso/core",
3
- "version": "0.7.96-dev",
3
+ "version": "0.7.97",
4
4
  "description": "HTML5 game engine",
5
5
  "main": "build/js/index.js",
6
6
  "author": "Megbrimef",
@@ -30,7 +30,8 @@
30
30
  "pixi-scrollbox": "^2.3.1",
31
31
  "pixi-spine": "^3.1.2",
32
32
  "pixi-viewport": "^4.34.0",
33
- "pixi.js": "^6.2.0"
33
+ "pixi.js": "^6.2.0",
34
+ "pixi-text-input": "^1.2.1"
34
35
  },
35
36
  "devDependencies": {
36
37
  "@babel/core": "^7.12.10",
@@ -11,7 +11,8 @@ let ConfigMain = {
11
11
  fps: {
12
12
  limit: 60, //max fps limit
13
13
  optimizeLowPerformance: false //down to 30 fps if lower 60
14
- }
14
+ },
15
+ domParentSelector: false //or '#app-container' - div selector, to append canvas
15
16
  };
16
17
 
17
18
  module.exports = ConfigMain;
@@ -1,10 +1,12 @@
1
1
  import * as PIXI from 'pixi.js';
2
+ import TextInput from 'pixi-text-input';
2
3
  window.PIXI = PIXI;
3
4
  window.PIXI.particles = require('pixi-particles');
4
5
 
5
6
  window.PIXI.particlesFx = require('@urso/revolt-fx');
6
7
 
7
8
  window.PIXI.spine = require("pixi-spine");
9
+ window.PIXI.TextInput = TextInput;
8
10
 
9
11
  import { AtlasAttachmentLoader, SkeletonJson } from "@pixi-spine/runtime-3.8";
10
12
  window.PIXI.spine.AtlasAttachmentLoader = AtlasAttachmentLoader;
@@ -1,9 +1,11 @@
1
1
  const ModulesObjectsBaseModel = require('./../baseModel');
2
2
 
3
3
  class ModulesObjectsModelsHitArea extends ModulesObjectsBaseModel {
4
+
4
5
  constructor(params) {
5
6
  super(params);
6
7
  this._isDisabled = false;
8
+ this._isDown = false;
7
9
 
8
10
  this.type = Urso.types.objects.HITAREA;
9
11
 
@@ -24,6 +26,17 @@ class ModulesObjectsModelsHitArea extends ModulesObjectsBaseModel {
24
26
  this.onOverCallback = Urso.helper.recursiveGet('onOverCallback', params, false);
25
27
  this.onOutCallback = Urso.helper.recursiveGet('onOutCallback', params, false);
26
28
  this.onTouchMoveCallback = Urso.helper.recursiveGet('onTouchMoveCallback', params, false);
29
+
30
+ /**
31
+ * customInteractionArea object ex:
32
+ * Circle: { "type": "circle", "params": [0, 0, 100] }
33
+ * Rectangle: { "type": "rectangle", "params": [0, 0, 100, 100] }
34
+ * Polygon: {
35
+ * "type": "polygon",
36
+ * "params": [ 0, 0, 100, 0, 100, 100, 50, 150, 0, 100 ];
37
+ * }
38
+ * */
39
+ this.customInteractionArea = Urso.helper.recursiveGet('customInteractionArea', params, null);
27
40
  }
28
41
 
29
42
  enable() {
@@ -56,11 +69,14 @@ class ModulesObjectsModelsHitArea extends ModulesObjectsBaseModel {
56
69
  this._baseObject
57
70
  .on('pointerdown', this._onPressDown.bind(this))
58
71
  .on('pointerup', this._onPressUp.bind(this))
59
- .on('pointerupoutside', this._onPressUp.bind(this))
72
+ .on('pointerupoutside', this._onPressUpOutside.bind(this))
60
73
  .on('pointerover', this._onOver.bind(this))
61
74
  .on('pointerout', this._onOut.bind(this))
62
75
  .on('touchmove', this._onTouchmove.bind(this));
63
- };
76
+
77
+ if (this.customInteractionArea)
78
+ this._baseObject.hitArea = this._getHitAreaObject(this.customInteractionArea);
79
+ }
64
80
 
65
81
  _onTouchmove(event) {
66
82
  const position = this._getEventLocalPosition(event);
@@ -73,6 +89,11 @@ class ModulesObjectsModelsHitArea extends ModulesObjectsBaseModel {
73
89
  if (this._isDisabled)
74
90
  return false;
75
91
 
92
+ if (this._isDown)
93
+ return false;
94
+
95
+ this._isDown = true;
96
+
76
97
  if (this.keyDownAction) {
77
98
  const position = this._getEventLocalPosition(event);
78
99
  this.keyDownAction(position);
@@ -83,12 +104,24 @@ class ModulesObjectsModelsHitArea extends ModulesObjectsBaseModel {
83
104
  if (this._isDisabled)
84
105
  return false;
85
106
 
107
+ if (!this._isDown)
108
+ return false;
109
+
110
+ this._isDown = false;
111
+
86
112
  if (this.action) {
87
113
  const position = this._getEventLocalPosition(event);
88
114
  this.action(position);
89
115
  }
90
116
  }
91
117
 
118
+ _onPressUpOutside() {
119
+ if (this._isDisabled)
120
+ return false;
121
+
122
+ this._isDown = false;
123
+ }
124
+
92
125
  _onOver() {
93
126
  if (this._isDisabled)
94
127
  return false;
@@ -114,6 +147,24 @@ class ModulesObjectsModelsHitArea extends ModulesObjectsBaseModel {
114
147
 
115
148
  return { x, y };
116
149
  }
150
+
151
+ _getHitAreaObject({ type, params }) {
152
+ if (!type) {
153
+ return null;
154
+ }
155
+
156
+ const objects = {
157
+ 'rectangle': PIXI.Rectangle,
158
+ 'circle': PIXI.Circle,
159
+ 'polygon': PIXI.Polygon
160
+ }
161
+
162
+ if (!objects[type]) {
163
+ return null;
164
+ }
165
+
166
+ return new objects[type](...params);
167
+ }
117
168
  }
118
169
 
119
170
  module.exports = ModulesObjectsModelsHitArea;
@@ -86,9 +86,10 @@ class ModulesObjectsModelsSpine extends ModulesObjectsBaseModel {
86
86
  * play spine animation and execute function after animation completes
87
87
  * @param {String} animation - name of the animation to be played
88
88
  * @param {Function} func - function to be executed
89
+ * @param {Number} [track] - you can define track number for current animation
89
90
  */
90
- playAndThen(animation, func) {
91
- this.playInSequenceAndThen([animation], func);
91
+ playAndThen(animation, func, track) {
92
+ this.playInSequenceAndThen([animation], func, track);
92
93
  }
93
94
 
94
95
  /**
@@ -103,17 +104,19 @@ class ModulesObjectsModelsSpine extends ModulesObjectsBaseModel {
103
104
  * play spine animations in sequence and execute function after last animation completes
104
105
  * @param {String[]} animations - names of the animations to be played
105
106
  * @param {Function} func - function to be executed
107
+ * @param {Number} [track] - you can define track number for current animation
106
108
  */
107
- playInSequenceAndThen(animations, func) {
108
- this._playInSequenceAndThen(animations, func);
109
+ playInSequenceAndThen(animations, func, track) {
110
+ this._playInSequenceAndThen(animations, func, track);
109
111
  }
110
112
 
111
113
  /**
112
114
  * play spine animations in sequence and execute function after last animation completes
113
115
  * @param {String[]} animations - names of the animations to be played
114
116
  * @param {Function} func - function to be executed
117
+ * @param {Number} [track] - you can define track number for current animation
115
118
  */
116
- _playInSequenceAndThen(animations, func) {
119
+ _playInSequenceAndThen(animations, func, track) {
117
120
  this.stop();
118
121
  let removeSelf = () => { };
119
122
  let animationCount = 0;
@@ -123,7 +126,7 @@ class ModulesObjectsModelsSpine extends ModulesObjectsBaseModel {
123
126
  animationCount++;
124
127
 
125
128
  if (animations[animationCount])
126
- this.play(animations[animationCount])
129
+ this.play(animations[animationCount], false, track)
127
130
  else {
128
131
  func && func();
129
132
  removeSelf();
@@ -133,7 +136,7 @@ class ModulesObjectsModelsSpine extends ModulesObjectsBaseModel {
133
136
 
134
137
  removeSelf = () => this._baseObject.state.removeListener(completer);
135
138
  this._baseObject.state.addListener(completer);
136
- this.play(animations[0]);
139
+ this.play(animations[0], false, track);
137
140
  }
138
141
 
139
142
  /**
@@ -319,7 +322,7 @@ class ModulesObjectsModelsSpine extends ModulesObjectsBaseModel {
319
322
  if (replaceSlotContents)
320
323
  currentSlot.removeChildren(); //todo check if its proxy and reset parent
321
324
 
322
- this.addChild(object); //todo make removeChild for addedToSlotObjects
325
+ this.addChild(object, true); //todo make removeChild for addedToSlotObjects
323
326
  currentSlot.addChild(object._baseObject);
324
327
  Urso.objects.refreshStyles();
325
328
  } else {
@@ -323,9 +323,9 @@ class PropertyAdapter {
323
323
  case 'left':
324
324
  return 0;
325
325
  case 'right':
326
- return object.parent ? this._getWidthAsNumber(object.parent) - this._getWidthAsNumber(object) : 0; //parentWidth-objectWidth
326
+ return object.parent ? this._getWidthAsNumber(object.parent) : 0; //parentWidth
327
327
  case 'center':
328
- const parentWidth = object.parent ? this._getWidthAsNumber(object.parent) - this._getWidthAsNumber(object) : 0;
328
+ const parentWidth = object.parent ? this._getWidthAsNumber(object.parent) : 0;
329
329
  return parentWidth / 2;
330
330
  default:
331
331
  Urso.logger.error('AlignX string is not valid!');
@@ -347,9 +347,9 @@ class PropertyAdapter {
347
347
  case 'top':
348
348
  return 0;
349
349
  case 'bottom':
350
- return object.parent ? this._getHeightAsNumber(object.parent) - this._getHeightAsNumber(object) : 0; //parentHeight
350
+ return object.parent ? this._getHeightAsNumber(object.parent) : 0; //parentHeight
351
351
  case 'center':
352
- const parentHeight = object.parent ? this._getHeightAsNumber(object.parent) - this._getHeightAsNumber(object) : 0;
352
+ const parentHeight = object.parent ? this._getHeightAsNumber(object.parent) : 0;
353
353
  return parentHeight / 2;
354
354
  default:
355
355
  Urso.logger.error('AlignY string is not valid!');
@@ -458,10 +458,7 @@ class PropertyAdapter {
458
458
  return this._getRoundedPercentageOfNumber(object[propertyName], parentValue);
459
459
 
460
460
  case 'boolean':
461
- if (this._canBeParent(object))
462
- return this._getPropertyAsNumber(object.parent, propertyName, parentPropertyName);
463
- else
464
- return object._baseObject[propertyName];
461
+ return this._getPropertyAsNumber(object.parent, propertyName, parentPropertyName)
465
462
 
466
463
  default:
467
464
  Urso.logger.error('Property value not number or string!', object, propertyName);
@@ -12,6 +12,7 @@ class ModulesObserverConfig {
12
12
  EXTRA_BROWSEREVENTS_POINTER_EVENT: 'extra.browserEvents.window.pointer.event',
13
13
  EXTRA_BROWSEREVENTS_WINDOW_PRE_RESIZE: 'extra.browserEvents.window.pre.resize',
14
14
  EXTRA_BROWSEREVENTS_WINDOW_RESIZE: 'extra.browserEvents.window.resize',
15
+ EXTRA_BROWSEREVENTS_PARENT_RESIZE: 'extra.browserEvents.parent.resize',
15
16
  EXTRA_BROWSEREVENTS_WINDOW_VISIBILITYCHANGE: 'extra.browserEvents.window.visibilitychange',
16
17
  MODULES_ASSETS_GROUP_LOADED: 'modules.assets.group.loaded',
17
18
  MODULES_ASSETS_LOAD_PROGRESS: 'modules.assets.load.progress',
@@ -34,8 +34,31 @@ class ModulesScenesPixiWrapper {
34
34
 
35
35
  //define renderer
36
36
  PIXI.utils.skipHello();
37
- this._renderer = new PIXI.Renderer({ preserveDrawingBuffer: true, width: 1, height: 1 });
38
- document.body.appendChild(this._renderer.view);
37
+ const app = new PIXI.Application();
38
+ this.ticker = app.ticker;
39
+ this.ticker.autoStart = false;
40
+ this.ticker.stop();
41
+
42
+ //this._renderer = new PIXI.Renderer({ preserveDrawingBuffer: true, width: 1, height: 1 });
43
+ //document.body.appendChild(this._renderer.view);
44
+ this._renderer = app.renderer;
45
+ let parentContainer = document.body;
46
+
47
+ if (Urso.config.domParentSelector) {
48
+ const container = document.querySelector(Urso.config.domParentSelector);
49
+
50
+ if (container) {
51
+ parentContainer = container;
52
+ } else {
53
+ Urso.logger.warn(`No element found for domParentSelector: ${Urso.config.domParentSelector}`);
54
+ Urso.logger.warn(`waitForDomElement...`);
55
+ Urso.helper.waitForDomElement(Urso.config.domParentSelector).then(() => {
56
+ parentContainer.appendChild(this._renderer.view);
57
+ });
58
+ }
59
+ }
60
+
61
+ parentContainer.appendChild(this._renderer.view);
39
62
 
40
63
  //root and world
41
64
  this._root = new PIXI.Container();
@@ -286,6 +309,8 @@ class ModulesScenesPixiWrapper {
286
309
 
287
310
  this.currentScene.update(deltaTime);
288
311
  this.currentScene.render();
312
+ //this._renderer.render(this._root);
313
+ this.ticker.update(deltaTime);
289
314
  this._renderer.render(this._root);
290
315
  };
291
316
 
@@ -10,6 +10,9 @@ class ModulesScenesResolutions {
10
10
  this.preResize = this.preResize.bind(this);
11
11
  this.refreshSceneSize();
12
12
 
13
+ this._customDomElementlatestWidth = 0;
14
+ this._customDomElementlatestHeight = 0;
15
+
13
16
  //TODO optimization (performance)
14
17
  /*if (devicePixelRatio > 2)
15
18
  devicePixelRatio = 2;*/ // when we are calculating canvas size
@@ -18,7 +21,52 @@ class ModulesScenesResolutions {
18
21
  _subscribeOnce() {
19
22
  this.addListener(Urso.events.EXTRA_BROWSEREVENTS_WINDOW_PRE_RESIZE, this.preResize, true);
20
23
  this.addListener(Urso.events.EXTRA_BROWSEREVENTS_WINDOW_RESIZE, this.refreshSceneSize, true);
24
+ this.addListener(Urso.events.EXTRA_BROWSEREVENTS_PARENT_RESIZE, this.refreshSceneSize, true);
21
25
  this.addListener(Urso.events.MODULES_SCENES_NEW_SCENE_INIT, this.refreshSceneSize, true);
26
+
27
+ if (Urso.config.domParentSelector) { this._observeCustomDomElementResize(); }
28
+ }
29
+
30
+ _observeCustomDomElementResize() {
31
+ const container = document.querySelector(Urso.config.domParentSelector);
32
+
33
+ if (!container) {
34
+ Urso.logger.warn(`No element found for domParentSelector: ${Urso.config.domParentSelector}`);
35
+ Urso.logger.warn(`waitForDomElement...`);
36
+ Urso.helper.waitForDomElement(Urso.config.domParentSelector).then(() => {
37
+ this._observeCustomDomElementResize();
38
+ });
39
+ return;
40
+ }
41
+
42
+ const ro = new ResizeObserver((entries) => {
43
+ for (const entry of entries) {
44
+ if (entry.target.resizeHandler) {
45
+ entry.target.resizeHandler(entry.target.clientHeight, entry.target.clientWidth);
46
+ }
47
+ }
48
+ });
49
+
50
+ container.resizeHandler = this._customDomElementResizeHandler.bind(this);
51
+ ro.observe(container);
52
+ }
53
+
54
+ _customDomElementResizeHandler(newHeight, newWidth) {
55
+ let needResize = false;
56
+
57
+ if (this._customDomElementlatestWidth !== newWidth) {
58
+ this._customDomElementlatestWidth = newWidth;
59
+ needResize = true;
60
+ }
61
+
62
+ if (this._customDomElementlatestHeight !== newHeight) {
63
+ this._customDomElementlatestHeight = newHeight;
64
+ needResize = true;
65
+ }
66
+
67
+ if (needResize) {
68
+ this.emit(Urso.events.EXTRA_BROWSEREVENTS_PARENT_RESIZE);
69
+ }
22
70
  }
23
71
 
24
72
  getTemplateSize() {
@@ -73,6 +121,17 @@ class ModulesScenesResolutions {
73
121
  height: window.innerHeight
74
122
  };
75
123
 
124
+ if (Urso.config.domParentSelector) {
125
+ const container = document.querySelector(Urso.config.domParentSelector);
126
+
127
+ if (container) {
128
+ windowSize = {
129
+ width: container.offsetWidth,
130
+ height: container.offsetHeight
131
+ };
132
+ }
133
+ }
134
+
76
135
  if (window.devicePixelRatio && window.devicePixelRatio !== 1) {
77
136
  windowSize.width *= window.devicePixelRatio;
78
137
  windowSize.height *= window.devicePixelRatio;
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_urso_core=self.webpackChunk_urso_core||[]).push([[162],{88058:(d,a,r)=>{var O=r(8507),X=r(36697),e=r(46719);O.XO.add(X.U),O.XO.add(e.y)},42162:(d,a,r)=>{r.r(a),r(88058),r(26197),r(17801),r(25361),r(28849),r(28299),r(15311),r(4241),r(11981),r(51437),r(95902)},95902:(d,a,r)=>{var O=r(8507),X=r(69430),e=r(90825);O.XO.add(e.u),O.XO.add(X.L)},25361:(d,a,r)=>{var O=r(8507),X=r(40378),e=r(49260);O.XO.add(e.S),O.XO.add(X.GH)},28849:(d,a,r)=>{var O=r(8507),X=r(41892);O.XO.add(X.G)},51437:(d,a,r)=>{var O=r(8507),X=r(56880);O.XO.add(X.e)},11981:(d,a,r)=>{var O=r(8507),X=r(75773);O.XO.add(X.x)},15311:(d,a,r)=>{var O=r(8507),X=r(70661);O.XO.add(X.n)},4241:(d,a,r)=>{var O=r(8507),X=r(76829),e=r(47602);O.XO.add(e.Q),O.XO.add(X.n)},28299:(d,a,r)=>{var O=r(8507),X=r(45369),e=r(87278);O.XO.add(e.p),O.XO.add(X.e)}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_urso_core=self.webpackChunk_urso_core||[]).push([[24],{88058:(d,a,r)=>{var O=r(8507),X=r(36697),v=r(46719);O.XO.add(X.U),O.XO.add(v.y)},22024:(d,a,r)=>{r.r(a);var O=r(8507),X=r(44980),v=r(83946),e=r(74302);O.XO.add(v.a),X.mc.mixin(e.K),r(88058);var c=r(60809),s=r(90317);O.XO.add(c.C),X.mc.mixin(s.e),r(26197),r(17801),r(25361),r(28849),r(28299),r(15311),r(4241),r(11981),r(51437),r(95902)},95902:(d,a,r)=>{var O=r(8507),X=r(69430),v=r(90825);O.XO.add(v.u),O.XO.add(X.L)},25361:(d,a,r)=>{var O=r(8507),X=r(40378),v=r(49260);O.XO.add(v.S),O.XO.add(X.GH)},28849:(d,a,r)=>{var O=r(8507),X=r(41892);O.XO.add(X.G)},51437:(d,a,r)=>{var O=r(8507),X=r(56880);O.XO.add(X.e)},11981:(d,a,r)=>{var O=r(8507),X=r(75773);O.XO.add(X.x)},15311:(d,a,r)=>{var O=r(8507),X=r(70661);O.XO.add(X.n)},4241:(d,a,r)=>{var O=r(8507),X=r(76829),v=r(47602);O.XO.add(v.Q),O.XO.add(X.n)},28299:(d,a,r)=>{var O=r(8507),X=r(45369),v=r(87278);O.XO.add(v.p),O.XO.add(X.e)}}]);