@nocobase/client-v2 2.1.0-alpha.1 → 2.1.0-alpha.11

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 (46) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +99 -0
  3. package/es/Application.d.ts +124 -0
  4. package/es/MockApplication.d.ts +16 -0
  5. package/es/Plugin.d.ts +33 -0
  6. package/es/PluginManager.d.ts +46 -0
  7. package/es/PluginSettingsManager.d.ts +68 -0
  8. package/es/RouterManager.d.ts +69 -0
  9. package/es/WebSocketClient.d.ts +45 -0
  10. package/es/components/BlankComponent.d.ts +12 -0
  11. package/es/components/MainComponent.d.ts +10 -0
  12. package/es/components/RouterBridge.d.ts +13 -0
  13. package/es/components/RouterContextCleaner.d.ts +12 -0
  14. package/es/components/index.d.ts +10 -0
  15. package/es/context.d.ts +11 -0
  16. package/es/hooks/index.d.ts +11 -0
  17. package/es/hooks/useApp.d.ts +10 -0
  18. package/es/hooks/usePlugin.d.ts +11 -0
  19. package/es/hooks/useRouter.d.ts +9 -0
  20. package/es/index.d.ts +14 -0
  21. package/es/utils/globalDeps.d.ts +13 -0
  22. package/es/utils/index.d.ts +11 -0
  23. package/es/utils/remotePlugins.d.ts +44 -0
  24. package/es/utils/requirejs.d.ts +18 -0
  25. package/es/utils/types.d.ts +330 -0
  26. package/lib/Application.js +14 -4
  27. package/lib/PluginManager.js +1 -1
  28. package/lib/PluginSettingsManager.d.ts +1 -0
  29. package/lib/PluginSettingsManager.js +2 -1
  30. package/lib/RouterManager.d.ts +8 -0
  31. package/lib/RouterManager.js +35 -2
  32. package/lib/utils/globalDeps.d.ts +13 -0
  33. package/lib/utils/globalDeps.js +82 -0
  34. package/lib/utils/remotePlugins.js +2 -2
  35. package/package.json +6 -6
  36. package/src/Application.tsx +13 -4
  37. package/src/PluginManager.ts +1 -1
  38. package/src/PluginSettingsManager.ts +2 -0
  39. package/src/RouterManager.tsx +48 -2
  40. package/src/__tests__/app.test.tsx +55 -0
  41. package/src/__tests__/globalDeps.test.ts +26 -0
  42. package/src/__tests__/plugin.test.ts +61 -0
  43. package/src/__tests__/remotePlugins.test.ts +72 -0
  44. package/src/utils/globalDeps.ts +61 -0
  45. package/src/utils/remotePlugins.ts +2 -2
  46. package/LICENSE.txt +0 -172
@@ -0,0 +1,45 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Application } from './Application';
10
+ export type WebSocketClientOptions = {
11
+ reconnectInterval?: number;
12
+ reconnectAttempts?: number;
13
+ pingInterval?: number;
14
+ url?: string;
15
+ basename?: string;
16
+ protocols?: string | string[];
17
+ onServerDown?: any;
18
+ };
19
+ export declare class WebSocketClient {
20
+ protected _ws: WebSocket;
21
+ protected _reconnectTimes: number;
22
+ protected events: any[];
23
+ protected options: WebSocketClientOptions;
24
+ app: Application;
25
+ enabled: boolean;
26
+ connected: boolean;
27
+ serverDown: boolean;
28
+ lastMessage: {};
29
+ constructor(options: WebSocketClientOptions | boolean);
30
+ getSubAppName: (app: Application) => string;
31
+ getURL(): string;
32
+ get reconnectAttempts(): number;
33
+ get reconnectInterval(): number;
34
+ get pingInterval(): number;
35
+ get readyState(): number;
36
+ createWebSocket(): WebSocket;
37
+ connect(): void;
38
+ reconnect(): void;
39
+ close(): void;
40
+ send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
41
+ on(type: string, listener: any, options?: boolean | AddEventListenerOptions): void;
42
+ emit(type: string, args: any): void;
43
+ off(type: string, listener: any, options?: boolean | EventListenerOptions): void;
44
+ removeAllListeners(): void;
45
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { FC, ReactNode } from 'react';
10
+ export declare const BlankComponent: FC<{
11
+ children?: ReactNode;
12
+ }>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import React from 'react';
10
+ export declare const MainComponent: React.NamedExoticComponent<object>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Application } from '../Application';
10
+ export declare function useRouterSync(app: Application): void;
11
+ export declare function RouterBridge({ app }: {
12
+ app: any;
13
+ }): any;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { FC, ReactNode } from 'react';
10
+ export declare const RouterContextCleaner: FC<{
11
+ children?: ReactNode;
12
+ }>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export * from './BlankComponent';
10
+ export * from './RouterContextCleaner';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ /// <reference types="react" />
10
+ import type { Application } from './Application';
11
+ export declare const ApplicationContext: import("react").Context<Application>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export * from './useApp';
10
+ export * from './usePlugin';
11
+ export * from './useRouter';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import type { Application } from '../Application';
10
+ export declare const useApp: () => Application;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Plugin } from '../Plugin';
10
+ export declare function usePlugin<T extends typeof Plugin = any>(plugin: T): InstanceType<T>;
11
+ export declare function usePlugin<T extends {}>(name: string): T;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export declare const useRouter: () => import("../RouterManager").RouterManager;
package/es/index.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export * from './Application';
10
+ export * from './components';
11
+ export * from './context';
12
+ export * from './MockApplication';
13
+ export * from './Plugin';
14
+ export * from './WebSocketClient';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import type { RequireJS } from './requirejs';
10
+ /**
11
+ * @internal
12
+ */
13
+ export declare function defineGlobalDeps(requirejs: RequireJS): void;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import React, { ComponentType } from 'react';
10
+ export declare function normalizeContainer(container: Element | ShadowRoot | string): Element | null;
11
+ export declare const compose: (...components: [ComponentType, any][]) => (LastChild?: ComponentType) => React.FC;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import type { DevDynamicImport } from '../Application';
10
+ import type { Plugin } from '../Plugin';
11
+ import type { PluginData } from '../PluginManager';
12
+ import type { RequireJS } from './requirejs';
13
+ /**
14
+ * @internal
15
+ */
16
+ export declare function defineDevPlugins(plugins: Record<string, typeof Plugin>): void;
17
+ /**
18
+ * @internal
19
+ */
20
+ export declare function definePluginClient(packageName: string): void;
21
+ /**
22
+ * @internal
23
+ */
24
+ export declare function configRequirejs(requirejs: any, pluginData: PluginData[]): void;
25
+ /**
26
+ * @internal
27
+ */
28
+ export declare function processRemotePlugins(pluginData: PluginData[], resolve: (plugins: [string, typeof Plugin][]) => void): (...pluginModules: (typeof Plugin & {
29
+ default?: typeof Plugin;
30
+ })[]) => void;
31
+ /**
32
+ * @internal
33
+ */
34
+ export declare function getRemotePlugins(requirejs: any, pluginData?: PluginData[]): Promise<Array<[string, typeof Plugin]>>;
35
+ interface GetPluginsOption {
36
+ requirejs: RequireJS;
37
+ pluginData: PluginData[];
38
+ devDynamicImport?: DevDynamicImport;
39
+ }
40
+ /**
41
+ * @internal
42
+ */
43
+ export declare function getPlugins(options: GetPluginsOption): Promise<Array<[string, typeof Plugin]>>;
44
+ export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import type { Require, RequireDefine } from './types';
10
+ export interface RequireJS {
11
+ require: Require;
12
+ requirejs: Require;
13
+ define: RequireDefine;
14
+ }
15
+ /**
16
+ * @internal
17
+ */
18
+ export declare function getRequireJs(): RequireJS;
@@ -0,0 +1,330 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ /** vim: et:ts=4:sw=4:sts=4
10
+ * @license RequireJS 2.3.6 Copyright jQuery Foundation and other contributors.
11
+ * Released under MIT license, https://github.com/requirejs/requirejs/blob/master/LICENSE
12
+ */
13
+ interface RequireModule {
14
+ /** */
15
+ config(): {};
16
+ }
17
+ interface RequireMap {
18
+ /** */
19
+ prefix: string;
20
+ /** */
21
+ name: string;
22
+ /** */
23
+ parentMap: RequireMap;
24
+ /** */
25
+ url: string;
26
+ /** */
27
+ originalName: string;
28
+ /** */
29
+ fullName: string;
30
+ }
31
+ interface RequireError extends Error {
32
+ /**
33
+ * The error ID that maps to an ID on a web page.
34
+ */
35
+ requireType: string;
36
+ /**
37
+ * Required modules.
38
+ */
39
+ requireModules: string[] | null;
40
+ /**
41
+ * The original error, if there is one (might be null).
42
+ */
43
+ originalError: Error;
44
+ }
45
+ interface RequireShim {
46
+ /**
47
+ * List of dependencies.
48
+ */
49
+ deps?: string[] | undefined;
50
+ /**
51
+ * Name the module will be exported as.
52
+ */
53
+ exports?: string | undefined;
54
+ /**
55
+ * Initialize function with all dependcies passed in,
56
+ * if the function returns a value then that value is used
57
+ * as the module export value instead of the object
58
+ * found via the 'exports' string.
59
+ * @param dependencies
60
+ * @return
61
+ */
62
+ init?: ((...dependencies: any[]) => any) | undefined;
63
+ }
64
+ interface RequireConfig {
65
+ /**
66
+ * The root path to use for all module lookups.
67
+ */
68
+ baseUrl?: string | undefined;
69
+ /**
70
+ * Path mappings for module names not found directly under
71
+ * baseUrl.
72
+ */
73
+ paths?: {
74
+ [key: string]: any;
75
+ } | undefined;
76
+ /**
77
+ * Dictionary of Shim's.
78
+ * Can be of type RequireShim or string[] of dependencies
79
+ */
80
+ shim?: {
81
+ [key: string]: RequireShim | string[];
82
+ } | undefined;
83
+ /**
84
+ * For the given module prefix, instead of loading the
85
+ * module with the given ID, substitude a different
86
+ * module ID.
87
+ *
88
+ * @example
89
+ * requirejs.config({
90
+ * map: {
91
+ * 'some/newmodule': {
92
+ * 'foo': 'foo1.2'
93
+ * },
94
+ * 'some/oldmodule': {
95
+ * 'foo': 'foo1.0'
96
+ * }
97
+ * }
98
+ * });
99
+ */
100
+ map?: {
101
+ [id: string]: {
102
+ [id: string]: string;
103
+ };
104
+ } | undefined;
105
+ /**
106
+ * Allows pointing multiple module IDs to a module ID that contains a bundle of modules.
107
+ *
108
+ * @example
109
+ * requirejs.config({
110
+ * bundles: {
111
+ * 'primary': ['main', 'util', 'text', 'text!template.html'],
112
+ * 'secondary': ['text!secondary.html']
113
+ * }
114
+ * });
115
+ */
116
+ bundles?: {
117
+ [key: string]: string[];
118
+ } | undefined;
119
+ /**
120
+ * AMD configurations, use module.config() to access in
121
+ * define() functions
122
+ */
123
+ config?: {
124
+ [id: string]: {};
125
+ } | undefined;
126
+ /**
127
+ * Configures loading modules from CommonJS packages.
128
+ */
129
+ packages?: {} | undefined;
130
+ /**
131
+ * The number of seconds to wait before giving up on loading
132
+ * a script. The default is 7 seconds.
133
+ */
134
+ waitSeconds?: number | undefined;
135
+ /**
136
+ * A name to give to a loading context. This allows require.js
137
+ * to load multiple versions of modules in a page, as long as
138
+ * each top-level require call specifies a unique context string.
139
+ */
140
+ context?: string | undefined;
141
+ /**
142
+ * An array of dependencies to load.
143
+ */
144
+ deps?: string[] | undefined;
145
+ /**
146
+ * A function to pass to require that should be require after
147
+ * deps have been loaded.
148
+ * @param modules
149
+ */
150
+ callback?: ((...modules: any[]) => void) | undefined;
151
+ /**
152
+ * If set to true, an error will be thrown if a script loads
153
+ * that does not call define() or have shim exports string
154
+ * value that can be checked.
155
+ */
156
+ enforceDefine?: boolean | undefined;
157
+ /**
158
+ * If set to true, document.createElementNS() will be used
159
+ * to create script elements.
160
+ */
161
+ xhtml?: boolean | undefined;
162
+ /**
163
+ * Extra query string arguments appended to URLs that RequireJS
164
+ * uses to fetch resources. Most useful to cache bust when
165
+ * the browser or server is not configured correctly.
166
+ *
167
+ * As of RequireJS 2.2.0, urlArgs can be a function. If a
168
+ * function, it will receive the module ID and the URL as
169
+ * parameters, and it should return a string that will be added
170
+ * to the end of the URL. Return an empty string if no args.
171
+ * Be sure to take care of adding the '?' or '&' depending on
172
+ * the existing state of the URL.
173
+ *
174
+ * @example
175
+ *
176
+ * urlArgs: "bust=" + (new Date()).getTime()
177
+ *
178
+ * @example
179
+ *
180
+ * requirejs.config({
181
+ * urlArgs: function(id, url) {
182
+ * var args = 'v=1';
183
+ * if (url.indexOf('view.html') !== -1) {
184
+ * args = 'v=2'
185
+ * }
186
+ *
187
+ * return (url.indexOf('?') === -1 ? '?' : '&') + args;
188
+ * }
189
+ * });
190
+ */
191
+ urlArgs?: string | ((id: string, url: string) => string) | undefined;
192
+ /**
193
+ * Specify the value for the type="" attribute used for script
194
+ * tags inserted into the document by RequireJS. Default is
195
+ * "text/javascript". To use Firefox's JavasScript 1.8
196
+ * features, use "text/javascript;version=1.8".
197
+ */
198
+ scriptType?: string | undefined;
199
+ /**
200
+ * If set to true, skips the data-main attribute scanning done
201
+ * to start module loading. Useful if RequireJS is embedded in
202
+ * a utility library that may interact with other RequireJS
203
+ * library on the page, and the embedded version should not do
204
+ * data-main loading.
205
+ */
206
+ skipDataMain?: boolean | undefined;
207
+ /**
208
+ * Allow extending requirejs to support Subresource Integrity
209
+ * (SRI).
210
+ */
211
+ onNodeCreated?: ((node: HTMLScriptElement, config: RequireConfig, moduleName: string, url: string) => void) | undefined;
212
+ }
213
+ export interface Require {
214
+ /**
215
+ * Configure require.js
216
+ */
217
+ config(config: RequireConfig): Require;
218
+ /**
219
+ * CommonJS require call
220
+ * @param module Module to load
221
+ * @return The loaded module
222
+ */
223
+ (module: string): any;
224
+ /**
225
+ * Start the main app logic.
226
+ * Callback is optional.
227
+ * Can alternatively use deps and callback.
228
+ * @param modules Required modules to load.
229
+ */
230
+ (modules: string[]): void;
231
+ /**
232
+ * @see Require()
233
+ * @param ready Called when required modules are ready.
234
+ */
235
+ (modules: string[], ready: Function): void;
236
+ /**
237
+ * @see http://requirejs.org/docs/api.html#errbacks
238
+ * @param ready Called when required modules are ready.
239
+ */
240
+ (modules: string[], ready: Function, errback: Function): void;
241
+ /**
242
+ * Generate URLs from require module
243
+ * @param module Module to URL
244
+ * @return URL string
245
+ */
246
+ toUrl(module: string): string;
247
+ /**
248
+ * Returns true if the module has already been loaded and defined.
249
+ * @param module Module to check
250
+ */
251
+ defined(module: string): boolean;
252
+ /**
253
+ * Returns true if the module has already been requested or is in the process of loading and should be available at some point.
254
+ * @param module Module to check
255
+ */
256
+ specified(module: string): boolean;
257
+ /**
258
+ * On Error override
259
+ * @param err
260
+ */
261
+ onError(err: RequireError, errback?: (err: RequireError) => void): void;
262
+ /**
263
+ * Undefine a module
264
+ * @param module Module to undefine.
265
+ */
266
+ undef(module: string): void;
267
+ /**
268
+ * Semi-private function, overload in special instance of undef()
269
+ */
270
+ onResourceLoad(context: Object, map: RequireMap, depArray: RequireMap[]): void;
271
+ }
272
+ export interface RequireDefine {
273
+ /**
274
+ * Define Simple Name/Value Pairs
275
+ * @param config Dictionary of Named/Value pairs for the config.
276
+ */
277
+ (config: {
278
+ [key: string]: any;
279
+ }): void;
280
+ /**
281
+ * Define function.
282
+ * @param func: The function module.
283
+ */
284
+ (func: () => any): void;
285
+ /**
286
+ * Define function with dependencies.
287
+ * @param deps List of dependencies module IDs.
288
+ * @param ready Callback function when the dependencies are loaded.
289
+ * callback param deps module dependencies
290
+ * callback return module definition
291
+ */
292
+ (deps: string[], ready: Function): void;
293
+ /**
294
+ * Define module with simplified CommonJS wrapper.
295
+ * @param ready
296
+ * callback require requirejs instance
297
+ * callback exports exports object
298
+ * callback module module
299
+ * callback return module definition
300
+ */
301
+ (ready: (require: Require, exports: {
302
+ [key: string]: any;
303
+ }, module: RequireModule) => any): void;
304
+ /**
305
+ * Define a module with a name and dependencies.
306
+ * @param name The name of the module.
307
+ * @param deps List of dependencies module IDs.
308
+ * @param ready Callback function when the dependencies are loaded.
309
+ * callback deps module dependencies
310
+ * callback return module definition
311
+ */
312
+ (name: string, deps: string[], ready: Function): void;
313
+ /**
314
+ * Define a module with a name.
315
+ * @param name The name of the module.
316
+ * @param ready Callback function when the dependencies are loaded.
317
+ * callback return module definition
318
+ */
319
+ (name: string, ready: Function): void;
320
+ /**
321
+ * Used to allow a clear indicator that a global define function (as needed for script src browser loading) conforms
322
+ * to the AMD API, any global define function SHOULD have a property called "amd" whose value is an object.
323
+ * This helps avoid conflict with any other existing JavaScript code that could have defined a define() function
324
+ * that does not conform to the AMD API.
325
+ * define.amd.jQuery is specific to jQuery and indicates that the loader is able to account for multiple version
326
+ * of jQuery being loaded simultaneously.
327
+ */
328
+ amd: Object;
329
+ }
330
+ export {};
@@ -51,7 +51,7 @@ var import_reactive = require("@formily/reactive");
51
51
  var import_flow_engine = require("@nocobase/flow-engine");
52
52
  var import_sdk = require("@nocobase/sdk");
53
53
  var import_i18next = require("i18next");
54
- var import_lodash = __toESM(require("lodash"));
54
+ var import_lodash_es = require("lodash-es");
55
55
  var import_react = __toESM(require("react"));
56
56
  var import_client = require("react-dom/client");
57
57
  var import_react_i18next = require("react-i18next");
@@ -62,11 +62,13 @@ var import_RouterManager = require("./RouterManager");
62
62
  var import_WebSocketClient = require("./WebSocketClient");
63
63
  var import_components = require("./components");
64
64
  var import_utils = require("./utils");
65
+ var import_globalDeps = require("./utils/globalDeps");
65
66
  var import_requirejs = require("./utils/requirejs");
66
67
  var _providers, _router;
67
68
  const _Application = class _Application {
68
69
  constructor(options = {}) {
69
70
  this.options = options;
71
+ var _a;
70
72
  this.initRequireJs();
71
73
  (0, import_reactive.define)(this, {
72
74
  maintained: import_reactive.observable.ref,
@@ -74,10 +76,17 @@ const _Application = class _Application {
74
76
  error: import_reactive.observable.ref
75
77
  });
76
78
  this.devDynamicImport = options.devDynamicImport;
77
- this.components = import_lodash.default.merge(this.components, options.components);
79
+ this.components = (0, import_lodash_es.merge)(this.components, options.components);
78
80
  this.apiClient = new import_sdk.APIClient(options.apiClient);
79
81
  this.i18n = options.i18n || (0, import_i18next.createInstance)();
80
82
  this.router = new import_RouterManager.RouterManager(options.router, this);
83
+ if (typeof ((_a = options.router) == null ? void 0 : _a.basename) === "undefined") {
84
+ const publicPath = this.getPublicPath();
85
+ const basename = publicPath === "/" ? void 0 : publicPath.replace(/\/$/, "");
86
+ if (basename) {
87
+ this.router.setBasename(basename);
88
+ }
89
+ }
81
90
  this.pluginManager = new import_PluginManager.PluginManager(options.plugins, options.loadRemotePlugins, this);
82
91
  this.flowEngine = new import_flow_engine.FlowEngine();
83
92
  this.flowEngine.registerModels({ ApplicationModel });
@@ -210,6 +219,7 @@ const _Application = class _Application {
210
219
  return;
211
220
  }
212
221
  window["requirejs"] = this.requirejs = (0, import_requirejs.getRequireJs)();
222
+ (0, import_globalDeps.defineGlobalDeps)(this.requirejs);
213
223
  window.define = this.requirejs.define;
214
224
  }
215
225
  addDefaultProviders() {
@@ -377,7 +387,7 @@ const _Application = class _Application {
377
387
  }
378
388
  if (typeof Component === "function") return Component;
379
389
  if (typeof Component === "string") {
380
- const res = import_lodash.default.get(this.components, Component);
390
+ const res = (0, import_lodash_es.get)(this.components, Component);
381
391
  if (!res) {
382
392
  showError(`Component ${Component} not found`);
383
393
  return;
@@ -396,7 +406,7 @@ const _Application = class _Application {
396
406
  console.error("Component must have a displayName or pass name as second argument");
397
407
  return;
398
408
  }
399
- import_lodash.default.set(this.components, componentName, component);
409
+ (0, import_lodash_es.set)(this.components, componentName, component);
400
410
  }
401
411
  addComponents(components) {
402
412
  Object.keys(components).forEach((name) => {
@@ -60,7 +60,7 @@ const _PluginManager = class _PluginManager {
60
60
  }
61
61
  async initRemotePlugins() {
62
62
  var _a;
63
- const res = await this.app.apiClient.request({ url: "pm:listEnabled" });
63
+ const res = await this.app.apiClient.request({ url: "pm:listEnabledV2" });
64
64
  const pluginList = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.data) || [];
65
65
  const plugins = await (0, import_remotePlugins.getPlugins)({
66
66
  requirejs: this.app.requirejs,