用途:在修改 gradle/libs.versions.toml 中固定的 maplibre-js 版本后,更新 lib/maplibre-compose/src/jsMain/kotlin/org/maplibre/compose/gljs/ 下手写且内部的 MapLibre GL JS 绑定。
主要步骤:先备份旧声明(复制 build/js/node_modules/maplibre-gl/dist/maplibre-gl.d.ts 与 src 到临时目录);编辑 maplibre-js 并把 maplibre-styleSpec 设为新版本内置的 spec 版本,然后运行 ./gradlew kotlinNpmInstall 与 ./gradlew kotlinUpgradeYarnLock;用 diff 比对 .d.ts,只关注 GlJsModule.kt 与 GlJsTypes.kt 中出现的名称,检查重命名、删除、选项字段与返回结构变化,并确认窄化类型(如 LngLat、Point)仍有效。
还需查看两版本间 changelog,寻找值得绑定的新能力(commonMain 中仍抛 NotImplementedError 的缺口、TODO、新 API),共享 API 放 commonMain,共享行为测试放 liveMapTest,浏览器实现测试放 jsTest。随后比对上游源码复核 GlJsRuntime.kt 与 GlJsStyleBinding.setTransition 依赖的内部假设(lendingContext、redirectDefaultFramebuffer、interceptRepaintRequests、removingWithoutLosingContext、setTransition)。
验证:mise run test:js、./gradlew :demo-app:common:compileKotlinJs、mise run check,浏览器测试报告位于 lib/maplibre-compose/build/reports/tests/jsBrowserTest/。限制:Kotlin 编译不会校验外部声明与上游 TypeScript 的一致性,运行时测试只覆盖被调用的成员;若用户仅要求版本或兼容性更新,则不主动采纳新能力。