Skip to content

feat(container): add registerApi for H5 custom API registration#189

Merged
dos1in merged 1 commit intodidi:mainfrom
EchoTechFE:feat/h5-register-api
Apr 7, 2026
Merged

feat(container): add registerApi for H5 custom API registration#189
dos1in merged 1 commit intodidi:mainfrom
EchoTechFE:feat/h5-register-api

Conversation

@lbb00
Copy link
Copy Markdown
Contributor

@lbb00 lbb00 commented Mar 31, 2026

  • Add apiRegistry map, registerApi() and invokeApi() to MiniApp
  • Update bridge.js dispatch to use invokeApi() (registry-first, fallback to built-in)
  • Add test infrastructure and 7 unit tests for the registration mechanism

@dos1in
Copy link
Copy Markdown
Member

dos1in commented Apr 3, 2026

注入三方 api 将会在 星河开发计划 中实现。当前改动的方案只实现了 web 端的,不完善。

@lbb00
Copy link
Copy Markdown
Contributor Author

lbb00 commented Apr 3, 2026

@dos1in 这确实是个临时的方案,不然 Devtools 无法模拟一些 Dimina 缺失的 wx.xxx API。没有完整方案的原因是目前不太确定 Dimina 实现的具体计划,想尽可能少的对 Dimina 仓库进行大的改动。

目前我们在 iOS 用的是 DMPContainerApi.registerMethod,Android 是 MiniApp.getInstance().registerApi

@lbb00
Copy link
Copy Markdown
Contributor Author

lbb00 commented Apr 3, 2026

还有一个 pr 在等这个 pr 合入。是为了剥离 H5 Container 中的 appList 与 appManager 的依赖,并仿照安卓那一侧实现了

		for (const [name, handler] of Object.entries(devtoolsApis)) {
			AppManager.registerApi(name, handler)
		}

@lbb00 lbb00 closed this Apr 3, 2026
@lbb00 lbb00 reopened this Apr 3, 2026
@dos1in
Copy link
Copy Markdown
Member

dos1in commented Apr 7, 2026

解决代码冲突后合入~

@lbb00 lbb00 changed the title feat(container): add registerApi for H5 custom API registration [WIP] feat(container): add registerApi for H5 custom API registration Apr 7, 2026
@lbb00 lbb00 force-pushed the feat/h5-register-api branch from 3e8ef0c to 9c504e7 Compare April 7, 2026 11:00
- Add apiRegistry map, registerApi() and invokeApi() to MiniApp
- Update bridge.js dispatch to use invokeApi() (registry-first, fallback to built-in)
- Add test infrastructure and 7 unit tests for the registration mechanism
@lbb00 lbb00 force-pushed the feat/h5-register-api branch from 9c504e7 to 26e3091 Compare April 7, 2026 11:02
@lbb00 lbb00 changed the title [WIP] feat(container): add registerApi for H5 custom API registration feat(container): add registerApi for H5 custom API registration Apr 7, 2026
@lbb00
Copy link
Copy Markdown
Contributor Author

lbb00 commented Apr 7, 2026

@dos1in Done

@dos1in dos1in merged commit 39a8245 into didi:main Apr 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants