@cloudbase/lowcode-builder 0.1.18 → 0.1.21

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.
@@ -6,12 +6,12 @@ export declare const materialsDirName = "materials";
6
6
  * src/template的代码,在IDE编辑器插件中构建builder
7
7
  * 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488&region=ap-shanghai&path=%252Flcap-builder%252F
8
8
  */
9
- export declare const builderTemplateURL = "https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/template.zip";
9
+ export declare const builderTemplateURL = "https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/template_20220616.zip";
10
10
  /**
11
11
  * miniprogram的代码,IDE插件后续会提供端功能
12
12
  * 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488&region=ap-shanghai&path=%252Flcap-builder%252F
13
13
  */
14
- export declare const miniprogramURL = "https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/miniprogram_npm_20220425.zip";
14
+ export declare const miniprogramURL = "https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/miniprogram_npm_20220616.zip";
15
15
  /**
16
16
  * miniprogram_npm存放目录。IDE插件builder用到
17
17
  */
@@ -39,13 +39,12 @@ exports.materialsDirName = 'materials'; // materials diretory of current project
39
39
  * src/template的代码,在IDE编辑器插件中构建builder
40
40
  * 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488&region=ap-shanghai&path=%252Flcap-builder%252F
41
41
  */
42
- exports.builderTemplateURL = 'https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/template.zip';
42
+ exports.builderTemplateURL = 'https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/template_20220616.zip';
43
43
  /**
44
44
  * miniprogram的代码,IDE插件后续会提供端功能
45
45
  * 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488&region=ap-shanghai&path=%252Flcap-builder%252F
46
46
  */
47
- // export const miniprogramURL = 'https://cos-1252394733.cos.ap-nanjing.myqcloud.com/miniprogram_npm.zip';
48
- exports.miniprogramURL = 'https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/miniprogram_npm_20220425.zip';
47
+ exports.miniprogramURL = 'https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/miniprogram_npm_20220616.zip';
49
48
  /**
50
49
  * miniprogram_npm存放目录。IDE插件builder用到
51
50
  */
@@ -71,7 +71,7 @@ export interface IInstallOpts {
71
71
  }
72
72
  export declare function installDependencies(targetDir: string, options?: IInstallOpts): Promise<void>;
73
73
  export declare function getMaterialNodeModulesPathList(dependencies: IMaterialItem[] | undefined, materialsDir: string): string[];
74
- export declare function generateWebpackWebDevServerFile({ appBuildDir, buildTypeList, }: {
74
+ export declare function generateWebpackWebDevServerFile({ appBuildDir, buildTypeList }: {
75
75
  appBuildDir: any;
76
76
  buildTypeList: any;
77
77
  }): Promise<void>;
@@ -278,10 +278,7 @@ function getWebpackWebBuildParams(appId, appBuildDir, publicPath = '/', mode = c
278
278
  path: path_1.default.resolve(appBuildDir, './preview'),
279
279
  filename: '[name].[contenthash].bundle.js',
280
280
  chunkFilename: '[name].[contenthash].chunk.js',
281
- publicPath: buildTypeList.includes(common_1.BuildType.APP) ||
282
- buildTypeList.includes(common_1.BuildType.ADMIN_PORTAL)
283
- ? ''
284
- : publicPath,
281
+ publicPath: buildTypeList.includes(common_1.BuildType.APP) || buildTypeList.includes(common_1.BuildType.ADMIN_PORTAL) ? '' : publicPath,
285
282
  pathinfo: false,
286
283
  // clean: mode === WebpackModeType.PRODUCTION,
287
284
  },
@@ -340,9 +337,7 @@ function getAllPageMpEntryPath(allAppDataList, appBuildDir) {
340
337
  const { pageInstanceList, rootPath } = app;
341
338
  const packagePathStr = rootPath ? `packages/${rootPath}` : '';
342
339
  (0, weapps_core_1.loopDealWithFn)(pageInstanceList, (pageInstance) => {
343
- const pageName = rootPath
344
- ? `${rootPath}_${pageInstance.id}`
345
- : pageInstance.id;
340
+ const pageName = rootPath ? `${rootPath}_${pageInstance.id}` : pageInstance.id;
346
341
  entry[pageName] = path_1.default.resolve(appBuildDir, path_1.default.join('src', packagePathStr, `pages/${getPageName(pageInstance.id)}/main.mp.jsx`));
347
342
  });
348
343
  });
@@ -390,7 +385,7 @@ async function downloadDependencies(targetDir, srcZipUrl) {
390
385
  await compressing_1.default.zip.uncompress(response.data, targetDir);
391
386
  }
392
387
  catch (e) {
393
- console.error('Fail to download weapps material package ' + srcZipUrl, e);
388
+ console.error(`Fail to download weapps material package ${srcZipUrl}`, e);
394
389
  throw e;
395
390
  }
396
391
  }
@@ -407,9 +402,8 @@ async function installDependencies(targetDir, options = {}) {
407
402
  }
408
403
  }
409
404
  catch (e) { }
410
- if ((options === null || options === void 0 ? void 0 : options.ignoreInstall) &&
411
- fs_extra_1.default.existsSync(path_1.default.join(targetDir, 'node_modules'))) {
412
- console.log('ignore install dependencies in ' + targetDir);
405
+ if ((options === null || options === void 0 ? void 0 : options.ignoreInstall) && fs_extra_1.default.existsSync(path_1.default.join(targetDir, 'node_modules'))) {
406
+ console.log(`ignore install dependencies in ${targetDir}`);
413
407
  return;
414
408
  }
415
409
  // const isExist = fs.existsSync(path.join(targetDir, 'package-lock.json'))
@@ -418,16 +412,11 @@ async function installDependencies(targetDir, options = {}) {
418
412
  if (packageName && options.latest) {
419
413
  packageName = `${packageName}@latest`;
420
414
  }
421
- console.log('Installing dependencies in ' + targetDir);
415
+ console.log(`Installing dependencies in ${targetDir}`);
422
416
  const operationTag = `---------------- ${yarnExists ? 'yarn' : 'npm'} Install dependencies`;
423
417
  console.time(operationTag);
424
418
  const registry = `--registry=${config_1.npmRegistry}`;
425
- const npmOptions = [
426
- '--prefer-offline',
427
- '--no-audit',
428
- '--progress=false',
429
- registry,
430
- ];
419
+ const npmOptions = ['--prefer-offline', '--no-audit', '--progress=false', registry];
431
420
  if (options === null || options === void 0 ? void 0 : options.isDependence) {
432
421
  npmOptions.push('--production');
433
422
  }
@@ -474,7 +463,7 @@ function getMaterialNodeModulesPathList(dependencies = [], materialsDir) {
474
463
  }
475
464
  exports.getMaterialNodeModulesPathList = getMaterialNodeModulesPathList;
476
465
  // 生成devServer 核心依赖
477
- async function generateWebpackWebDevServerFile({ appBuildDir, buildTypeList, }) {
466
+ async function generateWebpackWebDevServerFile({ appBuildDir, buildTypeList }) {
478
467
  const dest = path_1.default.resolve(appBuildDir, `./webpack/devServer.js`);
479
468
  const template = await fs_extra_1.default.readFile(path_1.default.resolve(config_2.appTemplateDir, './webpack/devServer.js'), {
480
469
  encoding: 'utf8',
@@ -501,7 +490,7 @@ async function downloadAssets(targetDir, assetUrl) {
501
490
  // proxy: false
502
491
  }));
503
492
  if (err) {
504
- console.error('Fail to download weapps material package ' + assetUrl, err);
493
+ console.error(`Fail to download weapps material package ${assetUrl}`, err);
505
494
  throw err;
506
495
  }
507
496
  await fs_extra_1.default.ensureDir(targetDir);
@@ -1,7 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { IBuildContext } from '../mp/BuildContext';
3
3
  import { OutputType } from 'jszip';
4
- import { Buffer } from 'buffer';
5
4
  export default function generateFiles(appFileData: any, srcDir: string, dstDir: string, ctx: IBuildContext): Promise<string[]>;
6
5
  export declare function writeFile(outFile: string, content: string): Promise<boolean>;
7
6
  export declare function removeFile(file: string): void;
@@ -48,5 +47,5 @@ export declare function getFiles(dir: string, files_: any, replacePath?: string)
48
47
  */
49
48
  export declare function fileToZip(files: {
50
49
  [key: string]: Uint8Array;
51
- }, type: OutputType): Promise<string | Buffer | Uint8Array | ArrayBuffer | number[] | Blob>;
50
+ }, type: OutputType): Promise<string | Buffer | Uint8Array | number[] | ArrayBuffer | Blob>;
52
51
  export declare function strToBuf(str: any): Buffer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/lowcode-builder",
3
- "version": "0.1.18",
3
+ "version": "0.1.21",
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",
@@ -8,11 +8,13 @@
8
8
  "main": "lib/index.js",
9
9
  "types": "lib/index.d.ts",
10
10
  "directories": {
11
+ "dist": "dist",
11
12
  "lib": "lib",
12
13
  "test": "__tests__"
13
14
  },
14
15
  "files": [
15
16
  "lib",
17
+ "dist",
16
18
  "template"
17
19
  ],
18
20
  "publishConfig": {
@@ -37,7 +39,7 @@
37
39
  },
38
40
  "dependencies": {
39
41
  "@cloudbase/cals": "^0.3.29",
40
- "@cloudbase/lowcode-generator": "^0.6.21",
42
+ "@cloudbase/lowcode-generator": "^0.6.26",
41
43
  "axios": "^0.21.0",
42
44
  "browserfs": "^1.4.3",
43
45
  "browserify-zlib": "^0.2.0",
@@ -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.5",
6
+ "@cloudbase/weda-client": "^0.2.12",
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
  /**
@@ -1,3 +1,12 @@
1
+ /**
2
+ * 当本应用是乾坤子应用是,publicPath需要设置为子应用的相对路径
3
+ * 这个变量时序重要需要先初始化
4
+ */
5
+ if (window.__POWERED_BY_QIANKUN__) {
6
+ __webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
7
+ }
8
+
9
+
1
10
  import * as React from 'react'
2
11
  import * as ReactDOM from 'react-dom'
3
12
  import { setConfig } from './datasources/index'
@@ -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;