feat: 轻卡编译器支持 lifecycle params 表达式编译及模板耗时 Feature 校验#168
Open
lewiscutey wants to merge 2 commits into
Open
Conversation
…> 块中 lifecycle.create/update 的 params 表达式 - hap-compiler 新增 lifecycle 模块(parseLifecycle),校验 params 一级绑定 - hap-dsl-xvm 新增 lifecycle-loader 及片段接入,轻卡导出 lifecycle - hap-packager 注册 lifecycle loader,postHandleLiteCardRes 复用 markParams 将 lifecycle params 的 {{expr}} 编译为 #/$ JSON AST,静态值保持原样 需求二(P1):模板表达式禁止调用耗时 Feature - 校验 system.geolocation.getLocation / system.push.subscribe 等黑名单 - 命中模板表达式时编译报错(含行号与修改建议),params 中放行 补充 hap-packager 单测覆盖以上两个需求
…te-loader 上报为 webpack 编译错误,使 hap build 非零退出 - zip-plugin 打包前校验 compilation.errors,存在错误时跳过打包, 不再产出 rpk/rpks - 黑名单更新为 system.geolocation.getLocation 与 service.push.subscribe - 补充单测断言 fatal 标记及 service.push.subscribe 校验
010f5a1 to
d87e7a9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
轻卡 Feature 调用机制需要编译器支持两项能力(详见需求文档):
create.params/update.params中的{{ }}表达式需要编译为 JSON AST;改动内容
需求一(P0):lifecycle params 表达式编译
现状:编译器只提取
<data>块的uiData(→data)和actions,lifecycle字段被直接丢弃。本次让
lifecycle复用与 actions params 完全一致的编译规则:lifecycle模块(parseLifecycle),校验create/update的 params(一级绑定、参数名不能以$开头),并从入口导出。lifecycle-loader.js,接入片段体系(FRAG_TYPE.LIFECYCLE、processLifecycleFrag、makeLoaderString分支),轻卡在assemble()中导出lifecycle。LOADER_INFO_LIST注册 lifecycle loader(组装进#entry.lifecycle);postHandleLiteCardRes中新增postHandleLifecycle,复用markParams把 params 里的{{ expr }}编译为#key(JSON AST) +$key(原文) 对,纯静态值保持原样。编译产出示例:
需求二(P1):模板中禁止耗时 Feature 调用
测试
影响范围