@dckj-npm/lowcode-plugin-code-generator 1.3.2 → 1.3.4

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.
Files changed (85) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +53 -52
  3. package/es/components/CodeGenActionBtn/CodeGenActionBtn.js +19 -22
  4. package/es/components/CodeGenActionBtn/CodeGenActionBtn.scss +13 -13
  5. package/es/components/CodeGenPreview/CodeGenPreview.scss +16 -16
  6. package/es/components/CodeGenPreview/useIsInIntranet.js +15 -15
  7. package/es/components/CodeGenResult/CodeGenResult.js +11 -11
  8. package/es/components/CodeGenResult/CodeGenResult.scss +7 -7
  9. package/es/components/CodeSandboxPreview/CodeSandboxPreview.js +23 -23
  10. package/es/components/CodeSandboxPreview/CodeSandboxPreview.scss +18 -18
  11. package/es/components/FileTypeIcon/FileTypeIcon.scss +36 -36
  12. package/es/components/SourcesView/SourcesView.js +2 -1
  13. package/es/components/SourcesView/SourcesView.scss +24 -24
  14. package/es/demo/index.js +31 -32
  15. package/es/demo/index.scss +56 -56
  16. package/es/index.js +10 -9
  17. package/es/utils/utils.js +22 -25
  18. package/lib/components/CodeGenActionBtn/CodeGenActionBtn.js +20 -24
  19. package/lib/components/CodeGenActionBtn/CodeGenActionBtn.scss +13 -13
  20. package/lib/components/CodeGenPreview/CodeGenPreview.scss +16 -16
  21. package/lib/components/CodeGenPreview/useIsInIntranet.js +16 -17
  22. package/lib/components/CodeGenResult/CodeGenResult.js +12 -13
  23. package/lib/components/CodeGenResult/CodeGenResult.scss +7 -7
  24. package/lib/components/CodeSandboxPreview/CodeSandboxPreview.js +24 -25
  25. package/lib/components/CodeSandboxPreview/CodeSandboxPreview.scss +18 -18
  26. package/lib/components/FileTypeIcon/FileTypeIcon.scss +36 -36
  27. package/lib/components/GravityPreview/GravityPreview.js +1 -2
  28. package/lib/components/GravityPreview/GravitySdk.js +1 -2
  29. package/lib/components/SourcesView/SourcesView.js +3 -3
  30. package/lib/components/SourcesView/SourcesView.scss +24 -24
  31. package/lib/demo/index.js +32 -34
  32. package/lib/demo/index.scss +56 -56
  33. package/lib/index.js +11 -11
  34. package/lib/utils/utils.js +22 -25
  35. package/package.json +94 -94
  36. package/es/components/CodeGenActionBtn/CodeGenActionBtn.d.ts +0 -8
  37. package/es/components/CodeGenActionBtn/index.d.ts +0 -1
  38. package/es/components/CodeGenPreview/CodeGenPreview.d.ts +0 -8
  39. package/es/components/CodeGenPreview/fixPreviewCode.d.ts +0 -2
  40. package/es/components/CodeGenPreview/index.d.ts +0 -1
  41. package/es/components/CodeGenPreview/useIsInIntranet.d.ts +0 -4
  42. package/es/components/CodeGenResult/CodeGenResult.d.ts +0 -9
  43. package/es/components/CodeGenResult/index.d.ts +0 -1
  44. package/es/components/CodeSandboxPreview/CodeSandboxPreview.d.ts +0 -4
  45. package/es/components/CodeSandboxPreview/index.d.ts +0 -1
  46. package/es/components/FileTypeIcon/FileTypeIcon.d.ts +0 -6
  47. package/es/components/FileTypeIcon/index.d.ts +0 -1
  48. package/es/components/GravityCode/GravityCode.d.ts +0 -9
  49. package/es/components/GravityCode/index.d.ts +0 -1
  50. package/es/components/GravityPreview/ForceUpdate.d.ts +0 -6
  51. package/es/components/GravityPreview/GravityPreview.d.ts +0 -7
  52. package/es/components/GravityPreview/GravitySdk.d.ts +0 -10
  53. package/es/components/GravityPreview/index.d.ts +0 -1
  54. package/es/components/SourcesView/SourcesView.d.ts +0 -9
  55. package/es/components/SourcesView/index.d.ts +0 -1
  56. package/es/demo/index.d.ts +0 -1
  57. package/es/index.d.ts +0 -30
  58. package/es/types/SyncCodeGenResult.d.ts +0 -16
  59. package/es/types/index.d.ts +0 -1
  60. package/es/utils/utils.d.ts +0 -26
  61. package/lib/components/CodeGenActionBtn/CodeGenActionBtn.d.ts +0 -8
  62. package/lib/components/CodeGenActionBtn/index.d.ts +0 -1
  63. package/lib/components/CodeGenPreview/CodeGenPreview.d.ts +0 -8
  64. package/lib/components/CodeGenPreview/fixPreviewCode.d.ts +0 -2
  65. package/lib/components/CodeGenPreview/index.d.ts +0 -1
  66. package/lib/components/CodeGenPreview/useIsInIntranet.d.ts +0 -4
  67. package/lib/components/CodeGenResult/CodeGenResult.d.ts +0 -9
  68. package/lib/components/CodeGenResult/index.d.ts +0 -1
  69. package/lib/components/CodeSandboxPreview/CodeSandboxPreview.d.ts +0 -4
  70. package/lib/components/CodeSandboxPreview/index.d.ts +0 -1
  71. package/lib/components/FileTypeIcon/FileTypeIcon.d.ts +0 -6
  72. package/lib/components/FileTypeIcon/index.d.ts +0 -1
  73. package/lib/components/GravityCode/GravityCode.d.ts +0 -9
  74. package/lib/components/GravityCode/index.d.ts +0 -1
  75. package/lib/components/GravityPreview/ForceUpdate.d.ts +0 -6
  76. package/lib/components/GravityPreview/GravityPreview.d.ts +0 -7
  77. package/lib/components/GravityPreview/GravitySdk.d.ts +0 -10
  78. package/lib/components/GravityPreview/index.d.ts +0 -1
  79. package/lib/components/SourcesView/SourcesView.d.ts +0 -9
  80. package/lib/components/SourcesView/index.d.ts +0 -1
  81. package/lib/demo/index.d.ts +0 -1
  82. package/lib/index.d.ts +0 -30
  83. package/lib/types/SyncCodeGenResult.d.ts +0 -16
  84. package/lib/types/index.d.ts +0 -1
  85. package/lib/utils/utils.d.ts +0 -26
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Alibaba
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Alibaba
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,52 +1,53 @@
1
- # 集团低代码引擎 - 出码插件(浏览器里进行出码)
2
-
3
- ## 简介
4
-
5
- 本项目是出码模块的对应的浏览器里进行出码的插件
6
-
7
- ## 使用方法
8
-
9
- 1. 安装依赖 `npm install --save @alilc/lowcode-plugin-code-generator`
10
- 2. 注册插件:
11
-
12
- ```ts
13
- import { plugins } from '@alilc/lowcode-engine';
14
- import CodeGenPlugin from '@alilc/lowcode-plugin-code-generator';
15
-
16
- // 在你的初始化函数中:
17
- await plugins.register(CodeGenPlugin);
18
-
19
- // 如果您不希望自动加上出码按钮,则可以这样注册
20
- await plugins.register(CodeGenPlugin, { disableCodeGenActionBtn: true });
21
-
22
- ```
23
-
24
- 然后运行你的低代码编辑器项目即可。
25
-
26
- 参考:低代码编辑器的 Demo: <https://github.com/alibaba/lowcode-demo>
27
-
28
- ## 插件 API
29
-
30
- 本插件提供了出码的 API,注册了插件后, 可以这么样来用:
31
-
32
- ```js
33
- import { plugins } from '@alilc/lowcode-engine';
34
-
35
- const codeGenResult = plugins.codeGenerator.generateCode({
36
- solution: 'icejs',
37
- schema: await ctx.project.exportSchema(),
38
- });
39
-
40
- console.log('出码结果:', codeGenResult); // 这里就是出码结果
41
-
42
- ```
43
-
44
- ## 本地开发
45
-
46
- 常规两步即可开发调试:`npm i && npm start`
47
-
48
- ## 共建
49
-
50
- 欢迎参与共建,欢迎直接 fork 一份改改,补充您所需要的特性或修复 bug,然后提 PR 过来:
51
-
52
- -- 代码仓库:<https://github.com/alibaba/lowcode-code-generator-demo>
1
+ # 集团低代码引擎 - 出码插件(浏览器里进行出码)
2
+
3
+ ## 简介
4
+
5
+ 本项目是出码模块的对应的浏览器里进行出码的插件
6
+
7
+ ## 使用方法
8
+
9
+ 1. 安装依赖 `npm install --save @alilc/lowcode-plugin-code-generator`
10
+ 2. 注册插件:
11
+
12
+ ```ts
13
+ import { plugins } from '@alilc/lowcode-engine';
14
+ import CodeGenPlugin from '@alilc/lowcode-plugin-code-generator';
15
+
16
+ // 在你的初始化函数中:
17
+ await plugins.register(CodeGenPlugin);
18
+
19
+ // 如果您不希望自动加上出码按钮,则可以这样注册
20
+ await plugins.register(CodeGenPlugin, { disableCodeGenActionBtn: true });
21
+
22
+ ```
23
+
24
+ 然后运行你的低代码编辑器项目即可。
25
+
26
+ 参考:低代码编辑器的 Demo: <https://github.com/alibaba/lowcode-demo>
27
+
28
+ ## 插件 API
29
+
30
+ 本插件提供了出码的 API,注册了插件后, 可以这么样来用:
31
+
32
+ ```js
33
+ import { plugins } from '@alilc/lowcode-engine';
34
+
35
+ const codeGenResult = plugins.codeGenerator.generateCode({
36
+ solution: 'icejs',
37
+ schema: await ctx.project.exportSchema(),
38
+ });
39
+
40
+ console.log('出码结果:', codeGenResult); // 这里就是出码结果
41
+
42
+ ```
43
+
44
+ ## 本地开发
45
+
46
+ 常规两步即可开发调试:`npm i && npm start`
47
+
48
+ ## 共建
49
+
50
+ 欢迎参与共建,欢迎直接 fork 一份改改,补充您所需要的特性或修复 bug,然后提 PR 过来:
51
+
52
+ -- 代码仓库:<https://github.com/alibaba/lowcode-code-generator-demo>
53
+
@@ -23,8 +23,8 @@ export function CodeGenActionBtn(_ref) {
23
23
  setState = _useState[1];
24
24
  var handleClick = /*#__PURE__*/function () {
25
25
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
26
- var name, resourceList, allSchema, resultSchema, result;
27
- return _regeneratorRuntime.wrap(function _callee$(_context) {
26
+ var name, resourceList, allSchema, resultSchema, result, _t;
27
+ return _regeneratorRuntime.wrap(function (_context) {
28
28
  while (1) switch (_context.prev = _context.next) {
29
29
  case 0:
30
30
  _context.prev = 0;
@@ -40,23 +40,20 @@ export function CodeGenActionBtn(_ref) {
40
40
  // 获取 schema,并修正
41
41
  // const originalSchema = await project.exportSchema();
42
42
  name = getProjectId();
43
- _context.next = 5;
43
+ _context.next = 1;
44
44
  return getResourceListFromLocalStorage(name);
45
- case 5:
45
+ case 1:
46
46
  resourceList = _context.sent;
47
- console.log('resourceList', resourceList);
48
- _context.next = 9;
47
+ _context.next = 2;
49
48
  return getAllSchemaByResourceList(name, resourceList);
50
- case 9:
49
+ case 2:
51
50
  allSchema = _context.sent;
52
- _context.next = 12;
51
+ _context.next = 3;
53
52
  return Promise.all(allSchema.map(function (item) {
54
53
  return fixSchema(item);
55
54
  }));
56
- case 12:
55
+ case 3:
57
56
  resultSchema = _context.sent;
58
- console.log('allSchema', allSchema);
59
- console.log('resultSchema', resultSchema);
60
57
  // console.log('ctx ', ctx)
61
58
  // console.log('isActive ', ctx.workspace.isActive)
62
59
  // console.log('window.exportSchema ', ctx.workspace.window.exportSchema())
@@ -72,14 +69,14 @@ export function CodeGenActionBtn(_ref) {
72
69
  });
73
70
 
74
71
  // 出码...
75
- _context.next = 18;
72
+ _context.next = 4;
76
73
  return CodeGenerator.generateCode({
77
74
  solution: 'vuejs3',
78
75
  schema: resultSchema,
79
76
  flattenResult: true,
80
77
  resourceList: resourceList
81
78
  });
82
- case 18:
79
+ case 4:
83
80
  result = _context.sent;
84
81
  console.log('generated: ', result);
85
82
  setState(function (prev) {
@@ -88,23 +85,23 @@ export function CodeGenActionBtn(_ref) {
88
85
  result: result
89
86
  });
90
87
  });
91
- _context.next = 27;
88
+ _context.next = 6;
92
89
  break;
93
- case 23:
94
- _context.prev = 23;
95
- _context.t0 = _context["catch"](0);
96
- console.error('failed to run code generator: ', _context.t0);
90
+ case 5:
91
+ _context.prev = 5;
92
+ _t = _context["catch"](0);
93
+ console.error('failed to run code generator: ', _t);
97
94
  setState(function (prev) {
98
95
  return _extends({}, prev, {
99
96
  hasError: true,
100
- error: _context.t0 instanceof Error ? _context.t0 : new Error("" + ((_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message) || _context.t0))
97
+ error: _t instanceof Error ? _t : new Error("" + ((_t === null || _t === void 0 ? void 0 : _t.message) || _t))
101
98
  });
102
99
  });
103
- case 27:
100
+ case 6:
104
101
  case "end":
105
102
  return _context.stop();
106
103
  }
107
- }, _callee, null, [[0, 23]]);
104
+ }, _callee, null, [[0, 5]]);
108
105
  }));
109
106
  return function handleClick() {
110
107
  return _ref2.apply(this, arguments);
@@ -152,7 +149,7 @@ export function fixSchema(_x) {
152
149
  }
153
150
  function _fixSchema() {
154
151
  _fixSchema = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(schema) {
155
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
152
+ return _regeneratorRuntime.wrap(function (_context2) {
156
153
  while (1) switch (_context2.prev = _context2.next) {
157
154
  case 0:
158
155
  return _context2.abrupt("return", deepClone(_extends({}, schema, {
@@ -1,13 +1,13 @@
1
- .code-gen-plugin-loading {
2
- width: 100%;
3
- margin: 2em auto;
4
- }
5
-
6
- .code-gen-plugin-result {
7
- width: 100%;
8
- .next-message-error {
9
- .next-message-content {
10
- white-space: pre-wrap;
11
- }
12
- }
13
- }
1
+ .code-gen-plugin-loading {
2
+ width: 100%;
3
+ margin: 2em auto;
4
+ }
5
+
6
+ .code-gen-plugin-result {
7
+ width: 100%;
8
+ .next-message-error {
9
+ .next-message-content {
10
+ white-space: pre-wrap;
11
+ }
12
+ }
13
+ }
@@ -1,16 +1,16 @@
1
- .code-gen-preview-tabs {
2
- display: flex;
3
- flex-direction: column;
4
- height: 100%;
5
-
6
- .next-tabs-bar {
7
- flex-shrink: 0;
8
- }
9
-
10
- .next-tabs-content {
11
- flex: 1;
12
- .next-tabs-tabpane {
13
- height: 100%;
14
- }
15
- }
16
- }
1
+ .code-gen-preview-tabs {
2
+ display: flex;
3
+ flex-direction: column;
4
+ height: 100%;
5
+
6
+ .next-tabs-bar {
7
+ flex-shrink: 0;
8
+ }
9
+
10
+ .next-tabs-content {
11
+ flex: 1;
12
+ .next-tabs-tabpane {
13
+ height: 100%;
14
+ }
15
+ }
16
+ }
@@ -5,8 +5,8 @@ import React, { useEffect } from 'react';
5
5
  // 预先检测下是否在内网环境中
6
6
  var isInIntranetPromise = detectIsInIntranet();
7
7
 
8
- /**
9
- * 判断是否在内网环境中中
8
+ /**
9
+ * 判断是否在内网环境中中
10
10
  */
11
11
  export function useIsInIntranet() {
12
12
  var _React$useState = React.useState({
@@ -28,39 +28,39 @@ export function useIsInIntranet() {
28
28
  return state.isInIntranet;
29
29
  }
30
30
 
31
- /**
32
- * 判断是否在内网环境中中
31
+ /**
32
+ * 判断是否在内网环境中中
33
33
  */
34
34
  function detectIsInIntranet() {
35
35
  return _detectIsInIntranet.apply(this, arguments);
36
36
  }
37
37
  function _detectIsInIntranet() {
38
38
  _detectIsInIntranet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
39
- var res;
40
- return _regeneratorRuntime.wrap(function _callee$(_context) {
39
+ var res, _t;
40
+ return _regeneratorRuntime.wrap(function (_context) {
41
41
  while (1) switch (_context.prev = _context.next) {
42
42
  case 0:
43
43
  _context.prev = 0;
44
- _context.next = 3;
44
+ _context.next = 1;
45
45
  return fetch('https://dev.g.alicdn.com/ali-lowcode/ali-lowcode-materials/1.1.0/schema.json');
46
- case 3:
46
+ case 1:
47
47
  res = _context.sent;
48
48
  if (!res.ok) {
49
- _context.next = 6;
49
+ _context.next = 2;
50
50
  break;
51
51
  }
52
52
  return _context.abrupt("return", true);
53
- case 6:
53
+ case 2:
54
54
  return _context.abrupt("return", false);
55
- case 9:
56
- _context.prev = 9;
57
- _context.t0 = _context["catch"](0);
55
+ case 3:
56
+ _context.prev = 3;
57
+ _t = _context["catch"](0);
58
58
  return _context.abrupt("return", false);
59
- case 12:
59
+ case 4:
60
60
  case "end":
61
61
  return _context.stop();
62
62
  }
63
- }, _callee, null, [[0, 9]]);
63
+ }, _callee, null, [[0, 3]]);
64
64
  }));
65
65
  return _detectIsInIntranet.apply(this, arguments);
66
66
  }
@@ -31,8 +31,8 @@ export function CodeGenResult(_ref) {
31
31
  var gravityDemoHeight = paneState.expandedKeys.includes('sources') ? '40vh' : '80vh';
32
32
  var handleDownloadSources = /*#__PURE__*/function () {
33
33
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(e) {
34
- var zip;
35
- return _regeneratorRuntime.wrap(function _callee$(_context) {
34
+ var zip, _t;
35
+ return _regeneratorRuntime.wrap(function (_context) {
36
36
  while (1) switch (_context.prev = _context.next) {
37
37
  case 0:
38
38
  _context.prev = 0;
@@ -42,25 +42,25 @@ export function CodeGenResult(_ref) {
42
42
  Object.values((gravityCode === null || gravityCode === void 0 ? void 0 : gravityCode.modules) || {}).forEach(function (file) {
43
43
  zip.file(file.fpath.replace(/^\/+/, ''), file.code);
44
44
  });
45
- _context.next = 7;
45
+ _context.next = 1;
46
46
  return zip.generateAsync({
47
47
  type: 'blob'
48
48
  }).then(function (content) {
49
49
  FileSaver.saveAs(content, 'ali-lowcode-generated-sources.zip');
50
50
  });
51
- case 7:
52
- _context.next = 13;
51
+ case 1:
52
+ _context.next = 3;
53
53
  break;
54
- case 9:
55
- _context.prev = 9;
56
- _context.t0 = _context["catch"](0);
57
- console.log('failed to download sources: ', _context.t0);
54
+ case 2:
55
+ _context.prev = 2;
56
+ _t = _context["catch"](0);
57
+ console.log('failed to download sources: ', _t);
58
58
  Message.error('下载失败!');
59
- case 13:
59
+ case 3:
60
60
  case "end":
61
61
  return _context.stop();
62
62
  }
63
- }, _callee, null, [[0, 9]]);
63
+ }, _callee, null, [[0, 2]]);
64
64
  }));
65
65
  return function handleDownloadSources(_x) {
66
66
  return _ref2.apply(this, arguments);
@@ -1,7 +1,7 @@
1
- .code-gen-result {
2
- .code-gen-result-gravity-demo {
3
- iframe {
4
- height: 100%;
5
- }
6
- }
7
- }
1
+ .code-gen-result {
2
+ .code-gen-result-gravity-demo {
3
+ iframe {
4
+ height: 100%;
5
+ }
6
+ }
7
+ }
@@ -54,14 +54,14 @@ export function CodeSandboxPreview(_ref) {
54
54
  });
55
55
  });
56
56
  _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
57
- var sandboxId;
58
- return _regeneratorRuntime.wrap(function _callee$(_context) {
57
+ var sandboxId, _t;
58
+ return _regeneratorRuntime.wrap(function (_context) {
59
59
  while (1) switch (_context.prev = _context.next) {
60
60
  case 0:
61
61
  _context.prev = 0;
62
- _context.next = 3;
62
+ _context.next = 1;
63
63
  return createCodeSandbox(parameters);
64
- case 3:
64
+ case 1:
65
65
  sandboxId = _context.sent;
66
66
  if (!hasCanceled) {
67
67
  setState(function (prev) {
@@ -72,25 +72,25 @@ export function CodeSandboxPreview(_ref) {
72
72
  });
73
73
  });
74
74
  }
75
- _context.next = 10;
75
+ _context.next = 3;
76
76
  break;
77
- case 7:
78
- _context.prev = 7;
79
- _context.t0 = _context["catch"](0);
77
+ case 2:
78
+ _context.prev = 2;
79
+ _t = _context["catch"](0);
80
80
  if (!hasCanceled) {
81
81
  setState(function (prev) {
82
82
  return _extends({}, prev, {
83
83
  hasError: true,
84
- error: _context.t0,
84
+ error: _t,
85
85
  isCreating: false
86
86
  });
87
87
  });
88
88
  }
89
- case 10:
89
+ case 3:
90
90
  case "end":
91
91
  return _context.stop();
92
92
  }
93
- }, _callee, null, [[0, 7]]);
93
+ }, _callee, null, [[0, 2]]);
94
94
  }))();
95
95
  return function () {
96
96
  hasCanceled = true;
@@ -136,16 +136,16 @@ function createCodeSandbox(_x) {
136
136
  function _createCodeSandbox() {
137
137
  _createCodeSandbox = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(parameters) {
138
138
  var res, json, _ref3, sandbox_id;
139
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
139
+ return _regeneratorRuntime.wrap(function (_context2) {
140
140
  while (1) switch (_context2.prev = _context2.next) {
141
141
  case 0:
142
142
  if (Object.entries((parameters === null || parameters === void 0 ? void 0 : parameters.files) || {}).length) {
143
- _context2.next = 2;
143
+ _context2.next = 1;
144
144
  break;
145
145
  }
146
146
  return _context2.abrupt("return", '');
147
- case 2:
148
- _context2.next = 4;
147
+ case 1:
148
+ _context2.next = 2;
149
149
  return fetch('https://codesandbox.io/api/v1/sandboxes/define?json=1', {
150
150
  method: 'POST',
151
151
  headers: {
@@ -154,29 +154,29 @@ function _createCodeSandbox() {
154
154
  },
155
155
  body: JSON.stringify(parameters)
156
156
  });
157
- case 4:
157
+ case 2:
158
158
  res = _context2.sent;
159
159
  if (res.ok) {
160
- _context2.next = 7;
160
+ _context2.next = 3;
161
161
  break;
162
162
  }
163
163
  throw new Error("\u521B\u5EFA CodeSandbox \u5931\u8D25\uFF0C\u9519\u8BEF\u7801\uFF1A" + res.status + " " + res.statusText);
164
- case 7:
165
- _context2.next = 9;
164
+ case 3:
165
+ _context2.next = 4;
166
166
  return res.json()["catch"](function (err) {
167
167
  throw new Error("\u521B\u5EFA CodeSandbox \u5931\u8D25\uFF0C\u670D\u52A1\u5F02\u5E38(" + ((err === null || err === void 0 ? void 0 : err.message) || err || '未知异常') + ")");
168
168
  });
169
- case 9:
169
+ case 4:
170
170
  json = _context2.sent;
171
171
  _ref3 = json || {}, sandbox_id = _ref3.sandbox_id;
172
172
  if (!(!sandbox_id || typeof sandbox_id !== 'string')) {
173
- _context2.next = 13;
173
+ _context2.next = 5;
174
174
  break;
175
175
  }
176
176
  throw new Error("\u521B\u5EFA CodeSandbox \u5931\u8D25\uFF0C\u670D\u52A1\u54CD\u5E94\u5F02\u5E38");
177
- case 13:
177
+ case 5:
178
178
  return _context2.abrupt("return", sandbox_id);
179
- case 14:
179
+ case 6:
180
180
  case "end":
181
181
  return _context2.stop();
182
182
  }
@@ -1,18 +1,18 @@
1
- .code-gen-plugin-code-sandbox-preview {
2
- display: flex;
3
- flex-direction: row;
4
- align-items: center;
5
- align-content: center;
6
- justify-content: center;
7
- justify-items: center;
8
- height: 100%;
9
-
10
- iframe {
11
- width: 100%;
12
- height: 100%;
13
- min-height: 300px;
14
- border: 0;
15
- border-radius: 0;
16
- overflow: hidden;
17
- }
18
- }
1
+ .code-gen-plugin-code-sandbox-preview {
2
+ display: flex;
3
+ flex-direction: row;
4
+ align-items: center;
5
+ align-content: center;
6
+ justify-content: center;
7
+ justify-items: center;
8
+ height: 100%;
9
+
10
+ iframe {
11
+ width: 100%;
12
+ height: 100%;
13
+ min-height: 300px;
14
+ border: 0;
15
+ border-radius: 0;
16
+ overflow: hidden;
17
+ }
18
+ }
@@ -1,36 +1,36 @@
1
- // source: https://at.alicdn.com/t/font_2997782_rtal7ux80t.css
2
-
3
- @font-face {
4
- font-family: "file-types-iconfont"; /* Project id 2997782 */
5
- src: url('//at.alicdn.com/t/font_2997782_rtal7ux80t.woff2?t=1638951976966') format('woff2'),
6
- url('//at.alicdn.com/t/font_2997782_rtal7ux80t.woff?t=1638951976966') format('woff'),
7
- url('//at.alicdn.com/t/font_2997782_rtal7ux80t.ttf?t=1638951976966') format('truetype');
8
- }
9
-
10
- .file-types-iconfont {
11
- font-family: "file-types-iconfont" !important;
12
- font-size: 16px;
13
- font-style: normal;
14
- -webkit-font-smoothing: antialiased;
15
- -moz-osx-font-smoothing: grayscale;
16
- }
17
-
18
- .file-types-icon-folder:before {
19
- content: "\e6e9";
20
- }
21
-
22
- .file-types-icon-text:before {
23
- content: "\e6a7";
24
- }
25
-
26
- .file-types-icon-jsx:before {
27
- content: "\e63b";
28
- }
29
-
30
- .file-types-icon-js:before {
31
- content: "\e618";
32
- }
33
-
34
- .file-types-icon-json:before {
35
- content: "\e642";
36
- }
1
+ // source: https://at.alicdn.com/t/font_2997782_rtal7ux80t.css
2
+
3
+ @font-face {
4
+ font-family: "file-types-iconfont"; /* Project id 2997782 */
5
+ src: url('//at.alicdn.com/t/font_2997782_rtal7ux80t.woff2?t=1638951976966') format('woff2'),
6
+ url('//at.alicdn.com/t/font_2997782_rtal7ux80t.woff?t=1638951976966') format('woff'),
7
+ url('//at.alicdn.com/t/font_2997782_rtal7ux80t.ttf?t=1638951976966') format('truetype');
8
+ }
9
+
10
+ .file-types-iconfont {
11
+ font-family: "file-types-iconfont" !important;
12
+ font-size: 16px;
13
+ font-style: normal;
14
+ -webkit-font-smoothing: antialiased;
15
+ -moz-osx-font-smoothing: grayscale;
16
+ }
17
+
18
+ .file-types-icon-folder:before {
19
+ content: "\e6e9";
20
+ }
21
+
22
+ .file-types-icon-text:before {
23
+ content: "\e6a7";
24
+ }
25
+
26
+ .file-types-icon-jsx:before {
27
+ content: "\e63b";
28
+ }
29
+
30
+ .file-types-icon-js:before {
31
+ content: "\e618";
32
+ }
33
+
34
+ .file-types-icon-json:before {
35
+ content: "\e642";
36
+ }