@predy-js/render-interface 0.3.4-beta.15 → 0.3.4-beta.16

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/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Name: @predy-js/render-interface
3
3
  * Description: undefined
4
4
  * Author: undefined
5
- * Version: v0.3.4-beta.15
5
+ * Version: v0.3.4-beta.16
6
6
  */
7
7
 
8
8
  'use strict';
@@ -197,6 +197,12 @@ var EVENT_TYPE_TOUCH_START = 'touchstart';
197
197
  var EVENT_TYPE_TOUCH_MOVE = 'touchmove';
198
198
  var EVENT_TYPE_TOUCH_END = 'touchend';
199
199
  var EVENT_TYPE_TOUCH_CANCEL = 'touchcancel';
200
+ exports.PredyNativeEventType = void 0;
201
+ (function (PredyNativeEventType) {
202
+ PredyNativeEventType[PredyNativeEventType["touchstart"] = 1] = "touchstart";
203
+ PredyNativeEventType[PredyNativeEventType["touchmove"] = 2] = "touchmove";
204
+ PredyNativeEventType[PredyNativeEventType["touchend"] = 3] = "touchend";
205
+ })(exports.PredyNativeEventType || (exports.PredyNativeEventType = {}));
200
206
  // // 扩展事件类型
201
207
  // export enum EVENT_TYPE {
202
208
  // // 基础事件
@@ -6039,15 +6045,17 @@ var WebHandler = /** @class */ (function () {
6039
6045
  };
6040
6046
  WebHandler.prototype.handleEvent = function (type, e) {
6041
6047
  e.preventDefault();
6042
- var np = this.getNormalizedPos(e);
6048
+ // const np = this.getNormalizedPos(e);
6049
+ var rect = e.target.getBoundingClientRect();
6043
6050
  var pointer = {
6044
6051
  id: e.pointerId,
6045
- x: np[0],
6046
- y: np[1],
6047
- clientX: e.clientX,
6048
- clientY: e.clientY,
6049
- force: 1,
6052
+ x: e.clientX - rect.left,
6053
+ y: e.clientY - rect.top,
6050
6054
  ts: this.timeStamp,
6055
+ layout: {
6056
+ width: rect.width,
6057
+ height: rect.height,
6058
+ },
6051
6059
  };
6052
6060
  // 更新触点集合
6053
6061
  if (type === EVENT_TYPE_TOUCH_END) {
@@ -6074,7 +6082,12 @@ var WebHandler = /** @class */ (function () {
6074
6082
 
6075
6083
  var RNHandler = /** @class */ (function () {
6076
6084
  function RNHandler(system) {
6085
+ var _this = this;
6077
6086
  this.system = system;
6087
+ this.handleTouch = function (e) {
6088
+ e.preventDefault();
6089
+ _this.system.handleBaseEvent(e);
6090
+ };
6078
6091
  this.timeOrigin = Date.now();
6079
6092
  }
6080
6093
  Object.defineProperty(RNHandler.prototype, "timeStamp", {
@@ -6085,10 +6098,16 @@ var RNHandler = /** @class */ (function () {
6085
6098
  configurable: true
6086
6099
  });
6087
6100
  RNHandler.prototype.setup = function () {
6088
- throw new Error('Method not implemented.');
6101
+ var target = this.system.target;
6102
+ target.addEventListener('touchstart', this.handleTouch);
6103
+ target.addEventListener('touchmove', this.handleTouch);
6104
+ target.addEventListener('touchend', this.handleTouch);
6089
6105
  };
6090
6106
  RNHandler.prototype.teardown = function () {
6091
- throw new Error('Method not implemented.');
6107
+ var target = this.system.target;
6108
+ target.removeEventListener('touchstart', this.handleTouch);
6109
+ target.removeEventListener('touchmove', this.handleTouch);
6110
+ target.removeEventListener('touchend', this.handleTouch);
6092
6111
  };
6093
6112
  return RNHandler;
6094
6113
  }());
@@ -6103,7 +6122,7 @@ var H5Handler = /** @class */ (function () {
6103
6122
  var event = {
6104
6123
  type: type,
6105
6124
  timestamp: _this.timeStamp,
6106
- target: e.target,
6125
+ // target: e.target,
6107
6126
  touches: _this.encapsulate(e.targetTouches),
6108
6127
  changedTouches: _this.encapsulate(e.changedTouches),
6109
6128
  preventDefault: function () { return e.preventDefault(); },
@@ -6149,15 +6168,17 @@ var H5Handler = /** @class */ (function () {
6149
6168
  var touches = [];
6150
6169
  for (var i = 0; i < list.length; i++) {
6151
6170
  var touch = list[i];
6152
- var _a = this.getNormalizedPos(touch), x = _a[0], y = _a[1];
6171
+ // const [x, y] = this.getNormalizedPos(touch);
6172
+ var rect = touch.target.getBoundingClientRect();
6153
6173
  touches.push({
6154
6174
  id: touch.identifier,
6155
- x: x,
6156
- y: y,
6157
- clientX: touch.clientX,
6158
- clientY: touch.clientY,
6159
- force: 1,
6175
+ x: touch.clientX - rect.left,
6176
+ y: touch.clientY - rect.top,
6160
6177
  ts: this.timeStamp,
6178
+ layout: {
6179
+ width: rect.width,
6180
+ height: rect.height,
6181
+ },
6161
6182
  });
6162
6183
  }
6163
6184
  return touches;
@@ -6215,7 +6236,7 @@ var UniversalRecognizer = /** @class */ (function () {
6215
6236
  this.gestureStartTime = event.timestamp;
6216
6237
  this.trackedTouches.clear();
6217
6238
  event.touches.forEach(function (t) { return _this.trackedTouches.set(t.id, t); });
6218
- this.startPositions = event.touches.map(function (t) { return [t.clientX, t.clientY]; });
6239
+ this.startPositions = event.touches.map(function (t) { return [t.x, t.y]; });
6219
6240
  // 初始化多指手势数据
6220
6241
  if (this.options.touchCount > 1) {
6221
6242
  this.initialCenter = this.calculateCenter(event.touches);
@@ -6335,8 +6356,8 @@ var UniversalRecognizer = /** @class */ (function () {
6335
6356
  // 计算多点触控的平均移动量
6336
6357
  var totalDelta = [0, 0];
6337
6358
  event.touches.forEach(function (t, idx) {
6338
- totalDelta[0] += t.clientX - _this.startPositions[idx][0];
6339
- totalDelta[1] += t.clientY - _this.startPositions[idx][1];
6359
+ totalDelta[0] += t.x - _this.startPositions[idx][0];
6360
+ totalDelta[1] += t.y - _this.startPositions[idx][1];
6340
6361
  });
6341
6362
  return [totalDelta[0] / event.touches.length, totalDelta[1] / event.touches.length];
6342
6363
  };
@@ -6348,7 +6369,7 @@ var UniversalRecognizer = /** @class */ (function () {
6348
6369
  var currentCentroid = this.calculateCenter(touches);
6349
6370
  // 计算所有触点到中心点的平均距离
6350
6371
  var currentDistances = touches.map(function (t) {
6351
- return Math.hypot(t.clientX - currentCentroid[0], t.clientY - currentCentroid[1]);
6372
+ return Math.hypot(t.x - currentCentroid[0], t.y - currentCentroid[1]);
6352
6373
  });
6353
6374
  var currentAvgDistance = currentDistances.reduce(function (a, b) { return a + b; }) / touches.length;
6354
6375
  // 初始平均距离(从startPositions计算)
@@ -6367,7 +6388,7 @@ var UniversalRecognizer = /** @class */ (function () {
6367
6388
  var totalAngleChange = 0;
6368
6389
  touches.forEach(function (t, index) {
6369
6390
  // 当前触点角度
6370
- var currentAngle = Math.atan2(t.clientY - currentCentroid[1], t.clientX - currentCentroid[0]);
6391
+ var currentAngle = Math.atan2(t.y - currentCentroid[1], t.x - currentCentroid[0]);
6371
6392
  // 初始触点角度
6372
6393
  var initialPos = _this.startPositions[index];
6373
6394
  var initialAngle = Math.atan2(initialPos[1] - _this.initialCenter[1], initialPos[0] - _this.initialCenter[0]);
@@ -6388,14 +6409,14 @@ var UniversalRecognizer = /** @class */ (function () {
6388
6409
  UniversalRecognizer.prototype.calculateCenter = function (touchList) {
6389
6410
  var pointersLength = touchList.length;
6390
6411
  if (pointersLength === 1) {
6391
- return [touchList[0].clientX, touchList[0].clientY];
6412
+ return [touchList[0].x, touchList[0].y];
6392
6413
  }
6393
6414
  var x = 0;
6394
6415
  var y = 0;
6395
6416
  var i = 0;
6396
6417
  while (i < pointersLength) {
6397
- x += touchList[i].clientX;
6398
- y += touchList[i].clientY;
6418
+ x += touchList[i].x;
6419
+ y += touchList[i].y;
6399
6420
  i++;
6400
6421
  }
6401
6422
  return [x / pointersLength, y / pointersLength];
@@ -6579,7 +6600,7 @@ var BaseRecognizer = /** @class */ (function () {
6579
6600
  return BaseRecognizer;
6580
6601
  }());
6581
6602
 
6582
- consoleLog('version: ' + "0.3.4-beta.15");
6603
+ consoleLog('version: ' + "0.3.4-beta.16");
6583
6604
  var ModuleMsg = 'RI Package: @predy-js/render-interface';
6584
6605
 
6585
6606
  var RI = /*#__PURE__*/Object.freeze({
@@ -6622,6 +6643,7 @@ var RI = /*#__PURE__*/Object.freeze({
6622
6643
  EVENT_TYPE_TOUCH_MOVE: EVENT_TYPE_TOUCH_MOVE,
6623
6644
  EVENT_TYPE_TOUCH_END: EVENT_TYPE_TOUCH_END,
6624
6645
  EVENT_TYPE_TOUCH_CANCEL: EVENT_TYPE_TOUCH_CANCEL,
6646
+ get PredyNativeEventType () { return exports.PredyNativeEventType; },
6625
6647
  get GESTURE_DIRECTION () { return exports.GESTURE_DIRECTION; },
6626
6648
  get ShaderCompileResultStatus () { return exports.ShaderCompileResultStatus; },
6627
6649
  ShaderLibraryEmpty: ShaderLibraryEmpty