Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: zip publisher support browser #2744

Merged

Conversation

xiaohuoni
Copy link
Contributor

浏览器中出码支持下载项目 zip 包

浏览器中出码接入

随着现在电脑性能和浏览器技术的发展,出码其实已经不必非得在服务端做了,借助于 Web Worker 特性,可以在浏览器中进行出码:

  1. 安装依赖: npm install --save @alilc/lowcode-code-generator
  2. 引入代码生成器:
import * as CodeGenerator from '@alilc/lowcode-code-generator/standalone-loader';
  1. 【可选】提前初始化代码生成器:
// 提前初始化下,这样后面用的时候更快(这个 init 内部会提前准备好创建 worker 的一些资源)
await CodeGenerator.init();
  1. 出码
const project = await CodeGenerator.generateCode({
  solution: 'icejs', // 出码方案 (目前内置有 icejs 和 rax )
  schema, // 编排搭建出来的 schema
});

console.log(project); // 出码结果(默认是递归结构描述的,可以传 flattenResult: true 以生成扁平结构的结果)

注:一般来说在浏览器中出码适合做即时预览功能。

  1. 下载 zip 包
// 写入到 zip 包
await CodeGenerator.publishers.zip().publish({
  project, // 上一步生成的 project
  projectSlug: 'your-project-slug', // 项目标识 -- 对应下载 your-project-slug.zip 文件
});

Copy link

codecov bot commented Dec 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b2abb67) 85.28% compared to head (0bcb2ce) 85.30%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2744      +/-   ##
==========================================
+ Coverage   85.28%   85.30%   +0.01%     
==========================================
  Files         222      222              
  Lines        8953     8957       +4     
  Branches     2109     2112       +3     
==========================================
+ Hits         7636     7641       +5     
+ Misses       1227     1226       -1     
  Partials       90       90              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@liujuping liujuping requested review from qingniaotonghua and removed request for LeoYuan December 26, 2023 07:00
@qingniaotonghua
Copy link
Collaborator

请根据测试覆盖率报告补充一下对应的测试用例 @xiaohuoni

@xiaohuoni
Copy link
Contributor Author

@qingniaotonghua done

@liujuping
Copy link
Collaborator

@xiaohuoni 分支指向 develop。

@xiaohuoni xiaohuoni changed the base branch from main to develop January 2, 2024 10:01
@xiaohuoni
Copy link
Contributor Author

develop

奇怪,我上次分支的时候,没看到 develop 分支

@liujuping liujuping merged commit 7b85a35 into alibaba:develop Jan 2, 2024
10 checks passed
@xiaohuoni xiaohuoni deleted the feat-zip-publisher-support-browser branch January 3, 2024 01:37
@qingniaotonghua
Copy link
Collaborator

@alilc/lowcode-code-generator 1.1.7 已发布 @xiaohuoni @liujuping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants