@nocobase/plugin-multi-app-manager 0.9.4-alpha.2 → 0.10.0-alpha.2

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 +1,2 @@
1
- export declare const AppManager: () => JSX.Element;
1
+ import React from 'react';
2
+ export declare const AppManager: () => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const Settings: () => JSX.Element;
1
+ import React from 'react';
2
+ export declare const Settings: () => React.JSX.Element;
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  export { tableActionColumnSchema } from './settings/schemas/applications';
2
- declare const _default: (props: any) => JSX.Element;
3
+ declare const _default: (props: any) => React.JSX.Element;
3
4
  export default _default;
@@ -44,7 +44,6 @@ var _utils = require("./utils");
44
44
  var _applications = require("./settings/schemas/applications");
45
45
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
46
46
  const MultiAppManager = () => {
47
- const history = (0, _reactRouterDom().useHistory)();
48
47
  const _useRequest = (0, _client().useRequest)({
49
48
  resource: 'applications',
50
49
  action: 'listPinned'
@@ -5,6 +5,7 @@ export declare type AppOptionsFactory = (appName: string, mainApp: Application)
5
5
  export declare class PluginMultiAppManager extends Plugin {
6
6
  appDbCreator: AppDbCreator;
7
7
  appOptionsFactory: AppOptionsFactory;
8
+ private beforeGetApplicationMutex;
8
9
  setAppOptionsFactory(factory: AppOptionsFactory): void;
9
10
  setAppDbCreator(appDbCreator: AppDbCreator): void;
10
11
  static getDatabaseConfig(app: Application): IDatabaseOptions;
@@ -33,6 +33,13 @@ function path() {
33
33
  return data;
34
34
  }
35
35
  var _application = require("./models/application");
36
+ function _asyncMutex() {
37
+ const data = require("async-mutex");
38
+ _asyncMutex = function _asyncMutex() {
39
+ return data;
40
+ };
41
+ return data;
42
+ }
36
43
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
37
44
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
38
45
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -113,6 +120,7 @@ class PluginMultiAppManager extends _server().Plugin {
113
120
  super(...args);
114
121
  this.appDbCreator = defaultDbCreator;
115
122
  this.appOptionsFactory = defaultAppOptionsFactory;
123
+ this.beforeGetApplicationMutex = new (_asyncMutex().Mutex)();
116
124
  }
117
125
  setAppOptionsFactory(factory) {
118
126
  this.appOptionsFactory = factory;
@@ -197,36 +205,38 @@ class PluginMultiAppManager extends _server().Plugin {
197
205
  name,
198
206
  options
199
207
  }) {
200
- if (appManager.applications.has(name)) {
201
- return;
202
- }
203
- const applicationRecord = yield _this.app.db.getRepository('applications').findOne({
204
- filter: {
205
- name
208
+ yield _this.beforeGetApplicationMutex.runExclusive( /*#__PURE__*/_asyncToGenerator(function* () {
209
+ if (appManager.applications.has(name)) {
210
+ return;
206
211
  }
207
- });
208
- const instanceOptions = applicationRecord.get('options');
209
- // skip standalone deployment application
210
- if ((instanceOptions === null || instanceOptions === void 0 ? void 0 : instanceOptions.standaloneDeployment) && appManager.runningMode !== 'single') {
211
- return;
212
- }
213
- if (!applicationRecord) {
214
- return;
215
- }
216
- const subApp = yield applicationRecord.registerToMainApp(_this.app, {
217
- appOptionsFactory: _this.appOptionsFactory
218
- });
219
- // must skip load on upgrade
220
- if (!(options === null || options === void 0 ? void 0 : options.upgrading)) {
221
- yield subApp.load();
222
- }
212
+ const applicationRecord = yield _this.app.db.getRepository('applications').findOne({
213
+ filter: {
214
+ name
215
+ }
216
+ });
217
+ const instanceOptions = applicationRecord.get('options');
218
+ // skip standalone deployment application
219
+ if ((instanceOptions === null || instanceOptions === void 0 ? void 0 : instanceOptions.standaloneDeployment) && appManager.runningMode !== 'single') {
220
+ return;
221
+ }
222
+ if (!applicationRecord) {
223
+ return;
224
+ }
225
+ const subApp = yield applicationRecord.registerToMainApp(_this.app, {
226
+ appOptionsFactory: _this.appOptionsFactory
227
+ });
228
+ // must skip load on upgrade
229
+ if (!(options === null || options === void 0 ? void 0 : options.upgrading)) {
230
+ yield subApp.load();
231
+ }
232
+ }));
223
233
  });
224
234
  return function (_x6) {
225
235
  return _ref5.apply(this, arguments);
226
236
  };
227
237
  }());
228
238
  _this.app.on('afterStart', /*#__PURE__*/function () {
229
- var _ref6 = _asyncToGenerator(function* (app) {
239
+ var _ref7 = _asyncToGenerator(function* (app) {
230
240
  const repository = _this.db.getRepository('applications');
231
241
  const appManager = _this.app.appManager;
232
242
  if (appManager.runningMode == 'single') {
@@ -272,11 +282,11 @@ class PluginMultiAppManager extends _server().Plugin {
272
282
  }
273
283
  });
274
284
  return function (_x7) {
275
- return _ref6.apply(this, arguments);
285
+ return _ref7.apply(this, arguments);
276
286
  };
277
287
  }());
278
288
  _this.app.on('afterUpgrade', /*#__PURE__*/function () {
279
- var _ref7 = _asyncToGenerator(function* (app, options) {
289
+ var _ref8 = _asyncToGenerator(function* (app, options) {
280
290
  const cliArgs = options === null || options === void 0 ? void 0 : options.cliArgs;
281
291
  const repository = _this.db.getRepository('applications');
282
292
  const findOptions = {};
@@ -321,7 +331,7 @@ class PluginMultiAppManager extends _server().Plugin {
321
331
  }
322
332
  });
323
333
  return function (_x8, _x9) {
324
- return _ref7.apply(this, arguments);
334
+ return _ref8.apply(this, arguments);
325
335
  };
326
336
  }());
327
337
  _this.app.resourcer.registerActionHandlers({
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-multi-app-manager",
3
- "version": "0.9.4-alpha.2",
4
- "description": "",
3
+ "displayName": "multi app manager",
4
+ "displayName.zh-CN": "多应用管理",
5
+ "description": "manage app",
6
+ "description.zh-CN": "管理应用",
7
+ "version": "0.10.0-alpha.2",
5
8
  "license": "AGPL-3.0",
6
9
  "main": "./lib/index.js",
7
10
  "types": "./lib/index.d.ts",
8
11
  "dependencies": {
9
- "@nocobase/server": "0.9.4-alpha.2"
12
+ "@nocobase/server": "0.10.0-alpha.2",
13
+ "async-mutex": "^0.3.2"
10
14
  },
11
- "gitHead": "2bc19a85bf9425aa220b6c467315c8087f333a7e"
15
+ "gitHead": "85028ae1733fcbd46ecd5d291dacbdc175f7f073"
12
16
  }