@cloud-app-dev/vidc 2.1.0-alpha.8 → 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.
@@ -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
- console.debug('LoaderApp is destory!');
104
-
105
- if (app) {
106
- app.unmount(props);
107
- setStatus('unmount');
108
- app = null;
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.8",
5
+ "version": "2.1.0-alpha.9",
6
6
  "scripts": {
7
7
  "start": "dumi dev",
8
8
  "docs:build": "dumi build",