@cloudbase/lowcode-builder 0.1.16 → 0.1.19

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/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/lowcode-builder",
3
- "version": "0.1.16",
3
+ "version": "0.1.19",
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",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@cloudbase/cals": "^0.3.29",
40
- "@cloudbase/lowcode-generator": "^0.6.22",
40
+ "@cloudbase/lowcode-generator": "^0.6.26",
41
41
  "axios": "^0.21.0",
42
42
  "browserfs": "^1.4.3",
43
43
  "browserify-zlib": "^0.2.0",
@@ -84,4 +84,4 @@
84
84
  "webpack-dev-server": "^4.7.3",
85
85
  "worker-loader": "^3.0.8"
86
86
  }
87
- }
87
+ }
@@ -1,8 +1,7 @@
1
- import { setConfig, getAccessToken, initTcb } from './datasources/index'
2
1
  import lifeCycle from './lowcode/lifecycle'
3
2
  import { app } from './app/weapps-api'
4
3
  // 引入数据源管理器并进行初始化
5
- import { EXTRA_API, createStateDataSourceVar, generateParamsParser } from './datasources/index'
4
+ import { setConfig, getAccessToken, EXTRA_API, createStateDataSourceVar, generateParamsParser } from './datasources/index'
6
5
  import { redirectToLogin, findLoginPage, getAuthConfig } from './common/util'
7
6
 
8
7
  const $app = app;
@@ -220,20 +220,6 @@ export function set(object, path, value) {
220
220
  return object
221
221
  }
222
222
 
223
- /*
224
- 根据 object对象的path路径获取值。 如果解析 value 是 undefined 会以 defaultValue 取代。
225
- */
226
- export function getter(context, path, defaultValue = undefined) {
227
- return lodashGet(context, path, defaultValue);
228
- }
229
-
230
- /*
231
- 设置 object对象中对应 path 属性路径上的值,如果path不存在,则创建。 缺少的索引属性会创建为数组,而缺少的属性会创建为对象。 使用_.setWith 定制path创建
232
- */
233
- export function setter(context, path, value = undefined) {
234
- return lodashSet(context, path, value);
235
- }
236
-
237
223
  export function findLoginPage() {
238
224
  const { app } = getApp();
239
225
  const { pages = [] } = app.__internal__.getConfig();
@@ -367,295 +353,3 @@ export function redirectToLogin(currentPage) {
367
353
  });
368
354
  }
369
355
  }
370
-
371
- // 日期转换
372
- class CustomDate {
373
- constructor() {
374
- this.i18n = {
375
- dayNames: [
376
- 'Sun',
377
- 'Mon',
378
- 'Tue',
379
- 'Wed',
380
- 'Thu',
381
- 'Fri',
382
- 'Sat',
383
- 'Sunday',
384
- 'Monday',
385
- 'Tuesday',
386
- 'Wednesday',
387
- 'Thursday',
388
- 'Friday',
389
- 'Saturday',
390
- ],
391
- monthNames: [
392
- 'Jan',
393
- 'Feb',
394
- 'Mar',
395
- 'Apr',
396
- 'May',
397
- 'Jun',
398
- 'Jul',
399
- 'Aug',
400
- 'Sep',
401
- 'Oct',
402
- 'Nov',
403
- 'Dec',
404
- 'January',
405
- 'February',
406
- 'March',
407
- 'April',
408
- 'May',
409
- 'June',
410
- 'July',
411
- 'August',
412
- 'September',
413
- 'October',
414
- 'November',
415
- 'December',
416
- ],
417
- timeNames: ['a', 'p', 'am', 'pm', 'A', 'P', 'AM', 'PM'],
418
- };
419
- this.masks = {
420
- default: 'ddd mmm dd yyyy HH:MM:ss',
421
- shortDate: 'm/d/yy',
422
- paddedShortDate: 'mm/dd/yyyy',
423
- mediumDate: 'mmm d, yyyy',
424
- longDate: 'mmmm d, yyyy',
425
- fullDate: 'dddd, mmmm d, yyyy',
426
- shortTime: 'h:MM TT',
427
- mediumTime: 'h:MM:ss TT',
428
- longTime: 'h:MM:ss TT Z',
429
- isoDate: 'yyyy-mm-dd',
430
- isoTime: 'HH:MM:ss',
431
- isoDateTime: 'yyyy-mm-dd\'T\'HH:MM:sso',
432
- isoUtcDateTime: 'UTC:yyyy-mm-dd\'T\'HH:MM:ss\'Z\'',
433
- expiresHeaderFormat: 'ddd, dd mmm yyyy HH:MM:ss Z',
434
- };
435
- this.token = /d{1,4}|D{3,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|W{1,2}|[LlopSZN]|"[^"]*"|'[^']*'/g;
436
- this.timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g;
437
- this.timezoneClip = /[^-+\dA-Z]/g;
438
- }
439
-
440
- /*
441
- *
442
- | Name | Mask | Example |
443
- | ----------------- | ------------------------------ | ------------------------ |
444
- | `default` | `ddd mmm dd yyyy HH:MM:ss` | Sat Jun 09 2007 17:46:21 |
445
- | `shortDate` | `m/d/yy` | 6/9/07 |
446
- | `paddedShortDate` | `mm/dd/yyyy` | 06/09/2007 |
447
- | `mediumDate` | `mmm d, yyyy` | Jun 9, 2007 |
448
- | `longDate` | `mmmm d, yyyy` | June 9, 2007 |
449
- | `fullDate` | `dddd, mmmm d, yyyy` | Saturday, June 9, 2007 |
450
- | `shortTime` | `h:MM TT` | 5:46 PM |
451
- | `mediumTime` | `h:MM:ss TT` | 5:46:21 PM |
452
- | `longTime` | `h:MM:ss TT Z` | 5:46:21 PM EST |
453
- | `isoDate` | `yyyy-mm-dd` | 2007-06-09 |
454
- | `isoTime` | `HH:MM:ss` | 17:46:21 |
455
- | `isoDateTime` | `yyyy-mm-dd'T'HH:MM:sso` | 2007-06-09T17:46:21+0700 |
456
- | `isoUtcDateTime` | `UTC:yyyy-mm-dd'T'HH:MM:ss'Z'` | 2007-06-09T22:46:21Z |
457
- *
458
- */
459
- format(date, mask, utc, gmt) {
460
- let newMask = mask;
461
- let newDate = date;
462
- let newUtc = utc;
463
- let newGmt = gmt;
464
- if (arguments.length === 1 && this._kindOf(newDate) === 'string' && !/\d/.test(newDate))
465
- newDate = undefined;
466
- newDate = newDate || newDate === 0 ? newDate : new Date();
467
- if (!(newDate instanceof Date))
468
- newDate = new Date(newDate);
469
- if (isNaN(newDate))
470
- throw TypeError('Invalid date');
471
- newMask = String(this.masks[newMask] || newMask || this.masks['default']);
472
- const maskSlice = newMask.slice(0, 4);
473
- if (maskSlice === 'UTC:' || maskSlice === 'GMT:') {
474
- newMask = newMask.slice(4);
475
- newUtc = true;
476
- if (maskSlice === 'GMT:')
477
- newGmt = true;
478
- }
479
- const _ = newUtc ? 'getUTC' : 'get';
480
- const _d = newDate[`${_}Date`]();
481
- const D = newDate[`${_}Day`]();
482
- const _m = newDate[`${_}Month`]();
483
- const y = newDate[`${_}FullYear`]();
484
- const _H = newDate[`${_}Hours`]();
485
- const _M = newDate[`${_}Minutes`]();
486
- const _s = newDate[`${_}Seconds`]();
487
- const _L = newDate[`${_}Milliseconds`]();
488
- const _o = newUtc ? 0 : newDate.getTimezoneOffset();
489
- const _W = this._getWeek(newDate);
490
- const _N = this._getDayOfWeek(newDate);
491
- // eslint-disable-next-line @typescript-eslint/no-this-alias
492
- const self = this;
493
- // @ts-ignore
494
- // @ts-ignore
495
- const flags = {
496
- d: () => _d,
497
- dd: () => self._pad(_d),
498
- ddd: () => self.i18n.dayNames[D],
499
- DDD: () => self._getDayName({ y, m: _m, d: _d, _, dayName: self.i18n.dayNames[D], short: true }),
500
- dddd: () => self.i18n.dayNames[D + 7],
501
- DDDD: () => self._getDayName({ y: y, m: _m, d: _d, _: _, dayName: self.i18n.dayNames[D + 7] }),
502
- m: () => _m + 1,
503
- mm: () => self._pad(_m + 1),
504
- mmm: () => self.i18n.monthNames[_m],
505
- mmmm: () => self.i18n.monthNames[_m + 12],
506
- yy: () => String(y)
507
- .slice(2),
508
- yyyy: () => self._pad(y, 4),
509
- h: () => _H % 12 || 12,
510
- hh: () => self._pad(_H % 12 || 12),
511
- H: () => _H,
512
- HH: () => self._pad(_H),
513
- M: () => _M,
514
- MM: () => self._pad(_M),
515
- s: () => _s,
516
- ss: () => self._pad(_s),
517
- l: () => self._pad(_L, 3),
518
- L: () => self._pad(Math.floor(_L / 10)),
519
- t: () => (_H < 12 ? self.i18n.timeNames[0] : self.i18n.timeNames[1]),
520
- tt: () => (_H < 12 ? self.i18n.timeNames[2] : self.i18n.timeNames[3]),
521
- T: () => (_H < 12 ? self.i18n.timeNames[4] : self.i18n.timeNames[5]),
522
- TT: () => (_H < 12 ? self.i18n.timeNames[6] : self.i18n.timeNames[7]),
523
- // eslint-disable-next-line no-nested-ternary
524
- Z: () => newGmt ? 'GMT' : newUtc ? 'UTC' : (String(newDate)
525
- .match(self.timezone) || ['']).pop()
526
- .replace(self.timezoneClip, '')
527
- .replace(/GMT\+0000/g, 'UTC'),
528
- o: () => (_o > 0 ? '-' : '+') + self._pad(Math.floor(Math.abs(_o) / 60) * 100 + (Math.abs(_o) % 60), 4),
529
- p: () => `${(_o > 0 ? '-' : '+') + self._pad(Math.floor(Math.abs(_o) / 60), 2)}:${self._pad(Math.floor(Math.abs(_o) % 60), 2)}`,
530
- // @ts-ignore
531
- S: () => ['th', 'st', 'nd', 'rd'][_d % 10 > 3 ? 0 : (((_d % 100) - (_d % 10) != 10) * _d) % 10],
532
- W: () => _W,
533
- WW: () => self._pad(_W),
534
- N: () => _N,
535
- };
536
- return mask.replace(this.token, (match) => {
537
- if (match in flags) {
538
- return flags[match]();
539
- }
540
- return match.slice(1, match.length - 1);
541
- });
542
- }
543
-
544
- _pad(val, len) {
545
- let newVal = String(val);
546
- const newLen = len || 2;
547
- while (newVal.length < newLen) {
548
- newVal = `0${newVal}`;
549
- }
550
- return newVal;
551
- }
552
-
553
- _getDayName(_ref) {
554
- const { y, m, d, _, dayName } = _ref;
555
- const _ref$short = _ref['short'];
556
- const _short = _ref$short === void 0 ? false : _ref$short;
557
- const today = new Date();
558
- const yesterday = new Date();
559
- yesterday.setDate(yesterday[`${_}Date`]() - 1);
560
- const tomorrow = new Date();
561
- tomorrow.setDate(tomorrow[`${_}Date`]() + 1);
562
- const today_d = function today_d() {
563
- return today[`${_}Date`]();
564
- };
565
- const today_m = function today_m() {
566
- return today[`${_}Month`]();
567
- };
568
- const today_y = function today_y() {
569
- return today[`${_}FullYear`]();
570
- };
571
- const yesterday_d = function yesterday_d() {
572
- return yesterday[`${_}Date`]();
573
- };
574
- const yesterday_m = function yesterday_m() {
575
- return yesterday[`${_}Month`]();
576
- };
577
- const yesterday_y = function yesterday_y() {
578
- return yesterday[`${_}FullYear`]();
579
- };
580
- const tomorrow_d = function tomorrow_d() {
581
- return tomorrow[`${_}Date`]();
582
- };
583
- const tomorrow_m = function tomorrow_m() {
584
- return tomorrow[`${_}Month`]();
585
- };
586
- const tomorrow_y = function tomorrow_y() {
587
- return tomorrow[`${_}FullYear`]();
588
- };
589
- if (today_y() === y && today_m() === m && today_d() === d) {
590
- return _short ? 'Tdy' : 'Today';
591
- }
592
- if (yesterday_y() === y && yesterday_m() === m && yesterday_d() === d) {
593
- return _short ? 'Ysd' : 'Yesterday';
594
- }
595
- if (tomorrow_y() === y && tomorrow_m() === m && tomorrow_d() === d) {
596
- return _short ? 'Tmw' : 'Tomorrow';
597
- }
598
- return dayName;
599
- }
600
-
601
- _getWeek(date) {
602
- const targetThursday = new Date(date.getFullYear(), date.getMonth(), date.getDate());
603
- targetThursday.setDate(targetThursday.getDate() - ((targetThursday.getDay() + 6) % 7) + 3);
604
- const firstThursday = new Date(targetThursday.getFullYear(), 0, 4);
605
- firstThursday.setDate(firstThursday.getDate() - ((firstThursday.getDay() + 6) % 7) + 3);
606
- const ds = targetThursday.getTimezoneOffset() - firstThursday.getTimezoneOffset();
607
- targetThursday.setHours(targetThursday.getHours() - ds);
608
- const weekDiff = (targetThursday - firstThursday) / (864e5 * 7);
609
- return 1 + Math.floor(weekDiff);
610
- }
611
-
612
- _getDayOfWeek(date) {
613
- let dow = date.getDay();
614
- if (dow === 0) {
615
- dow = 7;
616
- }
617
- return dow;
618
- }
619
-
620
- _kindOf(val) {
621
- if (val === null) {
622
- return 'null';
623
- }
624
- if (val === undefined) {
625
- return 'undefined';
626
- }
627
- if (this._typeof(val) !== 'object') {
628
- return this._typeof(val);
629
- }
630
- if (Array.isArray(val)) {
631
- return 'array';
632
- }
633
- return {}.toString
634
- .call(val)
635
- .slice(8, -1)
636
- .toLowerCase();
637
- }
638
-
639
- _typeof(obj) {
640
- if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') {
641
- this._typeof = function _typeof(obj) {
642
- return typeof obj;
643
- };
644
- } else {
645
- this._typeof = function _typeof(obj) {
646
- return obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype
647
- ? 'symbol'
648
- : typeof obj;
649
- };
650
- }
651
- return this._typeof(obj);
652
- }
653
- }
654
-
655
- const dataInstance = new CustomDate();
656
- export const formatDate = new CustomDate().format.bind(dataInstance);
657
- export const utils = {
658
- formatDate,
659
- get: getter,
660
- set: setter,
661
- };
@@ -3,8 +3,8 @@
3
3
  "version": "1.0.8",
4
4
  "scripts": {},
5
5
  "dependencies": {
6
- "@cloudbase/weda-client": "^0.2.2",
7
- "@cloudbase/oauth": "0.1.1-alpha.2",
6
+ "@cloudbase/weda-client": "^0.2.4",
7
+ "@cloudbase/oauth": "0.1.1-alpha.5",
8
8
  "mobx": "^5.15.4",
9
9
  "lodash.get": "^4.4.2",
10
10
  "lodash.set": "^4.3.2",
@@ -9,7 +9,7 @@
9
9
  "@tcwd/weapps-core": "2.2.6",
10
10
  "@tcwd/weapps-sdk": "1.2.9",
11
11
  "@zxing/library": "^0.18.6",
12
- "@cloudbase/weda-client": "^0.2.2",
12
+ "@cloudbase/weda-client": "^0.2.4",
13
13
  "fastclick": "^1.0.6",
14
14
  "lodash": "^4.17.19",
15
15
  "mobx": "^5.15.4",
@@ -3,12 +3,10 @@ import { createComputed } from 'utils';
3
3
  import store, { subPackageName } from '../store';
4
4
  import computed from '../store/computed';
5
5
  import common from './common';
6
- import { formatDate } from '../utils/date';
7
- import { getter, setter, _isMobile } from '../utils';
6
+ import { _isMobile } from '../utils';
8
7
  import actionMap from './material-actions';
9
- import { scanCodeApi } from '../utils/scan-code-action';
10
8
  import { createWebApp, _ACTIONS_KEY as ACTIONS_KEY, _ROUTER_KEY as ROUTER_KEY } from '@cloudbase/weda-client';
11
- import { createDataset, EXTRA_API } from '../datasources/index'
9
+ import { createDataset, EXTRA_API } from '../datasources/index';
12
10
 
13
11
  const mainAppKey = '__weappsMainApp';
14
12
  const appGlobal = process.env.isMiniprogram ? getApp() : window;
@@ -35,7 +33,7 @@ function createGlboalApi() {
35
33
  state: store,
36
34
  computed: createComputed(computed.global),
37
35
  common,
38
- ...mpApp
36
+ ...mpApp,
39
37
  // ... other sdk apis & apis from mp
40
38
  }; // The global api exposed to lowcode
41
39
 
@@ -44,11 +42,7 @@ function createGlboalApi() {
44
42
  globalAPI.state.dataset = dataset;
45
43
  globalAPI.setState = (userSetState) => {
46
44
  Object.keys(userSetState).forEach((keyPath) => {
47
- globalAPI.utils.set(
48
- globalAPI.dataset.state,
49
- keyPath,
50
- userSetState[keyPath]
51
- );
45
+ globalAPI.utils.set(globalAPI.dataset.state, keyPath, userSetState[keyPath]);
52
46
  });
53
47
  };
54
48
  /**
@@ -10,20 +10,6 @@ export function createComputed(funcs, bindContext = null) {
10
10
  return obj;
11
11
  }
12
12
 
13
- /*
14
- 根据 object对象的path路径获取值。 如果解析 value 是 undefined 会以 defaultValue 取代。
15
- */
16
- export function getter(context, path, defaultValue = undefined) {
17
- return lodashGet(context, path, defaultValue);
18
- }
19
-
20
- /*
21
- 设置 object对象中对应 path 属性路径上的值,如果path不存在,则创建。 缺少的索引属性会创建为数组,而缺少的属性会创建为对象。 使用_.setWith 定制path创建
22
- */
23
- export function setter(context, path, value = undefined) {
24
- return lodashSet(context, path, value);
25
- }
26
-
27
13
  export function checkVisible({ _visible }) {
28
14
  return _visible !== false && _visible !== '';
29
15
  }
@@ -69,10 +55,10 @@ export function _isMobile() {
69
55
  (function (a) {
70
56
  if (
71
57
  /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(
72
- a
58
+ a,
73
59
  ) ||
74
60
  /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(
75
- a.substr(0, 4)
61
+ a.substr(0, 4),
76
62
  )
77
63
  )
78
64
  check = true;