@cloudbase/lowcode-builder 1.8.45-beta.3 → 1.8.45-ide.1

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.
@@ -1,3 +1,3 @@
1
1
  export declare function BabelTransform(code: any, options?: {
2
2
  IIFE?: boolean;
3
- }): any;
3
+ }): string;
@@ -1,69 +1,75 @@
1
1
  "use strict";
2
+ /* eslint-disable no-new-func */
3
+ // import { transformSync } from '@babel/core';
2
4
  Object.defineProperty(exports, "__esModule", { value: true });
3
5
  exports.BabelTransform = void 0;
4
- /* eslint-disable no-new-func */
5
- const core_1 = require("@babel/core");
6
+ // export function BabelTransform(
7
+ // code,
8
+ // options: {
9
+ // IIFE?: boolean;
10
+ // } = {},
11
+ // ) {
12
+ // const { IIFE = false } = options;
13
+ // /**
14
+ // * 如果 trim 完为空
15
+ // * 则原样不用再编译了
16
+ // */
17
+ // if (!code?.trim?.()) {
18
+ // return code;
19
+ // }
20
+ // try {
21
+ // /**
22
+ // * 如果是基础字面量的话
23
+ // * 可以直接使用原值,不用过babel
24
+ // */
25
+ // if (typeof code === 'string' && JSON.parse(code?.trim?.())) {
26
+ // return code;
27
+ // }
28
+ // } catch (e) {}
29
+ // try {
30
+ // const simpleWrapped = `(\n${code || 'undefined'}\n)`;
31
+ // const { code: expression } =
32
+ // transformSync(IIFE ? `(()=>${simpleWrapped})()` : simpleWrapped, {
33
+ // cwd: __dirname,
34
+ // sourceType: 'script',
35
+ // comments: false,
36
+ // // minified: true,
37
+ // presets: [
38
+ // [
39
+ // '@babel/preset-env',
40
+ // {
41
+ // targets: {
42
+ // /**
43
+ // * 支持 proxy 的版本
44
+ // * 低于这个版本完全无法支持
45
+ // */
46
+ // // browsers: ['chrome >= 49', 'iOS >= 10', 'safari >= 10'],
47
+ // /**
48
+ // * 一个相对较高的版本,包涵解构赋值,这样不用注入太多 polifill
49
+ // * 但是不包涵 options chain
50
+ // * 基本上是 es2019
51
+ // */
52
+ // browsers: ['chrome >= 67', 'iOS >= 12', 'safari >= 12'],
53
+ // },
54
+ // include: [
55
+ // // es2015
56
+ // '@babel/plugin-transform-arrow-functions',
57
+ // ],
58
+ // },
59
+ // ],
60
+ // ],
61
+ // }) || {};
62
+ // const res = expression?.replace?.(/;$/, '') || code;
63
+ // if (expression) {
64
+ // new Function(`return (\n${res}\n)`);
65
+ // }
66
+ // return res;
67
+ // } catch (e: any) {
68
+ // console.error(`transform [${code}] fail:`, e?.message);
69
+ // return code;
70
+ // }
71
+ // }
6
72
  function BabelTransform(code, options = {}) {
7
- var _a, _b, _c;
8
- const { IIFE = false } = options;
9
- /**
10
- * 如果 trim 完为空
11
- * 则原样不用再编译了
12
- */
13
- if (!((_a = code === null || code === void 0 ? void 0 : code.trim) === null || _a === void 0 ? void 0 : _a.call(code))) {
14
- return code;
15
- }
16
- try {
17
- /**
18
- * 如果是基础字面量的话
19
- * 可以直接使用原值,不用过babel
20
- */
21
- if (typeof code === 'string' && JSON.parse((_b = code === null || code === void 0 ? void 0 : code.trim) === null || _b === void 0 ? void 0 : _b.call(code))) {
22
- return code;
23
- }
24
- }
25
- catch (e) { }
26
- try {
27
- const simpleWrapped = `(\n${code || 'undefined'}\n)`;
28
- const { code: expression } = (0, core_1.transformSync)(IIFE ? `(()=>${simpleWrapped})()` : simpleWrapped, {
29
- cwd: __dirname,
30
- sourceType: 'script',
31
- comments: false,
32
- // minified: true,
33
- presets: [
34
- [
35
- '@babel/preset-env',
36
- {
37
- targets: {
38
- /**
39
- * 支持 proxy 的版本
40
- * 低于这个版本完全无法支持
41
- */
42
- // browsers: ['chrome >= 49', 'iOS >= 10', 'safari >= 10'],
43
- /**
44
- * 一个相对较高的版本,包涵解构赋值,这样不用注入太多 polifill
45
- * 但是不包涵 options chain
46
- * 基本上是 es2019
47
- */
48
- browsers: ['chrome >= 67', 'iOS >= 12', 'safari >= 12'],
49
- },
50
- include: [
51
- // es2015
52
- '@babel/plugin-transform-arrow-functions',
53
- ],
54
- },
55
- ],
56
- ],
57
- }) || {};
58
- const res = ((_c = expression === null || expression === void 0 ? void 0 : expression.replace) === null || _c === void 0 ? void 0 : _c.call(expression, /;$/, '')) || code;
59
- if (expression) {
60
- new Function(`return (\n${res}\n)`);
61
- }
62
- return res;
63
- }
64
- catch (e) {
65
- console.error(`transform [${code}] fail:`, e === null || e === void 0 ? void 0 : e.message);
66
- return code;
67
- }
73
+ return '';
68
74
  }
69
75
  exports.BabelTransform = BabelTransform;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/lowcode-builder",
3
- "version": "1.8.45-beta.3",
3
+ "version": "1.8.45-ide.1",
4
4
  "description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
5
5
  "author": "yhsunshining@gmail.com",
6
6
  "homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
@@ -31,21 +31,16 @@
31
31
  "build": "tsc",
32
32
  "test:build": "ts-node ./__tests__/build.ts",
33
33
  "dev:web:serve": "rm -rf dist && node ./webpack/scripts/web.pre.js && cross-env NODE_ENV=development webpack-dev-server --config ./webpack/web.config.js",
34
- "dev:web": "rm -rf dist && cross-env NODE_ENV=development webpack --config ./webpack/web.config.js",
35
- "build:web": "rm -rf dist && cross-env NODE_ENV=production webpack --config ./webpack/web.config.js && cp -Rf dist/ lib/",
36
- "build:template": "./scripts/buildTemplate.sh",
37
- "dev:debug": "tsc-watch --onSuccess 'npm run build-dev-web-and-push'",
38
- "build-dev-web-and-push": "npm run dev:web && clear && yalc publish --push",
39
- "release": "yarn npm whoami --publish && npm run build && npm run build:web && yarn set version 1.22.19 && yarn config set version-tag-prefix '@cloudbase/lowcode-builder@' && yarn version --no-commit-hooks --message 'chore(builder): v%s' && yarn config set version-tag-prefix v && yarn set version 3.6.2 && yarn npm publish"
34
+ "dev:web": "rm -rf dist && node ./webpack/scripts/web.pre.js && cross-env NODE_ENV=development webpack --config ./webpack/web.config.js && node ./webpack/scripts/web.post.js",
35
+ "build:web": "rm -rf dist && node ./webpack/scripts/web.pre.js && cross-env NODE_ENV=production webpack --config ./webpack/web.config.js && node ./webpack/scripts/web.post.js",
36
+ "build:template": "./scripts/buildTemplate.sh"
40
37
  },
41
38
  "bugs": {
42
39
  "url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
43
40
  },
44
41
  "dependencies": {
45
- "@babel/core": "7.21.4",
46
- "@babel/preset-env": "7.21.4",
47
- "@cloudbase/cals": "^1.0.31-beta.2",
48
- "@cloudbase/lowcode-generator": "^1.8.15-beta.2",
42
+ "@cloudbase/cals": "^1.0.29",
43
+ "@cloudbase/lowcode-generator": "^1.8.14",
49
44
  "axios": "^0.21.0",
50
45
  "browserfs": "^1.4.3",
51
46
  "browserify-zlib": "^0.2.0",
@@ -81,7 +76,6 @@
81
76
  "jest": "^27.5.1",
82
77
  "ts-loader": "^8.3.0",
83
78
  "ts-node": "^10.4.0",
84
- "tsc-watch": "^6.0.4",
85
79
  "typescript": "^4.7.4",
86
80
  "uglifyjs-webpack-plugin": "^2.2.0",
87
81
  "webpack-cli": "^4.9.1",
@@ -14,7 +14,7 @@ export default {
14
14
  }
15
15
  for (const id in widgets) {
16
16
  const props = widgets[id]
17
- dataFactory['<%= dataPropNames.widgetProp %>' + id] = () => resolveWidgetData(props, id)
17
+ dataFactory['<%= dataPropNames.widgetProp %>' + id] = () => resolveWidgetData(props)
18
18
  }
19
19
  const disposers = []
20
20
  for (const k in dataFactory) {
@@ -51,7 +51,7 @@ const EXTRA_PROPS_MAP = [
51
51
  return map;
52
52
  }, {});
53
53
 
54
- function resolveWidgetProp(props, widgetId) {
54
+ function resolveWidgetProp(props) {
55
55
  let { classList = [], _staticResourceAttribute = ['src'], ...restProps } = props;
56
56
  const data = {};
57
57
  Object.keys(restProps).forEach((key) => {
@@ -64,7 +64,7 @@ function resolveWidgetProp(props, widgetId) {
64
64
  data[key] = restProps[key];
65
65
  });
66
66
  data.style = styleToCss(restProps.style);
67
- data.className = `${widgetId ? `wd-comp-id-${widgetId}` : ''} ${classList.join ? classList.join(' ') : classList}`;
67
+ data.className = classList.join ? classList.join(' ') : classList;
68
68
 
69
69
  _staticResourceAttribute?.forEach?.((property) => {
70
70
  processStaticResourceAttribute(data, undefined, property);
@@ -73,11 +73,11 @@ function resolveWidgetProp(props, widgetId) {
73
73
  }
74
74
 
75
75
  // widget prop -> wxml data
76
- export function resolveWidgetData(props, widgetId) {
76
+ export function resolveWidgetData(props) {
77
77
  if (!Array.isArray(props)) {
78
- return resolveWidgetProp(props, widgetId);
78
+ return resolveWidgetProp(props);
79
79
  }
80
- return props.map(prop => resolveWidgetData(prop, widgetId));
80
+ return props.map(resolveWidgetData);
81
81
  }
82
82
 
83
83
  export function createWidgets(widgetProps, dataBinds, ownerMpInst, widgetHolder) {
@@ -591,7 +591,7 @@ export function disposeWidget(widget, noRecursive = false) {
591
591
  export function createInitData(widgets, dataBinds, keyPrefix = '') {
592
592
  return Object.keys(widgets).reduce((result, id) => {
593
593
  if (!isWidgetInFor(id, widgets, dataBinds)) {
594
- result[keyPrefix + id] = resolveWidgetData(widgets[id], id);
594
+ result[keyPrefix + id] = resolveWidgetData(widgets[id]);
595
595
  } else {
596
596
  result[keyPrefix + id] = [];
597
597
  }