@effindomv2/fui-as 0.1.42 → 0.1.43

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effindomv2/fui-as",
3
- "version": "0.1.42",
3
+ "version": "0.1.43",
4
4
  "private": false,
5
5
  "license": "AGPL-3.0-only OR LicenseRef-EffinDom-Commercial",
6
6
  "description": "EffinDom v2 AssemblyScript frontend framework SDK and browser harness",
@@ -96,7 +96,7 @@
96
96
  },
97
97
  "dependencies": {
98
98
  "@assemblyscript/loader": "^0.28.19",
99
- "@effindomv2/runtime": "0.1.22"
99
+ "@effindomv2/runtime": "0.1.23"
100
100
  },
101
101
  "devDependencies": {
102
102
  "@as-pect/assembly": "9.0.0",
package/scripts/build.sh CHANGED
@@ -23,10 +23,18 @@ DEFAULT_MANIFEST_PATH="./runtime/dist/effindom.v2.manifest.json"
23
23
  LOADING_OVERLAY_STYLES_FILE="${PACKAGE_DIR}/browser/loading-overlay-styles.html"
24
24
  LOADING_OVERLAY_BODY_FILE="${PACKAGE_DIR}/browser/loading-overlay-body.html"
25
25
  RUNTIME_PACKAGE_DIR="${PACKAGE_DIR}/node_modules/@effindomv2/runtime"
26
+ FILE_PROCESSING_WORKER_SOURCE="${REPO_ROOT}/v2/browser-bridge/src/managed-harness/file-processing-worker.ts"
27
+ WORKER_BOOTSTRAP_SOURCE="${REPO_ROOT}/v2/browser-bridge/src/managed-harness/worker-bootstrap.ts"
26
28
 
27
29
  if [ ! -d "${RUNTIME_PACKAGE_DIR}" ]; then
28
30
  RUNTIME_PACKAGE_DIR="${REPO_ROOT}/node_modules/@effindomv2/runtime"
29
31
  fi
32
+ if [ ! -f "${FILE_PROCESSING_WORKER_SOURCE}" ]; then
33
+ FILE_PROCESSING_WORKER_SOURCE="${RUNTIME_PACKAGE_DIR}/src/managed-harness/file-processing-worker.ts"
34
+ fi
35
+ if [ ! -f "${WORKER_BOOTSTRAP_SOURCE}" ]; then
36
+ WORKER_BOOTSTRAP_SOURCE="${RUNTIME_PACKAGE_DIR}/src/managed-harness/worker-bootstrap.ts"
37
+ fi
30
38
 
31
39
  rm -rf "${OUT_DIR}"
32
40
  mkdir -p "${PACKAGE_DIR}/build" "${OUT_DIR}" "${DEMO_OUT_DIR}" "${WORKER_BUILD_DIR}"
@@ -331,7 +339,7 @@ npx esbuild "${PACKAGE_DIR}/demo/harness.ts" \
331
339
  --outfile="${DEMO_OUT_DIR}/harness.js" \
332
340
  --sourcemap
333
341
 
334
- npx esbuild "${RUNTIME_PACKAGE_DIR}/src/managed-harness/file-processing-worker.ts" \
342
+ npx esbuild "${FILE_PROCESSING_WORKER_SOURCE}" \
335
343
  --bundle \
336
344
  --format=iife \
337
345
  --platform=browser \
@@ -346,7 +354,7 @@ cp "${FILE_PROCESSING_WORKER_MAP_BUILD}" "${OUT_DIR}/file-processing-worker.js.m
346
354
  cp "${FILE_PROCESSING_WORKER_BUILD}" "${DEMO_OUT_DIR}/file-processing-worker.js"
347
355
  cp "${FILE_PROCESSING_WORKER_MAP_BUILD}" "${DEMO_OUT_DIR}/file-processing-worker.js.map"
348
356
 
349
- npx esbuild "${RUNTIME_PACKAGE_DIR}/src/managed-harness/worker-bootstrap.ts" \
357
+ npx esbuild "${WORKER_BOOTSTRAP_SOURCE}" \
350
358
  --bundle \
351
359
  --format=iife \
352
360
  --platform=browser \
package/src/FuiExports.ts CHANGED
@@ -29,6 +29,7 @@ export {
29
29
  __fui_get_gesture_intent,
30
30
  __fui_get_long_press_minimum_duration_ms,
31
31
  __fui_get_long_press_movement_tolerance,
32
+ __fui_long_press_continues_pointer_events,
32
33
  __fui_on_gesture_event,
33
34
  __fui_on_long_press_event,
34
35
  __fui_on_key_event,
@@ -48,6 +48,8 @@ export class DragGesture {
48
48
  private thresholdValue: f32 = DEFAULT_DRAG_THRESHOLD;
49
49
  private pointerDownValue: bool = false;
50
50
  private dragStartedValue: bool = false;
51
+ private awaitingLongPressValue: bool = false;
52
+ private pointerCapturedValue: bool = false;
51
53
  private startX: f32 = 0.0;
52
54
  private startY: f32 = 0.0;
53
55
  private lastPointerX: f32 = 0.0;
@@ -67,12 +69,13 @@ export class DragGesture {
67
69
  return this;
68
70
  }
69
71
 
70
- handlePointerDown(x: f32, y: f32, modifiers: KeyModifier = 0): void {
72
+ handlePointerDown(x: f32, y: f32, modifiers: KeyModifier = 0, waitForLongPress: bool = false): void {
71
73
  if (this.pointerDownValue) {
72
74
  this.cancel();
73
75
  }
74
76
  this.pointerDownValue = true;
75
77
  this.dragStartedValue = false;
78
+ this.awaitingLongPressValue = waitForLongPress;
76
79
  this.startX = x;
77
80
  this.startY = y;
78
81
  this.lastPointerX = x;
@@ -80,8 +83,10 @@ export class DragGesture {
80
83
  this.lastDispatchedX = x;
81
84
  this.lastDispatchedY = y;
82
85
  this.lastModifiers = modifiers;
83
- this.host._captureDragPointer();
84
- if (this.thresholdValue <= 0.0) {
86
+ if (!waitForLongPress) {
87
+ this.capturePointer();
88
+ }
89
+ if (!waitForLongPress && this.thresholdValue <= 0.0) {
85
90
  this.beginDrag(x, y, modifiers);
86
91
  }
87
92
  }
@@ -93,6 +98,9 @@ export class DragGesture {
93
98
  this.lastPointerX = x;
94
99
  this.lastPointerY = y;
95
100
  this.lastModifiers = modifiers;
101
+ if (this.awaitingLongPressValue) {
102
+ return;
103
+ }
96
104
  if (!this.dragStartedValue) {
97
105
  if (!this.hasExceededThreshold(x - this.startX, y - this.startY)) {
98
106
  return;
@@ -102,6 +110,24 @@ export class DragGesture {
102
110
  this.emitDelta(x, y, modifiers);
103
111
  }
104
112
 
113
+ handleLongPress(x: f32, y: f32, modifiers: KeyModifier = 0): bool {
114
+ if (!this.pointerDownValue) {
115
+ this.pointerDownValue = true;
116
+ this.dragStartedValue = false;
117
+ this.startX = x;
118
+ this.startY = y;
119
+ this.lastDispatchedX = x;
120
+ this.lastDispatchedY = y;
121
+ }
122
+ this.awaitingLongPressValue = false;
123
+ this.lastPointerX = x;
124
+ this.lastPointerY = y;
125
+ this.lastModifiers = modifiers;
126
+ this.capturePointer();
127
+ this.beginDrag(x, y, modifiers);
128
+ return true;
129
+ }
130
+
105
131
  handlePointerUp(x: f32, y: f32, modifiers: KeyModifier = 0): void {
106
132
  if (!this.pointerDownValue) {
107
133
  return;
@@ -123,7 +149,8 @@ export class DragGesture {
123
149
  }
124
150
  this.pointerDownValue = false;
125
151
  this.dragStartedValue = false;
126
- this.host._releaseDragPointer();
152
+ this.awaitingLongPressValue = false;
153
+ this.releasePointer();
127
154
  }
128
155
 
129
156
  cancel(): void {
@@ -143,7 +170,8 @@ export class DragGesture {
143
170
  }
144
171
  this.pointerDownValue = false;
145
172
  this.dragStartedValue = false;
146
- this.host._releaseDragPointer();
173
+ this.awaitingLongPressValue = false;
174
+ this.releasePointer();
147
175
  }
148
176
 
149
177
  private beginDrag(x: f32, y: f32, modifiers: u32): void {
@@ -182,4 +210,16 @@ export class DragGesture {
182
210
  }
183
211
  return ((totalDeltaX * totalDeltaX) + (totalDeltaY * totalDeltaY)) >= (this.thresholdValue * this.thresholdValue);
184
212
  }
213
+
214
+ private capturePointer(): void {
215
+ if (this.pointerCapturedValue) return;
216
+ this.pointerCapturedValue = true;
217
+ this.host._captureDragPointer();
218
+ }
219
+
220
+ private releasePointer(): void {
221
+ if (!this.pointerCapturedValue) return;
222
+ this.pointerCapturedValue = false;
223
+ this.host._releaseDragPointer();
224
+ }
185
225
  }
@@ -290,6 +290,11 @@ export class EventRouter {
290
290
  return <u64>HandleValue.Invalid;
291
291
  }
292
292
 
293
+ static longPressContinuesPointerEvents(handle: u64): bool {
294
+ const node = this.resolveNode(handle);
295
+ return node !== null && changetype<Node>(node).longPressContinuesPointerEventsForRouting;
296
+ }
297
+
293
298
  private static hasImageContextMenuTargetDescendant(node: Node): bool {
294
299
  for (let index = 0; index < node.childCount; ++index) {
295
300
  const child = node.getChildAt(index);
package/src/core/Node.ts CHANGED
@@ -843,7 +843,11 @@ export abstract class Node implements DragGestureHost, Disposable {
843
843
  }
844
844
 
845
845
  get hasLongPressGestureForRouting(): bool {
846
- return this.longPressGestureCallback !== null || this.longPressGestureBinding !== null;
846
+ return this.longPressGestureCallback !== null || this.longPressGestureBinding !== null || this._hasDragSource();
847
+ }
848
+
849
+ get longPressContinuesPointerEventsForRouting(): bool {
850
+ return this._hasDragSource();
847
851
  }
848
852
 
849
853
  get longPressMinimumDurationMsForRouting(): i32 {
@@ -2253,7 +2257,8 @@ export abstract class Node implements DragGestureHost, Disposable {
2253
2257
  const dragGesture = this._hasDragSource() ? this.dragGestureValue : null;
2254
2258
  const isPrimaryButton = isPrimaryActivationPointer(event);
2255
2259
  if (dragGesture !== null && isPrimaryButton) {
2256
- dragGesture.handlePointerDown(nodeX, nodeY, _modifiers);
2260
+ const waitForLongPress = event.pointerType == PointerType.Touch || event.pointerType == PointerType.Pen;
2261
+ dragGesture.handlePointerDown(nodeX, nodeY, _modifiers, waitForLongPress);
2257
2262
  this.dragClickPending = this.pointerClickCallback !== null || this.pointerClickBinding !== null;
2258
2263
  this.dragClickPendingCount = event.clickCount;
2259
2264
  this.clickPending = false;
@@ -2479,6 +2484,12 @@ export abstract class Node implements DragGestureHost, Disposable {
2479
2484
  if (binding !== null) {
2480
2485
  binding.invoke(event);
2481
2486
  }
2487
+ if (!event.handled && (event.pointerType == PointerType.Touch || event.pointerType == PointerType.Pen)) {
2488
+ const dragGesture = this._hasDragSource() ? this.dragGestureValue : null;
2489
+ if (dragGesture !== null) {
2490
+ event.handled = dragGesture.handleLongPress(event.x, event.y, event.modifiers);
2491
+ }
2492
+ }
2482
2493
  return event.handled;
2483
2494
  }
2484
2495
 
@@ -150,6 +150,10 @@ export function __fui_get_long_press_movement_tolerance(handle: u64): f32 {
150
150
  return EventRouter.getLongPressMovementTolerance(handle);
151
151
  }
152
152
 
153
+ export function __fui_long_press_continues_pointer_events(handle: u64): bool {
154
+ return EventRouter.longPressContinuesPointerEvents(handle);
155
+ }
156
+
153
157
  export function __fui_on_gesture_event(
154
158
  handle: u64,
155
159
  phase: u32,