test: make particle package consumer reach READY
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled

This commit is contained in:
OpenAI Codex
2026-09-09 11:50:37 +08:00
parent 5261f21c1a
commit afc29e13fa

View File

@@ -3,7 +3,7 @@ import { Button, SafeAreaView, StyleSheet, Text, View, findNodeHandle } from "re
import { File, Paths } from "expo-file-system";
import { Camera, Map, WeatherRuntime, createParticleWeatherStyle } from "@navsea/maplibre-particle-rn";
const metadata = JSON.stringify({ schema: "maplibre-particle-field/v1", fieldId: "consumer-smoke", fieldType: "WIND", displayDomain: "GLOBAL", generation: 1, validTime: 1786060800000, dataVersion: 1, bounds: { west: -180, south: -85, east: 180, north: 85 }, grid: { width: 2, height: 2 }, vector: { layout: "interleaved-uv", encoding: "float32-le", noData: -9999 }, payload: { byteLength: 32 } });
const metadata = (generation: number, validTime: number) => JSON.stringify({ schema: "maplibre-particle-field/v1", fieldId: `consumer-smoke-${generation}`, fieldType: "WIND", displayDomain: "GLOBAL", generation, validTime, dataVersion: generation, bounds: { west: -180, south: -85, east: 180, north: 85 }, grid: { width: 2, height: 2 }, vector: { layout: "interleaved-uv", encoding: "float32-le", noData: -9999 }, payload: { byteLength: 32 } });
function writeFixture() {
const bytes = new Uint8Array(32); const view = new DataView(bytes.buffer);
@@ -19,7 +19,7 @@ export default function App() {
}, []);
const submit = useCallback(async () => {
if (tag == null) return;
try { await WeatherRuntime.clearWindFields(tag); const result = await WeatherRuntime.submitWindField(tag, metadata, writeFixture()); const runtime = await WeatherRuntime.getState(tag); setState(`${result} / ${runtime.state}`); } catch (error) { setState(String(error)); }
try { await WeatherRuntime.clearWindFields(tag); const payload = writeFixture(); const t0 = await WeatherRuntime.submitWindField(tag, metadata(1, 1786060800000), payload); const t1 = await WeatherRuntime.submitWindField(tag, metadata(2, 1786082400000), payload); const runtime = await WeatherRuntime.getState(tag); setState(`T0 ${t0} / T1 ${t1} / ${runtime.state}`); } catch (error) { setState(String(error)); }
}, [tag]);
return <SafeAreaView style={styles.root}><View style={styles.map}><Map mapStyle={createParticleWeatherStyle()} onDidFinishLoadingStyle={onStyle}><Camera initialViewState={{ center: [135, 32], zoom: 3.9 }} /></Map></View><View style={styles.controls}><Text>Package smoke: {state}</Text><Button title="Submit canonical fixture" onPress={() => void submit()} /></View></SafeAreaView>;
}