@cloudbase/cals 1.1.14 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{parser → cjs/parser}/cals/index.d.ts +1 -1
- package/lib/cjs/parser/cals/index.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/block/helpers/get-component-namespace.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/block/helpers/merge-dataset.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/block/helpers/merge-listeners.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/block/helpers/merge-resources.d.ts.map +1 -0
- package/lib/{parser → cjs/parser}/cals/utils/block/helpers/remap-component-ids.d.ts +2 -2
- package/lib/cjs/parser/cals/utils/block/helpers/remap-component-ids.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/block/helpers/renew-id-in-code.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/block/helpers/renew-id-in-expr.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/block/helpers/renew-id-in-resource.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/block/helpers/resolve-new-id.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/block/index.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/code/index.d.ts.map +1 -0
- package/lib/{parser → cjs/parser}/cals/utils/common.d.ts +1 -1
- package/lib/cjs/parser/cals/utils/common.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/getUsedReference.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/getUsedResources.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/runtime.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/spinoff/index.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/style.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/template.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/version/common.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/version/config.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/version/index.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/version/parses.d.ts.map +1 -0
- package/lib/cjs/parser/cals/utils/version/utils.d.ts.map +1 -0
- package/lib/cjs/parser/dependiencies/index.d.ts.map +1 -0
- package/lib/cjs/parser/expression/index.d.ts.map +1 -0
- package/lib/cjs/parser/index.d.ts.map +1 -0
- package/lib/cjs/parser/plugins/postcss-rpx2clac.d.ts.map +1 -0
- package/lib/cjs/types/basic/app.d.ts.map +1 -0
- package/lib/cjs/types/basic/common.d.ts.map +1 -0
- package/lib/cjs/types/basic/component.d.ts.map +1 -0
- package/lib/cjs/types/basic/datasource.d.ts.map +1 -0
- package/lib/cjs/types/index.d.ts.map +1 -0
- package/lib/{types → cjs/types}/lcds.d.ts +4 -4
- package/lib/cjs/types/lcds.d.ts.map +1 -0
- package/lib/{types → cjs/types}/platform/app.d.ts +2 -2
- package/lib/cjs/types/platform/app.d.ts.map +1 -0
- package/lib/cjs/types/platform/common.d.ts.map +1 -0
- package/lib/{types → cjs/types}/platform/component.d.ts +1 -1
- package/lib/cjs/types/platform/component.d.ts.map +1 -0
- package/lib/{types → cjs/types}/platform/datasource.d.ts +4 -4
- package/lib/cjs/types/platform/datasource.d.ts.map +1 -0
- package/lib/cjs/types/platform/eventFlow.d.ts.map +1 -0
- package/lib/cjs/types/platform/query.d.ts.map +1 -0
- package/lib/{types → cjs/types}/platform/theme.d.ts +4 -4
- package/lib/cjs/types/platform/theme.d.ts.map +1 -0
- package/lib/cjs/utils/CSSProperty.d.ts.map +1 -0
- package/lib/cjs/utils/color-generator/core.d.ts.map +1 -0
- package/lib/cjs/utils/color-generator/generate.d.ts.map +1 -0
- package/lib/cjs/utils/color-generator/utils.d.ts.map +1 -0
- package/lib/cjs/utils/constant.d.ts.map +1 -0
- package/lib/cjs/utils/dts/auto-generated.d.ts.map +1 -0
- package/lib/{utils → cjs/utils}/dts/build.d.ts.map +1 -1
- package/lib/cjs/utils/dts/index.d.ts.map +1 -0
- package/lib/cjs/utils/index.d.ts.map +1 -0
- package/lib/cjs/utils/version/common.d.ts.map +1 -0
- package/lib/cjs/utils/version/featureChecker.d.ts.map +1 -0
- package/lib/cjs/utils/version/migrations/version4.d.ts.map +1 -0
- package/lib/esm/parser/cals/index.d.ts +625 -0
- package/lib/esm/parser/cals/index.d.ts.map +1 -0
- package/lib/esm/parser/cals/index.js +1548 -0
- package/lib/esm/parser/cals/utils/block/helpers/get-component-namespace.d.ts +2 -0
- package/lib/esm/parser/cals/utils/block/helpers/get-component-namespace.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/block/helpers/get-component-namespace.js +5 -0
- package/lib/esm/parser/cals/utils/block/helpers/merge-dataset.d.ts +6 -0
- package/lib/esm/parser/cals/utils/block/helpers/merge-dataset.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/block/helpers/merge-dataset.js +13 -0
- package/lib/esm/parser/cals/utils/block/helpers/merge-listeners.d.ts +6 -0
- package/lib/esm/parser/cals/utils/block/helpers/merge-listeners.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/block/helpers/merge-listeners.js +10 -0
- package/lib/esm/parser/cals/utils/block/helpers/merge-resources.d.ts +6 -0
- package/lib/esm/parser/cals/utils/block/helpers/merge-resources.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/block/helpers/merge-resources.js +25 -0
- package/lib/esm/parser/cals/utils/block/helpers/remap-component-ids.d.ts +30 -0
- package/lib/esm/parser/cals/utils/block/helpers/remap-component-ids.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/block/helpers/remap-component-ids.js +125 -0
- package/lib/esm/parser/cals/utils/block/helpers/renew-id-in-code.d.ts +7 -0
- package/lib/esm/parser/cals/utils/block/helpers/renew-id-in-code.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/block/helpers/renew-id-in-code.js +9 -0
- package/lib/esm/parser/cals/utils/block/helpers/renew-id-in-expr.d.ts +8 -0
- package/lib/esm/parser/cals/utils/block/helpers/renew-id-in-expr.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/block/helpers/renew-id-in-expr.js +56 -0
- package/lib/esm/parser/cals/utils/block/helpers/renew-id-in-resource.d.ts +15 -0
- package/lib/esm/parser/cals/utils/block/helpers/renew-id-in-resource.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/block/helpers/renew-id-in-resource.js +13 -0
- package/lib/esm/parser/cals/utils/block/helpers/resolve-new-id.d.ts +7 -0
- package/lib/esm/parser/cals/utils/block/helpers/resolve-new-id.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/block/helpers/resolve-new-id.js +17 -0
- package/lib/esm/parser/cals/utils/block/index.d.ts +67 -0
- package/lib/esm/parser/cals/utils/block/index.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/block/index.js +451 -0
- package/lib/esm/parser/cals/utils/code/index.d.ts +36 -0
- package/lib/esm/parser/cals/utils/code/index.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/code/index.js +401 -0
- package/lib/esm/parser/cals/utils/common.d.ts +35 -0
- package/lib/esm/parser/cals/utils/common.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/common.js +301 -0
- package/lib/esm/parser/cals/utils/getUsedReference.d.ts +8 -0
- package/lib/esm/parser/cals/utils/getUsedReference.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/getUsedReference.js +54 -0
- package/lib/esm/parser/cals/utils/getUsedResources.d.ts +10 -0
- package/lib/esm/parser/cals/utils/getUsedResources.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/getUsedResources.js +132 -0
- package/lib/esm/parser/cals/utils/runtime.d.ts +14 -0
- package/lib/esm/parser/cals/utils/runtime.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/runtime.js +254 -0
- package/lib/esm/parser/cals/utils/spinoff/index.d.ts +10 -0
- package/lib/esm/parser/cals/utils/spinoff/index.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/spinoff/index.js +95 -0
- package/lib/esm/parser/cals/utils/style.d.ts +43 -0
- package/lib/esm/parser/cals/utils/style.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/style.js +463 -0
- package/lib/esm/parser/cals/utils/template.d.ts +6 -0
- package/lib/esm/parser/cals/utils/template.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/template.js +221 -0
- package/lib/esm/parser/cals/utils/version/common.d.ts +5 -0
- package/lib/esm/parser/cals/utils/version/common.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/version/common.js +375 -0
- package/lib/esm/parser/cals/utils/version/config.d.ts +16 -0
- package/lib/esm/parser/cals/utils/version/config.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/version/config.js +241 -0
- package/lib/esm/parser/cals/utils/version/index.d.ts +3 -0
- package/lib/esm/parser/cals/utils/version/index.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/version/index.js +68 -0
- package/lib/esm/parser/cals/utils/version/parses.d.ts +16 -0
- package/lib/esm/parser/cals/utils/version/parses.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/version/parses.js +560 -0
- package/lib/esm/parser/cals/utils/version/utils.d.ts +14 -0
- package/lib/esm/parser/cals/utils/version/utils.d.ts.map +1 -0
- package/lib/esm/parser/cals/utils/version/utils.js +129 -0
- package/lib/esm/parser/dependiencies/index.d.ts +143 -0
- package/lib/esm/parser/dependiencies/index.d.ts.map +1 -0
- package/lib/esm/parser/dependiencies/index.js +684 -0
- package/lib/esm/parser/expression/index.d.ts +123 -0
- package/lib/esm/parser/expression/index.d.ts.map +1 -0
- package/lib/esm/parser/expression/index.js +296 -0
- package/lib/esm/parser/index.d.ts +13 -0
- package/lib/esm/parser/index.d.ts.map +1 -0
- package/lib/esm/parser/index.js +12 -0
- package/lib/esm/parser/plugins/postcss-rpx2clac.d.ts +18 -0
- package/lib/esm/parser/plugins/postcss-rpx2clac.d.ts.map +1 -0
- package/lib/esm/parser/plugins/postcss-rpx2clac.js +67 -0
- package/lib/esm/types/basic/app.d.ts +76 -0
- package/lib/esm/types/basic/app.d.ts.map +1 -0
- package/lib/esm/types/basic/app.js +1 -0
- package/lib/esm/types/basic/common.d.ts +125 -0
- package/lib/esm/types/basic/common.d.ts.map +1 -0
- package/lib/esm/types/basic/common.js +1 -0
- package/lib/esm/types/basic/component.d.ts +212 -0
- package/lib/esm/types/basic/component.d.ts.map +1 -0
- package/lib/esm/types/basic/component.js +1 -0
- package/lib/esm/types/basic/datasource.d.ts +50 -0
- package/lib/esm/types/basic/datasource.d.ts.map +1 -0
- package/lib/esm/types/basic/datasource.js +1 -0
- package/lib/esm/types/index.d.ts +12 -0
- package/lib/esm/types/index.d.ts.map +1 -0
- package/lib/esm/types/index.js +14 -0
- package/lib/esm/types/lcds.d.ts +610 -0
- package/lib/esm/types/lcds.d.ts.map +1 -0
- package/lib/esm/types/lcds.js +22 -0
- package/lib/esm/types/platform/app.d.ts +276 -0
- package/lib/esm/types/platform/app.d.ts.map +1 -0
- package/lib/esm/types/platform/app.js +8 -0
- package/lib/esm/types/platform/common.d.ts +190 -0
- package/lib/esm/types/platform/common.d.ts.map +1 -0
- package/lib/esm/types/platform/common.js +84 -0
- package/lib/esm/types/platform/component.d.ts +166 -0
- package/lib/esm/types/platform/component.d.ts.map +1 -0
- package/lib/esm/types/platform/component.js +8 -0
- package/lib/esm/types/platform/datasource.d.ts +500 -0
- package/lib/esm/types/platform/datasource.d.ts.map +1 -0
- package/lib/esm/types/platform/datasource.js +6 -0
- package/lib/esm/types/platform/eventFlow.d.ts +20 -0
- package/lib/esm/types/platform/eventFlow.d.ts.map +1 -0
- package/lib/esm/types/platform/eventFlow.js +1 -0
- package/lib/esm/types/platform/query.d.ts +78 -0
- package/lib/esm/types/platform/query.d.ts.map +1 -0
- package/lib/esm/types/platform/query.js +12 -0
- package/lib/esm/types/platform/theme.d.ts +47 -0
- package/lib/esm/types/platform/theme.d.ts.map +1 -0
- package/lib/esm/types/platform/theme.js +1 -0
- package/lib/esm/utils/CSSProperty.d.ts +64 -0
- package/lib/esm/utils/CSSProperty.d.ts.map +1 -0
- package/lib/esm/utils/CSSProperty.js +86 -0
- package/lib/esm/utils/color-generator/core.d.ts +52 -0
- package/lib/esm/utils/color-generator/core.d.ts.map +1 -0
- package/lib/esm/utils/color-generator/core.js +57 -0
- package/lib/esm/utils/color-generator/generate.d.ts +67 -0
- package/lib/esm/utils/color-generator/generate.d.ts.map +1 -0
- package/lib/esm/utils/color-generator/generate.js +92 -0
- package/lib/esm/utils/color-generator/utils.d.ts +15 -0
- package/lib/esm/utils/color-generator/utils.d.ts.map +1 -0
- package/lib/esm/utils/color-generator/utils.js +30 -0
- package/lib/esm/utils/constant.d.ts +65 -0
- package/lib/esm/utils/constant.d.ts.map +1 -0
- package/lib/esm/utils/constant.js +69 -0
- package/lib/esm/utils/dts/auto-generated.d.ts +2 -0
- package/lib/esm/utils/dts/auto-generated.d.ts.map +1 -0
- package/lib/esm/utils/dts/auto-generated.js +1796 -0
- package/lib/esm/utils/dts/build.d.ts +2 -0
- package/lib/esm/utils/dts/build.d.ts.map +1 -0
- package/lib/esm/utils/dts/build.js +147 -0
- package/lib/esm/utils/dts/index.d.ts +141 -0
- package/lib/esm/utils/dts/index.d.ts.map +1 -0
- package/lib/esm/utils/dts/index.js +1071 -0
- package/lib/esm/utils/index.d.ts +9 -0
- package/lib/esm/utils/index.d.ts.map +1 -0
- package/lib/esm/utils/index.js +8 -0
- package/lib/esm/utils/version/common.d.ts +3 -0
- package/lib/esm/utils/version/common.d.ts.map +1 -0
- package/lib/esm/utils/version/common.js +22 -0
- package/lib/esm/utils/version/featureChecker.d.ts +5 -0
- package/lib/esm/utils/version/featureChecker.d.ts.map +1 -0
- package/lib/esm/utils/version/featureChecker.js +32 -0
- package/lib/esm/utils/version/migrations/version4.d.ts +3 -0
- package/lib/esm/utils/version/migrations/version4.d.ts.map +1 -0
- package/lib/esm/utils/version/migrations/version4.js +192 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/package.json +7 -5
- package/lib/parser/cals/index.d.ts.map +0 -1
- package/lib/parser/cals/utils/block/helpers/get-component-namespace.d.ts.map +0 -1
- package/lib/parser/cals/utils/block/helpers/merge-dataset.d.ts.map +0 -1
- package/lib/parser/cals/utils/block/helpers/merge-listeners.d.ts.map +0 -1
- package/lib/parser/cals/utils/block/helpers/merge-resources.d.ts.map +0 -1
- package/lib/parser/cals/utils/block/helpers/remap-component-ids.d.ts.map +0 -1
- package/lib/parser/cals/utils/block/helpers/renew-id-in-code.d.ts.map +0 -1
- package/lib/parser/cals/utils/block/helpers/renew-id-in-expr.d.ts.map +0 -1
- package/lib/parser/cals/utils/block/helpers/renew-id-in-resource.d.ts.map +0 -1
- package/lib/parser/cals/utils/block/helpers/resolve-new-id.d.ts.map +0 -1
- package/lib/parser/cals/utils/block/index.d.ts.map +0 -1
- package/lib/parser/cals/utils/code/index.d.ts.map +0 -1
- package/lib/parser/cals/utils/common.d.ts.map +0 -1
- package/lib/parser/cals/utils/getUsedReference.d.ts.map +0 -1
- package/lib/parser/cals/utils/getUsedResources.d.ts.map +0 -1
- package/lib/parser/cals/utils/runtime.d.ts.map +0 -1
- package/lib/parser/cals/utils/spinoff/index.d.ts.map +0 -1
- package/lib/parser/cals/utils/style.d.ts.map +0 -1
- package/lib/parser/cals/utils/template.d.ts.map +0 -1
- package/lib/parser/cals/utils/version/common.d.ts.map +0 -1
- package/lib/parser/cals/utils/version/config.d.ts.map +0 -1
- package/lib/parser/cals/utils/version/index.d.ts.map +0 -1
- package/lib/parser/cals/utils/version/parses.d.ts.map +0 -1
- package/lib/parser/cals/utils/version/utils.d.ts.map +0 -1
- package/lib/parser/dependiencies/index.d.ts.map +0 -1
- package/lib/parser/expression/index.d.ts.map +0 -1
- package/lib/parser/index.d.ts.map +0 -1
- package/lib/parser/plugins/postcss-rpx2clac.d.ts.map +0 -1
- package/lib/types/basic/app.d.ts.map +0 -1
- package/lib/types/basic/common.d.ts.map +0 -1
- package/lib/types/basic/component.d.ts.map +0 -1
- package/lib/types/basic/datasource.d.ts.map +0 -1
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/lcds.d.ts.map +0 -1
- package/lib/types/platform/app.d.ts.map +0 -1
- package/lib/types/platform/common.d.ts.map +0 -1
- package/lib/types/platform/component.d.ts.map +0 -1
- package/lib/types/platform/datasource.d.ts.map +0 -1
- package/lib/types/platform/eventFlow.d.ts.map +0 -1
- package/lib/types/platform/query.d.ts.map +0 -1
- package/lib/types/platform/theme.d.ts.map +0 -1
- package/lib/utils/CSSProperty.d.ts.map +0 -1
- package/lib/utils/color-generator/core.d.ts.map +0 -1
- package/lib/utils/color-generator/generate.d.ts.map +0 -1
- package/lib/utils/color-generator/utils.d.ts.map +0 -1
- package/lib/utils/constant.d.ts.map +0 -1
- package/lib/utils/dts/auto-generated.d.ts.map +0 -1
- package/lib/utils/dts/index.d.ts.map +0 -1
- package/lib/utils/index.d.ts.map +0 -1
- package/lib/utils/version/common.d.ts.map +0 -1
- package/lib/utils/version/featureChecker.d.ts.map +0 -1
- package/lib/utils/version/migrations/version4.d.ts.map +0 -1
- /package/lib/{parser → cjs/parser}/cals/index.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/block/helpers/get-component-namespace.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/block/helpers/get-component-namespace.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/block/helpers/merge-dataset.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/block/helpers/merge-dataset.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/block/helpers/merge-listeners.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/block/helpers/merge-listeners.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/block/helpers/merge-resources.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/block/helpers/merge-resources.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/block/helpers/remap-component-ids.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/block/helpers/renew-id-in-code.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/block/helpers/renew-id-in-code.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/block/helpers/renew-id-in-expr.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/block/helpers/renew-id-in-expr.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/block/helpers/renew-id-in-resource.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/block/helpers/renew-id-in-resource.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/block/helpers/resolve-new-id.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/block/helpers/resolve-new-id.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/block/index.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/block/index.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/code/index.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/code/index.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/common.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/getUsedReference.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/getUsedReference.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/getUsedResources.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/getUsedResources.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/runtime.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/runtime.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/spinoff/index.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/spinoff/index.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/style.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/style.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/template.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/template.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/version/common.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/version/common.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/version/config.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/version/config.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/version/index.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/version/index.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/version/parses.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/version/parses.js +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/version/utils.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/cals/utils/version/utils.js +0 -0
- /package/lib/{parser → cjs/parser}/dependiencies/index.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/dependiencies/index.js +0 -0
- /package/lib/{parser → cjs/parser}/expression/index.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/expression/index.js +0 -0
- /package/lib/{parser → cjs/parser}/index.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/index.js +0 -0
- /package/lib/{parser → cjs/parser}/plugins/postcss-rpx2clac.d.ts +0 -0
- /package/lib/{parser → cjs/parser}/plugins/postcss-rpx2clac.js +0 -0
- /package/lib/{types → cjs/types}/basic/app.d.ts +0 -0
- /package/lib/{types → cjs/types}/basic/app.js +0 -0
- /package/lib/{types → cjs/types}/basic/common.d.ts +0 -0
- /package/lib/{types → cjs/types}/basic/common.js +0 -0
- /package/lib/{types → cjs/types}/basic/component.d.ts +0 -0
- /package/lib/{types → cjs/types}/basic/component.js +0 -0
- /package/lib/{types → cjs/types}/basic/datasource.d.ts +0 -0
- /package/lib/{types → cjs/types}/basic/datasource.js +0 -0
- /package/lib/{types → cjs/types}/index.d.ts +0 -0
- /package/lib/{types → cjs/types}/index.js +0 -0
- /package/lib/{types → cjs/types}/lcds.js +0 -0
- /package/lib/{types → cjs/types}/platform/app.js +0 -0
- /package/lib/{types → cjs/types}/platform/common.d.ts +0 -0
- /package/lib/{types → cjs/types}/platform/common.js +0 -0
- /package/lib/{types → cjs/types}/platform/component.js +0 -0
- /package/lib/{types → cjs/types}/platform/datasource.js +0 -0
- /package/lib/{types → cjs/types}/platform/eventFlow.d.ts +0 -0
- /package/lib/{types → cjs/types}/platform/eventFlow.js +0 -0
- /package/lib/{types → cjs/types}/platform/query.d.ts +0 -0
- /package/lib/{types → cjs/types}/platform/query.js +0 -0
- /package/lib/{types → cjs/types}/platform/theme.js +0 -0
- /package/lib/{utils → cjs/utils}/CSSProperty.d.ts +0 -0
- /package/lib/{utils → cjs/utils}/CSSProperty.js +0 -0
- /package/lib/{utils → cjs/utils}/color-generator/core.d.ts +0 -0
- /package/lib/{utils → cjs/utils}/color-generator/core.js +0 -0
- /package/lib/{utils → cjs/utils}/color-generator/generate.d.ts +0 -0
- /package/lib/{utils → cjs/utils}/color-generator/generate.js +0 -0
- /package/lib/{utils → cjs/utils}/color-generator/utils.d.ts +0 -0
- /package/lib/{utils → cjs/utils}/color-generator/utils.js +0 -0
- /package/lib/{utils → cjs/utils}/constant.d.ts +0 -0
- /package/lib/{utils → cjs/utils}/constant.js +0 -0
- /package/lib/{utils → cjs/utils}/dts/auto-generated.d.ts +0 -0
- /package/lib/{utils → cjs/utils}/dts/auto-generated.js +0 -0
- /package/lib/{utils → cjs/utils}/dts/build.d.ts +0 -0
- /package/lib/{utils → cjs/utils}/dts/build.js +0 -0
- /package/lib/{utils → cjs/utils}/dts/index.d.ts +0 -0
- /package/lib/{utils → cjs/utils}/dts/index.js +0 -0
- /package/lib/{utils → cjs/utils}/index.d.ts +0 -0
- /package/lib/{utils → cjs/utils}/index.js +0 -0
- /package/lib/{utils → cjs/utils}/version/common.d.ts +0 -0
- /package/lib/{utils → cjs/utils}/version/common.js +0 -0
- /package/lib/{utils → cjs/utils}/version/featureChecker.d.ts +0 -0
- /package/lib/{utils → cjs/utils}/version/featureChecker.js +0 -0
- /package/lib/{utils → cjs/utils}/version/migrations/version4.d.ts +0 -0
- /package/lib/{utils → cjs/utils}/version/migrations/version4.js +0 -0
|
@@ -0,0 +1,1548 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import lodashGet from 'lodash/get';
|
|
13
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
14
|
+
import lodashUnset from 'lodash/unset';
|
|
15
|
+
import lodashSet from 'lodash/set';
|
|
16
|
+
import isArray from 'lodash/isArray';
|
|
17
|
+
import isObject from 'lodash/isObject';
|
|
18
|
+
import { ECodeName, ECodeType, EResourceType } from '../../types/platform/common';
|
|
19
|
+
import { ActionType, DynamicValueParser, PropBindType } from '../expression';
|
|
20
|
+
import { isEmptyObj, isValidClassNameListBind, isValidStyleBind, walkThroughComponents, DYNAMIC_KEY_REG, } from './utils/common';
|
|
21
|
+
import { removeInvalidStyleFormValue } from './utils/style';
|
|
22
|
+
import { getValidValue, readDirectives, readDynamicData, readListeners, writeListeners } from './utils/runtime';
|
|
23
|
+
import { COMPONENT_SELECTABLEBLOCK_WHITELIST, MODULE_SELECTABLEBLOCK_REGEX } from './utils/version/config';
|
|
24
|
+
import { generateDefaultCode } from './utils/template';
|
|
25
|
+
import { isEnablePageRoot, isEnbaleObserverVersion, isEnableSimpleComponentInvoke, } from '../../utils/version/featureChecker';
|
|
26
|
+
import { OFFICIAL_LIB_KEY, SPINOFF_SUFFIX, getUsedReference, } from '../../utils';
|
|
27
|
+
import { generateBlockTemplateMap } from './utils/getUsedReference';
|
|
28
|
+
import { VisitedMap } from './utils/block/helpers/remap-component-ids';
|
|
29
|
+
import { getComponentNamespace } from './utils/block/helpers/get-component-namespace';
|
|
30
|
+
import { expandComponentReference, collapseComponentReference, } from './utils/block/index';
|
|
31
|
+
export { getUsedComps, generateCustomLoginConfigPathname, replaceGloalIdentifier } from './utils/common';
|
|
32
|
+
export { generateDefaultCode } from './utils/template';
|
|
33
|
+
export function serializeValue({ ctx, key, dynamicValue, scope = 'page', streamlineDefaultValue, }) {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
let { value } = dynamicValue;
|
|
36
|
+
let { dependenciesMap = {} } = ctx;
|
|
37
|
+
if (dynamicValue.type && dynamicValue.type !== 'static') {
|
|
38
|
+
key = `:${key}`;
|
|
39
|
+
switch (dynamicValue.type) {
|
|
40
|
+
case PropBindType.state:
|
|
41
|
+
case PropBindType.computed:
|
|
42
|
+
case PropBindType.dataVar:
|
|
43
|
+
case PropBindType.stateData:
|
|
44
|
+
case PropBindType.params: {
|
|
45
|
+
const TYPE_MAP = {
|
|
46
|
+
[PropBindType.prop]: 'props',
|
|
47
|
+
[PropBindType.state]: 'state',
|
|
48
|
+
[PropBindType.computed]: 'computed',
|
|
49
|
+
[PropBindType.dataVar]: 'dataVar',
|
|
50
|
+
[PropBindType.stateData]: 'dataset.state',
|
|
51
|
+
[PropBindType.params]: 'dataset.params',
|
|
52
|
+
};
|
|
53
|
+
let exp = dynamicValue.value;
|
|
54
|
+
let reg = /^(.*?)\./;
|
|
55
|
+
let prefix = exp;
|
|
56
|
+
let matched = exp.match(reg);
|
|
57
|
+
if (matched) {
|
|
58
|
+
prefix = matched[1];
|
|
59
|
+
}
|
|
60
|
+
let replacer = scope === 'component' ? '$comp' : '$page';
|
|
61
|
+
if (prefix === 'global') {
|
|
62
|
+
replacer = '$app';
|
|
63
|
+
}
|
|
64
|
+
else if (/^comp-\w+/.test(prefix) || /^\$comp_\w+/.test(prefix)) {
|
|
65
|
+
replacer = '$comp';
|
|
66
|
+
}
|
|
67
|
+
replacer += `.${TYPE_MAP[dynamicValue.type]}.`;
|
|
68
|
+
value = exp.replace(reg, replacer);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
case PropBindType.prop: {
|
|
72
|
+
const isNeg = dynamicValue.value.startsWith('!');
|
|
73
|
+
value = isNeg
|
|
74
|
+
? dynamicValue.value.replace('!', '!$comp.props.data.')
|
|
75
|
+
: `$comp.props.data.${dynamicValue.value}`;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
case PropBindType.forItem: {
|
|
79
|
+
value = `$for.${dynamicValue.value}`;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case PropBindType.slot: {
|
|
83
|
+
value = '$slot';
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
case PropBindType.expression: {
|
|
87
|
+
// Todo: 表达式转义
|
|
88
|
+
// app.state => $app.state
|
|
89
|
+
// forItems.state => $for.state
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else if (streamlineDefaultValue) {
|
|
95
|
+
let { module = '', component = '' } = ctx.component || {};
|
|
96
|
+
let sourceKey = `${module}:${component}`;
|
|
97
|
+
let config = (_b = (_a = dependenciesMap === null || dependenciesMap === void 0 ? void 0 : dependenciesMap[sourceKey]) === null || _a === void 0 ? void 0 : _a.dataForm) === null || _b === void 0 ? void 0 : _b[key];
|
|
98
|
+
if ((config === null || config === void 0 ? void 0 : config.default) === value || (config && config.default === undefined && value === '')) {
|
|
99
|
+
value = undefined;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return { key, value, extra: dynamicValue.extra };
|
|
103
|
+
}
|
|
104
|
+
export function deserializeValue(ctx, key, value, extra) {
|
|
105
|
+
var _a;
|
|
106
|
+
let matched = key.match(DYNAMIC_KEY_REG);
|
|
107
|
+
if (matched) {
|
|
108
|
+
let key = matched[1];
|
|
109
|
+
let type = PropBindType.expression;
|
|
110
|
+
try {
|
|
111
|
+
let parser = new DynamicValueParser(value, { pageId: (_a = ctx.page) === null || _a === void 0 ? void 0 : _a.id });
|
|
112
|
+
let res = parser.parse();
|
|
113
|
+
type = res.type;
|
|
114
|
+
if ((res === null || res === void 0 ? void 0 : res.value) != undefined) {
|
|
115
|
+
value = res.value;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch (e) {
|
|
119
|
+
if (typeof value === 'boolean') {
|
|
120
|
+
type = PropBindType.static;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
type = PropBindType.expression;
|
|
124
|
+
try {
|
|
125
|
+
value = value.replace(/\$app\./g, 'app.').replace(/\$for\./g, 'forItems.');
|
|
126
|
+
}
|
|
127
|
+
catch (e) { }
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
key,
|
|
132
|
+
value: { type, value, extra },
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
return {
|
|
137
|
+
key,
|
|
138
|
+
value: value === undefined
|
|
139
|
+
? undefined
|
|
140
|
+
: {
|
|
141
|
+
type: undefined /* 'static'*/,
|
|
142
|
+
value,
|
|
143
|
+
extra,
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
export function serializeDynamicMap(props) {
|
|
149
|
+
return serializeDynamicMapWithExtra(props).data;
|
|
150
|
+
}
|
|
151
|
+
function serializeDynamicMapWithExtra({ ctx, map = {}, scope = 'page', streamlineDefaultValue, }) {
|
|
152
|
+
let data = {};
|
|
153
|
+
let extra = {};
|
|
154
|
+
Object.keys(map)
|
|
155
|
+
.sort((a, b) => {
|
|
156
|
+
const aPath = a.split('.');
|
|
157
|
+
const bPath = b.split('.');
|
|
158
|
+
const isADynamic = aPath[0].startsWith(':');
|
|
159
|
+
const isBDynamic = bPath[0].startsWith(':');
|
|
160
|
+
if (isADynamic !== isBDynamic) {
|
|
161
|
+
return isADynamic ? -1 : 1;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
return aPath > bPath ? 1 : -1;
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
.forEach((key) => {
|
|
168
|
+
let { key: processedKey, value: processedValue, extra: processedExtra, } = serializeValue({
|
|
169
|
+
ctx,
|
|
170
|
+
key,
|
|
171
|
+
dynamicValue: map[key],
|
|
172
|
+
scope,
|
|
173
|
+
streamlineDefaultValue,
|
|
174
|
+
});
|
|
175
|
+
let matched = processedKey.match(DYNAMIC_KEY_REG);
|
|
176
|
+
let originKey = processedKey;
|
|
177
|
+
if (matched) {
|
|
178
|
+
originKey = matched[1];
|
|
179
|
+
if (!originKey) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
lodashUnset(data, originKey);
|
|
183
|
+
}
|
|
184
|
+
const originKeyArr = originKey.split('.');
|
|
185
|
+
if (lodashGet(data, processedKey) == undefined) {
|
|
186
|
+
/* 选区结构处理 [formily] to [CALS] */
|
|
187
|
+
if (Array.isArray(processedValue) && (processedValue === null || processedValue === void 0 ? void 0 : processedValue.some((item) => !!(item === null || item === void 0 ? void 0 : item.selectableBlock)))) {
|
|
188
|
+
let valueTmp = cloneDeep(processedValue);
|
|
189
|
+
processedValue = valueTmp === null || valueTmp === void 0 ? void 0 : valueTmp.map((_value) => {
|
|
190
|
+
var _a, _b, _c;
|
|
191
|
+
const xProp = (_a = _value === null || _value === void 0 ? void 0 : _value.selectableBlock) === null || _a === void 0 ? void 0 : _a['x-props'];
|
|
192
|
+
const xComponent = (_c = (_b = _value === null || _value === void 0 ? void 0 : _value.selectableBlock) === null || _b === void 0 ? void 0 : _b['x-component']) === null || _c === void 0 ? void 0 : _c.toLowerCase();
|
|
193
|
+
const module = xComponent === null || xComponent === void 0 ? void 0 : xComponent.split(':')[0];
|
|
194
|
+
const component = xComponent === null || xComponent === void 0 ? void 0 : xComponent.split(':')[1];
|
|
195
|
+
if (xProp &&
|
|
196
|
+
MODULE_SELECTABLEBLOCK_REGEX.test(module) &&
|
|
197
|
+
COMPONENT_SELECTABLEBLOCK_WHITELIST.includes(component)) {
|
|
198
|
+
_value.selectableBlock = serializeRuntimeComponent(ctx, _value.selectableBlock);
|
|
199
|
+
}
|
|
200
|
+
return _value;
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
// 为动态数据且有多级,将{":range.0.label": "$page.dataset.state.test1"}转为{ range: [{ ":label": "$page.dataset.state.test1"}] }
|
|
204
|
+
if (matched && originKeyArr.length >= 2) {
|
|
205
|
+
lodashSet(data, replaceWithColon(originKey), cloneDeep(processedValue));
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
data[processedKey] = cloneDeep(processedValue);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
extra[originKey] = processedExtra;
|
|
212
|
+
});
|
|
213
|
+
return { data, extra };
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* 将{ range: [{ label: "$page.dataset.state.test1"}] }的path range.0.label 转为range.0.:label
|
|
217
|
+
* @param key
|
|
218
|
+
* @returns
|
|
219
|
+
*/
|
|
220
|
+
function replaceWithColon(key) {
|
|
221
|
+
const keyArr = key.split('.');
|
|
222
|
+
// 最深一层前面加上":"
|
|
223
|
+
keyArr[keyArr.length - 1] = `:${keyArr[keyArr.length - 1]}`;
|
|
224
|
+
return keyArr.join('.');
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* 预处理,先还原数据。
|
|
228
|
+
* 将range: [{":label": "$page.dataset.state.test1"}]还原为:":range.0.label": "$page.dataset.state.test1"
|
|
229
|
+
* 支持递归
|
|
230
|
+
* @param parent 根节点
|
|
231
|
+
* @param current 当前节点
|
|
232
|
+
* @param path 路径
|
|
233
|
+
* @returns
|
|
234
|
+
*/
|
|
235
|
+
function recoverSynamicMap(parent, current, path = '') {
|
|
236
|
+
Object.keys(current).forEach((key) => {
|
|
237
|
+
let value = current[key];
|
|
238
|
+
if (isArray(value)) {
|
|
239
|
+
// 注意如果是 selectableBlock 独立处理
|
|
240
|
+
if (value === null || value === void 0 ? void 0 : value.some((item) => !!(item === null || item === void 0 ? void 0 : item.selectableBlock))) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
// 数组必须在前面
|
|
244
|
+
value.forEach((valueItem, valueIndex) => {
|
|
245
|
+
if (isObject(valueItem)) {
|
|
246
|
+
valueItem = recoverSynamicMap(parent, valueItem, `${path === '' ? '' : `${path}.`}${key}.${valueIndex}`);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
else if (isObject(value)) {
|
|
251
|
+
value = recoverSynamicMap(parent, value, `${path === '' ? '' : `${path}.`}${key}`);
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
const matched = key.match(DYNAMIC_KEY_REG);
|
|
255
|
+
if (matched) {
|
|
256
|
+
parent[`:${path === '' ? '' : `${path}.`}${matched[1]}`] = current[key];
|
|
257
|
+
if (current !== parent) {
|
|
258
|
+
// 如果是第一层级,说明current和parent相等,不unset
|
|
259
|
+
lodashUnset(current, key);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
return current;
|
|
265
|
+
}
|
|
266
|
+
export function deserializeDynamicMap(ctx, map, extraMap) {
|
|
267
|
+
var _a, _b;
|
|
268
|
+
let data = {};
|
|
269
|
+
const clonedMap = cloneDeep(map);
|
|
270
|
+
// 还原flatten path
|
|
271
|
+
map = recoverSynamicMap(clonedMap, clonedMap, '');
|
|
272
|
+
for (let key in map || {}) {
|
|
273
|
+
let value = map === null || map === void 0 ? void 0 : map[key];
|
|
274
|
+
let matched = key.match(DYNAMIC_KEY_REG);
|
|
275
|
+
if (matched && !matched[1]) {
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
let { key: processedKey, value: processedValue } = deserializeValue(ctx, key, value, extraMap === null || extraMap === void 0 ? void 0 : extraMap[matched ? matched[1] : key]);
|
|
279
|
+
/* 选区结构处理 [CALS] to [formily] */
|
|
280
|
+
if (Array.isArray(processedValue === null || processedValue === void 0 ? void 0 : processedValue.value) && ((_a = processedValue === null || processedValue === void 0 ? void 0 : processedValue.value) === null || _a === void 0 ? void 0 : _a.some((item) => !!(item === null || item === void 0 ? void 0 : item.selectableBlock)))) {
|
|
281
|
+
(_b = processedValue === null || processedValue === void 0 ? void 0 : processedValue.value) === null || _b === void 0 ? void 0 : _b.forEach((_value) => {
|
|
282
|
+
var _a, _b, _c, _d;
|
|
283
|
+
const module = (_b = (_a = _value === null || _value === void 0 ? void 0 : _value.selectableBlock) === null || _a === void 0 ? void 0 : _a.module) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
284
|
+
const component = (_d = (_c = _value === null || _value === void 0 ? void 0 : _value.selectableBlock) === null || _c === void 0 ? void 0 : _c.component) === null || _d === void 0 ? void 0 : _d.toLowerCase();
|
|
285
|
+
if (_value.selectableBlock &&
|
|
286
|
+
MODULE_SELECTABLEBLOCK_REGEX.test(module) &&
|
|
287
|
+
COMPONENT_SELECTABLEBLOCK_WHITELIST.includes(component)) {
|
|
288
|
+
_value.selectableBlock = deserializeRuntimeComponent(ctx, _value.selectableBlock);
|
|
289
|
+
}
|
|
290
|
+
return _value;
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
if (processedValue !== undefined) {
|
|
294
|
+
data[processedKey] = processedValue;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return data;
|
|
298
|
+
}
|
|
299
|
+
export function serializeAttributes(ctx, scope, attributes = {}) {
|
|
300
|
+
var _a;
|
|
301
|
+
return (_a = serializeAttributesWithExtra(ctx, scope, attributes)) === null || _a === void 0 ? void 0 : _a.data;
|
|
302
|
+
}
|
|
303
|
+
function serializeAttributesWithExtra(ctx, scope, attributes = {}) {
|
|
304
|
+
return serializeDynamicMapWithExtra({
|
|
305
|
+
ctx,
|
|
306
|
+
scope,
|
|
307
|
+
map: attributes,
|
|
308
|
+
streamlineDefaultValue: ctx.streamlineDefaultValue,
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
export function deserializeAttributes(ctx, attributes = {}, attributesExtraData = {}) {
|
|
312
|
+
const reservedAttributes = ['style', 'commonStyle', 'class'];
|
|
313
|
+
const reservedAttributesMap = reservedAttributes.reduce((map, key) => {
|
|
314
|
+
map[key] = true;
|
|
315
|
+
map[`:${key}`] = true;
|
|
316
|
+
return map;
|
|
317
|
+
}, {});
|
|
318
|
+
let restAttributes = {};
|
|
319
|
+
for (let key in attributes) {
|
|
320
|
+
if (reservedAttributesMap[key]) {
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
restAttributes[key] = attributes[key];
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return deserializeDynamicMap(ctx, restAttributes, attributesExtraData);
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* 将dataset({state: {}, params: {}})从 weapp 结构转换为cals结构
|
|
331
|
+
* 目前仅转换 state 中的 initMethod.params 和 updateMethod.params
|
|
332
|
+
*/
|
|
333
|
+
export function serializeDataset(ctx, dataset) {
|
|
334
|
+
if (!dataset) {
|
|
335
|
+
return dataset;
|
|
336
|
+
}
|
|
337
|
+
const result = JSON.parse(JSON.stringify(dataset || {}));
|
|
338
|
+
Object.values(result.state || {}).forEach((state) => {
|
|
339
|
+
var _a, _b, _c, _d;
|
|
340
|
+
if (state.varType !== 'datasource')
|
|
341
|
+
return;
|
|
342
|
+
if ((_a = state.initMethod) === null || _a === void 0 ? void 0 : _a.params) {
|
|
343
|
+
state.initMethod.params = (_b = serializeDynamicMapWithExtra({
|
|
344
|
+
ctx,
|
|
345
|
+
map: state.initMethod.params,
|
|
346
|
+
})) === null || _b === void 0 ? void 0 : _b.data;
|
|
347
|
+
}
|
|
348
|
+
if ((_c = state.updateMethod) === null || _c === void 0 ? void 0 : _c.params) {
|
|
349
|
+
state.updateMethod.params = (_d = serializeDynamicMapWithExtra({
|
|
350
|
+
ctx,
|
|
351
|
+
map: state.updateMethod.params,
|
|
352
|
+
})) === null || _d === void 0 ? void 0 : _d.data;
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
Object.entries(result.query || {}).forEach(([key, query]) => {
|
|
356
|
+
var _a, _b, _c, _d;
|
|
357
|
+
let { dataSourceName, method, listeners, handler, data, args } = query, restQuery = __rest(query, ["dataSourceName", "method", "listeners", "handler", "data", "args"]);
|
|
358
|
+
let isDeprecatedVersion = false;
|
|
359
|
+
let mergedData = (_a = serializeDynamicMapWithExtra({
|
|
360
|
+
ctx,
|
|
361
|
+
map: data || {},
|
|
362
|
+
})) === null || _a === void 0 ? void 0 : _a.data;
|
|
363
|
+
if (dataSourceName && !handler) {
|
|
364
|
+
handler = {
|
|
365
|
+
moduleName: 'platform',
|
|
366
|
+
name: 'cloud.callDataSource',
|
|
367
|
+
};
|
|
368
|
+
isDeprecatedVersion = true;
|
|
369
|
+
mergedData = {
|
|
370
|
+
dataSourceName,
|
|
371
|
+
methodName: method === null || method === void 0 ? void 0 : method.name,
|
|
372
|
+
params: (_b = serializeDynamicMapWithExtra({
|
|
373
|
+
ctx,
|
|
374
|
+
map: (method === null || method === void 0 ? void 0 : method.params) || {},
|
|
375
|
+
})) === null || _b === void 0 ? void 0 : _b.data,
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
const argsData = (_c = serializeDynamicMapWithExtra({
|
|
379
|
+
ctx,
|
|
380
|
+
map: args || {},
|
|
381
|
+
})) === null || _c === void 0 ? void 0 : _c.data;
|
|
382
|
+
let processedHandler = {
|
|
383
|
+
module: handler === null || handler === void 0 ? void 0 : handler.moduleName,
|
|
384
|
+
name: handler === null || handler === void 0 ? void 0 : handler.name,
|
|
385
|
+
':code': handler === null || handler === void 0 ? void 0 : handler.code,
|
|
386
|
+
};
|
|
387
|
+
if (isDeprecatedVersion) {
|
|
388
|
+
processedHandler.params = mergedData;
|
|
389
|
+
}
|
|
390
|
+
else if (mergedData && data) {
|
|
391
|
+
processedHandler.params = mergedData;
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
processedHandler = Object.assign(Object.assign({}, argsData), processedHandler);
|
|
395
|
+
}
|
|
396
|
+
result.query[key] = Object.assign(Object.assign({}, restQuery), { handler: processedHandler, listeners: (_d = listeners === null || listeners === void 0 ? void 0 : listeners.map) === null || _d === void 0 ? void 0 : _d.call(listeners, (listener) => serializeListener(ctx, listener)) });
|
|
397
|
+
});
|
|
398
|
+
return result;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* 反序列化布局模板
|
|
402
|
+
* @param ctx
|
|
403
|
+
* @param templates
|
|
404
|
+
*/
|
|
405
|
+
export function deserializeTemplates(ctx, templates) {
|
|
406
|
+
const layout = {};
|
|
407
|
+
templates.forEach((template) => {
|
|
408
|
+
const { listeners = [] } = processListeners((template === null || template === void 0 ? void 0 : template.listeners) || []);
|
|
409
|
+
layout[template.id] = {
|
|
410
|
+
id: template.id,
|
|
411
|
+
name: template.name,
|
|
412
|
+
label: template.label,
|
|
413
|
+
data: (template === null || template === void 0 ? void 0 : template.data) || {},
|
|
414
|
+
dataset: deserializeDataset(ctx, template.dataset),
|
|
415
|
+
componentInstances: deserializeComponent(ctx, template.items || []),
|
|
416
|
+
listeners: (listeners === null || listeners === void 0 ? void 0 : listeners.map((item) => {
|
|
417
|
+
return deserializeListener(ctx, item);
|
|
418
|
+
})) || [],
|
|
419
|
+
};
|
|
420
|
+
});
|
|
421
|
+
return layout;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* 将dataset({state: {}, params: {}})从 cals 结构转换为weapp结构
|
|
425
|
+
* 目前仅转换 state 中的 initMethod.params 和 updateMethod.params
|
|
426
|
+
*/
|
|
427
|
+
export function deserializeDataset(ctx, dataset) {
|
|
428
|
+
if (!dataset) {
|
|
429
|
+
return dataset;
|
|
430
|
+
}
|
|
431
|
+
// 克隆, 避免引用问题
|
|
432
|
+
const result = JSON.parse(JSON.stringify(dataset || {}));
|
|
433
|
+
Object.values(result.state || {}).forEach((state) => {
|
|
434
|
+
var _a, _b;
|
|
435
|
+
if (state.varType !== 'datasource')
|
|
436
|
+
return;
|
|
437
|
+
if ((_a = state.initMethod) === null || _a === void 0 ? void 0 : _a.params) {
|
|
438
|
+
state.initMethod.params = deserializeDynamicMap(ctx, state.initMethod.params);
|
|
439
|
+
}
|
|
440
|
+
if ((_b = state.updateMethod) === null || _b === void 0 ? void 0 : _b.params) {
|
|
441
|
+
state.updateMethod.params = deserializeDynamicMap(ctx, state.updateMethod.params);
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
Object.entries(result.query || {}).forEach(([key, query]) => {
|
|
445
|
+
var _a, _b;
|
|
446
|
+
const _c = normalizeQuery(query), { handler, listeners } = _c, restQuery = __rest(_c, ["handler", "listeners"]);
|
|
447
|
+
let paramsDynamicMap = generateHandlerParamsDynamicMap(handler);
|
|
448
|
+
result.query[key] = Object.assign(Object.assign({}, restQuery), { handler: {
|
|
449
|
+
moduleName: handler === null || handler === void 0 ? void 0 : handler.module,
|
|
450
|
+
name: (handler === null || handler === void 0 ? void 0 : handler.name) || '',
|
|
451
|
+
code: (handler === null || handler === void 0 ? void 0 : handler[':code']) || (handler === null || handler === void 0 ? void 0 : handler.code),
|
|
452
|
+
}, data: deserializeDynamicMap(ctx, ((_a = paramsDynamicMap.params) === null || _a === void 0 ? void 0 : _a[0]) || {}), args: deserializeDynamicMap(ctx, paramsDynamicMap), listeners: (_b = listeners === null || listeners === void 0 ? void 0 : listeners.map) === null || _b === void 0 ? void 0 : _b.call(listeners, (listener) => {
|
|
453
|
+
return deserializeListener(ctx, listener);
|
|
454
|
+
}) });
|
|
455
|
+
});
|
|
456
|
+
return result;
|
|
457
|
+
}
|
|
458
|
+
export function normalizeQuery(query) {
|
|
459
|
+
let { dataSourceName, method, handler } = query, restQuery = __rest(query, ["dataSourceName", "method", "handler"]);
|
|
460
|
+
if (dataSourceName && !handler) {
|
|
461
|
+
handler = {
|
|
462
|
+
module: 'platform',
|
|
463
|
+
name: 'cloud.callDataSource',
|
|
464
|
+
params: {
|
|
465
|
+
dataSourceName,
|
|
466
|
+
methodName: (method === null || method === void 0 ? void 0 : method.name) || '',
|
|
467
|
+
params: (method === null || method === void 0 ? void 0 : method.params) || {},
|
|
468
|
+
},
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
return Object.assign(Object.assign({}, restQuery), { handler });
|
|
472
|
+
}
|
|
473
|
+
function serializeDirecties(ctx, directives, scope = 'page') {
|
|
474
|
+
var _a;
|
|
475
|
+
let processed = {
|
|
476
|
+
':if': directives.waIf
|
|
477
|
+
? serializeValue({
|
|
478
|
+
ctx,
|
|
479
|
+
key: 'waIf',
|
|
480
|
+
dynamicValue: directives.waIf,
|
|
481
|
+
scope,
|
|
482
|
+
}).value
|
|
483
|
+
: undefined,
|
|
484
|
+
':for': directives.waFor
|
|
485
|
+
? `${(_a = ctx.component) === null || _a === void 0 ? void 0 : _a.id} in ${serializeValue({
|
|
486
|
+
ctx,
|
|
487
|
+
key: 'waFor',
|
|
488
|
+
dynamicValue: directives.waFor,
|
|
489
|
+
scope,
|
|
490
|
+
}).value}`
|
|
491
|
+
: undefined,
|
|
492
|
+
key: directives.waForKey
|
|
493
|
+
? serializeValue({
|
|
494
|
+
ctx,
|
|
495
|
+
key: 'waForKey',
|
|
496
|
+
dynamicValue: directives.waForKey,
|
|
497
|
+
scope,
|
|
498
|
+
}).value
|
|
499
|
+
: undefined,
|
|
500
|
+
':display': directives.waDisplay
|
|
501
|
+
? serializeValue({
|
|
502
|
+
ctx,
|
|
503
|
+
key: 'waDisplay',
|
|
504
|
+
dynamicValue: directives.waDisplay,
|
|
505
|
+
scope,
|
|
506
|
+
}).value
|
|
507
|
+
: undefined,
|
|
508
|
+
};
|
|
509
|
+
for (let key in processed) {
|
|
510
|
+
let map = processed;
|
|
511
|
+
if (map[key] !== undefined) {
|
|
512
|
+
return processed;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
return undefined;
|
|
516
|
+
}
|
|
517
|
+
function deserializeDirecties(ctx, directives) {
|
|
518
|
+
let waIf = (directives === null || directives === void 0 ? void 0 : directives[':if']) !== undefined ? deserializeValue(ctx, ':if', directives[':if']).value : { value: true };
|
|
519
|
+
let waDisplay = (directives === null || directives === void 0 ? void 0 : directives[':display']) !== undefined
|
|
520
|
+
? deserializeValue(ctx, ':display', directives[':display']).value
|
|
521
|
+
: { value: true };
|
|
522
|
+
let waFor = (directives === null || directives === void 0 ? void 0 : directives[':for']) ? deserializeValue(ctx, ':for', directives[':for']).value : undefined;
|
|
523
|
+
const waForKey = (directives === null || directives === void 0 ? void 0 : directives.key) ? deserializeValue(ctx, 'key', directives.key).value : undefined;
|
|
524
|
+
if (waFor) {
|
|
525
|
+
let { type, value } = waFor;
|
|
526
|
+
if (type === PropBindType.expression) {
|
|
527
|
+
/**
|
|
528
|
+
* 配合 builder render 一起使用
|
|
529
|
+
*/
|
|
530
|
+
waFor.value = value.replace(/^(.*?in\s)/, '');
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
let processed = {
|
|
534
|
+
waIf: (waIf === null || waIf === void 0 ? void 0 : waIf.value) === true ? undefined : waIf,
|
|
535
|
+
waDisplay: (waDisplay === null || waDisplay === void 0 ? void 0 : waDisplay.value) === true ? undefined : waDisplay,
|
|
536
|
+
waFor,
|
|
537
|
+
waForKey,
|
|
538
|
+
};
|
|
539
|
+
for (let key in processed) {
|
|
540
|
+
let map = processed;
|
|
541
|
+
if (map[key] !== undefined) {
|
|
542
|
+
return processed;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
return undefined;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* TODO
|
|
549
|
+
* heander 更新为表达式
|
|
550
|
+
*/
|
|
551
|
+
function serializeListener(ctx, listener) {
|
|
552
|
+
var _a;
|
|
553
|
+
const { data, extra = {} } = serializeDynamicMapWithExtra({
|
|
554
|
+
ctx,
|
|
555
|
+
map: listener.data,
|
|
556
|
+
}) || {};
|
|
557
|
+
const { data: args, extra: argsExtra = {} } = serializeDynamicMapWithExtra({
|
|
558
|
+
ctx,
|
|
559
|
+
map: listener.args || {},
|
|
560
|
+
}) || {};
|
|
561
|
+
const platfromListener = {
|
|
562
|
+
id: listener.key,
|
|
563
|
+
eventName: listener.trigger,
|
|
564
|
+
type: listener.type,
|
|
565
|
+
handler: {
|
|
566
|
+
name: listener.handler.name,
|
|
567
|
+
module: /^comp-\w+$/.test(listener.handler.moduleName)
|
|
568
|
+
? '$comp'
|
|
569
|
+
: listener.type === ActionType.Rematch && ((_a = ctx.page) === null || _a === void 0 ? void 0 : _a.id)
|
|
570
|
+
? ctx.page.id
|
|
571
|
+
: listener.handler.moduleName,
|
|
572
|
+
[':code']: listener.handler.code,
|
|
573
|
+
},
|
|
574
|
+
isCapturePhase: listener.isCapturePhase,
|
|
575
|
+
noPropagation: !!listener.noPropagation,
|
|
576
|
+
};
|
|
577
|
+
if (!listener.args && data) {
|
|
578
|
+
platfromListener.handler.params = data;
|
|
579
|
+
}
|
|
580
|
+
else {
|
|
581
|
+
platfromListener.handler = Object.assign(Object.assign({}, args), platfromListener.handler);
|
|
582
|
+
}
|
|
583
|
+
Object.entries({
|
|
584
|
+
handlerParamExtraData: extra,
|
|
585
|
+
handlerAragsExtraData: argsExtra,
|
|
586
|
+
}).forEach(([key, value]) => {
|
|
587
|
+
if (Object.keys(value).some((k) => extra[k] !== undefined)) {
|
|
588
|
+
if (!platfromListener.extra) {
|
|
589
|
+
platfromListener.extra = {};
|
|
590
|
+
}
|
|
591
|
+
platfromListener.extra[key] = value;
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
return platfromListener;
|
|
595
|
+
}
|
|
596
|
+
function deserializeListener(ctx, listener) {
|
|
597
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
598
|
+
let paramsDynamicMap = generateHandlerParamsDynamicMap(listener.handler);
|
|
599
|
+
let argsExtra = (_a = listener === null || listener === void 0 ? void 0 : listener.extra) === null || _a === void 0 ? void 0 : _a.handlerAragsExtraData;
|
|
600
|
+
if (!argsExtra && ((_b = listener === null || listener === void 0 ? void 0 : listener.extra) === null || _b === void 0 ? void 0 : _b.handlerAragsExtraData)) {
|
|
601
|
+
argsExtra = Object.entries((_c = listener === null || listener === void 0 ? void 0 : listener.extra) === null || _c === void 0 ? void 0 : _c.handlerAragsExtraData).reduce((map, [key, value]) => {
|
|
602
|
+
map[`params.0.${key}`] = value;
|
|
603
|
+
return map;
|
|
604
|
+
}, {});
|
|
605
|
+
}
|
|
606
|
+
let handler = {
|
|
607
|
+
name: (_d = listener.handler) === null || _d === void 0 ? void 0 : _d.name,
|
|
608
|
+
moduleName: (_e = listener.handler) === null || _e === void 0 ? void 0 : _e.module,
|
|
609
|
+
code: ((_f = listener.handler) === null || _f === void 0 ? void 0 : _f[':code']) || ((_g = listener.handler) === null || _g === void 0 ? void 0 : _g.code),
|
|
610
|
+
};
|
|
611
|
+
if (listener.type === ActionType.Rematch && ((_h = ctx.page) === null || _h === void 0 ? void 0 : _h.id)) {
|
|
612
|
+
handler.moduleName = ctx.page.id;
|
|
613
|
+
}
|
|
614
|
+
let processed = {
|
|
615
|
+
key: listener.id,
|
|
616
|
+
trigger: listener.eventName,
|
|
617
|
+
type: listener.type,
|
|
618
|
+
handler,
|
|
619
|
+
data: deserializeDynamicMap(ctx, ((_j = paramsDynamicMap.params) === null || _j === void 0 ? void 0 : _j[0]) || {}, ((_k = listener === null || listener === void 0 ? void 0 : listener.extra) === null || _k === void 0 ? void 0 : _k.handlerParamExtraData) || {}),
|
|
620
|
+
args: deserializeDynamicMap(ctx, paramsDynamicMap, argsExtra),
|
|
621
|
+
isCapturePhase: !!listener.isCapturePhase,
|
|
622
|
+
noPropagation: !!listener.noPropagation,
|
|
623
|
+
};
|
|
624
|
+
return processed;
|
|
625
|
+
}
|
|
626
|
+
function serializeDataVariables(ctx, data) {
|
|
627
|
+
let { title } = data, restData = __rest(data, ["title"]);
|
|
628
|
+
return Object.assign(Object.assign({ varType: 'datasource' }, restData), { label: title });
|
|
629
|
+
}
|
|
630
|
+
export function deserializeDataVariables(_, data) {
|
|
631
|
+
let { label } = data, restData = __rest(data, ["label"]);
|
|
632
|
+
return Object.assign(Object.assign({}, restData), { title: label });
|
|
633
|
+
}
|
|
634
|
+
function serializeCodeSource(_, data) {
|
|
635
|
+
const { type } = data;
|
|
636
|
+
return Object.assign(Object.assign({}, data), { type: EResourceType.CODE, codeType: type });
|
|
637
|
+
}
|
|
638
|
+
function deserializeCodeResource(_, data) {
|
|
639
|
+
const { type, codeType } = data, resData = __rest(data, ["type", "codeType"]);
|
|
640
|
+
return Object.assign(Object.assign({}, resData), { type: codeType });
|
|
641
|
+
}
|
|
642
|
+
function serializeModuleName(ctx, moduleName, componentName) {
|
|
643
|
+
let { dependenciesMap = {} } = ctx;
|
|
644
|
+
const reg = new RegExp(`${SPINOFF_SUFFIX}$`);
|
|
645
|
+
if (moduleName === OFFICIAL_LIB_KEY) {
|
|
646
|
+
moduleName = undefined;
|
|
647
|
+
}
|
|
648
|
+
else if (moduleName &&
|
|
649
|
+
!reg.test(moduleName) &&
|
|
650
|
+
!dependenciesMap[`${moduleName}:${componentName}`] &&
|
|
651
|
+
dependenciesMap[`${moduleName}${SPINOFF_SUFFIX}:${componentName}`]) {
|
|
652
|
+
return `${moduleName}${SPINOFF_SUFFIX}`;
|
|
653
|
+
}
|
|
654
|
+
return moduleName;
|
|
655
|
+
}
|
|
656
|
+
function deserializeModuleName({ dependenciesMap = {} }, componentName, moduleName) {
|
|
657
|
+
const reg = new RegExp(`${SPINOFF_SUFFIX}$`);
|
|
658
|
+
/**
|
|
659
|
+
* 无组件库名 且 有组件名
|
|
660
|
+
*/
|
|
661
|
+
if (!moduleName && componentName) {
|
|
662
|
+
return OFFICIAL_LIB_KEY;
|
|
663
|
+
}
|
|
664
|
+
else if (moduleName &&
|
|
665
|
+
!reg.test(moduleName) &&
|
|
666
|
+
!dependenciesMap[`${moduleName}:${componentName}`] &&
|
|
667
|
+
dependenciesMap[`${moduleName}${SPINOFF_SUFFIX}:${componentName}`]) {
|
|
668
|
+
return `${moduleName}${SPINOFF_SUFFIX}`;
|
|
669
|
+
}
|
|
670
|
+
return moduleName;
|
|
671
|
+
}
|
|
672
|
+
function serializeXIndex(ctx, list) {
|
|
673
|
+
return list
|
|
674
|
+
.sort((a, b) => { var _a, _b; return (((_a = a.extra) === null || _a === void 0 ? void 0 : _a.xIndex) || 0) - (((_b = b.extra) === null || _b === void 0 ? void 0 : _b.xIndex) || 0); })
|
|
675
|
+
.map((component) => {
|
|
676
|
+
const { extra } = component, restComponent = __rest(component, ["extra"]);
|
|
677
|
+
const _a = extra || {}, { xIndex } = _a, restExtra = __rest(_a, ["xIndex"]);
|
|
678
|
+
return Object.assign(Object.assign({}, restComponent), { extra: extra ? restExtra : undefined });
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
export function serializeComponent(ctx, component, scope = 'page') {
|
|
682
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
683
|
+
// const scope = ctx.component?.id ? 'component' : 'page'
|
|
684
|
+
const moduleName = (_a = component.xComponent) === null || _a === void 0 ? void 0 : _a.moduleName;
|
|
685
|
+
const componentName = ((_b = component.xComponent) === null || _b === void 0 ? void 0 : _b.name) || '';
|
|
686
|
+
const componentCtx = Object.assign(Object.assign({}, ctx), { component: {
|
|
687
|
+
id: component.id,
|
|
688
|
+
module: moduleName,
|
|
689
|
+
component: (_c = component.xComponent) === null || _c === void 0 ? void 0 : _c.name,
|
|
690
|
+
} });
|
|
691
|
+
if (componentCtx.dependencies && !componentCtx.dependenciesMap) {
|
|
692
|
+
componentCtx.dependenciesMap = processDependenceList2Map(componentCtx.dependencies || []);
|
|
693
|
+
}
|
|
694
|
+
let attributeMeta = serializeAttributesWithExtra(componentCtx, scope, (((_d = component === null || component === void 0 ? void 0 : component.xProps) === null || _d === void 0 ? void 0 : _d.data) || {})) || {};
|
|
695
|
+
const { data: attributes = {}, extra: attributeExtraData = {} } = attributeMeta;
|
|
696
|
+
let classListBindData = null;
|
|
697
|
+
let styleBindData = null;
|
|
698
|
+
if ((_e = component === null || component === void 0 ? void 0 : component.xProps) === null || _e === void 0 ? void 0 : _e.classListBind) {
|
|
699
|
+
classListBindData = serializeValue({
|
|
700
|
+
ctx: componentCtx,
|
|
701
|
+
key: 'classListBind',
|
|
702
|
+
dynamicValue: (_f = component === null || component === void 0 ? void 0 : component.xProps) === null || _f === void 0 ? void 0 : _f.classListBind,
|
|
703
|
+
scope,
|
|
704
|
+
});
|
|
705
|
+
if (classListBindData.extra) {
|
|
706
|
+
attributeExtraData.class = classListBindData.extra;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
if ((_g = component === null || component === void 0 ? void 0 : component.xProps) === null || _g === void 0 ? void 0 : _g.styleBind) {
|
|
710
|
+
styleBindData = serializeValue({
|
|
711
|
+
ctx: componentCtx,
|
|
712
|
+
key: 'styleBind',
|
|
713
|
+
dynamicValue: (_h = component === null || component === void 0 ? void 0 : component.xProps) === null || _h === void 0 ? void 0 : _h.styleBind,
|
|
714
|
+
});
|
|
715
|
+
if (styleBindData.extra) {
|
|
716
|
+
attributeExtraData.style = styleBindData.extra;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
return {
|
|
720
|
+
id: component.id,
|
|
721
|
+
label: getValidValue(component.label),
|
|
722
|
+
type: undefined,
|
|
723
|
+
module: serializeModuleName(componentCtx, moduleName, componentName),
|
|
724
|
+
component: componentName,
|
|
725
|
+
attributes: getValidValue(component.xProps
|
|
726
|
+
? Object.assign(Object.assign({}, attributes), { style: (_j = component.xProps) === null || _j === void 0 ? void 0 : _j.style, class: (_l = (_k = component.xProps) === null || _k === void 0 ? void 0 : _k.classList) === null || _l === void 0 ? void 0 : _l.join(' ') }) : undefined),
|
|
727
|
+
items: component.properties
|
|
728
|
+
? serializeXIndex(componentCtx, Object.keys(component.properties).map((key) => {
|
|
729
|
+
var _a;
|
|
730
|
+
return serializeComponent(componentCtx, Object.assign({ id: key }, (_a = component.properties) === null || _a === void 0 ? void 0 : _a[key]), scope);
|
|
731
|
+
}))
|
|
732
|
+
: undefined,
|
|
733
|
+
listeners: getValidValue((_o = (_m = component.xProps) === null || _m === void 0 ? void 0 : _m.listeners) === null || _o === void 0 ? void 0 : _o.map((listener) => {
|
|
734
|
+
return serializeListener(componentCtx, listener);
|
|
735
|
+
})),
|
|
736
|
+
directives: serializeDirecties(componentCtx, (((_p = component.xProps) === null || _p === void 0 ? void 0 : _p.directives) || {}), scope) || {
|
|
737
|
+
':if': true,
|
|
738
|
+
},
|
|
739
|
+
':class': classListBindData ? classListBindData.value : undefined,
|
|
740
|
+
':style': styleBindData ? styleBindData.value : undefined,
|
|
741
|
+
scopedStyle: getValidValue((_q = component.xProps) === null || _q === void 0 ? void 0 : _q.scopedStyle),
|
|
742
|
+
extra: Object.assign({ commonStyle: (_r = component.xProps) === null || _r === void 0 ? void 0 : _r.commonStyle, xIndex: component.xIndex, styleBindPath: (_s = component === null || component === void 0 ? void 0 : component.xProps) === null || _s === void 0 ? void 0 : _s.styleBindPath, staticResourceAttribute: (_t = component === null || component === void 0 ? void 0 : component.xProps) === null || _t === void 0 ? void 0 : _t.staticResourceAttribute, attributeExtraData: isEmptyObj(attributeExtraData) ? undefined : attributeExtraData, anchored: getValidValue(component.anchored), dataForm: getValidValue(component.dataForm) }, (ctx.dereference
|
|
743
|
+
? {}
|
|
744
|
+
: {
|
|
745
|
+
ref: getValidValue(component.ref),
|
|
746
|
+
include: getValidValue(component.include),
|
|
747
|
+
refAttributes: getValidValue(component.refAttributes),
|
|
748
|
+
})),
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
export function deserializeComponent(ctx, components) {
|
|
752
|
+
let componentMap = components.reduce((map, item, index) => {
|
|
753
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
754
|
+
const { attributeExtraData = {} } = item.extra || {};
|
|
755
|
+
let dynamicStyle = item[':style']
|
|
756
|
+
? deserializeValue(ctx, ':style', item[':style'], attributeExtraData.style).value
|
|
757
|
+
: undefined;
|
|
758
|
+
let dynamicClassList = item[':class']
|
|
759
|
+
? deserializeValue(ctx, ':class', item[':class'], attributeExtraData.class).value
|
|
760
|
+
: undefined;
|
|
761
|
+
const xComponent = {
|
|
762
|
+
moduleName: item.module,
|
|
763
|
+
name: item.component || undefined,
|
|
764
|
+
};
|
|
765
|
+
if (xComponent.name) {
|
|
766
|
+
xComponent.moduleName =
|
|
767
|
+
deserializeModuleName({ dependenciesMap: ctx.dependenciesMap }, xComponent.name, xComponent.moduleName) ||
|
|
768
|
+
xComponent.moduleName;
|
|
769
|
+
}
|
|
770
|
+
const xProps = {
|
|
771
|
+
data: deserializeAttributes(ctx, item.attributes, attributeExtraData),
|
|
772
|
+
directives: deserializeDirecties(ctx, item.directives || {}),
|
|
773
|
+
style: (_a = item.attributes) === null || _a === void 0 ? void 0 : _a.style,
|
|
774
|
+
styleBind: dynamicStyle
|
|
775
|
+
? {
|
|
776
|
+
type: dynamicStyle.type,
|
|
777
|
+
value: dynamicStyle.value,
|
|
778
|
+
}
|
|
779
|
+
: undefined,
|
|
780
|
+
commonStyle: (_b = item === null || item === void 0 ? void 0 : item.extra) === null || _b === void 0 ? void 0 : _b.commonStyle,
|
|
781
|
+
scopedStyle: (item === null || item === void 0 ? void 0 : item.scopedStyle) || undefined,
|
|
782
|
+
staticResourceAttribute: (_c = item === null || item === void 0 ? void 0 : item.extra) === null || _c === void 0 ? void 0 : _c.staticResourceAttribute,
|
|
783
|
+
classList: (_f = (_e = (_d = item.attributes) === null || _d === void 0 ? void 0 : _d.class) === null || _e === void 0 ? void 0 : _e.split(/\s/g)) === null || _f === void 0 ? void 0 : _f.filter((className) => !!className),
|
|
784
|
+
classListBind: item[':class']
|
|
785
|
+
? {
|
|
786
|
+
value: dynamicClassList === null || dynamicClassList === void 0 ? void 0 : dynamicClassList.value,
|
|
787
|
+
type: dynamicClassList === null || dynamicClassList === void 0 ? void 0 : dynamicClassList.type,
|
|
788
|
+
}
|
|
789
|
+
: undefined,
|
|
790
|
+
listeners: ((_g = item === null || item === void 0 ? void 0 : item.listeners) === null || _g === void 0 ? void 0 : _g.map((item) => {
|
|
791
|
+
return deserializeListener(ctx, item);
|
|
792
|
+
})) || [],
|
|
793
|
+
};
|
|
794
|
+
let processed = Object.assign({ xComponent: Object.values(xComponent).find((item) => item != undefined) ? xComponent : undefined, xProps: Object.values(xProps).find((item) => {
|
|
795
|
+
if (Array.isArray(item)) {
|
|
796
|
+
return !!item.length;
|
|
797
|
+
}
|
|
798
|
+
return item !== undefined && !isEmptyObj(item);
|
|
799
|
+
})
|
|
800
|
+
? xProps
|
|
801
|
+
: undefined, xIndex: ((_h = item.extra) === null || _h === void 0 ? void 0 : _h.xIndex) !== undefined ? (_j = item.extra) === null || _j === void 0 ? void 0 : _j.xIndex : index, label: (item === null || item === void 0 ? void 0 : item.label) !== undefined ? item === null || item === void 0 ? void 0 : item.label : undefined, properties: item.items ? deserializeComponent(ctx, item.items) : undefined, anchored: (_k = item === null || item === void 0 ? void 0 : item.extra) === null || _k === void 0 ? void 0 : _k.anchored, dataForm: (_l = item === null || item === void 0 ? void 0 : item.extra) === null || _l === void 0 ? void 0 : _l.dataForm }, (ctx.dereference
|
|
802
|
+
? {}
|
|
803
|
+
: {
|
|
804
|
+
include: getValidValue((_m = item === null || item === void 0 ? void 0 : item.extra) === null || _m === void 0 ? void 0 : _m.include),
|
|
805
|
+
ref: getValidValue((_o = item === null || item === void 0 ? void 0 : item.extra) === null || _o === void 0 ? void 0 : _o.ref),
|
|
806
|
+
refAttributes: getValidValue((_p = item === null || item === void 0 ? void 0 : item.extra) === null || _p === void 0 ? void 0 : _p.refAttributes),
|
|
807
|
+
}));
|
|
808
|
+
map[item.id] = processed;
|
|
809
|
+
return map;
|
|
810
|
+
}, {});
|
|
811
|
+
return componentMap;
|
|
812
|
+
}
|
|
813
|
+
export function serializePage(ctx, page) {
|
|
814
|
+
var _a, _b, _c, _d, _e, _f;
|
|
815
|
+
const pageCtx = Object.assign(Object.assign({}, ctx), { page });
|
|
816
|
+
if (pageCtx.dependencies && !pageCtx.dependenciesMap) {
|
|
817
|
+
pageCtx.dependenciesMap = processDependenceList2Map(pageCtx.dependencies || []);
|
|
818
|
+
}
|
|
819
|
+
let processedPage = {
|
|
820
|
+
id: page.id,
|
|
821
|
+
type: 'PAGE',
|
|
822
|
+
component: 'Page',
|
|
823
|
+
attributes: getValidValue((_a = serializeAttributesWithExtra(pageCtx, 'page', page.data)) === null || _a === void 0 ? void 0 : _a.data),
|
|
824
|
+
items: serializeXIndex(pageCtx, Object.keys(page.componentInstances || {}).map((id) => {
|
|
825
|
+
return serializeComponent(pageCtx, Object.assign({ id }, page.componentInstances[id]));
|
|
826
|
+
})),
|
|
827
|
+
directives: {
|
|
828
|
+
':if': true,
|
|
829
|
+
},
|
|
830
|
+
resources: (_b = page === null || page === void 0 ? void 0 : page.lowCodes) === null || _b === void 0 ? void 0 : _b.map((item) => serializeCodeSource(pageCtx, item)),
|
|
831
|
+
dataset: serializeDataset(ctx, page === null || page === void 0 ? void 0 : page.dataset),
|
|
832
|
+
dataVariables: getValidValue((_d = (_c = page === null || page === void 0 ? void 0 : page.vars) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.map((item) => serializeDataVariables(pageCtx, item))),
|
|
833
|
+
listeners: getValidValue((_e = ((page === null || page === void 0 ? void 0 : page.listeners) || [])) === null || _e === void 0 ? void 0 : _e.map((item) => {
|
|
834
|
+
return serializeListener(pageCtx, item);
|
|
835
|
+
}).concat(((_f = page === null || page === void 0 ? void 0 : page.eventFlows) === null || _f === void 0 ? void 0 : _f.reduce((list, flow) => {
|
|
836
|
+
var _a;
|
|
837
|
+
list.push(...(((_a = flow.listeners) === null || _a === void 0 ? void 0 : _a.map((item) => serializeListener(pageCtx, item))) || []));
|
|
838
|
+
return list;
|
|
839
|
+
}, [])) || [])),
|
|
840
|
+
extra: {
|
|
841
|
+
commonStyle: page === null || page === void 0 ? void 0 : page.commonStyle,
|
|
842
|
+
xIndex: page.xIndex,
|
|
843
|
+
staticResourceAttribute: page === null || page === void 0 ? void 0 : page.staticResourceAttribute,
|
|
844
|
+
hideAdminPortalMenu: page === null || page === void 0 ? void 0 : page.hideAdminPortalMenu,
|
|
845
|
+
},
|
|
846
|
+
};
|
|
847
|
+
if (page.style) {
|
|
848
|
+
lodashSet(processedPage, 'attributes.style', page.style);
|
|
849
|
+
}
|
|
850
|
+
if (page.styleBind) {
|
|
851
|
+
processedPage[':style'] = serializeValue({
|
|
852
|
+
ctx: pageCtx,
|
|
853
|
+
key: 'styleBind',
|
|
854
|
+
dynamicValue: page.styleBind,
|
|
855
|
+
}).value;
|
|
856
|
+
}
|
|
857
|
+
else if (page.styleBindPath) {
|
|
858
|
+
processedPage[':style'] = page.styleBindPath;
|
|
859
|
+
}
|
|
860
|
+
if (page.classListBind) {
|
|
861
|
+
processedPage[':class'] = serializeValue({
|
|
862
|
+
ctx: pageCtx,
|
|
863
|
+
key: 'classListBind',
|
|
864
|
+
dynamicValue: page.classListBind,
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
return processedPage;
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* 序列化布局
|
|
871
|
+
*/
|
|
872
|
+
export function serializeLayouts(ctx, layouts = {}) {
|
|
873
|
+
return Object.entries(layouts).map(([layoutId, layout]) => {
|
|
874
|
+
var _a;
|
|
875
|
+
const layoutExtraDetail = { name: layout.name, label: layout.label };
|
|
876
|
+
const temp = Object.assign({}, serializePage(ctx, layout));
|
|
877
|
+
const { type, component, attributes, directives, resources, dataVariables, listeners, extra } = temp, rest = __rest(temp, ["type", "component", "attributes", "directives", "resources", "dataVariables", "listeners", "extra"]);
|
|
878
|
+
return Object.assign(Object.assign(Object.assign({}, rest), { data: (_a = layout === null || layout === void 0 ? void 0 : layout.data) !== null && _a !== void 0 ? _a : {} }), layoutExtraDetail);
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
export function deserializePage(ctx, page) {
|
|
882
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
883
|
+
const { homePageId } = ctx, _pageCtx = __rest(ctx, ["homePageId"]);
|
|
884
|
+
let pageCtx = Object.assign(Object.assign({}, _pageCtx), { page });
|
|
885
|
+
let dynamicStyle = page[':style']
|
|
886
|
+
? deserializeValue(pageCtx, ':style', page[':style'], (_b = (_a = page === null || page === void 0 ? void 0 : page.extra) === null || _a === void 0 ? void 0 : _a.attributeExtraData) === null || _b === void 0 ? void 0 : _b.style).value
|
|
887
|
+
: undefined;
|
|
888
|
+
const instance = deserializeInstance(pageCtx, page);
|
|
889
|
+
return Object.assign(Object.assign({}, instance), { isHome: page.id === homePageId, vars: {
|
|
890
|
+
data: ((_c = page.dataVariables) === null || _c === void 0 ? void 0 : _c.map((item) => {
|
|
891
|
+
return deserializeDataVariables(undefined, item);
|
|
892
|
+
})) || [],
|
|
893
|
+
}, data: deserializeAttributes(pageCtx, page.attributes, (_d = page === null || page === void 0 ? void 0 : page.extra) === null || _d === void 0 ? void 0 : _d.attributeExtraData), style: (_e = page.attributes) === null || _e === void 0 ? void 0 : _e.style, commonStyle: (_f = page === null || page === void 0 ? void 0 : page.extra) === null || _f === void 0 ? void 0 : _f.commonStyle, staticResourceAttribute: (_g = page === null || page === void 0 ? void 0 : page.extra) === null || _g === void 0 ? void 0 : _g.staticResourceAttribute, hideAdminPortalMenu: (_h = page === null || page === void 0 ? void 0 : page.extra) === null || _h === void 0 ? void 0 : _h.hideAdminPortalMenu,
|
|
894
|
+
// TODO
|
|
895
|
+
// children: [],
|
|
896
|
+
styleBindPath: (dynamicStyle === null || dynamicStyle === void 0 ? void 0 : dynamicStyle.value) || undefined });
|
|
897
|
+
}
|
|
898
|
+
function deserializeInstance(ctx, instance, scope = 'page') {
|
|
899
|
+
var _a;
|
|
900
|
+
const instanceCtx = Object.assign(Object.assign({}, ctx), { page: scope === 'page' ? instance : undefined });
|
|
901
|
+
const { listeners = [], eventFlows } = processListeners((instance === null || instance === void 0 ? void 0 : instance.listeners) || []);
|
|
902
|
+
return {
|
|
903
|
+
id: instance.id || instance.name,
|
|
904
|
+
dataset: deserializeDataset(ctx, instance.dataset),
|
|
905
|
+
componentInstances: deserializeComponent(instanceCtx, instance.items || []),
|
|
906
|
+
lowCodes: (_a = instance === null || instance === void 0 ? void 0 : instance.resources) === null || _a === void 0 ? void 0 : _a.filter((item) => item.type === EResourceType.CODE && item.name !== ECodeName.PLACEHOLDER).map((item) => deserializeCodeResource(undefined, item)),
|
|
907
|
+
listeners: (listeners === null || listeners === void 0 ? void 0 : listeners.map((item) => {
|
|
908
|
+
return deserializeListener(ctx, item);
|
|
909
|
+
})) || [],
|
|
910
|
+
eventFlows: (eventFlows === null || eventFlows === void 0 ? void 0 : eventFlows.map((eventFlow) => {
|
|
911
|
+
var _a, _b;
|
|
912
|
+
return Object.assign(Object.assign({}, eventFlow), { listeners: ((_b = (_a = eventFlow.listeners) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, (item) => {
|
|
913
|
+
return deserializeListener(ctx, item);
|
|
914
|
+
})) || [] });
|
|
915
|
+
})) || [],
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* [WeApps协议] to [CALS协议]
|
|
920
|
+
*
|
|
921
|
+
* @param data
|
|
922
|
+
* @param optsions
|
|
923
|
+
*/
|
|
924
|
+
export function serializePlatformApp(data, optsions) {
|
|
925
|
+
var _a;
|
|
926
|
+
let { version, author, name, label, description, selectedPageId, pageInstanceList, lowCodes = [], datasources, vars, dataset, extra, dependencies: calsDependencies, miniprogramPlugins, lastDependencies, externalResources, schemaVersion, layouts, theme, componentPropsDatas } = data, restData = __rest(data, ["version", "author", "name", "label", "description", "selectedPageId", "pageInstanceList", "lowCodes", "datasources", "vars", "dataset", "extra", "dependencies", "miniprogramPlugins", "lastDependencies", "externalResources", "schemaVersion", "layouts", "theme", "componentPropsDatas"]);
|
|
927
|
+
let { dependencies = [] } = optsions || {};
|
|
928
|
+
const _b = extra || {}, { name: extraName, label: extraLabel, author: extraAuthor, description: extraDescription } = _b, restExtra = __rest(_b, ["name", "label", "author", "description"]);
|
|
929
|
+
const ctx = {
|
|
930
|
+
app: data,
|
|
931
|
+
dependencies,
|
|
932
|
+
dependenciesMap: processDependenceList2Map(dependencies),
|
|
933
|
+
};
|
|
934
|
+
const homePage = pageInstanceList === null || pageInstanceList === void 0 ? void 0 : pageInstanceList.find((page) => page.isHome);
|
|
935
|
+
let processed = {
|
|
936
|
+
label: label || extraLabel,
|
|
937
|
+
name: name || extraName,
|
|
938
|
+
author: author || extraAuthor,
|
|
939
|
+
version,
|
|
940
|
+
schemaVersion,
|
|
941
|
+
description: description || extraDescription,
|
|
942
|
+
externalResources,
|
|
943
|
+
main: homePage ? homePage.id : ((_a = pageInstanceList === null || pageInstanceList === void 0 ? void 0 : pageInstanceList[0]) === null || _a === void 0 ? void 0 : _a.id) || selectedPageId,
|
|
944
|
+
items: pageInstanceList === null || pageInstanceList === void 0 ? void 0 : pageInstanceList.map((page) => serializePage(ctx, page)),
|
|
945
|
+
resources: lowCodes === null || lowCodes === void 0 ? void 0 : lowCodes.map((item) => serializeCodeSource(ctx, item)),
|
|
946
|
+
dataSources: datasources,
|
|
947
|
+
dataset: serializeDataset(ctx, dataset),
|
|
948
|
+
dataVariables: getValidValue(vars === null || vars === void 0 ? void 0 : vars.data.map((item) => serializeDataVariables(ctx, item))),
|
|
949
|
+
dependencies: calsDependencies,
|
|
950
|
+
templates: serializeLayouts(ctx, layouts),
|
|
951
|
+
theme,
|
|
952
|
+
extra: Object.assign(Object.assign(Object.assign({}, restExtra), restData), { miniprogramPlugins, historyType: data.historyType, npmDependencies: data.npmDependencies || {}, plugins: data.plugins, maxID: data.maxID, rootPath: data.rootPath, themeVars: data.themeVars, presetColors: data.presetColors, appConfig: data.appConfig, lastDependencies, componentPropsDatas: componentPropsDatas instanceof Map
|
|
953
|
+
? JSON.parse(JSON.stringify(componentPropsDatas)) // map 序列化为普通数组(componentPropsDatas 是嵌套 map 结构)
|
|
954
|
+
: componentPropsDatas }),
|
|
955
|
+
};
|
|
956
|
+
return processed;
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* [CALS协议] to [WeApps协议]
|
|
960
|
+
*
|
|
961
|
+
* @param data
|
|
962
|
+
*/
|
|
963
|
+
export function deserializePlatformApp(data, optsions) {
|
|
964
|
+
var _a, _b;
|
|
965
|
+
let homePageId = data.main || ((_a = data.items[0]) === null || _a === void 0 ? void 0 : _a.id) || '';
|
|
966
|
+
let extra = data.extra || {};
|
|
967
|
+
const { historyType, npmDependencies, plugins, maxID, rootPath, themeVars, presetColors, appConfig, miniprogramPlugins, compHiddenConfig, lastDependencies } = extra, restExtra = __rest(extra, ["historyType", "npmDependencies", "plugins", "maxID", "rootPath", "themeVars", "presetColors", "appConfig", "miniprogramPlugins", "compHiddenConfig", "lastDependencies"]);
|
|
968
|
+
const ctx = {
|
|
969
|
+
app: data,
|
|
970
|
+
dependencies: (optsions === null || optsions === void 0 ? void 0 : optsions.dependencies) || [],
|
|
971
|
+
homePageId,
|
|
972
|
+
dependenciesMap: processDependenceList2Map(((optsions === null || optsions === void 0 ? void 0 : optsions.dependencies) || [])),
|
|
973
|
+
};
|
|
974
|
+
let processed = {
|
|
975
|
+
id: data.id,
|
|
976
|
+
version: data.version,
|
|
977
|
+
author: data.author,
|
|
978
|
+
name: data.name,
|
|
979
|
+
label: data.label,
|
|
980
|
+
description: data.description,
|
|
981
|
+
selectedPageId: homePageId,
|
|
982
|
+
historyType,
|
|
983
|
+
theme: data.theme,
|
|
984
|
+
pageInstanceList: (data.items || []).map((page) => deserializePage(ctx, page)),
|
|
985
|
+
// lowCodes: data.resources || [],
|
|
986
|
+
lowCodes: (data.resources || [])
|
|
987
|
+
.filter((item) => item.type === EResourceType.CODE && item.name !== ECodeName.PLACEHOLDER)
|
|
988
|
+
.map((item) => deserializeCodeResource(undefined, item)),
|
|
989
|
+
datasources: data.dataSources,
|
|
990
|
+
dataset: deserializeDataset(ctx, data.dataset),
|
|
991
|
+
vars: {
|
|
992
|
+
data: ((_b = data.dataVariables) === null || _b === void 0 ? void 0 : _b.map((item) => {
|
|
993
|
+
return deserializeDataVariables(undefined, item);
|
|
994
|
+
})) || [],
|
|
995
|
+
},
|
|
996
|
+
compHiddenConfig: compHiddenConfig || {},
|
|
997
|
+
npmDependencies: npmDependencies || {},
|
|
998
|
+
plugins: plugins || [],
|
|
999
|
+
maxID,
|
|
1000
|
+
rootPath,
|
|
1001
|
+
themeVars,
|
|
1002
|
+
presetColors: presetColors || [],
|
|
1003
|
+
appConfig,
|
|
1004
|
+
miniprogramPlugins,
|
|
1005
|
+
externalResources: data.externalResources,
|
|
1006
|
+
extra: Object.assign(Object.assign({}, restExtra), { name: data.name, author: data.author, description: data.description, lastDependencies }),
|
|
1007
|
+
dependencies: data.dependencies,
|
|
1008
|
+
// TODO
|
|
1009
|
+
// emitEvents: [], { "name": "自定义校验规则", "eventName": "validator" }
|
|
1010
|
+
schemaVersion: data.schemaVersion,
|
|
1011
|
+
layouts: deserializeTemplates(ctx, data.templates || []),
|
|
1012
|
+
};
|
|
1013
|
+
return processed;
|
|
1014
|
+
}
|
|
1015
|
+
export function deserializeCompositeComponent(component, options) {
|
|
1016
|
+
const ctx = {
|
|
1017
|
+
dependencies: (options === null || options === void 0 ? void 0 : options.dependencies) || [],
|
|
1018
|
+
dependenciesMap: processDependenceList2Map(((options === null || options === void 0 ? void 0 : options.dependencies) || [])),
|
|
1019
|
+
};
|
|
1020
|
+
return deserializeInstance(ctx, component);
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* page
|
|
1024
|
+
* [formily] to [CALS]
|
|
1025
|
+
* @deprecated 已过时,使用会产生意外错误,如不包含事件流
|
|
1026
|
+
*/
|
|
1027
|
+
export function serializeRuntimePage(ctx, page) {
|
|
1028
|
+
var _a, _b, _c, _d, _e;
|
|
1029
|
+
const pageCtx = Object.assign(Object.assign({}, ctx), { dependenciesMap: processDependenceList2Map(ctx.dependencies || []), page: { id: page.id } });
|
|
1030
|
+
let processedPage = {
|
|
1031
|
+
id: page.id,
|
|
1032
|
+
type: 'PAGE',
|
|
1033
|
+
component: 'Page',
|
|
1034
|
+
attributes: (_a = serializeAttributesWithExtra(pageCtx, 'page', readDynamicData(page))) === null || _a === void 0 ? void 0 : _a.data,
|
|
1035
|
+
items: getValidValue(Object.keys(((_b = page.componentSchemaJson) === null || _b === void 0 ? void 0 : _b.properties) || {}).map((id) => {
|
|
1036
|
+
var _a;
|
|
1037
|
+
return serializeRuntimeComponent(pageCtx, Object.assign({ id }, (_a = page.componentSchemaJson) === null || _a === void 0 ? void 0 : _a.properties[id]));
|
|
1038
|
+
})),
|
|
1039
|
+
resources: (_c = page === null || page === void 0 ? void 0 : page.codeModules) === null || _c === void 0 ? void 0 : _c.map((item) => serializeCodeSource(pageCtx, item)),
|
|
1040
|
+
/**
|
|
1041
|
+
* 感觉此处有问题,状态应该无法直接透传才对
|
|
1042
|
+
*/
|
|
1043
|
+
dataset: serializeRuntimeDataset(pageCtx, page === null || page === void 0 ? void 0 : page.dataset),
|
|
1044
|
+
dataVariables: getValidValue((_e = (_d = page === null || page === void 0 ? void 0 : page.vars) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.map((item) => serializeDataVariables(pageCtx, item))),
|
|
1045
|
+
listeners: getValidValue(readListeners(page.listenerInstances || []).map((item) => {
|
|
1046
|
+
return serializeListener(pageCtx, item);
|
|
1047
|
+
})),
|
|
1048
|
+
extra: {
|
|
1049
|
+
commonStyle: getValidValue(removeInvalidStyleFormValue(page.style)),
|
|
1050
|
+
styleBindPath: getValidValue(page.styleBindPath),
|
|
1051
|
+
xIndex: page.xIndex,
|
|
1052
|
+
},
|
|
1053
|
+
};
|
|
1054
|
+
if (isValidStyleBind(page.styleBind) && getValidValue(page.styleBind)) {
|
|
1055
|
+
page[':style'] = serializeValue({
|
|
1056
|
+
ctx: pageCtx,
|
|
1057
|
+
key: 'styleBind',
|
|
1058
|
+
dynamicValue: page.styleBind,
|
|
1059
|
+
}).value;
|
|
1060
|
+
}
|
|
1061
|
+
if (isValidClassNameListBind(page.classListBind) && getValidValue(page.classListBind)) {
|
|
1062
|
+
page[':class'] = serializeValue({
|
|
1063
|
+
ctx: pageCtx,
|
|
1064
|
+
key: 'classListBind',
|
|
1065
|
+
dynamicValue: page.classListBind,
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
1068
|
+
return processedPage;
|
|
1069
|
+
}
|
|
1070
|
+
export function serializeRuntimeDataset(ctx, dataset) {
|
|
1071
|
+
if (!dataset) {
|
|
1072
|
+
return dataset;
|
|
1073
|
+
}
|
|
1074
|
+
const { query } = dataset, resetDataset = __rest(dataset, ["query"]);
|
|
1075
|
+
return Object.assign(Object.assign({}, resetDataset), { query: query
|
|
1076
|
+
? Object.entries(query).reduce((map, [key, query]) => {
|
|
1077
|
+
var _a;
|
|
1078
|
+
let { dataSourceName, listenerInstances, method, handler, data, dataTypes, dataBinds } = query, restQuey = __rest(query, ["dataSourceName", "listenerInstances", "method", "handler", "data", "dataTypes", "dataBinds"]);
|
|
1079
|
+
if (dataSourceName && !handler) {
|
|
1080
|
+
let { data: paramsData, dataBinds: paramsDataBinds = [], dataTypes: paramsDataTypes = [] } = method || {};
|
|
1081
|
+
handler = {
|
|
1082
|
+
moduleName: 'platform',
|
|
1083
|
+
name: 'cloud.callDataSource',
|
|
1084
|
+
};
|
|
1085
|
+
data = {
|
|
1086
|
+
dataSourceName,
|
|
1087
|
+
methodName: method === null || method === void 0 ? void 0 : method.name,
|
|
1088
|
+
params: paramsData,
|
|
1089
|
+
};
|
|
1090
|
+
dataTypes =
|
|
1091
|
+
paramsDataTypes.map((item) => (Object.assign(Object.assign({}, item), { propertyPath: `params.${item.propertyPath}` }))) || [];
|
|
1092
|
+
dataBinds = paramsDataBinds === null || paramsDataBinds === void 0 ? void 0 : paramsDataBinds.map((bind) => (Object.assign(Object.assign({}, bind), { propertyPath: `params.${bind.propertyPath}` })));
|
|
1093
|
+
}
|
|
1094
|
+
map[key] = Object.assign(Object.assign({}, restQuey), { handler: {
|
|
1095
|
+
module: 'platform',
|
|
1096
|
+
name: 'cloud.callDataSource',
|
|
1097
|
+
params: serializeAttributesWithExtra(ctx, 'page', getValidValue(readDynamicData({ data, dataTypes, dataBinds })) || {}).data || {},
|
|
1098
|
+
}, listeners: (_a = getValidValue(readListeners(listenerInstances || []))) === null || _a === void 0 ? void 0 : _a.map((listener /* IEventListener */) => {
|
|
1099
|
+
return serializeListener(ctx, listener);
|
|
1100
|
+
}) });
|
|
1101
|
+
return map;
|
|
1102
|
+
}, {})
|
|
1103
|
+
: query });
|
|
1104
|
+
}
|
|
1105
|
+
// /**
|
|
1106
|
+
// * page
|
|
1107
|
+
// * [CALS] to [formily]
|
|
1108
|
+
// */
|
|
1109
|
+
// export function deserializeRuntimePage(
|
|
1110
|
+
// ctx,
|
|
1111
|
+
// page: IPageComponent
|
|
1112
|
+
// ): IPageInstance {}
|
|
1113
|
+
/**
|
|
1114
|
+
* component
|
|
1115
|
+
* [formily] to [CALS]
|
|
1116
|
+
*/
|
|
1117
|
+
export function serializeRuntimeComponent(ctx, component) {
|
|
1118
|
+
var _a, _b, _c;
|
|
1119
|
+
if (!component.id) {
|
|
1120
|
+
component.id = component.key;
|
|
1121
|
+
}
|
|
1122
|
+
let processed = {
|
|
1123
|
+
id: component.id,
|
|
1124
|
+
type: undefined,
|
|
1125
|
+
component: '',
|
|
1126
|
+
label: getValidValue(component.label),
|
|
1127
|
+
};
|
|
1128
|
+
let props = component['x-props'];
|
|
1129
|
+
const { dependencies = [] } = ctx;
|
|
1130
|
+
if (props === null || props === void 0 ? void 0 : props.sourceKey) {
|
|
1131
|
+
const [moduleName, name = ''] = props.sourceKey.split(':');
|
|
1132
|
+
const componentCtx = Object.assign(Object.assign({}, ctx), { component: { id: component.id, module: moduleName, component: name } });
|
|
1133
|
+
if (componentCtx.dependencies && !componentCtx.dependenciesMap) {
|
|
1134
|
+
componentCtx.dependenciesMap = processDependenceList2Map(componentCtx.dependencies || []);
|
|
1135
|
+
}
|
|
1136
|
+
const excludeKeys = (props.dataTypes || [])
|
|
1137
|
+
.filter((dataType) => dataType.type !== 'slot')
|
|
1138
|
+
.map((dataType) => dataType.propertyPath);
|
|
1139
|
+
let properties = component.properties || {};
|
|
1140
|
+
const { data: attributes = {}, extra: attributeExtraData = {} } = serializeAttributesWithExtra(componentCtx, 'page', getValidValue(readDynamicData(props)) || {}) || {};
|
|
1141
|
+
let styleBindData = null;
|
|
1142
|
+
let classListBindData = null;
|
|
1143
|
+
if ((_a = props === null || props === void 0 ? void 0 : props.styleBind) === null || _a === void 0 ? void 0 : _a.bindDataPath) {
|
|
1144
|
+
styleBindData = serializeValue({
|
|
1145
|
+
ctx: componentCtx,
|
|
1146
|
+
key: 'styleBind',
|
|
1147
|
+
dynamicValue: {
|
|
1148
|
+
type: props.styleBind.type,
|
|
1149
|
+
value: props.styleBind.bindDataPath,
|
|
1150
|
+
extra: props.styleBind.extra,
|
|
1151
|
+
},
|
|
1152
|
+
});
|
|
1153
|
+
if (styleBindData === null || styleBindData === void 0 ? void 0 : styleBindData.extra) {
|
|
1154
|
+
attributeExtraData.style = styleBindData === null || styleBindData === void 0 ? void 0 : styleBindData.extra;
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
if (isValidClassNameListBind(props.classNameListBind)) {
|
|
1158
|
+
classListBindData = serializeValue({
|
|
1159
|
+
ctx: componentCtx,
|
|
1160
|
+
key: 'classListBind',
|
|
1161
|
+
dynamicValue: getValidValue({
|
|
1162
|
+
type: props.classNameListBind.type,
|
|
1163
|
+
value: props.classNameListBind.bindDataPath,
|
|
1164
|
+
}),
|
|
1165
|
+
});
|
|
1166
|
+
if (classListBindData === null || classListBindData === void 0 ? void 0 : classListBindData.extra) {
|
|
1167
|
+
attributeExtraData.class = classListBindData === null || classListBindData === void 0 ? void 0 : classListBindData.extra;
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
processed = Object.assign(Object.assign({}, processed), { module: serializeModuleName(componentCtx, moduleName, name), component: name, attributes: Object.assign(Object.assign({}, attributes), { style: getValidValue(props.style), class: (_b = getValidValue(props.classNameList)) === null || _b === void 0 ? void 0 : _b.join(' ') }), items: getValidValue(Object.keys(properties)
|
|
1171
|
+
.filter((key) => !excludeKeys.includes(key))
|
|
1172
|
+
.sort((a, b) => properties[a]['x-index'] - properties[b]['x-index'])
|
|
1173
|
+
.map((key) => serializeRuntimeComponent(ctx, Object.assign({ id: key }, properties[key])))), listeners: (_c = getValidValue(readListeners(props.listenerInstances))) === null || _c === void 0 ? void 0 : _c.map((listener /* IEventListener */) => {
|
|
1174
|
+
return serializeListener(componentCtx, listener);
|
|
1175
|
+
}), directives: serializeDirecties(componentCtx, (getValidValue(readDirectives(props)) || {})) || undefined, ':class': (classListBindData === null || classListBindData === void 0 ? void 0 : classListBindData.value) || undefined, ':style': (styleBindData === null || styleBindData === void 0 ? void 0 : styleBindData.value) || undefined, scopedStyle: getValidValue(props.scopedStyle), extra: {
|
|
1176
|
+
commonStyle: getValidValue(removeInvalidStyleFormValue(props.commonStyle)),
|
|
1177
|
+
xIndex: getValidValue(component['x-index']),
|
|
1178
|
+
styleBindPath: getValidValue(props.styleBindPath),
|
|
1179
|
+
staticResourceAttribute: getValidValue(props.staticResourceAttribute),
|
|
1180
|
+
attributeExtraData: isEmptyObj(attributeExtraData) ? undefined : attributeExtraData,
|
|
1181
|
+
anchored: getValidValue(component.anchored),
|
|
1182
|
+
dataForm: getValidValue(component.dataForm),
|
|
1183
|
+
} });
|
|
1184
|
+
}
|
|
1185
|
+
else {
|
|
1186
|
+
let items = Object.keys(component.properties || {})
|
|
1187
|
+
.sort((a, b) => component.properties[a]['x-index'] - component.properties[b]['x-index'])
|
|
1188
|
+
.map((key) => serializeRuntimeComponent(ctx, Object.assign({ id: key }, component.properties[key])));
|
|
1189
|
+
processed = Object.assign(Object.assign({}, processed), { items: getValidValue(items), directives: props
|
|
1190
|
+
? serializeDirecties(ctx, (getValidValue(readDirectives(props)) || {})) || undefined
|
|
1191
|
+
: undefined });
|
|
1192
|
+
}
|
|
1193
|
+
return processed;
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* component
|
|
1197
|
+
* [CALS] to [formily]
|
|
1198
|
+
* To be continue, currently support listener
|
|
1199
|
+
*/
|
|
1200
|
+
export function deserializeRuntimeComponent(ctx, component) {
|
|
1201
|
+
const { id, module, component: runtimeComponent, listeners = [] } = component;
|
|
1202
|
+
let listenerInstances = getValidValue(writeListeners((listeners === null || listeners === void 0 ? void 0 : listeners.map((item) => {
|
|
1203
|
+
return Object.assign({ sourceKey: `${module}:${runtimeComponent}` }, deserializeListener(ctx, item));
|
|
1204
|
+
})) || []));
|
|
1205
|
+
const target = {
|
|
1206
|
+
key: id,
|
|
1207
|
+
type: 'object',
|
|
1208
|
+
properties: {},
|
|
1209
|
+
'x-component': `${module}:${runtimeComponent}`,
|
|
1210
|
+
'x-props': {
|
|
1211
|
+
sourceKey: `${module}:${runtimeComponent}`,
|
|
1212
|
+
listenerInstances: listenerInstances || [],
|
|
1213
|
+
},
|
|
1214
|
+
};
|
|
1215
|
+
return target;
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* 处理 dependencies 组件库描述列表到map
|
|
1219
|
+
*/
|
|
1220
|
+
function processDependenceList2Map(dependencies = []) {
|
|
1221
|
+
let map = dependencies.reduce((map, componentLib) => {
|
|
1222
|
+
let { components = [] } = componentLib;
|
|
1223
|
+
for (let item of components) {
|
|
1224
|
+
map[item.sourceKey] = item;
|
|
1225
|
+
}
|
|
1226
|
+
return map;
|
|
1227
|
+
}, {});
|
|
1228
|
+
return map;
|
|
1229
|
+
}
|
|
1230
|
+
export function deserializeComponentLibraryMeta(meta) {
|
|
1231
|
+
let { components = {}, actions = {}, styles = [], dependencies = {} } = meta, restLibraryMeta = __rest(meta, ["components", "actions", "styles", "dependencies"]);
|
|
1232
|
+
let processedComponents = {};
|
|
1233
|
+
for (const componentName in components) {
|
|
1234
|
+
let component = components[componentName];
|
|
1235
|
+
let _a = (component.meta || {}), { title, description, category, icon, extra = {} } = _a, restComponentMeta = __rest(_a, ["title", "description", "category", "icon", "extra"]);
|
|
1236
|
+
processedComponents[componentName] = Object.assign(Object.assign({ title: title || component.name || componentName, desc: description || '', category: category || '', thumbnail: icon }, extra), restComponentMeta);
|
|
1237
|
+
}
|
|
1238
|
+
return Object.assign(Object.assign({}, restLibraryMeta), { styles,
|
|
1239
|
+
dependencies, components: processedComponents, actions });
|
|
1240
|
+
}
|
|
1241
|
+
export function processRuntimeCodeResources(ctx, resources = [], scope) {
|
|
1242
|
+
const { id } = ctx;
|
|
1243
|
+
const fileTypes = [ECodeType.STYLE, ECodeType.STATE, ECodeType.LIFECYCLE, ECodeType.COMPUTEDN];
|
|
1244
|
+
const CODE_TYPE_NAME_MAP = {
|
|
1245
|
+
[ECodeType.STATE]: ECodeName.STATE,
|
|
1246
|
+
[ECodeType.COMPUTEDN]: ECodeName.COMPUTEDN,
|
|
1247
|
+
[ECodeType.STYLE]: ECodeName.STYLE,
|
|
1248
|
+
[ECodeType.LIFECYCLE]: ECodeName.LIFECYCLE,
|
|
1249
|
+
[ECodeType.MPCONFIG]: ECodeName.MPCONFIG,
|
|
1250
|
+
};
|
|
1251
|
+
const isComponent = id === '$comp' || scope === 'component';
|
|
1252
|
+
if (id === 'global' || scope === 'app') {
|
|
1253
|
+
fileTypes.push(ECodeType.THEME, ECodeType.MPCONFIG);
|
|
1254
|
+
}
|
|
1255
|
+
const EXIST_FILE_TYPE_MAP = {};
|
|
1256
|
+
resources.forEach((mod) => {
|
|
1257
|
+
if (mod.type === ECodeType.NORMAL_MODULE && mod.name === ECodeName.MPCONFIG) {
|
|
1258
|
+
mod.type = ECodeType.MPCONFIG;
|
|
1259
|
+
}
|
|
1260
|
+
EXIST_FILE_TYPE_MAP[mod.type] = true;
|
|
1261
|
+
});
|
|
1262
|
+
fileTypes.forEach((type) => {
|
|
1263
|
+
const isHasLowcodeIndex = EXIST_FILE_TYPE_MAP[type];
|
|
1264
|
+
if (!isHasLowcodeIndex) {
|
|
1265
|
+
const name = CODE_TYPE_NAME_MAP[type] || type;
|
|
1266
|
+
const dir = type === ECodeType.MPCONFIG ? ECodeName.NORMAL_MODULE : '';
|
|
1267
|
+
const path = [id, dir, name].filter(Boolean).join('/');
|
|
1268
|
+
resources.unshift({
|
|
1269
|
+
name,
|
|
1270
|
+
type,
|
|
1271
|
+
code: generateDefaultCode(ctx, type, isComponent ? 'component' : id === 'global' ? 'app' : 'page'),
|
|
1272
|
+
path,
|
|
1273
|
+
system: true,
|
|
1274
|
+
});
|
|
1275
|
+
}
|
|
1276
|
+
});
|
|
1277
|
+
return resources.filter((m) => m.name !== ECodeName.PLACEHOLDER);
|
|
1278
|
+
}
|
|
1279
|
+
/**
|
|
1280
|
+
* 解析 cals version 来生成 feature map
|
|
1281
|
+
*/
|
|
1282
|
+
export function parseVersion(version = '', dependencies = []) {
|
|
1283
|
+
const list = version.split('.');
|
|
1284
|
+
const FEATURE_MAP = {
|
|
1285
|
+
/**
|
|
1286
|
+
* 默认单位为 px,
|
|
1287
|
+
* 然后进行动态转换 为 rem及rpx
|
|
1288
|
+
*/
|
|
1289
|
+
defaultDynamicCssUnit: true,
|
|
1290
|
+
/**
|
|
1291
|
+
* 是否 observer 组件 ref
|
|
1292
|
+
*/
|
|
1293
|
+
enableObserverRef: false,
|
|
1294
|
+
/**
|
|
1295
|
+
* 是否生成页面根节点(mp)
|
|
1296
|
+
* 以及对根节点加 id
|
|
1297
|
+
*/
|
|
1298
|
+
enablePageRoot: false,
|
|
1299
|
+
/**
|
|
1300
|
+
* 是否依赖 数据源 profile
|
|
1301
|
+
*/
|
|
1302
|
+
staticDatasourceProfile: true,
|
|
1303
|
+
/**
|
|
1304
|
+
* 是否启用异步组件库
|
|
1305
|
+
*/
|
|
1306
|
+
enableAsyncMaterials: false,
|
|
1307
|
+
/**
|
|
1308
|
+
* 使用简单的组件api调用方式
|
|
1309
|
+
* $w.componentId.method()
|
|
1310
|
+
*/
|
|
1311
|
+
disablePageComponentInvoke: false,
|
|
1312
|
+
};
|
|
1313
|
+
if (list[0] === '4' || version === 'latest') {
|
|
1314
|
+
FEATURE_MAP.defaultDynamicCssUnit = false;
|
|
1315
|
+
}
|
|
1316
|
+
FEATURE_MAP.enableObserverRef = isEnbaleObserverVersion(dependencies);
|
|
1317
|
+
FEATURE_MAP.enablePageRoot = isEnablePageRoot(dependencies);
|
|
1318
|
+
FEATURE_MAP.staticDatasourceProfile = !isEnablePageRoot(dependencies);
|
|
1319
|
+
FEATURE_MAP.disablePageComponentInvoke = isEnableSimpleComponentInvoke(dependencies);
|
|
1320
|
+
// FEATURE_MAP.enableAsyncMaterials = isEnableAsyncMaterials(dependencies);
|
|
1321
|
+
return FEATURE_MAP;
|
|
1322
|
+
}
|
|
1323
|
+
export function processListeners(listeners, options) {
|
|
1324
|
+
const { strict = false } = options || {};
|
|
1325
|
+
const listenerEventNameMap = listeners.reduce((map, listener) => {
|
|
1326
|
+
const { eventName } = listener;
|
|
1327
|
+
if (!map[eventName]) {
|
|
1328
|
+
map[eventName] = [];
|
|
1329
|
+
}
|
|
1330
|
+
map[eventName].push(listener);
|
|
1331
|
+
return map;
|
|
1332
|
+
}, {});
|
|
1333
|
+
const flowListenerIdMap = {};
|
|
1334
|
+
const eventFlowMap = {};
|
|
1335
|
+
listeners.forEach((listener) => {
|
|
1336
|
+
const { id, eventName } = listener;
|
|
1337
|
+
if (flowListenerIdMap[id]) {
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
const [_, eventFlowId] = eventName.match(/(.*?)\.start/) || [];
|
|
1341
|
+
const evnetTree = [];
|
|
1342
|
+
let eventFlow = { id: '', listeners: [] };
|
|
1343
|
+
if (eventFlowId) {
|
|
1344
|
+
eventFlow.id = eventFlowId;
|
|
1345
|
+
if (listener.description) {
|
|
1346
|
+
eventFlow.description = listener.description;
|
|
1347
|
+
}
|
|
1348
|
+
if (listener.label) {
|
|
1349
|
+
eventFlow.label = listener.label;
|
|
1350
|
+
}
|
|
1351
|
+
eventFlowMap[eventFlowId] = eventFlow;
|
|
1352
|
+
evnetTree.push(eventName);
|
|
1353
|
+
}
|
|
1354
|
+
for (let eventName of evnetTree) {
|
|
1355
|
+
const list = listenerEventNameMap[eventName] || [];
|
|
1356
|
+
if (strict && list.length > 1) {
|
|
1357
|
+
throw new Error(`事件流 ${eventFlowId} 中 ${eventName} 事件存在并发调用`);
|
|
1358
|
+
}
|
|
1359
|
+
list.forEach((item) => {
|
|
1360
|
+
flowListenerIdMap[item.id] = eventFlowId;
|
|
1361
|
+
for (const eventName in listenerEventNameMap) {
|
|
1362
|
+
if ((eventName === null || eventName === void 0 ? void 0 : eventName.startsWith(`${item.id}.`)) && listenerEventNameMap[eventName]) {
|
|
1363
|
+
evnetTree.push(eventName);
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1368
|
+
});
|
|
1369
|
+
const rawListeners = [];
|
|
1370
|
+
listeners.forEach((listener) => {
|
|
1371
|
+
const flowId = flowListenerIdMap[listener.id];
|
|
1372
|
+
if (flowId && eventFlowMap[flowId]) {
|
|
1373
|
+
eventFlowMap[flowId].listeners.push(listener);
|
|
1374
|
+
}
|
|
1375
|
+
else {
|
|
1376
|
+
rawListeners.push(listener);
|
|
1377
|
+
}
|
|
1378
|
+
});
|
|
1379
|
+
return { listeners: rawListeners, eventFlows: Object.values(eventFlowMap) };
|
|
1380
|
+
}
|
|
1381
|
+
export function processDependenciesVersionMap(dependencies = {}) {
|
|
1382
|
+
return Object.entries(dependencies).reduce((map, [key, value]) => {
|
|
1383
|
+
const version = parseDependenciesVersion(value);
|
|
1384
|
+
if (version) {
|
|
1385
|
+
map[key] = version;
|
|
1386
|
+
}
|
|
1387
|
+
return map;
|
|
1388
|
+
}, {});
|
|
1389
|
+
}
|
|
1390
|
+
export function parseDependenciesVersion(version) {
|
|
1391
|
+
try {
|
|
1392
|
+
const wedaProtocoReg = /^weda:[\w\W]+$/;
|
|
1393
|
+
if (wedaProtocoReg.test(version)) {
|
|
1394
|
+
return new URL(version).searchParams.get('v');
|
|
1395
|
+
}
|
|
1396
|
+
return version;
|
|
1397
|
+
}
|
|
1398
|
+
catch (err) {
|
|
1399
|
+
console.error('getVersionFromDependenciesValue err', err);
|
|
1400
|
+
return '';
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
export function processTemplatesToDependiencies(templates = []) {
|
|
1404
|
+
return {
|
|
1405
|
+
name: '$template',
|
|
1406
|
+
version: 'latest',
|
|
1407
|
+
srcZipUrl: '',
|
|
1408
|
+
mpPkgUrl: '',
|
|
1409
|
+
actions: [],
|
|
1410
|
+
components: templates === null || templates === void 0 ? void 0 : templates.map((item /* : ICompositedComponent */) => {
|
|
1411
|
+
var _a, _b, _c;
|
|
1412
|
+
const weappsData = deserializeCompositeComponent(item, { dependencies: [] });
|
|
1413
|
+
return {
|
|
1414
|
+
id: (item.id || item.name),
|
|
1415
|
+
name: item.name || '',
|
|
1416
|
+
materialName: '$template',
|
|
1417
|
+
componentInstances: weappsData.componentInstances,
|
|
1418
|
+
compConfig: item.compConfig || {},
|
|
1419
|
+
dataForm: item.dataForm || ((_a = item.data) === null || _a === void 0 ? void 0 : _a.properties) || {},
|
|
1420
|
+
emitEvents: item.emitEvents ||
|
|
1421
|
+
((_b = item.events) === null || _b === void 0 ? void 0 : _b.map((item) => {
|
|
1422
|
+
return { eventName: item.name, name: item.title };
|
|
1423
|
+
})),
|
|
1424
|
+
lowCodes: ((_c = weappsData.lowCodes) === null || _c === void 0 ? void 0 : _c.map((module) => {
|
|
1425
|
+
var _a, _b;
|
|
1426
|
+
return Object.assign(Object.assign({}, module), { path: (_b = (_a = module.path) === null || _a === void 0 ? void 0 : _a.replace) === null || _b === void 0 ? void 0 : _b.call(_a, /^.*?\//, `$comp/`) });
|
|
1427
|
+
})) || [],
|
|
1428
|
+
/**
|
|
1429
|
+
* @TODO: 二者归一化
|
|
1430
|
+
* lcds.Icompinent.meta !== ICompositedComponent.meta
|
|
1431
|
+
*/
|
|
1432
|
+
meta: item.meta || {
|
|
1433
|
+
title: item.name || '',
|
|
1434
|
+
syncProps: {},
|
|
1435
|
+
inputProps: {},
|
|
1436
|
+
platforms: { mp: {} },
|
|
1437
|
+
},
|
|
1438
|
+
npmDependencies: {},
|
|
1439
|
+
listeners: weappsData.listeners || [],
|
|
1440
|
+
/**
|
|
1441
|
+
* 扩展 dataset 和 eventFlows 数据
|
|
1442
|
+
*/
|
|
1443
|
+
dataset: weappsData.dataset,
|
|
1444
|
+
eventFlows: weappsData.eventFlows || [],
|
|
1445
|
+
};
|
|
1446
|
+
}),
|
|
1447
|
+
isComposite: true,
|
|
1448
|
+
schemaVersion: '3.0.0',
|
|
1449
|
+
};
|
|
1450
|
+
}
|
|
1451
|
+
export function generateHandlerParamsDynamicMap(handler) {
|
|
1452
|
+
const isArguments = !(handler === null || handler === void 0 ? void 0 : handler.params) || Array.isArray(handler === null || handler === void 0 ? void 0 : handler.params);
|
|
1453
|
+
let handerParam = {
|
|
1454
|
+
params: isArguments ? (handler === null || handler === void 0 ? void 0 : handler.params) || [] : [handler === null || handler === void 0 ? void 0 : handler.params],
|
|
1455
|
+
};
|
|
1456
|
+
Object.entries(handler || {}).forEach(([key, value]) => {
|
|
1457
|
+
if (/^:params\./.test(key) || key === ':params') {
|
|
1458
|
+
const processedKey = isArguments ? key : key.replace(/^:params/, ':params.0');
|
|
1459
|
+
handerParam[processedKey] = value;
|
|
1460
|
+
}
|
|
1461
|
+
});
|
|
1462
|
+
return handerParam;
|
|
1463
|
+
}
|
|
1464
|
+
/**
|
|
1465
|
+
* 精简过滤子包数据
|
|
1466
|
+
* 仅保留子包自身数据
|
|
1467
|
+
*/
|
|
1468
|
+
export function streamlineSubApp(cals) {
|
|
1469
|
+
const { schemaVersion, id, name, description, label, main, items = [], extra } = cals;
|
|
1470
|
+
const { originHistoryId, pageTree, rootPath } = extra;
|
|
1471
|
+
return {
|
|
1472
|
+
schemaVersion,
|
|
1473
|
+
id,
|
|
1474
|
+
name,
|
|
1475
|
+
label,
|
|
1476
|
+
description,
|
|
1477
|
+
main,
|
|
1478
|
+
items,
|
|
1479
|
+
extra: {
|
|
1480
|
+
pageTree,
|
|
1481
|
+
originHistoryId,
|
|
1482
|
+
rootPath,
|
|
1483
|
+
},
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
/**
|
|
1487
|
+
* 还原引用
|
|
1488
|
+
*/
|
|
1489
|
+
export function collapseCalsReference(cals, options) {
|
|
1490
|
+
var _a;
|
|
1491
|
+
const { blockTemplates = [] } = options;
|
|
1492
|
+
const ctx = {
|
|
1493
|
+
blockTemplateMap: generateBlockTemplateMap(blockTemplates),
|
|
1494
|
+
enableRestore: true,
|
|
1495
|
+
};
|
|
1496
|
+
const res = Object.assign(Object.assign({}, cals), { items: (_a = cals.items) === null || _a === void 0 ? void 0 : _a.map((page) => {
|
|
1497
|
+
var _a;
|
|
1498
|
+
return Object.assign(Object.assign({}, page), { items: (_a = page.items) === null || _a === void 0 ? void 0 : _a.map((component) => collapseComponentReference(ctx, component)) });
|
|
1499
|
+
}) });
|
|
1500
|
+
return res;
|
|
1501
|
+
}
|
|
1502
|
+
/**
|
|
1503
|
+
* 展开引用
|
|
1504
|
+
*/
|
|
1505
|
+
export function expandCalsReference(cals, options) {
|
|
1506
|
+
const { blockTemplates = [] } = options;
|
|
1507
|
+
const blockTemplateMap = generateBlockTemplateMap(blockTemplates);
|
|
1508
|
+
const ctx = {
|
|
1509
|
+
blockTemplateMap,
|
|
1510
|
+
strict: options.strict,
|
|
1511
|
+
visiting: {
|
|
1512
|
+
existing: new VisitedMap(),
|
|
1513
|
+
untilNow: new VisitedMap(),
|
|
1514
|
+
},
|
|
1515
|
+
processPickedTeamplate: options.processPickedTeamplate,
|
|
1516
|
+
};
|
|
1517
|
+
const { refs } = getUsedReference([cals], blockTemplates);
|
|
1518
|
+
[cals]
|
|
1519
|
+
.concat(Array.from(refs)
|
|
1520
|
+
.map((key) => { var _a; return (_a = blockTemplateMap[key]) === null || _a === void 0 ? void 0 : _a.content; })
|
|
1521
|
+
.filter((item) => !!item))
|
|
1522
|
+
.forEach((cals, index) => {
|
|
1523
|
+
var _a, _b;
|
|
1524
|
+
(_b = (_a = cals.items) === null || _a === void 0 ? void 0 : _a.forEach) === null || _b === void 0 ? void 0 : _b.call(_a, (page) => {
|
|
1525
|
+
walkThroughComponents(page.items || [], (component) => {
|
|
1526
|
+
const { component: componentName } = component;
|
|
1527
|
+
if (typeof componentName === 'string' && componentName) {
|
|
1528
|
+
const { untilNow, existing } = ctx.visiting;
|
|
1529
|
+
const namespace = getComponentNamespace(componentName);
|
|
1530
|
+
if (index === 0) {
|
|
1531
|
+
untilNow.add(namespace, component.id);
|
|
1532
|
+
}
|
|
1533
|
+
existing.add(namespace, component.id);
|
|
1534
|
+
}
|
|
1535
|
+
});
|
|
1536
|
+
});
|
|
1537
|
+
});
|
|
1538
|
+
const res = Object.assign(Object.assign({}, cals), {
|
|
1539
|
+
// 先置空,等待后续填充
|
|
1540
|
+
items: [] });
|
|
1541
|
+
res.items = cals === null || cals === void 0 ? void 0 : cals.items.map((_a) => {
|
|
1542
|
+
var _b, _c;
|
|
1543
|
+
var { items: orignItems } = _a, page = __rest(_a, ["items"]);
|
|
1544
|
+
const items = (_c = (_b = orignItems === null || orignItems === void 0 ? void 0 : orignItems.map) === null || _b === void 0 ? void 0 : _b.call(orignItems, (component) => expandComponentReference(Object.assign(Object.assign({}, ctx), { patchRef: options.enableRestore ? undefined : { cals: res, page } }), component))) === null || _c === void 0 ? void 0 : _c.filter((item) => !!item);
|
|
1545
|
+
return Object.assign(Object.assign({}, page), { items });
|
|
1546
|
+
});
|
|
1547
|
+
return res;
|
|
1548
|
+
}
|