@uneven/tpl-runtime
v0.1.0
Published
SWP TP4 cross-platform medical device template runtime
Readme
@uneven/tpl-runtime
TP4 医疗设备模板的无框架 DOM 运行时。核心包不依赖 Vue、Pinia 或业务 API,可用于 Vue 2.7、Vue 3 和纯 Web 设备页面。
当前能力
- TP4/旧模板版本路由;旧模板通过宿主
legacyAdapter回退现有 ParserV3。 editor.bounds精确布局,缺失时回退 0-based Grid。- fixed 逻辑画布等比缩放。
primitive.text/image/rect与 Renderer Registry。- 数据路径解析与按数据源增量区域刷新。
- Android/Linux/Harmony Platform Adapter。
- bed/door/beside/whiteboard/watchboard Device Profile。
- HCareLabel 与自由
representativeElements。 - 可复制的诊断信息,不因未知组件导致整页崩溃。
安装与发布
cd packages/template-runtime
pnpm install
pnpm test
pnpm build
npm publish构建输出:ESM、UMD/CJS 和 TypeScript 声明。
基础使用
import {
AndroidPlatformAdapter,
BedDeviceProfile,
createTemplateRuntime,
} from '@uneven/tpl-runtime'
const runtime = createTemplateRuntime({
container: document.querySelector('#template-root')!,
template: templateContent,
platformAdapter: new AndroidPlatformAdapter(fileUrlPrefix),
deviceProfile: new BedDeviceProfile(),
legacyAdapter: {
mount(template, container) {
// 交给 medical-device-v2 的 ParserV3 宿主组件。
mountExistingParserV3(template, container)
},
},
})
await runtime.mount()
runtime.updateDataBatch({
bedDeviceInfoVo: device.bedDeviceInfoVo,
bedSickInfoVo: device.bedSickInfoVo,
bedSickNursingLabelList: device.bedSickNursingLabelList,
})medical-device-v2 接入
参考 examples/medical-device-v2.ts。推荐在现有 src/pages/home/index.tsx 外增加版本路由:TP4 挂载本包,旧 JSON 继续渲染 ParserV3。Pinia 只由宿主 Adapter 读取,本包不直接依赖设备 Store。
Android/Linux 的文件前缀、JSBridge、本地资源和交互差异放入 PlatformAdapter;床头机/门口机等数据整形和专用组件放入 DeviceProfile。
扩展组件
registry.register('whiteboard.module', whiteboardRenderer)
registry.registerLegacy('HVideo', videoRenderer)扩展设备类型时新增 DeviceProfile,扩展系统端时新增 PlatformAdapter,不要修改 Parser。
生命周期
设备页面卸载时必须调用 runtime.destroy(),释放 ResizeObserver、数据订阅和 Platform Adapter。
当前边界
- 当前内置基础组件与护理标签;白板/看板业务组件通过插件注册。
- responsive 布局预留,当前 fixed 模式完整实现。
- transforms 结构已保留,业务变换函数可在后续版本注册。
