microts: AOT views receive button press edges only, with no release, hold or touch position

オープン
#727 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
30/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
rust, typescript

調査の方向性

Start at microts/compiler/aot-solid-frontend.ts:518, where ActionHandler props are lowered, and at engine/microts-runtime/src/ui.rs:42–49 with resolve_input (545–579), where held buttons and released edges already exist. Read microts-reference.md (Host elements and input), microts-pages.md (Input.target) and input-focus.md (Buttons) to understand the guest-side contract. Done means the onRelease/hold/touch-phase API is specified and wired through compiler and runtime, with a test showing an AOT app compiles and receives a release edge.

索引モデルが issue の本文から書いたものです。

説明

enhancement

Version

PocketJS v0.17.0 (83c6cac9, current main). macOS 27.2 arm64, Bun 1.4.2.

Gap

In the AOT view subset, input reaches the application as:

  • ActionHandler with onPress: one event on the press edge, optionally latched (microts/compiler/aot-solid-frontend.ts:518; microts-reference.md, "Host elements and input");
  • AxisHandler deltas and MotionHandler updates;
  • a touch as the pressed node in Input.target (microts-pages.md).

microts::Input already carries the held buttons and the released edges (engine/microts-runtime/src/ui.rs:42–49, resolve_input at 545–579), but no handler and no model API exposes them. A guest application reads the held bitmask every frame (input-focus.md, "Buttons") and touch positions through touches().

Devices with two or three buttons and no touch panel distinguish a click from a long press, repeat while a button is held, and use button combinations (A+B). A touch panel needs positions for drags and swipes. An AOT application cannot express these today.

Repro

pocket.host.json, pocket.host.config.ts, main.tsx
{
  "format": "pocket-host/2",
  "id": "repro-esp32s3",
  "platform": "esp-idf",
  "form": "takeover",
  "cadences": [30],
  "display": {
    "logicalViewports": [[240, 240]],
    "presentations": ["native"],
    "rasterDensity": 1,
    "animation": "repaint"
  },
  "panel": { "primary": [240, 240] },
  "capabilities": ["input.buttons", "text.glyphs.baked"]
}
// pocket.host.config.ts
import { defineHostConfig } from "@pocketjs/framework/host-config";

export default defineHostConfig({
  host: "./pocket.host.json",
  app: {
    id: "dev.example.repro",
    title: "Repro",
    version: "0.1.0",
    entry: "main.tsx",
    output: "repro",
    framework: "solid",
    viewport: { logical: [240, 240], presentation: "native" },
    features: ["input.buttons", "text.glyphs.baked"],
    aot: true,
    model: "compiled",
  },
});
// main.tsx
import { mount } from "@pocketjs/framework/solid";
import App from "./app.tsx";
mount(() => <App />);
// app.ts
import { createSignal } from "solid-js";
import type { i32 } from "@pocketjs/framework/solid/std";
export const [presses, setPresses] = createSignal<i32>(0);
export function down(): void {
  setPresses(presses() + 1);
}
export function up(): void {
  setPresses(presses() - 1);
}
// app.tsx
import { ActionHandler, Text, View } from "@pocketjs/framework/solid/components";
import { BTN } from "@pocketjs/framework/input";
import { down, presses, up } from "./app";

export default function App() {
  return (
    <View class="w-full h-full p-4 bg-slate-100">
      <ActionHandler button={BTN.CROSS} onPress={() => down()} onRelease={() => up()} />
      <Text class="text-lg text-slate-900">{presses()}</Text>
    </View>
  );
}
bun $POCKETJS/tools/pocket.ts compile --config pocket.host.config.ts --aot --out gen

Actual

PocketJS: app.tsx:8:64 TS2322: Type '{ button: 16384; onPress: () => void; onRelease: () => void; }' is not assignable to type 'ActionHandlerProps'.
  Property 'onRelease' does not exist on type 'ActionHandlerProps'.

Requested

  • onRelease on ActionHandler, and either a hold event (after a duration, with an optional repeat interval) or the press duration in onRelease;
  • a way for compiled models to read the held button mask, so that combinations can be tested;
  • for touch hosts, a handler or model input with the contact position and phase (down, move, up).

Workaround

The product's host code writes the raw button mask and pointer state into model fields every frame, and model code implements click, long press and drag on them. The rules then live outside the view subset, and each product writes them again.

主要言語
TypeScript
スター
1.6k
フォーク
88
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pocket-stack/pocketjs のほかの issue

pocket-stack/pocketjs の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。