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

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.mjs 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.13
5
+ * Version: v0.3.4-beta.15
6
6
  */
7
7
 
8
8
  /******************************************************************************
@@ -6161,86 +6161,6 @@ var H5Handler = /** @class */ (function () {
6161
6161
  return H5Handler;
6162
6162
  }());
6163
6163
 
6164
- var PredyEventSystem = /** @class */ (function () {
6165
- function PredyEventSystem(target, env) {
6166
- this._handlerMap = new Map();
6167
- this._enabled = true;
6168
- this.target = target;
6169
- this._platformHandler = this.createPlatformHandler(env);
6170
- this._platformHandler.setup();
6171
- this.setRecognizer(new BaseRecognizer());
6172
- }
6173
- Object.defineProperty(PredyEventSystem.prototype, "enabled", {
6174
- get: function () {
6175
- return this._enabled;
6176
- },
6177
- set: function (value) {
6178
- this._enabled = value;
6179
- },
6180
- enumerable: false,
6181
- configurable: true
6182
- });
6183
- PredyEventSystem.prototype.createPlatformHandler = function (env) {
6184
- switch (env) {
6185
- case EventSystemEnv.web:
6186
- return new WebHandler(this);
6187
- case EventSystemEnv.rn:
6188
- return new RNHandler(this);
6189
- case EventSystemEnv.h5:
6190
- return new H5Handler(this);
6191
- default:
6192
- throw new Error("Unsupported platform ".concat(env));
6193
- }
6194
- };
6195
- PredyEventSystem.prototype.setRecognizer = function (recognizer) {
6196
- recognizer._callback = this.dispatch.bind(this);
6197
- this.recognizer = recognizer;
6198
- };
6199
- // 事件分发入口
6200
- PredyEventSystem.prototype.handleBaseEvent = function (event) {
6201
- if (!this.enabled) {
6202
- return;
6203
- }
6204
- // 识别手势
6205
- var gestureType = this.recognizer.detect(event);
6206
- if (gestureType) {
6207
- this.dispatch(gestureType, event);
6208
- }
6209
- if (event.touches.length === 0) {
6210
- this.recognizer.reset();
6211
- }
6212
- };
6213
- PredyEventSystem.prototype.dispatch = function (type, event) {
6214
- var _a;
6215
- (_a = this._handlerMap.get(type)) === null || _a === void 0 ? void 0 : _a.forEach(function (fn) { return fn(event); });
6216
- };
6217
- PredyEventSystem.prototype.addEventListener = function (type, handler) {
6218
- var _this = this;
6219
- var set = this._handlerMap.get(type) || new Set();
6220
- set.add(handler);
6221
- this._handlerMap.set(type, set);
6222
- return function () { return _this.removeEventListener(type, handler); };
6223
- };
6224
- PredyEventSystem.prototype.removeEventListener = function (type, handler) {
6225
- var _a;
6226
- (_a = this._handlerMap.get(type)) === null || _a === void 0 ? void 0 : _a.delete(handler);
6227
- };
6228
- PredyEventSystem.prototype.destroy = function () {
6229
- this._platformHandler.teardown();
6230
- this._handlerMap.clear();
6231
- };
6232
- return PredyEventSystem;
6233
- }());
6234
- var BaseRecognizer = /** @class */ (function () {
6235
- function BaseRecognizer() {
6236
- }
6237
- BaseRecognizer.prototype.detect = function (event) {
6238
- return event.type;
6239
- };
6240
- BaseRecognizer.prototype.reset = function () { };
6241
- return BaseRecognizer;
6242
- }());
6243
-
6244
6164
  var UniversalRecognizer = /** @class */ (function () {
6245
6165
  function UniversalRecognizer(options) {
6246
6166
  this._state = RecognizerState.UNDETERMINED;
@@ -6303,16 +6223,26 @@ var UniversalRecognizer = /** @class */ (function () {
6303
6223
  if (![RecognizerState.BEGAN, RecognizerState.ACTIVE].includes(this.state)) {
6304
6224
  return;
6305
6225
  }
6306
- // 验证触点数量一致性
6307
- if (event.touches.length !== this.options.touchCount) {
6226
+ // 验证触点数量
6227
+ if (!this.validateTouchCount(event)) {
6308
6228
  this.reset();
6309
6229
  return;
6310
6230
  }
6311
- // 核心验证逻辑
6312
- if (!this.validateGesture(event)) {
6231
+ // 验证时间区间
6232
+ if (!this.validateDuration(event)) {
6313
6233
  this.handleFailure();
6314
6234
  return;
6315
6235
  }
6236
+ // 验证距离区间
6237
+ if (!this.validateDistance(event)) {
6238
+ return;
6239
+ }
6240
+ // 方向/路径验证
6241
+ if (this.options.direction !== undefined) {
6242
+ if (!this.validateDirection(event)) {
6243
+ return;
6244
+ }
6245
+ }
6316
6246
  // 更新状态为持续活动
6317
6247
  if (this.state === RecognizerState.BEGAN) {
6318
6248
  this.setState(RecognizerState.ACTIVE);
@@ -6324,9 +6254,8 @@ var UniversalRecognizer = /** @class */ (function () {
6324
6254
  if (![RecognizerState.BEGAN, RecognizerState.ACTIVE].includes(this.state)) {
6325
6255
  return;
6326
6256
  }
6327
- // 最终验证(例如点击的持续时间)
6328
- var isValid = this.validateFinalConditions(event);
6329
- if (isValid) {
6257
+ // 最终验证
6258
+ if (this.validateDuration(event)) {
6330
6259
  this.setState(RecognizerState.END);
6331
6260
  if (this.validateThreshold(event)) {
6332
6261
  this.trigger(event);
@@ -6340,26 +6269,6 @@ var UniversalRecognizer = /** @class */ (function () {
6340
6269
  /**
6341
6270
  * 手势识别核心算法
6342
6271
  */
6343
- UniversalRecognizer.prototype.validateGesture = function (event) {
6344
- // 基础验证
6345
- if (!this.validateTouchCount(event)) {
6346
- return false;
6347
- }
6348
- if (!this.validateDuration(event)) {
6349
- return false;
6350
- }
6351
- if (!this.validateDistance(event)) {
6352
- return false;
6353
- }
6354
- // 方向/路径验证
6355
- if (this.options.direction !== undefined) {
6356
- if (!this.validateDirection(event)) {
6357
- return false;
6358
- }
6359
- }
6360
- // 高级手势验证
6361
- return true;
6362
- };
6363
6272
  UniversalRecognizer.prototype.validateTouchCount = function (event) {
6364
6273
  return event.touches.length === this.options.touchCount;
6365
6274
  };
@@ -6417,19 +6326,6 @@ var UniversalRecognizer = /** @class */ (function () {
6417
6326
  return true;
6418
6327
  }
6419
6328
  };
6420
- UniversalRecognizer.prototype.validateFinalConditions = function (event) {
6421
- // 验证时间区间
6422
- var duration = event.timestamp - this.gestureStartTime;
6423
- if (this.options.minDuration && duration < this.options.minDuration) {
6424
- return false;
6425
- }
6426
- if (this.options.maxDuration && duration > this.options.maxDuration) {
6427
- return false;
6428
- }
6429
- // 验证点击次数(需要外部状态管理)
6430
- // 此处需要结合外部计数器实现双击等逻辑
6431
- return true;
6432
- };
6433
6329
  UniversalRecognizer.prototype.calculateOverallDelta = function (event) {
6434
6330
  var _this = this;
6435
6331
  // 计算多点触控的平均移动量
@@ -6595,7 +6491,91 @@ var UniversalRecognizer = /** @class */ (function () {
6595
6491
  return UniversalRecognizer;
6596
6492
  }());
6597
6493
 
6598
- consoleLog('version: ' + "0.3.4-beta.13");
6494
+ var PredyEventSystem = /** @class */ (function () {
6495
+ function PredyEventSystem(target, env) {
6496
+ this._handlerMap = new Map();
6497
+ this._enabled = true;
6498
+ this.target = target;
6499
+ this._platformHandler = this.createPlatformHandler(env);
6500
+ this._platformHandler.setup();
6501
+ this.setRecognizer(new BaseRecognizer());
6502
+ }
6503
+ Object.defineProperty(PredyEventSystem.prototype, "enabled", {
6504
+ get: function () {
6505
+ return this._enabled;
6506
+ },
6507
+ set: function (value) {
6508
+ this._enabled = value;
6509
+ },
6510
+ enumerable: false,
6511
+ configurable: true
6512
+ });
6513
+ PredyEventSystem.prototype.createPlatformHandler = function (env) {
6514
+ switch (env) {
6515
+ case EventSystemEnv.web:
6516
+ return new WebHandler(this);
6517
+ case EventSystemEnv.rn:
6518
+ return new RNHandler(this);
6519
+ case EventSystemEnv.h5:
6520
+ return new H5Handler(this);
6521
+ default:
6522
+ throw new Error("Unsupported platform ".concat(env));
6523
+ }
6524
+ };
6525
+ PredyEventSystem.prototype.setRecognizer = function (recognizer) {
6526
+ recognizer._callback = this.dispatch.bind(this);
6527
+ this.recognizer = recognizer;
6528
+ };
6529
+ PredyEventSystem.prototype.setUniversalRecognizer = function (options) {
6530
+ var r = new UniversalRecognizer(options);
6531
+ this.setRecognizer(r);
6532
+ };
6533
+ // 事件分发入口
6534
+ PredyEventSystem.prototype.handleBaseEvent = function (event) {
6535
+ if (!this.enabled) {
6536
+ return;
6537
+ }
6538
+ // 识别手势
6539
+ var gestureType = this.recognizer.detect(event);
6540
+ if (gestureType) {
6541
+ this.dispatch(gestureType, event);
6542
+ }
6543
+ if (event.touches.length === 0) {
6544
+ this.recognizer.reset();
6545
+ }
6546
+ };
6547
+ PredyEventSystem.prototype.dispatch = function (type, event) {
6548
+ var _a;
6549
+ (_a = this._handlerMap.get(type)) === null || _a === void 0 ? void 0 : _a.forEach(function (fn) { return fn(event); });
6550
+ };
6551
+ PredyEventSystem.prototype.addEventListener = function (type, handler) {
6552
+ var _this = this;
6553
+ var set = this._handlerMap.get(type) || new Set();
6554
+ set.add(handler);
6555
+ this._handlerMap.set(type, set);
6556
+ return function () { return _this.removeEventListener(type, handler); };
6557
+ };
6558
+ PredyEventSystem.prototype.removeEventListener = function (type, handler) {
6559
+ var _a;
6560
+ (_a = this._handlerMap.get(type)) === null || _a === void 0 ? void 0 : _a.delete(handler);
6561
+ };
6562
+ PredyEventSystem.prototype.destroy = function () {
6563
+ this._platformHandler.teardown();
6564
+ this._handlerMap.clear();
6565
+ };
6566
+ return PredyEventSystem;
6567
+ }());
6568
+ var BaseRecognizer = /** @class */ (function () {
6569
+ function BaseRecognizer() {
6570
+ }
6571
+ BaseRecognizer.prototype.detect = function (event) {
6572
+ return event.type;
6573
+ };
6574
+ BaseRecognizer.prototype.reset = function () { };
6575
+ return BaseRecognizer;
6576
+ }());
6577
+
6578
+ consoleLog('version: ' + "0.3.4-beta.15");
6599
6579
  var ModuleMsg = 'RI Package: @predy-js/render-interface';
6600
6580
 
6601
6581
  var RI = /*#__PURE__*/Object.freeze({
@@ -6617,7 +6597,6 @@ var RI = /*#__PURE__*/Object.freeze({
6617
6597
  setDefaultTextureFactory: setDefaultTextureFactory,
6618
6598
  MarsTextureFactory: MarsTextureFactory,
6619
6599
  EventSystem: PredyEventSystem,
6620
- PredyUniversalRecognizer: UniversalRecognizer,
6621
6600
  get DestroyOptions () { return DestroyOptions; },
6622
6601
  get PredyTextEncoding () { return PredyTextEncoding; },
6623
6602
  get PredyVideoCodec () { return PredyVideoCodec; },
@@ -6651,5 +6630,5 @@ else if (typeof global === 'object') {
6651
6630
  global.PredyRI = RI;
6652
6631
  }
6653
6632
 
6654
- export { DestroyOptions, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_CANCEL, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, PredyEventSystem as EventSystem, EventSystemEnv, GESTURE_DIRECTION, GPUBufferOptionsMemoryShared, MarsGeometry as Geometry, MarsInstancedMesh as InstancedMesh, MarsTextureFactory, MarsMaterial as Material, MarsMaterialDataBlock as MaterialDataBlock, MarsMesh as Mesh, ModuleMsg, PredyResourceCacheStatus, PredyTextEncoding, UniversalRecognizer as PredyUniversalRecognizer, PredyVideoCodec, RecognizerState, MarsRenderFrame as RenderFrame, MarsRenderPass as RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassMeshOrder, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, MarsRenderer as Renderer, ShaderCompileResultStatus, ShaderLibraryEmpty, MarsSharedGeometry as SharedGeometry, MarsTexture as Texture, TextureLoadAction, TextureSourceType, TextureStoreAction, constants, getDefaultGPUCapability, getDefaultTextureFactory, setDefaultTextureFactory };
6633
+ export { DestroyOptions, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_CANCEL, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, PredyEventSystem as EventSystem, EventSystemEnv, GESTURE_DIRECTION, GPUBufferOptionsMemoryShared, MarsGeometry as Geometry, MarsInstancedMesh as InstancedMesh, MarsTextureFactory, MarsMaterial as Material, MarsMaterialDataBlock as MaterialDataBlock, MarsMesh as Mesh, ModuleMsg, PredyResourceCacheStatus, PredyTextEncoding, PredyVideoCodec, RecognizerState, MarsRenderFrame as RenderFrame, MarsRenderPass as RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassMeshOrder, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, MarsRenderer as Renderer, ShaderCompileResultStatus, ShaderLibraryEmpty, MarsSharedGeometry as SharedGeometry, MarsTexture as Texture, TextureLoadAction, TextureSourceType, TextureStoreAction, constants, getDefaultGPUCapability, getDefaultTextureFactory, setDefaultTextureFactory };
6655
6634
  //# sourceMappingURL=index.mjs.map