microts: Solid AOT Text takes no style, so text colour cannot follow model data, and Image src must be a string literal
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 52/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
Direzione di ricerca
Start at microts/compiler/aot-solid-frontend.ts around lines 622 and 651, where the accepted attributes for Text and Image are declared, and read the View style handling above them to see how style is parsed and how StyleObject is typed. Then read the "Host elements and input" section of microts-reference.md for the documented surface. Reproduce with the compile --aot command in the issue and use the six-row table as the acceptance list: Text accepting textColor/opacity through style, and Image src accepting conditionals whose leaves are string literals.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Version
PocketJS v0.17.0 (83c6cac9, current main). macOS 27.2 arm64, Bun 1.4.2.
Gap
The AOT view subset lets View bind host properties to model values through style, including colours (style={{ bgColor: tint() }} with a Color signal compiles). Text accepts class and ref only, and Image accepts class, ref and a literal src (microts/compiler/aot-solid-frontend.ts:622, :651; microts-reference.md, "Host elements and input"). Use cases from device UIs:
- a value whose text colour depends on its range (a battery percentage, a temperature);
- a list row whose text colour comes from the row's data;
- an icon chosen by state (battery level, connection state, weather).
Class ternaries with full literal leaves cover a fixed set of colours, and <Show>/<Switch> with one Image per asset covers a fixed set of icons; both grow with the number of cases.
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 { Color, Px } from "@pocketjs/framework/solid/std";
export const [tint, setTint] = createSignal<Color>("#ff0000");
export const [width, setWidth] = createSignal<Px>(40);
export const [icon, setIcon] = createSignal<string>("a.png");
// app.tsx; ELEMENT is one of the lines in the table below
import { Image, Text, View } from "@pocketjs/framework/solid/components";
import { icon, tint, width } from "./app";
export default function App() {
return (
<View class="w-full h-full p-4 bg-slate-100">
ELEMENT
</View>
);
}
bun $POCKETJS/tools/pocket.ts compile --config pocket.host.config.ts --aot --out gen
Actual
| ELEMENT | Result |
|---|---|
<View class="h-4 w-4" style={{ bgColor: tint() }} /> |
compiles |
<View class="h-4" style={{ width: width() }} /> |
compiles |
<Text class="text-lg" style={{ opacity: 0.5 }}>A</Text> |
app.tsx:7:29: error: Text does not accept style |
<Text class="text-lg" style={{ color: tint() }}>A</Text> |
TS2561: Object literal may only specify known properties, but 'color' does not exist in type 'StyleObject'. Did you mean to write 'bgColor'? |
<Image class="w-4 h-4" src={icon()} /> |
app.tsx:7:30: error: src requires a static string literal |
<Image class="w-4 h-4" src={width() > 10 ? "a.png" : "b.png"} /> |
app.tsx:7:30: error: src requires a static string literal |
Requested
styleonTextwith the style properties that apply to text (textColor,opacity), typed and checked as onView.Image srcas a conditional whose leaves are string literals, asclassaccepts. Every leaf is known at compile time, so the image set baked intoload_imagesstays static.
- Lingua principale
- TypeScript
- Stelle
- 1.6k
- Fork
- 88
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pocket-stack/pocketjs
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
pocket-stack/pocketjs#729 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
pocket-stack/pocketjs#725 ·
-
enhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
pocket-stack/pocketjs#724 ·
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 62/100
pocket-stack/pocketjs#728 ·
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
pocket-stack/pocketjs#727 ·
Tutte le issue di pocket-stack/pocketjs
Issue simili
-
kind:defect
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
mux-labs/mux-frontend#1240 ·
I maintainer di solito rispondono entro 1 giorno
-
area: agents-mcp priority: normal
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
I maintainer di solito rispondono entro 1 giorno
-
Wait for the IDS correction dialog to settle in the stale-audit testForse già presa @louistrue l’ha presa oggi. Apertaready
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Hono path parameters with a regex pattern keep the pattern in the OpenAPI pathForse già presa @0z5a l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
cloudflare/chanfana#400 ·
I maintainer di solito rispondono entro 1 giorno