@cloud-app-dev/vidc 2.1.0-alpha.6 → 2.1.0-alpha.9

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/es/Dict/hook.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  import { DictItem } from './interface';
2
2
  export declare function useDict(typeCode: string | number): DictItem[];
3
- export declare function useTypeCodes(): DictItem[];
4
3
  export declare function useDicts(typeCodes?: any[], isWebVisible?: boolean): DictItem[][];
package/es/Dict/hook.js CHANGED
@@ -19,7 +19,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
19
19
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
20
 
21
21
  import { useMemo, useState, useEffect } from 'react';
22
- import { queryByTypeCode, queryByTypeCodes, queryTypeCodes, formartItemTextExt } from './utils';
22
+ import { queryByTypeCode, queryByTypeCodes, formartItemTextExt } from './utils';
23
23
  import LMDict from './cache';
24
24
  export function useDict(typeCode) {
25
25
  var _useState = useState(LMDict.data[typeCode] || []),
@@ -47,22 +47,6 @@ export function useDict(typeCode) {
47
47
  }, [typeCode]);
48
48
  return codes;
49
49
  }
50
- export function useTypeCodes() {
51
- var _useState3 = useState(LMDict.data['typeCodes'] || []),
52
- _useState4 = _slicedToArray(_useState3, 2),
53
- typeCodes = _useState4[0],
54
- setTypeCodes = _useState4[1];
55
-
56
- useEffect(function () {
57
- if (!LMDict.data['typeCodes']) {
58
- queryTypeCodes().then(function (res) {
59
- setTypeCodes(res);
60
- LMDict.updateDictMap('typeCode', res);
61
- });
62
- }
63
- }, []);
64
- return typeCodes;
65
- }
66
50
  export function useDicts() {
67
51
  var typeCodes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
68
52
  var isWebVisible = arguments.length > 1 ? arguments[1] : undefined;
@@ -70,14 +54,14 @@ export function useDicts() {
70
54
  return typeCodes.toString();
71
55
  }, [typeCodes]);
72
56
 
73
- var _useState5 = useState(function () {
57
+ var _useState3 = useState(function () {
74
58
  return typeCodes.map(function (v) {
75
59
  return LMDict.data[v] ? LMDict.data[v] : [];
76
60
  });
77
61
  }),
78
- _useState6 = _slicedToArray(_useState5, 2),
79
- dicts = _useState6[0],
80
- setDicts = _useState6[1];
62
+ _useState4 = _slicedToArray(_useState3, 2),
63
+ dicts = _useState4[0],
64
+ setDicts = _useState4[1];
81
65
 
82
66
  useEffect(function () {
83
67
  var codes = typeCodes.filter(function (v) {
@@ -1,13 +1,9 @@
1
1
  import * as device from './device';
2
- import { useDict, useDicts, useTypeCodes } from './hook';
3
- import { withDict, withTypeCodes } from './desc';
2
+ import { useDict, useDicts } from './hook';
4
3
  declare const Dict: {
5
4
  useDict: typeof useDict;
6
5
  useDicts: typeof useDicts;
7
6
  device: typeof device;
8
7
  cacheMap: import("./interface").CacheDictType;
9
- withDict: typeof withDict;
10
- useTypeCodes: typeof useTypeCodes;
11
- withTypeCodes: typeof withTypeCodes;
12
8
  };
13
9
  export default Dict;
package/es/Dict/index.js CHANGED
@@ -1,14 +1,10 @@
1
1
  import LMDict from './cache';
2
2
  import * as device from './device';
3
- import { useDict, useDicts, useTypeCodes } from './hook';
4
- import { withDict, withTypeCodes } from './desc';
3
+ import { useDict, useDicts } from './hook';
5
4
  var Dict = {
6
5
  useDict: useDict,
7
6
  useDicts: useDicts,
8
7
  device: device,
9
- cacheMap: LMDict,
10
- withDict: withDict,
11
- useTypeCodes: useTypeCodes,
12
- withTypeCodes: withTypeCodes
8
+ cacheMap: LMDict
13
9
  };
14
10
  export default Dict;
@@ -5,7 +5,6 @@ export declare function queryByTypeCode(typeCode: any): Promise<{
5
5
  export declare function queryByTypeCodes(typeCodes?: any[], isWebVisible?: boolean): Promise<{
6
6
  data: DictItem[];
7
7
  }>;
8
- export declare function queryTypeCodes(): Promise<DictItem[]>;
9
8
  export declare function formartItemTextExt(text: string): {
10
9
  [key: string]: any;
11
10
  };
package/es/Dict/utils.js CHANGED
@@ -29,13 +29,6 @@ export function queryByTypeCodes() {
29
29
  }
30
30
  });
31
31
  }
32
- export function queryTypeCodes() {
33
- return Service.http({
34
- url: "/micro-apps/micro-dep-librarys/config/typeCodes.json",
35
- method: 'get',
36
- requestId: 'queryTypeCodes'
37
- });
38
- }
39
32
  export function formartItemTextExt(text) {
40
33
  var ext = {};
41
34
 
@@ -11,7 +11,6 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
11
11
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
13
13
  import React, { useState, useEffect } from 'react';
14
- import Dict from '../Dict';
15
14
  import Config from '../Config';
16
15
  import { queryBSConfig, queryMicroApplicationList, querySystemUpdate, queryDefaultTheme } from './utils';
17
16
 
@@ -28,7 +27,6 @@ function InitialConfig(_ref) {
28
27
  state = _useState2[0],
29
28
  setState = _useState2[1];
30
29
 
31
- Dict.useTypeCodes();
32
30
  useEffect(function () {
33
31
  var arr = [queryBSConfig(), queryMicroApplicationList(), querySystemUpdate(), queryDefaultTheme()];
34
32
  Promise.all(arr).then(function (_ref2) {
@@ -99,7 +99,7 @@ export function initialization() {
99
99
  userFeatures: featureIds,
100
100
  systemFeatures: systemFeatures.data,
101
101
  operationInfo: centerInfo.data,
102
- themeConfig: ((_a = themeInfo === null || themeInfo === void 0 ? void 0 : themeInfo.data) === null || _a === void 0 ? void 0 : _a.content) || {}
102
+ themeConfig: ((_a = themeInfo === null || themeInfo === void 0 ? void 0 : themeInfo.data) === null || _a === void 0 ? void 0 : _a.info) || {}
103
103
  });
104
104
 
105
105
  case 24:
@@ -1,3 +1,5 @@
1
+ import _useUnmount from "ahooks/es/useUnmount";
2
+ import _useMount from "ahooks/es/useMount";
1
3
  import _uuid from "@cloud-app-dev/utils/es/uuid";
2
4
 
3
5
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
@@ -13,7 +15,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
13
15
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
16
 
15
17
  import { __awaiter } from "tslib";
16
- import React, { useRef, useEffect, useState, useMemo } from 'react';
18
+ import React, { useRef, useState, useMemo } from 'react';
17
19
  import { getMicroConfig } from './utils';
18
20
  import LoaderModule from './loader';
19
21
  import "./index.css";
@@ -36,8 +38,7 @@ function LoaderApp(_ref) {
36
38
  status = _useState2[0],
37
39
  setStatus = _useState2[1];
38
40
 
39
- useEffect(function () {
40
- var app;
41
+ _useMount(function () {
41
42
  var config = getMicroConfig(appConfig, appProps, domRef.current);
42
43
 
43
44
  if (!config) {
@@ -72,26 +73,25 @@ function LoaderApp(_ref) {
72
73
  while (1) {
73
74
  switch (_context.prev = _context.next) {
74
75
  case 0:
75
- app = mod;
76
76
  loadedAppRef.current = mod;
77
77
 
78
78
  if (!status) {
79
- _context.next = 5;
79
+ _context.next = 4;
80
80
  break;
81
81
  }
82
82
 
83
- _context.next = 5;
84
- return app.bootstrap(props);
83
+ _context.next = 4;
84
+ return mod.bootstrap(props);
85
85
 
86
- case 5:
86
+ case 4:
87
87
  setStatus('bootstrap');
88
- _context.next = 8;
89
- return app.mount(props);
88
+ _context.next = 7;
89
+ return mod.mount(props);
90
90
 
91
- case 8:
91
+ case 7:
92
92
  setStatus('mount');
93
93
 
94
- case 9:
94
+ case 8:
95
95
  case "end":
96
96
  return _context.stop();
97
97
  }
@@ -99,16 +99,20 @@ function LoaderApp(_ref) {
99
99
  }, _callee);
100
100
  }));
101
101
  });
102
- return function () {
103
- try {
104
- app.unmount(props);
105
- setStatus('unmount');
106
- app = null;
107
- } catch (error) {
108
- console.error(error);
109
- }
110
- };
111
- }, []);
102
+ });
103
+
104
+ _useUnmount(function () {
105
+ if (loadedAppRef.current) {
106
+ var app = loadedAppRef.current;
107
+ var props = Object.assign(Object.assign({}, appProps), {
108
+ container: domRef.current
109
+ });
110
+ app.unmount(props);
111
+ setStatus('unmount');
112
+ loadedAppRef.current = null;
113
+ }
114
+ });
115
+
112
116
  return /*#__PURE__*/React.createElement("main", {
113
117
  ref: domRef,
114
118
  className: "loaded-app-layout ".concat(appConfig.routerPrefix, "-").concat(id),
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "private": false,
3
3
  "name": "@cloud-app-dev/vidc",
4
4
  "description": "Video Image Data Componennts",
5
- "version": "2.1.0-alpha.6",
5
+ "version": "2.1.0-alpha.9",
6
6
  "scripts": {
7
7
  "start": "dumi dev",
8
8
  "docs:build": "dumi build",
package/es/Dict/desc.d.ts DELETED
@@ -1,64 +0,0 @@
1
- import React from 'react';
2
- import { DictItem } from './interface';
3
- export declare function withDict(codes?: any[], isWebVisible?: boolean): (Component: any) => (props: any) => JSX.Element;
4
- export declare function withTypeCodes(Component: any): {
5
- new (props: any): {
6
- componentDidMount(): void;
7
- render(): JSX.Element;
8
- context: any;
9
- setState<K extends "typeCodes" | "isInit">(state: {
10
- typeCodes: DictItem[];
11
- isInit: boolean;
12
- } | ((prevState: Readonly<{
13
- typeCodes: DictItem[];
14
- isInit: boolean;
15
- }>, props: Readonly<any>) => {
16
- typeCodes: DictItem[];
17
- isInit: boolean;
18
- } | Pick<{
19
- typeCodes: DictItem[];
20
- isInit: boolean;
21
- }, K>) | Pick<{
22
- typeCodes: DictItem[];
23
- isInit: boolean;
24
- }, K>, callback?: () => void): void;
25
- forceUpdate(callback?: () => void): void;
26
- readonly props: Readonly<any> & Readonly<{
27
- children?: React.ReactNode;
28
- }>;
29
- state: Readonly<{
30
- typeCodes: DictItem[];
31
- isInit: boolean;
32
- }>;
33
- refs: {
34
- [key: string]: React.ReactInstance;
35
- };
36
- shouldComponentUpdate?(nextProps: Readonly<any>, nextState: Readonly<{
37
- typeCodes: DictItem[];
38
- isInit: boolean;
39
- }>, nextContext: any): boolean;
40
- componentWillUnmount?(): void;
41
- componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
42
- getSnapshotBeforeUpdate?(prevProps: Readonly<any>, prevState: Readonly<{
43
- typeCodes: DictItem[];
44
- isInit: boolean;
45
- }>): any;
46
- componentDidUpdate?(prevProps: Readonly<any>, prevState: Readonly<{
47
- typeCodes: DictItem[];
48
- isInit: boolean;
49
- }>, snapshot?: any): void;
50
- componentWillMount?(): void;
51
- UNSAFE_componentWillMount?(): void;
52
- componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void;
53
- UNSAFE_componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void;
54
- componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<{
55
- typeCodes: DictItem[];
56
- isInit: boolean;
57
- }>, nextContext: any): void;
58
- UNSAFE_componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<{
59
- typeCodes: DictItem[];
60
- isInit: boolean;
61
- }>, nextContext: any): void;
62
- };
63
- contextType?: React.Context<any>;
64
- };
package/es/Dict/desc.js DELETED
@@ -1,162 +0,0 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
-
3
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
-
5
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
6
-
7
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
-
9
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
10
-
11
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
-
13
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14
-
15
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
16
-
17
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18
-
19
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
20
-
21
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
22
-
23
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
24
-
25
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
26
-
27
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
28
-
29
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
30
-
31
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
32
-
33
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
34
-
35
- import React, { useRef, useState, useEffect } from 'react';
36
- import { queryByTypeCodes, queryTypeCodes, formartItemTextExt } from './utils';
37
- import LMDict from './cache';
38
- export function withDict() {
39
- var codes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
40
- var isWebVisible = arguments.length > 1 ? arguments[1] : undefined;
41
- return function (Component) {
42
- return function (props) {
43
- var isInitRef = useRef(false);
44
-
45
- var _useState = useState(function () {
46
- var map = {};
47
- codes.forEach(function (code) {
48
- if (LMDict.data[code]) {
49
- map[code] = LMDict.data[code];
50
- } else {
51
- map[code] = [];
52
- }
53
- });
54
- return map;
55
- }),
56
- _useState2 = _slicedToArray(_useState, 2),
57
- dictMap = _useState2[0],
58
- setDictMap = _useState2[1];
59
-
60
- useEffect(function () {
61
- var nocacheCodes = codes.filter(function (v) {
62
- return !LMDict.data[v];
63
- });
64
-
65
- if (nocacheCodes.length === 0) {
66
- isInitRef.current = true;
67
- setDictMap(function (old) {
68
- return Object.assign({}, old);
69
- });
70
- return;
71
- }
72
-
73
- queryByTypeCodes(nocacheCodes, isWebVisible).then(function (res) {
74
- isInitRef.current = true;
75
- var data = res.data;
76
- data.forEach(function (item) {
77
- item.label = item.name;
78
- item.value = item.code;
79
- item = Object.assign(Object.assign({}, item), formartItemTextExt(item.extText));
80
- });
81
- setDictMap(function (old) {
82
- nocacheCodes.forEach(function (code) {
83
- var itemCodes = data.filter(function (v1) {
84
- return +v1.typeCode === +code;
85
- });
86
- old[code] = itemCodes;
87
- LMDict.updateDictMap(code, itemCodes);
88
- });
89
- return Object.assign({}, old);
90
- });
91
- });
92
- }, []);
93
-
94
- if (!isInitRef.current) {
95
- return null;
96
- }
97
-
98
- return /*#__PURE__*/React.createElement(Component, Object.assign({}, props, {
99
- dictMap: dictMap
100
- }));
101
- };
102
- };
103
- }
104
- export function withTypeCodes(Component) {
105
- return /*#__PURE__*/function (_React$Component) {
106
- _inherits(withTypeCodesComponent, _React$Component);
107
-
108
- var _super = _createSuper(withTypeCodesComponent);
109
-
110
- function withTypeCodesComponent(props) {
111
- var _this;
112
-
113
- _classCallCheck(this, withTypeCodesComponent);
114
-
115
- _this = _super.call(this, props);
116
- _this.state = {
117
- typeCodes: LMDict.data['typeCodes'] || [],
118
- isInit: false
119
- };
120
- return _this;
121
- }
122
-
123
- _createClass(withTypeCodesComponent, [{
124
- key: "componentDidMount",
125
- value: function componentDidMount() {
126
- var _this2 = this;
127
-
128
- if (!LMDict.data['typeCodes']) {
129
- queryTypeCodes().then(function (res) {
130
- LMDict.updateDictMap('typeCodes', res);
131
-
132
- _this2.setState({
133
- typeCodes: res,
134
- isInit: true
135
- });
136
- }).catch(function () {
137
- _this2.setState({
138
- typeCodes: [],
139
- isInit: true
140
- });
141
- });
142
- } else this.setState({
143
- typeCodes: LMDict.data['typeCodes'],
144
- isInit: true
145
- });
146
- }
147
- }, {
148
- key: "render",
149
- value: function render() {
150
- if (!this.state.isInit) {
151
- return null;
152
- }
153
-
154
- return /*#__PURE__*/React.createElement(Component, Object.assign({}, this.props, {
155
- typeCodes: this.state.typeCodes
156
- }));
157
- }
158
- }]);
159
-
160
- return withTypeCodesComponent;
161
- }(React.Component);
162
- }