@sepveneto/dao 0.1.5 → 0.1.6

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/dist/dao.js CHANGED
@@ -65,7 +65,7 @@ var Matrix = class n {
65
65
  j == null ? this.x = this.y = n : (this.x = n, this.y = j);
66
66
  }
67
67
  copyFrom(n) {
68
- this.set(n.x, n.y);
68
+ return this.set(n.x, n.y), this;
69
69
  }
70
70
  };
71
71
  function nextPow2(n) {
@@ -73,7 +73,7 @@ function nextPow2(n) {
73
73
  }
74
74
  var FederatedEvent = class {
75
75
  constructor(n) {
76
- this.system = n;
76
+ this.global = new Vector2(), this.screen = new Vector2(), this.system = n;
77
77
  }
78
78
  getLocalPosition(n, j) {
79
79
  return n.worldTransform.applyInverse(j || this.global);
@@ -83,7 +83,10 @@ var FederatedEvent = class {
83
83
  }
84
84
  }, _EventSystem, PROPAGATION_LIMIT = 2048, EventSystem = class {
85
85
  constructor(n) {
86
- this.domElement = null, this.rootTarget = null, this.resolution = 1, this._allInteractiveElements = [], this._hitElements = [], this._isPointerMoveEvent = !1, this.mappingState = { trackingData: {} }, this.renderer = n, this.resolution = n.resolution, this._onPointerDown = this._onPointerDown.bind(this), this._onPointerMove = this._onPointerMove.bind(this), this._onPointerUp = this._onPointerUp.bind(this), this._onPointerOverOut = this._onPointerOverOut.bind(this), this.init();
86
+ this.domElement = null, this.rootTarget = null, this.resolution = 1, this._allInteractiveElements = [], this._hitElements = [], this._isPointerMoveEvent = !1, this.mappingState = { trackingData: {} }, this.renderer = n, this.resolution = n.resolution, this._rootPointerEvent = new FederatedEvent(null), this._onPointerDown = this._onPointerDown.bind(this), this._onPointerMove = this._onPointerMove.bind(this), this._onPointerUp = this._onPointerUp.bind(this), this._onPointerOverOut = this._onPointerOverOut.bind(this), this.init();
87
+ }
88
+ get pointer() {
89
+ return this._rootPointerEvent;
87
90
  }
88
91
  trackingData(n) {
89
92
  return this.mappingState.trackingData[n] || (this.mappingState.trackingData[n] = {
@@ -136,76 +139,77 @@ var FederatedEvent = class {
136
139
  var j;
137
140
  if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
138
141
  this._isPointerMoveEvent = !0, this._allInteractiveElements.length = 0, this._hitElements.length = 0;
139
- let M = this.createPointEvent(n);
142
+ let M = this._bootstrapEvent(this._rootPointerEvent, n), N = this.createPointEvent(M);
140
143
  this._isPointerMoveEvent = !1;
141
- let N = this.trackingData(n.pointerId), P = findMountedTarget(N.overTargets);
142
- if (((j = N.overTargets) == null ? void 0 : j.length) > 0 && P !== M.target) {
143
- let j = this.createPointEvent(n, "pointerout", P);
144
- this.dispatchEvent(j, "pointerout");
145
- let N = M.composedPath();
146
- if (!N.includes(P)) {
147
- let j = this.createPointEvent(n, "pointerleave", P);
148
- for (; j.target && !N.includes(j.target);) j.currentTarget = j.target, this._notifyTarget(j), j.target = j.target.parent;
144
+ let P = this.trackingData(n.pointerId), F = findMountedTarget(P.overTargets);
145
+ if (((j = P.overTargets) == null ? void 0 : j.length) > 0 && F !== N.target) {
146
+ let n = this.createPointEvent(M, "pointerout", F);
147
+ this.dispatchEvent(n, "pointerout");
148
+ let j = N.composedPath();
149
+ if (!j.includes(F)) {
150
+ let n = this.createPointEvent(M, "pointerleave", F);
151
+ for (; n.target && !j.includes(n.target);) n.currentTarget = n.target, this._notifyTarget(n), n.target = n.target.parent;
149
152
  }
150
153
  }
151
- if (P !== M.target) {
152
- let n = "pointerover", j = this.clonePointEvent(M, n);
154
+ if (F !== N.target) {
155
+ let n = "pointerover", j = this.clonePointEvent(N, n);
153
156
  this.dispatchEvent(j, n);
154
- let N = P == null ? void 0 : P.parent;
155
- for (; N && N !== this.rootTarget.parent && N !== M.target;) N = N.parent;
156
- if (!N || N === this.rootTarget.parent) {
157
- let n = this.clonePointEvent(M, "pointerenter");
158
- for (; n.target && n.target !== P && n.target !== this.rootTarget.parent;) n.currentTarget = n.target, this._notifyTarget(n), n.target = n.target.parent;
157
+ let M = F == null ? void 0 : F.parent;
158
+ for (; M && M !== this.rootTarget.parent && M !== N.target;) M = M.parent;
159
+ if (!M || M === this.rootTarget.parent) {
160
+ let n = this.clonePointEvent(N, "pointerenter");
161
+ for (; n.target && n.target !== F && n.target !== this.rootTarget.parent;) n.currentTarget = n.target, this._notifyTarget(n), n.target = n.target.parent;
159
162
  }
160
163
  }
161
- this.dispatchEvent(M, "pointermove");
162
- let F = this._allInteractiveElements;
163
- for (let n = F.length - 1; n >= 0; --n) M.currentTarget = F[n], this._notifyTarget(M, "globalpointermove");
164
- this._allInteractiveElements.length = 0, this._hitElements.length = 0, N.overTargets = M.composedPath();
164
+ this.dispatchEvent(N, "pointermove");
165
+ let I = this._allInteractiveElements;
166
+ for (let n = I.length - 1; n >= 0; --n) N.currentTarget = I[n], this._notifyTarget(N, "globalpointermove");
167
+ this._allInteractiveElements.length = 0, this._hitElements.length = 0, P.overTargets = N.composedPath();
165
168
  }
166
169
  _onPointerDown(n) {
167
170
  if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
168
- let j = this.createPointEvent(n);
169
- this.dispatchEvent(j, "pointerdown");
170
- let M = this.trackingData(n.pointerId);
171
- M.pressTargetsByButton[n.button] = j.composedPath();
171
+ let j = this._bootstrapEvent(this._rootPointerEvent, n), M = this.createPointEvent(j);
172
+ this.dispatchEvent(M, "pointerdown");
173
+ let N = this.trackingData(n.pointerId);
174
+ N.pressTargetsByButton[n.button] = M.composedPath();
172
175
  }
173
176
  _onPointerOverOut(n) {
174
177
  if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
175
- let j = this.createPointEvent(n);
176
- this.dispatchEvent(j, "pointerout");
178
+ let j = this._bootstrapEvent(this._rootPointerEvent, n), M = this.createPointEvent(j);
179
+ this.dispatchEvent(M, "pointerout");
177
180
  }
178
181
  _onPointerUp(n) {
179
182
  if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
180
183
  let j = n.target;
181
184
  n.composedPath && n.composedPath().length > 1 && (j = n.composedPath()[0]);
182
- let M = j === this.domElement ? "" : "outside", N = this.createPointEvent(n);
183
- this.dispatchEvent(N, `pointerup${M}`);
185
+ let M = this._bootstrapEvent(this._rootPointerEvent, n), N = j === this.domElement ? "" : "outside", P = this.createPointEvent(M);
186
+ this.dispatchEvent(P, `pointerup${N}`);
184
187
  }
185
188
  _isInteractive(n) {
186
189
  return n === "static";
187
190
  }
191
+ _bootstrapEvent(n, j) {
192
+ return n.nativeEvent = j, this.mapPositionToPoint(n.screen, j.clientX, j.clientY), n.global.copyFrom(n.screen), j.type === "pointerleave" ? n.type = "pointerout" : n.type = j.type, n;
193
+ }
188
194
  createPointEvent(n, j, M) {
189
195
  var N;
190
- let P = this.mapPositionToPoint(n.clientX, n.clientY);
191
- n.type === "pointerleave" && (j = "pointerout");
192
- let F = new FederatedEvent(this);
193
- return F.type = j, F.nativeEvent = n, F.target = (N = M == null ? this.hitTest(P.x, P.y) : M) == null ? this._hitElements[0] : N, F.global = P, F;
196
+ let P = new FederatedEvent(this);
197
+ return P.global.copyFrom(n.global), P.screen.copyFrom(n.screen), P.nativeEvent = n.nativeEvent, P.target = (N = M == null ? this.hitTest(P.global.x, P.global.y) : M) == null ? this._hitElements[0] : N, j && (P.type = j), P;
194
198
  }
195
199
  clonePointEvent(n, j) {
196
200
  let M = new FederatedEvent(this);
197
201
  return M.nativeEvent = n.nativeEvent, M.global = n.global, M.type = j == null ? n.type : j, M.path = n.composedPath().slice(), M.target = n.target, M;
198
202
  }
199
- mapPositionToPoint(n, j) {
200
- let M = this.domElement, N = M.isConnected ? M.getBoundingClientRect() : {
203
+ mapPositionToPoint(n, j, M) {
204
+ let N = this.domElement, P = N.isConnected ? N.getBoundingClientRect() : {
201
205
  x: 0,
202
206
  y: 0,
203
- width: M.width,
204
- height: M.height,
207
+ width: N.width,
208
+ height: N.height,
205
209
  left: 0,
206
210
  top: 0
207
- }, P = 1 / this.resolution, F = new Vector2();
208
- return F.x = (n - N.left) * (M.width / N.width) * P, F.y = (j - N.top) * (M.height / N.height) * P, F;
211
+ }, F = 1 / this.resolution;
212
+ return n.x = (j - P.left) * (N.width / P.width) * F, n.y = (M - P.top) * (N.height / P.height) * F, n;
209
213
  }
210
214
  hitTest(n, j) {
211
215
  let M = this._isPointerMoveEvent, N = this[M ? "hitTestMoveRecursive" : "hitTestRecursive"](this.rootTarget, this.rootTarget.eventMode, new Vector2(n, j));
@@ -1298,7 +1302,12 @@ function toStrokeStyle(n, j) {
1298
1302
  }
1299
1303
  var Graphics = class extends ViewContainer {
1300
1304
  constructor(n) {
1301
- super(), this.renderPipeId = "graphics", n instanceof GraphicsContext ? this.context = n : this.context = new GraphicsContext();
1305
+ n instanceof GraphicsContext && (n = { context: n });
1306
+ let { context: j, ...M } = n || {};
1307
+ super({
1308
+ label: "Graphics",
1309
+ ...M
1310
+ }), this.renderPipeId = "graphics", j ? this.context = j : this.context = new GraphicsContext();
1302
1311
  }
1303
1312
  setStrokeStyle(...n) {
1304
1313
  return this._callContextMethod("setStrokeStyle", n);
@@ -2447,6 +2456,6 @@ var AssetsClass = class {
2447
2456
  }
2448
2457
  };
2449
2458
  const Assets = new AssetsClass();
2450
- export { Application, Assets, AssetsClass, CanvasRenderer, Container, Graphics, GraphicsContext, GraphicsPipe, Matrix, PI_2, Rectangle, RenderGroup, Sprite, Text, TextPipe, Texture, Ticker, TickerListener, UPDATE_BLEND, UPDATE_COLOR, UPDATE_TRANSFORM, UPDATE_VISIBLE, Vector2, ViewContainer, buildShapePath, nextPow2 };
2459
+ export { Application, Assets, AssetsClass, CanvasRenderer, Container, Graphics, GraphicsContext, GraphicsPipe, Matrix, PI_2, Rectangle, RenderGroup, RenderTexture, Sprite, Text, TextPipe, Texture, Ticker, TickerListener, UPDATE_BLEND, UPDATE_COLOR, UPDATE_TRANSFORM, UPDATE_VISIBLE, Vector2, ViewContainer, buildShapePath, nextPow2 };
2451
2460
 
2452
2461
  //# sourceMappingURL=dao.js.map