release: prepare MapLibre Particle Android v1 package
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { useCallback, useState } from "react";
|
||||
import { Button, SafeAreaView, StyleSheet, Text, View, findNodeHandle } from "react-native";
|
||||
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 } });
|
||||
|
||||
function writeFixture() {
|
||||
const bytes = new Uint8Array(32); const view = new DataView(bytes.buffer);
|
||||
for (let offset = 0; offset < bytes.byteLength; offset += 8) { view.setFloat32(offset, 5, true); view.setFloat32(offset + 4, 1, true); }
|
||||
const file = new File(Paths.cache, "navsea-particle-consumer-smoke.f32"); file.write(bytes); return file.uri;
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
const [tag, setTag] = useState<number | null>(null); const [state, setState] = useState("STYLE_LOADING");
|
||||
const onStyle = useCallback(async (event: unknown) => {
|
||||
const value = findNodeHandle((event as { target?: unknown }).target as never); if (value == null) return;
|
||||
try { await WeatherRuntime.attach(value); setTag(value); setState("WAITING_FOR_FIELDS"); } catch (error) { setState(String(error)); }
|
||||
}, []);
|
||||
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)); }
|
||||
}, [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>;
|
||||
}
|
||||
const styles = StyleSheet.create({ root: { flex: 1 }, map: { flex: 1 }, controls: { padding: 12, backgroundColor: "white" } });
|
||||
@@ -0,0 +1,14 @@
|
||||
# MapLibreParticlePackageConsumerTestHost
|
||||
|
||||
这是发布包 Consumer smoke host,不引用 `packages/`、Test Host bridge 源码、MapLibre Native source tree 或 workspace dependency。其 `package.json` 只直接依赖 `@navsea/maplibre-particle-rn@13.4.1-particle.1`;Map、Camera、WeatherRuntime 和 style helper 全部从该发布包导入。
|
||||
|
||||
最终 registry 未决定时,先在包目录生成 tarball,再在本目录手工执行:
|
||||
|
||||
```bash
|
||||
npm install /absolute/path/navsea-maplibre-particle-rn-13.4.1-particle.1.tgz --save-exact
|
||||
npm install --ignore-scripts
|
||||
npx expo prebuild --platform android --clean
|
||||
npx expo run:android
|
||||
```
|
||||
|
||||
该 `.tgz` 是发布物而非源码路径。用户还需将 `cc.navsea.maplibre:android-sdk-particle-opengl:13.4.1-particle.1` 手工发布至 Maven Local 或临时 staging;package plugin 会将 MLRN 的唯一 OpenGL SDK 请求替换为该正式 artifact。Codex 不执行上述 Android 命令。
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"expo": {
|
||||
"name": "MapLibre Particle Package Consumer",
|
||||
"slug": "maplibre-particle-package-consumer",
|
||||
"version": "0.1.0",
|
||||
"orientation": "landscape",
|
||||
"newArchEnabled": true,
|
||||
"plugins": ["@navsea/maplibre-particle-rn/app.plugin"],
|
||||
"android": { "package": "cc.navsea.maplibre.particle.consumer", "minSdkVersion": 24 }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "maplibre-particle-package-consumer-test-host",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"packageManager": "npm@10.9.4",
|
||||
"scripts": {
|
||||
"typecheck": "tsc --noEmit",
|
||||
"start": "expo start --port 8092",
|
||||
"android": "expo run:android"
|
||||
},
|
||||
"dependencies": {
|
||||
"@navsea/maplibre-particle-rn": "13.4.1-particle.1",
|
||||
"expo": "56.0.4",
|
||||
"expo-file-system": "56.0.11",
|
||||
"react": "19.2.3",
|
||||
"react-native": "0.85.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "19.2.5",
|
||||
"typescript": "5.9.3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"extends": "expo/tsconfig.base",
|
||||
"compilerOptions": { "strict": true, "noEmit": true },
|
||||
"include": ["App.tsx"]
|
||||
}
|
||||
Reference in New Issue
Block a user