@dckj-npm/lowcode-plugin-code-generator 1.0.3 → 1.0.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.
@@ -4,9 +4,9 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import './CodeGenActionBtn.scss';
5
5
  import React, { useState } from 'react';
6
6
  import * as CodeGenerator from '@dckj-npm/lowcode-code-generator/standalone-loader';
7
- import { TransformStage } from '@alilc/lowcode-types';
8
7
  import { Button, Drawer, Loading, Message } from '@alifd/next';
9
8
  import coerce from 'semver/functions/coerce';
9
+ import { project } from '@alilc/lowcode-engine';
10
10
  import { CodeGenResult } from '../CodeGenResult';
11
11
  export function CodeGenActionBtn(_ref) {
12
12
  var ctx = _ref.ctx;
@@ -23,7 +23,7 @@ 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 originalSchema, originalSchema2, schema, result;
26
+ var originalSchema, schema, result;
27
27
  return _regeneratorRuntime.wrap(function _callee$(_context) {
28
28
  while (1) switch (_context.prev = _context.next) {
29
29
  case 0:
@@ -39,25 +39,22 @@ export function CodeGenActionBtn(_ref) {
39
39
 
40
40
  // 获取 schema,并修正
41
41
  _context.next = 4;
42
- return ctx.project.exportSchema(TransformStage.Save);
42
+ return project.exportSchema();
43
43
  case 4:
44
44
  originalSchema = _context.sent;
45
45
  console.log('ctx ', ctx);
46
- console.log('isActive ', ctx.workspace.isActive);
47
- console.log('window ', ctx.workspace.window);
48
- console.log('skeleton ', ctx.workspace.skeleton);
49
- console.log('windows ', ctx.workspace.windows);
50
- console.log('ctx ', ctx.workspace.currentProject);
51
- _context.next = 13;
52
- return ctx.project.exportSchema();
53
- case 13:
54
- originalSchema2 = _context.sent;
55
- _context.next = 16;
46
+ // console.log('isActive ', ctx.workspace.isActive)
47
+ // console.log('window.exportSchema ', ctx.workspace.window.exportSchema())
48
+ // console.log('skeleton ', ctx.workspace.skeleton)
49
+ // console.log('windows ', ctx.workspace.windows)
50
+ // const originalSchema2 = await ctx.project.exportSchema();
51
+ _context.next = 8;
56
52
  return fixSchema(originalSchema);
57
- case 16:
53
+ case 8:
58
54
  schema = _context.sent;
59
55
  console.log('got schema:222222 ', schema);
60
- console.log('got schema:33333333 ', originalSchema2);
56
+ // console.log('got schema:33333333 ', originalSchema2);
57
+
61
58
  setState(function (prev) {
62
59
  return _extends({}, prev, {
63
60
  schema: schema,
@@ -66,13 +63,13 @@ export function CodeGenActionBtn(_ref) {
66
63
  });
67
64
 
68
65
  // 出码...
69
- _context.next = 22;
66
+ _context.next = 13;
70
67
  return CodeGenerator.generateCode({
71
68
  solution: 'vuejs3',
72
69
  schema: schema,
73
70
  flattenResult: true
74
71
  });
75
- case 22:
72
+ case 13:
76
73
  result = _context.sent;
77
74
  console.log('generated: ', result);
78
75
  setState(function (prev) {
@@ -81,10 +78,10 @@ export function CodeGenActionBtn(_ref) {
81
78
  result: result
82
79
  });
83
80
  });
84
- _context.next = 31;
81
+ _context.next = 22;
85
82
  break;
86
- case 27:
87
- _context.prev = 27;
83
+ case 18:
84
+ _context.prev = 18;
88
85
  _context.t0 = _context["catch"](0);
89
86
  console.error('failed to run code generator: ', _context.t0);
90
87
  setState(function (prev) {
@@ -93,11 +90,11 @@ export function CodeGenActionBtn(_ref) {
93
90
  error: _context.t0 instanceof Error ? _context.t0 : new Error("" + ((_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message) || _context.t0))
94
91
  });
95
92
  });
96
- case 31:
93
+ case 22:
97
94
  case "end":
98
95
  return _context.stop();
99
96
  }
100
- }, _callee, null, [[0, 27]]);
97
+ }, _callee, null, [[0, 18]]);
101
98
  }));
102
99
  return function handleClick() {
103
100
  return _ref2.apply(this, arguments);
@@ -10,9 +10,9 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
10
10
  require("./CodeGenActionBtn.scss");
11
11
  var _react = _interopRequireWildcard(require("react"));
12
12
  var CodeGenerator = _interopRequireWildcard(require("@dckj-npm/lowcode-code-generator/standalone-loader"));
13
- var _lowcodeTypes = require("@alilc/lowcode-types");
14
13
  var _next = require("@alifd/next");
15
14
  var _coerce = _interopRequireDefault(require("semver/functions/coerce"));
15
+ var _lowcodeEngine = require("@alilc/lowcode-engine");
16
16
  var _CodeGenResult = require("../CodeGenResult");
17
17
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
18
18
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
@@ -31,7 +31,7 @@ function CodeGenActionBtn(_ref) {
31
31
  setState = _useState[1];
32
32
  var handleClick = /*#__PURE__*/function () {
33
33
  var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
34
- var originalSchema, originalSchema2, schema, result;
34
+ var originalSchema, schema, result;
35
35
  return _regenerator["default"].wrap(function _callee$(_context) {
36
36
  while (1) switch (_context.prev = _context.next) {
37
37
  case 0:
@@ -47,25 +47,22 @@ function CodeGenActionBtn(_ref) {
47
47
 
48
48
  // 获取 schema,并修正
49
49
  _context.next = 4;
50
- return ctx.project.exportSchema(_lowcodeTypes.TransformStage.Save);
50
+ return _lowcodeEngine.project.exportSchema();
51
51
  case 4:
52
52
  originalSchema = _context.sent;
53
53
  console.log('ctx ', ctx);
54
- console.log('isActive ', ctx.workspace.isActive);
55
- console.log('window ', ctx.workspace.window);
56
- console.log('skeleton ', ctx.workspace.skeleton);
57
- console.log('windows ', ctx.workspace.windows);
58
- console.log('ctx ', ctx.workspace.currentProject);
59
- _context.next = 13;
60
- return ctx.project.exportSchema();
61
- case 13:
62
- originalSchema2 = _context.sent;
63
- _context.next = 16;
54
+ // console.log('isActive ', ctx.workspace.isActive)
55
+ // console.log('window.exportSchema ', ctx.workspace.window.exportSchema())
56
+ // console.log('skeleton ', ctx.workspace.skeleton)
57
+ // console.log('windows ', ctx.workspace.windows)
58
+ // const originalSchema2 = await ctx.project.exportSchema();
59
+ _context.next = 8;
64
60
  return fixSchema(originalSchema);
65
- case 16:
61
+ case 8:
66
62
  schema = _context.sent;
67
63
  console.log('got schema:222222 ', schema);
68
- console.log('got schema:33333333 ', originalSchema2);
64
+ // console.log('got schema:33333333 ', originalSchema2);
65
+
69
66
  setState(function (prev) {
70
67
  return (0, _extends2["default"])({}, prev, {
71
68
  schema: schema,
@@ -74,13 +71,13 @@ function CodeGenActionBtn(_ref) {
74
71
  });
75
72
 
76
73
  // 出码...
77
- _context.next = 22;
74
+ _context.next = 13;
78
75
  return CodeGenerator.generateCode({
79
76
  solution: 'vuejs3',
80
77
  schema: schema,
81
78
  flattenResult: true
82
79
  });
83
- case 22:
80
+ case 13:
84
81
  result = _context.sent;
85
82
  console.log('generated: ', result);
86
83
  setState(function (prev) {
@@ -89,10 +86,10 @@ function CodeGenActionBtn(_ref) {
89
86
  result: result
90
87
  });
91
88
  });
92
- _context.next = 31;
89
+ _context.next = 22;
93
90
  break;
94
- case 27:
95
- _context.prev = 27;
91
+ case 18:
92
+ _context.prev = 18;
96
93
  _context.t0 = _context["catch"](0);
97
94
  console.error('failed to run code generator: ', _context.t0);
98
95
  setState(function (prev) {
@@ -101,11 +98,11 @@ function CodeGenActionBtn(_ref) {
101
98
  error: _context.t0 instanceof Error ? _context.t0 : new Error("" + ((_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message) || _context.t0))
102
99
  });
103
100
  });
104
- case 31:
101
+ case 22:
105
102
  case "end":
106
103
  return _context.stop();
107
104
  }
108
- }, _callee, null, [[0, 27]]);
105
+ }, _callee, null, [[0, 18]]);
109
106
  }));
110
107
  return function handleClick() {
111
108
  return _ref2.apply(this, arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dckj-npm/lowcode-plugin-code-generator",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "集团低代码引擎 - 浏览器出码插件",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -32,6 +32,8 @@
32
32
  ],
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
+ "@alifd/build-plugin-lowcode": "^0.4.0",
36
+ "@alilc/build-plugin-alt": "^1.3.4",
35
37
  "@alilc/lowcode-code-generator": "^1.0.4",
36
38
  "@alilc/lowcode-plugin-base-monaco-editor": "^1.0.0",
37
39
  "@alilc/lowcode-types": "^1.0.0",