@elurjs/universal 0.1.2 → 0.1.3

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.
@@ -31,7 +31,7 @@ export const httpModuleDef: NativeModuleDef = {
31
31
  abiVersion: NATIVE_ABI_VERSION,
32
32
  version: "1.0.0",
33
33
  capabilities: ["http-client"],
34
- platforms: ["android", "linux"],
34
+ platforms: ["android", "linux", "windows"],
35
35
  commands: {
36
36
  request: {
37
37
  input: {
@@ -18,7 +18,7 @@ export const uiModuleDef: NativeModuleDef = {
18
18
  abiVersion: NATIVE_ABI_VERSION,
19
19
  version: "1.0.0",
20
20
  capabilities: ["ui-host"],
21
- platforms: ["android", "linux"],
21
+ platforms: ["android", "linux", "windows"],
22
22
  commands: {
23
23
  measureInWindow: {
24
24
  input: { id: "number" },
@@ -40,7 +40,7 @@ export const cryptoModuleDef: NativeModuleDef = {
40
40
  abiVersion: NATIVE_ABI_VERSION,
41
41
  version: "1.0.0",
42
42
  capabilities: ["ed25519-verify"],
43
- platforms: ["android", "linux"],
43
+ platforms: ["android", "linux", "windows"],
44
44
  commands: {
45
45
  verify: {
46
46
  input: { payload: "string", sig: "string", key: "string" },
@@ -53,14 +53,15 @@ export function profileFromRuntime(
53
53
  ): { profile: SduiProfile | null; diagnostics: Diagnostic[] } {
54
54
  const platform = v.platform as CapabilityPlatform;
55
55
  if (platform !== "web" && platform !== "android" &&
56
- platform !== "linux") {
56
+ platform !== "linux" && platform !== "windows") {
57
57
  return {
58
58
  profile: null,
59
59
  diagnostics: [diagnostic("sdui.profile.platform", "capability",
60
60
  "error",
61
61
  `plataforma "${v.platform}" sin columna en la matriz — ` +
62
62
  "no hay perfil servible",
63
- { actual: v.platform, expected: "web|android|linux" })],
63
+ { actual: v.platform,
64
+ expected: "web|android|linux|windows" })],
64
65
  };
65
66
  }
66
67
  const profile: SduiProfile = { platform, ir: v.ir };
@@ -225,6 +225,8 @@ class ElurRenderer(
225
225
  var hover: InputChannel? = null
226
226
  var pointer: InputChannel? = null
227
227
  var contextMenu: InputChannel? = null
228
+ var pinch: InputChannel? = null
229
+ private var scaleDet: android.view.ScaleGestureDetector? = null
228
230
  private val density = view.resources.displayMetrics.density
229
231
  private val slop =
230
232
  android.view.ViewConfiguration.get(view.context).scaledTouchSlop.toDouble()
@@ -240,7 +242,8 @@ class ElurRenderer(
240
242
  pan == null &&
241
243
  hover == null &&
242
244
  pointer == null &&
243
- contextMenu == null
245
+ contextMenu == null &&
246
+ pinch == null
244
247
 
245
248
  fun install() {
246
249
  view.setOnTouchListener { v, ev -> onTouch(v, ev) }
@@ -265,6 +268,51 @@ class ElurRenderer(
265
268
  view.setOnContextClickListener(null)
266
269
  view.isContextClickable = false
267
270
  }
271
+ // pinch: ScaleGestureDetector del framework — payload del
272
+ // contrato {scale,focalX,focalY,phase} en dp (events.ts).
273
+ scaleDet =
274
+ if (pinch != null)
275
+ android.view.ScaleGestureDetector(
276
+ view.context,
277
+ object :
278
+ android.view.ScaleGestureDetector
279
+ .SimpleOnScaleGestureListener() {
280
+ override fun onScaleBegin(
281
+ d: android.view.ScaleGestureDetector
282
+ ): Boolean {
283
+ emitPinch("start", d)
284
+ return true
285
+ }
286
+
287
+ override fun onScale(
288
+ d: android.view.ScaleGestureDetector
289
+ ): Boolean {
290
+ emitPinch("move", d)
291
+ return true
292
+ }
293
+
294
+ override fun onScaleEnd(
295
+ d: android.view.ScaleGestureDetector
296
+ ) {
297
+ emitPinch("end", d)
298
+ }
299
+ })
300
+ else null
301
+ }
302
+
303
+ private fun emitPinch(phase: String, d: android.view.ScaleGestureDetector) {
304
+ val ch = pinch ?: return
305
+ callEventHandler(
306
+ ch.handler,
307
+ "pinch",
308
+ "user",
309
+ "{\"phase\":\"$phase\",\"scale\":${d.scaleFactor}," +
310
+ "\"focalX\":${lg(d.focusX)},\"focalY\":${lg(d.focusY)}}",
311
+ ch.continuous && phase == "move",
312
+ ch.payload,
313
+ "pinch:$id"
314
+ )
315
+ scheduleFrameCallback()
268
316
  }
269
317
 
270
318
  fun uninstall() {
@@ -274,6 +322,7 @@ class ElurRenderer(
274
322
  view.isLongClickable = false
275
323
  view.setOnContextClickListener(null)
276
324
  view.isContextClickable = false
325
+ scaleDet = null
277
326
  }
278
327
 
279
328
  private fun lg(px: Float) = px / density
@@ -312,6 +361,7 @@ class ElurRenderer(
312
361
  }
313
362
 
314
363
  private fun onTouch(v: View, ev: MotionEvent): Boolean {
364
+ scaleDet?.onTouchEvent(ev)
315
365
  when (ev.actionMasked) {
316
366
  MotionEvent.ACTION_DOWN -> {
317
367
  downX = ev.x
@@ -4817,7 +4867,7 @@ class ElurRenderer(
4817
4867
  "endReached" -> {
4818
4868
  // Sintetizado por el reconciler sobre `scroll`.
4819
4869
  }
4820
- "longPress", "pan", "hover", "pointer", "contextMenu", "contextmenu" -> {
4870
+ "longPress", "pan", "hover", "pointer", "contextMenu", "contextmenu", "pinch" -> {
4821
4871
  val view = views[id] ?: return
4822
4872
  val g = gestures.getOrPut(id) { NodeGestures(id, view) }
4823
4873
  val ch = InputChannel(handler, continuous, payload)
@@ -4826,6 +4876,7 @@ class ElurRenderer(
4826
4876
  "pan" -> g.pan = ch
4827
4877
  "hover" -> g.hover = ch
4828
4878
  "pointer" -> g.pointer = ch
4879
+ "pinch" -> g.pinch = ch
4829
4880
  else -> g.contextMenu = ch
4830
4881
  }
4831
4882
  g.install()
@@ -5115,13 +5166,14 @@ class ElurRenderer(
5115
5166
  (views[id] as? ElurScrollView)?.onRefreshTrigger = null
5116
5167
  }
5117
5168
  "endReached" -> {}
5118
- "longPress", "pan", "hover", "pointer", "contextMenu", "contextmenu" -> {
5169
+ "longPress", "pan", "hover", "pointer", "contextMenu", "contextmenu", "pinch" -> {
5119
5170
  val g = gestures[id] ?: return
5120
5171
  when (event) {
5121
5172
  "longPress" -> g.longPress = null
5122
5173
  "pan" -> g.pan = null
5123
5174
  "hover" -> g.hover = null
5124
5175
  "pointer" -> g.pointer = null
5176
+ "pinch" -> g.pinch = null
5125
5177
  else -> g.contextMenu = null
5126
5178
  }
5127
5179
  if (g.isEmpty()) {