@nocobase/client 0.11.1-alpha.4 → 0.12.0-alpha.1

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.
Files changed (179) hide show
  1. package/es/appInfo/CurrentAppInfoProvider.d.ts +9 -1
  2. package/es/application/Application.d.ts +15 -2
  3. package/es/application/Application.js +13 -5
  4. package/es/application/PluginManager.d.ts +10 -1
  5. package/es/application/PluginManager.js +197 -74
  6. package/es/application/utils/globalDeps.d.ts +2 -0
  7. package/es/application/utils/globalDeps.js +154 -0
  8. package/es/application/utils/remotePlugins.d.ts +15 -0
  9. package/es/application/utils/remotePlugins.js +162 -0
  10. package/es/application/utils/requirejs.d.ts +11 -0
  11. package/es/application/utils/requirejs.js +1879 -0
  12. package/es/block-provider/BlockProvider.js +3 -0
  13. package/es/block-provider/hooks/index.d.ts +1 -0
  14. package/es/block-provider/hooks/index.js +1 -1
  15. package/es/collection-manager/Configuration/AddFieldAction.js +7 -2
  16. package/es/collection-manager/Configuration/EditFieldAction.js +7 -2
  17. package/es/collection-manager/hooks/useDialect.d.ts +5 -0
  18. package/es/collection-manager/hooks/useDialect.js +13 -0
  19. package/es/collection-manager/interfaces/color.d.ts +2 -0
  20. package/es/collection-manager/interfaces/color.js +28 -0
  21. package/es/collection-manager/interfaces/index.d.ts +1 -0
  22. package/es/collection-manager/interfaces/index.js +1 -0
  23. package/es/collection-manager/interfaces/json.js +16 -1
  24. package/es/locale/en_US.d.ts +5 -0
  25. package/es/locale/en_US.js +6 -1
  26. package/es/locale/index.d.ts +0 -1
  27. package/es/locale/index.js +0 -1
  28. package/es/locale/ja_JP.d.ts +5 -0
  29. package/es/locale/ja_JP.js +6 -1
  30. package/es/locale/zh_CN.d.ts +5 -0
  31. package/es/locale/zh_CN.js +6 -1
  32. package/es/nocobase-buildin-plugin/index.d.ts +1 -1
  33. package/es/nocobase-buildin-plugin/index.js +104 -66
  34. package/es/nocobase-buildin-plugin/plugins/LocalePlugin.js +4 -4
  35. package/es/route-switch/antd/admin-layout/index.d.ts +1 -0
  36. package/es/route-switch/antd/admin-layout/index.js +25 -6
  37. package/es/schema-component/antd/__builtins__/hooks/useToken.d.ts +2 -6
  38. package/es/schema-component/antd/__builtins__/hooks/useToken.js +1 -2
  39. package/es/schema-component/antd/action/Action.Designer.js +145 -22
  40. package/es/schema-component/antd/action/Action.js +1 -1
  41. package/es/schema-component/antd/association-field/AssociationSelect.js +19 -3
  42. package/es/schema-component/antd/association-field/InternalSubTable.js +21 -16
  43. package/es/schema-component/antd/association-field/InternalTag.d.ts +2 -0
  44. package/es/schema-component/antd/association-field/InternalTag.js +123 -0
  45. package/es/schema-component/antd/association-field/ReadPretty.js +6 -5
  46. package/es/schema-component/antd/association-field/util.d.ts +1 -0
  47. package/es/schema-component/antd/association-field/util.js +26 -0
  48. package/es/schema-component/antd/calendar/Calendar.js +1 -1
  49. package/es/schema-component/antd/calendar/DeleteEvent.js +1 -1
  50. package/es/schema-component/antd/calendar/utils.d.ts +2 -2
  51. package/es/schema-component/antd/calendar/utils.js +1 -1
  52. package/es/schema-component/antd/color-picker/ColorPicker.d.ts +3 -0
  53. package/es/schema-component/antd/color-picker/ColorPicker.js +50 -0
  54. package/es/schema-component/antd/color-picker/ReadPretty.d.ts +7 -0
  55. package/es/schema-component/antd/color-picker/ReadPretty.js +20 -0
  56. package/es/schema-component/antd/color-picker/index.d.ts +1 -0
  57. package/es/schema-component/antd/color-picker/index.js +1 -0
  58. package/es/schema-component/antd/color-picker/util.d.ts +31 -0
  59. package/es/schema-component/antd/color-picker/util.js +175 -0
  60. package/es/schema-component/antd/date-picker/ReadPretty.js +2 -1
  61. package/es/schema-component/antd/date-picker/util.d.ts +19 -19
  62. package/es/schema-component/antd/date-picker/util.js +2 -1
  63. package/es/schema-component/antd/form-item/FormItem.js +22 -8
  64. package/es/schema-component/antd/form-v2/Templates.js +1 -1
  65. package/es/schema-component/antd/index.d.ts +1 -0
  66. package/es/schema-component/antd/index.js +1 -0
  67. package/es/schema-component/antd/remote-select/RemoteSelect.js +1 -1
  68. package/es/schema-component/antd/table-v2/Table.Column.Designer.d.ts +4 -0
  69. package/es/schema-component/antd/table-v2/Table.Column.Designer.js +67 -7
  70. package/es/schema-component/antd/table-v2/Table.js +1 -1
  71. package/es/schema-component/antd/time-picker/ReadPretty.js +1 -1
  72. package/es/schema-component/antd/variable/Input.js +2 -1
  73. package/es/schema-component/antd/variable/XButton.d.ts +2 -8
  74. package/es/schema-component/common/utils/uitls.js +8 -8
  75. package/es/schema-component/hooks/useFieldModeOptions.js +15 -0
  76. package/es/schema-settings/DataTemplates/FormDataTemplates.js +17 -1
  77. package/es/schema-settings/DataTemplates/components/DataTemplateTitle.js +3 -0
  78. package/es/schema-settings/DataTemplates/hooks/useCollectionState.d.ts +2 -9
  79. package/es/schema-settings/DataTemplates/hooks/useCollectionState.js +24 -6
  80. package/es/schema-settings/DataTemplates/utils.d.ts +3 -0
  81. package/es/schema-settings/DataTemplates/utils.js +244 -0
  82. package/es/schema-settings/SchemaSettings.js +24 -24
  83. package/es/style/useToken.d.ts +2 -6
  84. package/es/style/useToken.js +1 -2
  85. package/lib/appInfo/CurrentAppInfoProvider.d.ts +9 -1
  86. package/lib/application/Application.d.ts +15 -2
  87. package/lib/application/Application.js +13 -5
  88. package/lib/application/PluginManager.d.ts +10 -1
  89. package/lib/application/PluginManager.js +197 -74
  90. package/lib/application/utils/globalDeps.d.ts +2 -0
  91. package/lib/application/utils/globalDeps.js +163 -0
  92. package/lib/application/utils/remotePlugins.d.ts +15 -0
  93. package/lib/application/utils/remotePlugins.js +170 -0
  94. package/lib/application/utils/requirejs.d.ts +11 -0
  95. package/lib/application/utils/requirejs.js +1885 -0
  96. package/lib/block-provider/BlockProvider.js +3 -0
  97. package/lib/block-provider/hooks/index.d.ts +1 -0
  98. package/lib/block-provider/hooks/index.js +3 -1
  99. package/lib/collection-manager/Configuration/AddFieldAction.js +8 -2
  100. package/lib/collection-manager/Configuration/EditFieldAction.js +7 -2
  101. package/lib/collection-manager/hooks/useDialect.d.ts +5 -0
  102. package/lib/collection-manager/hooks/useDialect.js +20 -0
  103. package/lib/collection-manager/interfaces/color.d.ts +2 -0
  104. package/lib/collection-manager/interfaces/color.js +35 -0
  105. package/lib/collection-manager/interfaces/index.d.ts +1 -0
  106. package/lib/collection-manager/interfaces/index.js +11 -0
  107. package/lib/collection-manager/interfaces/json.js +17 -1
  108. package/lib/locale/en_US.d.ts +5 -0
  109. package/lib/locale/en_US.js +6 -1
  110. package/lib/locale/index.d.ts +0 -1
  111. package/lib/locale/index.js +0 -8
  112. package/lib/locale/ja_JP.d.ts +5 -0
  113. package/lib/locale/ja_JP.js +6 -1
  114. package/lib/locale/zh_CN.d.ts +5 -0
  115. package/lib/locale/zh_CN.js +6 -1
  116. package/lib/nocobase-buildin-plugin/index.d.ts +1 -1
  117. package/lib/nocobase-buildin-plugin/index.js +104 -66
  118. package/lib/nocobase-buildin-plugin/plugins/LocalePlugin.js +5 -4
  119. package/lib/route-switch/antd/admin-layout/index.d.ts +1 -0
  120. package/lib/route-switch/antd/admin-layout/index.js +25 -6
  121. package/lib/schema-component/antd/__builtins__/hooks/useToken.d.ts +2 -6
  122. package/lib/schema-component/antd/__builtins__/hooks/useToken.js +1 -2
  123. package/lib/schema-component/antd/action/Action.Designer.js +153 -30
  124. package/lib/schema-component/antd/action/Action.js +4 -4
  125. package/lib/schema-component/antd/association-field/AssociationSelect.js +19 -4
  126. package/lib/schema-component/antd/association-field/InternalSubTable.js +19 -14
  127. package/lib/schema-component/antd/association-field/InternalTag.d.ts +2 -0
  128. package/lib/schema-component/antd/association-field/InternalTag.js +134 -0
  129. package/lib/schema-component/antd/association-field/ReadPretty.js +10 -9
  130. package/lib/schema-component/antd/association-field/util.d.ts +1 -0
  131. package/lib/schema-component/antd/association-field/util.js +28 -1
  132. package/lib/schema-component/antd/calendar/Calendar.js +8 -8
  133. package/lib/schema-component/antd/calendar/DeleteEvent.js +3 -2
  134. package/lib/schema-component/antd/calendar/utils.d.ts +2 -2
  135. package/lib/schema-component/antd/calendar/utils.js +2 -2
  136. package/lib/schema-component/antd/color-picker/ColorPicker.d.ts +3 -0
  137. package/lib/schema-component/antd/color-picker/ColorPicker.js +59 -0
  138. package/lib/schema-component/antd/color-picker/ReadPretty.d.ts +7 -0
  139. package/lib/schema-component/antd/color-picker/ReadPretty.js +28 -0
  140. package/lib/schema-component/antd/color-picker/index.d.ts +1 -0
  141. package/lib/schema-component/antd/color-picker/index.js +16 -0
  142. package/lib/schema-component/antd/color-picker/util.d.ts +31 -0
  143. package/lib/schema-component/antd/color-picker/util.js +185 -0
  144. package/lib/schema-component/antd/date-picker/ReadPretty.js +2 -1
  145. package/lib/schema-component/antd/date-picker/util.d.ts +19 -19
  146. package/lib/schema-component/antd/date-picker/util.js +8 -6
  147. package/lib/schema-component/antd/form-item/FormItem.js +21 -7
  148. package/lib/schema-component/antd/form-v2/Templates.js +1 -1
  149. package/lib/schema-component/antd/index.d.ts +1 -0
  150. package/lib/schema-component/antd/index.js +11 -0
  151. package/lib/schema-component/antd/remote-select/RemoteSelect.js +2 -2
  152. package/lib/schema-component/antd/table-v2/Table.Column.Designer.d.ts +4 -0
  153. package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +69 -8
  154. package/lib/schema-component/antd/table-v2/Table.js +1 -1
  155. package/lib/schema-component/antd/time-picker/ReadPretty.js +2 -2
  156. package/lib/schema-component/antd/variable/Input.js +2 -1
  157. package/lib/schema-component/antd/variable/XButton.d.ts +2 -8
  158. package/lib/schema-component/common/utils/uitls.js +9 -9
  159. package/lib/schema-component/hooks/useFieldModeOptions.js +15 -0
  160. package/lib/schema-settings/DataTemplates/FormDataTemplates.js +17 -1
  161. package/lib/schema-settings/DataTemplates/components/DataTemplateTitle.js +3 -0
  162. package/lib/schema-settings/DataTemplates/hooks/useCollectionState.d.ts +2 -9
  163. package/lib/schema-settings/DataTemplates/hooks/useCollectionState.js +33 -14
  164. package/lib/schema-settings/DataTemplates/utils.d.ts +3 -0
  165. package/lib/schema-settings/DataTemplates/utils.js +254 -0
  166. package/lib/schema-settings/SchemaSettings.js +21 -21
  167. package/lib/style/useToken.d.ts +2 -6
  168. package/lib/style/useToken.js +1 -2
  169. package/package.json +21 -16
  170. package/.dumi/theme/builtins/LangSwitch/index.tsx +0 -11
  171. package/.dumi/theme/builtins/Previewer/index.tsx +0 -23
  172. package/es/schema-component/antd/cron/locale/index.d.ts +0 -36
  173. package/es/schema-component/antd/cron/locale/index.js +0 -4
  174. package/lib/schema-component/antd/cron/locale/index.d.ts +0 -36
  175. package/lib/schema-component/antd/cron/locale/index.js +0 -12
  176. /package/es/{schema-component/antd/cron/locale/zh-CN.d.ts → locale/cron/zh_CN.d.ts} +0 -0
  177. /package/es/{schema-component/antd/cron/locale/zh-CN.js → locale/cron/zh_CN.js} +0 -0
  178. /package/lib/{schema-component/antd/cron/locale/zh-CN.d.ts → locale/cron/zh_CN.d.ts} +0 -0
  179. /package/lib/{schema-component/antd/cron/locale/zh-CN.js → locale/cron/zh_CN.js} +0 -0
@@ -1,4 +1,12 @@
1
1
  import React from 'react';
2
2
  export declare const CurrentAppInfoContext: React.Context<any>;
3
- export declare const useCurrentAppInfo: () => any;
3
+ export declare const useCurrentAppInfo: () => {
4
+ data: {
5
+ database: {
6
+ dialect: string;
7
+ };
8
+ lang: string;
9
+ version: string;
10
+ };
11
+ };
4
12
  export declare const CurrentAppInfoProvider: (props: any) => React.JSX.Element;
@@ -2,8 +2,15 @@ import { APIClientOptions } from '@nocobase/sdk';
2
2
  import { i18n as i18next } from 'i18next';
3
3
  import React, { ComponentType, ReactElement } from 'react';
4
4
  import { APIClient } from '../api-client';
5
+ import type { Plugin } from './Plugin';
5
6
  import { PluginManager, PluginType } from './PluginManager';
6
7
  import { ComponentTypeAndString, RouterManager, RouterOptions } from './RouterManager';
8
+ import type { RequireJS } from './utils/requirejs';
9
+ declare global {
10
+ interface Window {
11
+ define: RequireJS['define'];
12
+ }
13
+ }
7
14
  export type ComponentAndProps<T = any> = [ComponentType, T];
8
15
  export interface ApplicationOptions {
9
16
  apiClient?: APIClientOptions;
@@ -13,7 +20,9 @@ export interface ApplicationOptions {
13
20
  components?: Record<string, ComponentType>;
14
21
  scopes?: Record<string, any>;
15
22
  router?: RouterOptions;
16
- dynamicImport?: any;
23
+ devPlugins?: Record<string, Promise<{
24
+ default: typeof Plugin;
25
+ }>>;
17
26
  }
18
27
  export declare class Application {
19
28
  protected options: ApplicationOptions;
@@ -24,10 +33,14 @@ export declare class Application {
24
33
  apiClient: APIClient;
25
34
  components: Record<string, ComponentType>;
26
35
  pm: PluginManager;
36
+ devPlugins: Record<string, Promise<{
37
+ default: typeof Plugin;
38
+ }>>;
39
+ requirejs: RequireJS;
27
40
  constructor(options?: ApplicationOptions);
41
+ private initRequireJs;
28
42
  private addDefaultProviders;
29
43
  private addReactRouterComponents;
30
- get dynamicImport(): any;
31
44
  getComposeProviders(): React.FC;
32
45
  use<T = any>(component: ComponentType, props?: T): number;
33
46
  addProvider<T = any>(component: ComponentType, props?: T): number;
@@ -29,6 +29,8 @@ import { PluginManager } from './PluginManager';
29
29
  import { RouterManager } from './RouterManager';
30
30
  import { AppComponent, BlankComponent, defaultAppComponents } from './components';
31
31
  import { compose, normalizeContainer } from './utils';
32
+ import { defineGlobalDeps } from './utils/globalDeps';
33
+ import { getRequireJs } from './utils/requirejs';
32
34
  export var Application = /*#__PURE__*/function () {
33
35
  function Application() {
34
36
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -41,7 +43,11 @@ export var Application = /*#__PURE__*/function () {
41
43
  this.apiClient = void 0;
42
44
  this.components = _objectSpread({}, defaultAppComponents);
43
45
  this.pm = void 0;
46
+ this.devPlugins = {};
47
+ this.requirejs = void 0;
44
48
  this.options = options;
49
+ this.initRequireJs();
50
+ this.devPlugins = options.devPlugins || {};
45
51
  this.scopes = merge(this.scopes, options.scopes);
46
52
  this.components = merge(this.components, options.components);
47
53
  this.apiClient = new APIClient(options.apiClient);
@@ -55,6 +61,13 @@ export var Application = /*#__PURE__*/function () {
55
61
  this.addProviders(options.providers || []);
56
62
  }
57
63
  _createClass(Application, [{
64
+ key: "initRequireJs",
65
+ value: function initRequireJs() {
66
+ this.requirejs = getRequireJs();
67
+ defineGlobalDeps(this.requirejs);
68
+ window.define = this.requirejs.define;
69
+ }
70
+ }, {
58
71
  key: "addDefaultProviders",
59
72
  value: function addDefaultProviders() {
60
73
  this.use(APIClientProvider, {
@@ -73,11 +86,6 @@ export var Application = /*#__PURE__*/function () {
73
86
  NavLink: NavLink
74
87
  });
75
88
  }
76
- }, {
77
- key: "dynamicImport",
78
- get: function get() {
79
- return this.options.dynamicImport;
80
- }
81
89
  }, {
82
90
  key: "getComposeProviders",
83
91
  value: function getComposeProviders() {
@@ -5,14 +5,23 @@ export type PluginOptions<T = any> = {
5
5
  config?: T;
6
6
  };
7
7
  export type PluginType<Opts = any> = typeof Plugin | [typeof Plugin, PluginOptions<Opts>];
8
+ export type PluginData = {
9
+ name: string;
10
+ packageName: string;
11
+ version: string;
12
+ url: string;
13
+ type: 'local' | 'upload' | 'npm';
14
+ };
8
15
  export declare class PluginManager {
9
16
  protected _plugins: PluginType[];
10
17
  protected app: Application;
11
18
  protected pluginInstances: Map<typeof Plugin, Plugin>;
12
19
  protected pluginsAliases: Record<string, Plugin>;
13
- private loadStaticPlugin;
20
+ private initPlugins;
14
21
  constructor(_plugins: PluginType[], app: Application);
22
+ init(_plugins: PluginType[]): Promise<void>;
15
23
  private initStaticPlugins;
24
+ private initRemotePlugins;
16
25
  add<T = any>(plugin: typeof Plugin, opts?: PluginOptions<T>): Promise<void>;
17
26
  get<T extends typeof Plugin>(PluginClass: T): InstanceType<T>;
18
27
  get<T extends {}>(name: string): T;
@@ -12,6 +12,7 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
12
12
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
13
  function _asyncIterator(iterable) { var method, async, sync, retry = 2; for ("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;) { if (async && null != (method = iterable[async])) return method.call(iterable); if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable)); async = "@@asyncIterator", sync = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
14
14
  function AsyncFromSyncIterator(s) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var done = r.done; return Promise.resolve(r.value).then(function (value) { return { value: value, done: done }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(s) { this.s = s, this.n = s.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, return: function _return(value) { var ret = this.s.return; return void 0 === ret ? Promise.resolve({ value: value, done: !0 }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments)); }, throw: function _throw(value) { var thr = this.s.return; return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(s); }
15
+ import { getPlugins } from './utils/remotePlugins';
15
16
  export var PluginManager = /*#__PURE__*/function () {
16
17
  function PluginManager(_plugins, app) {
17
18
  _classCallCheck(this, PluginManager);
@@ -19,16 +20,39 @@ export var PluginManager = /*#__PURE__*/function () {
19
20
  this.app = void 0;
20
21
  this.pluginInstances = new Map();
21
22
  this.pluginsAliases = {};
22
- this.loadStaticPlugin = void 0;
23
+ this.initPlugins = void 0;
23
24
  this._plugins = _plugins;
24
25
  this.app = app;
25
26
  this.app = app;
26
- this.loadStaticPlugin = this.initStaticPlugins(_plugins);
27
+ this.initPlugins = this.init(_plugins);
27
28
  }
28
29
  _createClass(PluginManager, [{
30
+ key: "init",
31
+ value: function () {
32
+ var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_plugins) {
33
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
34
+ while (1) switch (_context.prev = _context.next) {
35
+ case 0:
36
+ _context.next = 2;
37
+ return this.initStaticPlugins(_plugins);
38
+ case 2:
39
+ _context.next = 4;
40
+ return this.initRemotePlugins();
41
+ case 4:
42
+ case "end":
43
+ return _context.stop();
44
+ }
45
+ }, _callee, this);
46
+ }));
47
+ function init(_x) {
48
+ return _init.apply(this, arguments);
49
+ }
50
+ return init;
51
+ }()
52
+ }, {
29
53
  key: "initStaticPlugins",
30
54
  value: function () {
31
- var _initStaticPlugins = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
55
+ var _initStaticPlugins = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
32
56
  var _plugins,
33
57
  _iteratorAbruptCompletion,
34
58
  _didIteratorError,
@@ -38,96 +62,195 @@ export var PluginManager = /*#__PURE__*/function () {
38
62
  plugin,
39
63
  pluginClass,
40
64
  opts,
41
- _args = arguments;
42
- return _regeneratorRuntime().wrap(function _callee$(_context) {
43
- while (1) switch (_context.prev = _context.next) {
65
+ _args2 = arguments;
66
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
67
+ while (1) switch (_context2.prev = _context2.next) {
44
68
  case 0:
45
- _plugins = _args.length > 0 && _args[0] !== undefined ? _args[0] : [];
69
+ _plugins = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : [];
46
70
  _iteratorAbruptCompletion = false;
47
71
  _didIteratorError = false;
48
- _context.prev = 3;
72
+ _context2.prev = 3;
49
73
  _iterator = _asyncIterator(_plugins);
50
74
  case 5:
51
- _context.next = 7;
75
+ _context2.next = 7;
52
76
  return _iterator.next();
53
77
  case 7:
54
- if (!(_iteratorAbruptCompletion = !(_step = _context.sent).done)) {
55
- _context.next = 16;
78
+ if (!(_iteratorAbruptCompletion = !(_step = _context2.sent).done)) {
79
+ _context2.next = 16;
56
80
  break;
57
81
  }
58
82
  plugin = _step.value;
59
83
  pluginClass = Array.isArray(plugin) ? plugin[0] : plugin;
60
84
  opts = Array.isArray(plugin) ? plugin[1] : undefined;
61
- _context.next = 13;
85
+ _context2.next = 13;
62
86
  return this.add(pluginClass, opts);
63
87
  case 13:
64
88
  _iteratorAbruptCompletion = false;
65
- _context.next = 5;
89
+ _context2.next = 5;
66
90
  break;
67
91
  case 16:
68
- _context.next = 22;
92
+ _context2.next = 22;
69
93
  break;
70
94
  case 18:
71
- _context.prev = 18;
72
- _context.t0 = _context["catch"](3);
95
+ _context2.prev = 18;
96
+ _context2.t0 = _context2["catch"](3);
73
97
  _didIteratorError = true;
74
- _iteratorError = _context.t0;
98
+ _iteratorError = _context2.t0;
75
99
  case 22:
76
- _context.prev = 22;
77
- _context.prev = 23;
100
+ _context2.prev = 22;
101
+ _context2.prev = 23;
78
102
  if (!(_iteratorAbruptCompletion && _iterator.return != null)) {
79
- _context.next = 27;
103
+ _context2.next = 27;
80
104
  break;
81
105
  }
82
- _context.next = 27;
106
+ _context2.next = 27;
83
107
  return _iterator.return();
84
108
  case 27:
85
- _context.prev = 27;
109
+ _context2.prev = 27;
86
110
  if (!_didIteratorError) {
87
- _context.next = 30;
111
+ _context2.next = 30;
88
112
  break;
89
113
  }
90
114
  throw _iteratorError;
91
115
  case 30:
92
- return _context.finish(27);
116
+ return _context2.finish(27);
93
117
  case 31:
94
- return _context.finish(22);
118
+ return _context2.finish(22);
95
119
  case 32:
96
120
  case "end":
97
- return _context.stop();
121
+ return _context2.stop();
98
122
  }
99
- }, _callee, this, [[3, 18, 22, 32], [23,, 27, 31]]);
123
+ }, _callee2, this, [[3, 18, 22, 32], [23,, 27, 31]]);
100
124
  }));
101
125
  function initStaticPlugins() {
102
126
  return _initStaticPlugins.apply(this, arguments);
103
127
  }
104
128
  return initStaticPlugins;
105
129
  }()
130
+ }, {
131
+ key: "initRemotePlugins",
132
+ value: function () {
133
+ var _initRemotePlugins = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
134
+ var _res$data, _this$app$apiClient$a, _this$app$apiClient$a2, res, pluginList, plugins, _iteratorAbruptCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, plugin, _error$response;
135
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
136
+ while (1) switch (_context3.prev = _context3.next) {
137
+ case 0:
138
+ _context3.prev = 0;
139
+ _context3.next = 3;
140
+ return this.app.apiClient.request({
141
+ url: 'app:getPlugins'
142
+ });
143
+ case 3:
144
+ res = _context3.sent;
145
+ pluginList = ((_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.data) || [];
146
+ _context3.next = 7;
147
+ return getPlugins({
148
+ requirejs: this.app.requirejs,
149
+ pluginData: pluginList,
150
+ baseURL: (_this$app$apiClient$a = this.app.apiClient.axios) === null || _this$app$apiClient$a === void 0 ? void 0 : (_this$app$apiClient$a2 = _this$app$apiClient$a.defaults) === null || _this$app$apiClient$a2 === void 0 ? void 0 : _this$app$apiClient$a2.baseURL,
151
+ devPlugins: this.app.devPlugins
152
+ });
153
+ case 7:
154
+ plugins = _context3.sent;
155
+ _iteratorAbruptCompletion2 = false;
156
+ _didIteratorError2 = false;
157
+ _context3.prev = 10;
158
+ _iterator2 = _asyncIterator(plugins);
159
+ case 12:
160
+ _context3.next = 14;
161
+ return _iterator2.next();
162
+ case 14:
163
+ if (!(_iteratorAbruptCompletion2 = !(_step2 = _context3.sent).done)) {
164
+ _context3.next = 21;
165
+ break;
166
+ }
167
+ plugin = _step2.value;
168
+ _context3.next = 18;
169
+ return this.add(plugin);
170
+ case 18:
171
+ _iteratorAbruptCompletion2 = false;
172
+ _context3.next = 12;
173
+ break;
174
+ case 21:
175
+ _context3.next = 27;
176
+ break;
177
+ case 23:
178
+ _context3.prev = 23;
179
+ _context3.t0 = _context3["catch"](10);
180
+ _didIteratorError2 = true;
181
+ _iteratorError2 = _context3.t0;
182
+ case 27:
183
+ _context3.prev = 27;
184
+ _context3.prev = 28;
185
+ if (!(_iteratorAbruptCompletion2 && _iterator2.return != null)) {
186
+ _context3.next = 32;
187
+ break;
188
+ }
189
+ _context3.next = 32;
190
+ return _iterator2.return();
191
+ case 32:
192
+ _context3.prev = 32;
193
+ if (!_didIteratorError2) {
194
+ _context3.next = 35;
195
+ break;
196
+ }
197
+ throw _iteratorError2;
198
+ case 35:
199
+ return _context3.finish(32);
200
+ case 36:
201
+ return _context3.finish(27);
202
+ case 37:
203
+ _context3.next = 47;
204
+ break;
205
+ case 39:
206
+ _context3.prev = 39;
207
+ _context3.t1 = _context3["catch"](0);
208
+ if (!(401 === (_context3.t1 === null || _context3.t1 === void 0 ? void 0 : (_error$response = _context3.t1.response) === null || _error$response === void 0 ? void 0 : _error$response.status))) {
209
+ _context3.next = 46;
210
+ break;
211
+ }
212
+ this.app.apiClient.auth.setRole(null);
213
+ window.location.reload();
214
+ _context3.next = 47;
215
+ break;
216
+ case 46:
217
+ throw _context3.t1;
218
+ case 47:
219
+ case "end":
220
+ return _context3.stop();
221
+ }
222
+ }, _callee3, this, [[0, 39], [10, 23, 27, 37], [28,, 32, 36]]);
223
+ }));
224
+ function initRemotePlugins() {
225
+ return _initRemotePlugins.apply(this, arguments);
226
+ }
227
+ return initRemotePlugins;
228
+ }()
106
229
  }, {
107
230
  key: "add",
108
231
  value: function () {
109
- var _add = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(plugin) {
232
+ var _add = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(plugin) {
110
233
  var opts,
111
234
  instance,
112
- _args2 = arguments;
113
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
114
- while (1) switch (_context2.prev = _context2.next) {
235
+ _args4 = arguments;
236
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
237
+ while (1) switch (_context4.prev = _context4.next) {
115
238
  case 0:
116
- opts = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
239
+ opts = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
117
240
  instance = this.getInstance(plugin, opts);
118
241
  this.pluginInstances.set(plugin, instance);
119
242
  if (opts.name) {
120
243
  this.pluginsAliases[opts.name] = instance;
121
244
  }
122
- _context2.next = 6;
245
+ _context4.next = 6;
123
246
  return instance.afterAdd();
124
247
  case 6:
125
248
  case "end":
126
- return _context2.stop();
249
+ return _context4.stop();
127
250
  }
128
- }, _callee2, this);
251
+ }, _callee4, this);
129
252
  }));
130
- function add(_x) {
253
+ function add(_x2) {
131
254
  return _add.apply(this, arguments);
132
255
  }
133
256
  return add;
@@ -148,70 +271,70 @@ export var PluginManager = /*#__PURE__*/function () {
148
271
  }, {
149
272
  key: "load",
150
273
  value: function () {
151
- var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
152
- var _iterator2, _step2, plugin, _iterator3, _step3, _plugin;
153
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
154
- while (1) switch (_context3.prev = _context3.next) {
274
+ var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
275
+ var _iterator3, _step3, plugin, _iterator4, _step4, _plugin;
276
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
277
+ while (1) switch (_context5.prev = _context5.next) {
155
278
  case 0:
156
- _context3.next = 2;
157
- return this.loadStaticPlugin;
279
+ _context5.next = 2;
280
+ return this.initPlugins;
158
281
  case 2:
159
- _iterator2 = _createForOfIteratorHelper(this.pluginInstances.values());
160
- _context3.prev = 3;
161
- _iterator2.s();
282
+ _iterator3 = _createForOfIteratorHelper(this.pluginInstances.values());
283
+ _context5.prev = 3;
284
+ _iterator3.s();
162
285
  case 5:
163
- if ((_step2 = _iterator2.n()).done) {
164
- _context3.next = 11;
286
+ if ((_step3 = _iterator3.n()).done) {
287
+ _context5.next = 11;
165
288
  break;
166
289
  }
167
- plugin = _step2.value;
168
- _context3.next = 9;
290
+ plugin = _step3.value;
291
+ _context5.next = 9;
169
292
  return plugin.beforeLoad();
170
293
  case 9:
171
- _context3.next = 5;
294
+ _context5.next = 5;
172
295
  break;
173
296
  case 11:
174
- _context3.next = 16;
297
+ _context5.next = 16;
175
298
  break;
176
299
  case 13:
177
- _context3.prev = 13;
178
- _context3.t0 = _context3["catch"](3);
179
- _iterator2.e(_context3.t0);
300
+ _context5.prev = 13;
301
+ _context5.t0 = _context5["catch"](3);
302
+ _iterator3.e(_context5.t0);
180
303
  case 16:
181
- _context3.prev = 16;
182
- _iterator2.f();
183
- return _context3.finish(16);
304
+ _context5.prev = 16;
305
+ _iterator3.f();
306
+ return _context5.finish(16);
184
307
  case 19:
185
- _iterator3 = _createForOfIteratorHelper(this.pluginInstances.values());
186
- _context3.prev = 20;
187
- _iterator3.s();
308
+ _iterator4 = _createForOfIteratorHelper(this.pluginInstances.values());
309
+ _context5.prev = 20;
310
+ _iterator4.s();
188
311
  case 22:
189
- if ((_step3 = _iterator3.n()).done) {
190
- _context3.next = 28;
312
+ if ((_step4 = _iterator4.n()).done) {
313
+ _context5.next = 28;
191
314
  break;
192
315
  }
193
- _plugin = _step3.value;
194
- _context3.next = 26;
316
+ _plugin = _step4.value;
317
+ _context5.next = 26;
195
318
  return _plugin.load();
196
319
  case 26:
197
- _context3.next = 22;
320
+ _context5.next = 22;
198
321
  break;
199
322
  case 28:
200
- _context3.next = 33;
323
+ _context5.next = 33;
201
324
  break;
202
325
  case 30:
203
- _context3.prev = 30;
204
- _context3.t1 = _context3["catch"](20);
205
- _iterator3.e(_context3.t1);
326
+ _context5.prev = 30;
327
+ _context5.t1 = _context5["catch"](20);
328
+ _iterator4.e(_context5.t1);
206
329
  case 33:
207
- _context3.prev = 33;
208
- _iterator3.f();
209
- return _context3.finish(33);
330
+ _context5.prev = 33;
331
+ _iterator4.f();
332
+ return _context5.finish(33);
210
333
  case 36:
211
334
  case "end":
212
- return _context3.stop();
335
+ return _context5.stop();
213
336
  }
214
- }, _callee3, this, [[3, 13, 16, 19], [20, 30, 33, 36]]);
337
+ }, _callee5, this, [[3, 13, 16, 19], [20, 30, 33, 36]]);
215
338
  }));
216
339
  function load() {
217
340
  return _load.apply(this, arguments);
@@ -0,0 +1,2 @@
1
+ import type { RequireJS } from './requirejs';
2
+ export declare function defineGlobalDeps(requirejs: RequireJS): void;
@@ -0,0 +1,154 @@
1
+ import * as antdCssinjs from '@ant-design/cssinjs';
2
+ import * as antdIcons from '@ant-design/icons';
3
+ import * as dndKitAccessibility from '@dnd-kit/accessibility';
4
+ import * as dndKitCore from '@dnd-kit/core';
5
+ import * as dndKitModifiers from '@dnd-kit/modifiers';
6
+ import * as dndKitSortable from '@dnd-kit/sortable';
7
+ import * as dndKitUtilities from '@dnd-kit/utilities';
8
+ import * as emotionCss from '@emotion/css';
9
+ import * as formilyAntdV5 from '@formily/antd-v5';
10
+ import * as formilyCore from '@formily/core';
11
+ import * as formilyJsonSchema from '@formily/json-schema';
12
+ import * as formilyPath from '@formily/path';
13
+ import * as formilyReact from '@formily/react';
14
+ import * as formilyJsonReactive from '@formily/reactive';
15
+ import * as formilyReactiveReact from '@formily/reactive-react';
16
+ import * as formilyShared from '@formily/shared';
17
+ import * as formilyValidator from '@formily/validator';
18
+ import * as nocobaseEvaluators from '@nocobase/evaluators/client';
19
+ import * as nocobaseClientUtils from '@nocobase/utils/client';
20
+ import { dayjs } from '@nocobase/utils/client';
21
+ import * as ahooks from 'ahooks';
22
+ import * as antd from 'antd';
23
+ import * as antdStyle from 'antd-style';
24
+ import axios from 'axios';
25
+ import * as i18next from 'i18next';
26
+ import lodash from 'lodash';
27
+ import React from 'react';
28
+ import ReactDOM from 'react-dom';
29
+ import * as reactI18next from 'react-i18next';
30
+ import * as ReactRouter from 'react-router';
31
+ import * as ReactRouterDom from 'react-router-dom';
32
+ import jsxRuntime from 'react/jsx-runtime';
33
+ import * as nocobaseClient from '../../index';
34
+ export function defineGlobalDeps(requirejs) {
35
+ // react
36
+ requirejs.define('react', function () {
37
+ return React;
38
+ });
39
+ requirejs.define('react-dom', function () {
40
+ return ReactDOM;
41
+ });
42
+ requirejs.define('react/jsx-runtime', function () {
43
+ return jsxRuntime;
44
+ });
45
+ // react-router
46
+ requirejs.define('react-router', function () {
47
+ return ReactRouter;
48
+ });
49
+ requirejs.define('react-router-dom', function () {
50
+ return ReactRouterDom;
51
+ });
52
+ // antd
53
+ requirejs.define('antd', function () {
54
+ return antd;
55
+ });
56
+ requirejs.define('antd-style', function () {
57
+ return antdStyle;
58
+ });
59
+ requirejs.define('@ant-design/icons', function () {
60
+ return antdIcons;
61
+ });
62
+ requirejs.define('@ant-design/cssinjs', function () {
63
+ return antdCssinjs;
64
+ });
65
+ // i18next
66
+ requirejs.define('i18next', function () {
67
+ return i18next;
68
+ });
69
+ requirejs.define('react-i18next', function () {
70
+ return reactI18next;
71
+ });
72
+ // formily
73
+ requirejs.define('@formily/antd-v5', function () {
74
+ return formilyAntdV5;
75
+ });
76
+ requirejs.define('@formily/core', function () {
77
+ return formilyCore;
78
+ });
79
+ requirejs.define('@formily/react', function () {
80
+ return formilyReact;
81
+ });
82
+ requirejs.define('@formily/shared', function () {
83
+ return formilyShared;
84
+ });
85
+ requirejs.define('@formily/json-schema', function () {
86
+ return formilyJsonSchema;
87
+ });
88
+ requirejs.define('@formily/reactive', function () {
89
+ return formilyJsonReactive;
90
+ });
91
+ requirejs.define('@formily/path', function () {
92
+ return formilyPath;
93
+ });
94
+ requirejs.define('@formily/validator', function () {
95
+ return formilyValidator;
96
+ });
97
+ requirejs.define('@formily/reactive-react', function () {
98
+ return formilyReactiveReact;
99
+ });
100
+ // nocobase
101
+ requirejs.define('@nocobase/utils', function () {
102
+ return nocobaseClientUtils;
103
+ });
104
+ requirejs.define('@nocobase/utils/client', function () {
105
+ return nocobaseClientUtils;
106
+ });
107
+ requirejs.define('@nocobase/client', function () {
108
+ return nocobaseClient;
109
+ });
110
+ requirejs.define('@nocobase/client/client', function () {
111
+ return nocobaseClient;
112
+ });
113
+ requirejs.define('@nocobase/evaluators', function () {
114
+ return nocobaseEvaluators;
115
+ });
116
+ requirejs.define('@nocobase/evaluators/client', function () {
117
+ return nocobaseEvaluators;
118
+ });
119
+ // dnd-kit 相关
120
+ requirejs.define('@dnd-kit/accessibility', function () {
121
+ return dndKitAccessibility;
122
+ });
123
+ requirejs.define('@dnd-kit/core', function () {
124
+ return dndKitCore;
125
+ });
126
+ requirejs.define('@dnd-kit/modifiers', function () {
127
+ return dndKitModifiers;
128
+ });
129
+ requirejs.define('@dnd-kit/sortable', function () {
130
+ return dndKitSortable;
131
+ });
132
+ requirejs.define('@dnd-kit/utilities', function () {
133
+ return dndKitUtilities;
134
+ });
135
+ // utils
136
+ requirejs.define('axios', function () {
137
+ return axios;
138
+ });
139
+ requirejs.define('dayjs', function () {
140
+ return dayjs;
141
+ });
142
+ requirejs.define('lodash', function () {
143
+ return lodash;
144
+ });
145
+ requirejs.define('ahooks', function () {
146
+ return ahooks;
147
+ });
148
+ requirejs.define('@emotion/css', function () {
149
+ return emotionCss;
150
+ });
151
+ requirejs.define('dayjs', function () {
152
+ return dayjs;
153
+ });
154
+ }