@nocobase/client-v2 2.0.0-alpha.20

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 (70) hide show
  1. package/LICENSE.txt +172 -0
  2. package/lib/Application.d.ts +124 -0
  3. package/lib/Application.js +489 -0
  4. package/lib/MockApplication.d.ts +16 -0
  5. package/lib/MockApplication.js +96 -0
  6. package/lib/Plugin.d.ts +33 -0
  7. package/lib/Plugin.js +89 -0
  8. package/lib/PluginManager.d.ts +46 -0
  9. package/lib/PluginManager.js +114 -0
  10. package/lib/PluginSettingsManager.d.ts +67 -0
  11. package/lib/PluginSettingsManager.js +148 -0
  12. package/lib/RouterManager.d.ts +61 -0
  13. package/lib/RouterManager.js +198 -0
  14. package/lib/WebSocketClient.d.ts +45 -0
  15. package/lib/WebSocketClient.js +217 -0
  16. package/lib/components/BlankComponent.d.ts +12 -0
  17. package/lib/components/BlankComponent.js +48 -0
  18. package/lib/components/MainComponent.d.ts +10 -0
  19. package/lib/components/MainComponent.js +54 -0
  20. package/lib/components/RouterBridge.d.ts +13 -0
  21. package/lib/components/RouterBridge.js +66 -0
  22. package/lib/components/RouterContextCleaner.d.ts +12 -0
  23. package/lib/components/RouterContextCleaner.js +61 -0
  24. package/lib/components/index.d.ts +10 -0
  25. package/lib/components/index.js +32 -0
  26. package/lib/context.d.ts +11 -0
  27. package/lib/context.js +38 -0
  28. package/lib/hooks/index.d.ts +11 -0
  29. package/lib/hooks/index.js +34 -0
  30. package/lib/hooks/useApp.d.ts +10 -0
  31. package/lib/hooks/useApp.js +41 -0
  32. package/lib/hooks/usePlugin.d.ts +11 -0
  33. package/lib/hooks/usePlugin.js +42 -0
  34. package/lib/hooks/useRouter.d.ts +9 -0
  35. package/lib/hooks/useRouter.js +41 -0
  36. package/lib/index.d.ts +14 -0
  37. package/lib/index.js +40 -0
  38. package/lib/utils/index.d.ts +11 -0
  39. package/lib/utils/index.js +79 -0
  40. package/lib/utils/remotePlugins.d.ts +44 -0
  41. package/lib/utils/remotePlugins.js +131 -0
  42. package/lib/utils/requirejs.d.ts +18 -0
  43. package/lib/utils/requirejs.js +1361 -0
  44. package/lib/utils/types.d.ts +330 -0
  45. package/lib/utils/types.js +28 -0
  46. package/package.json +16 -0
  47. package/src/Application.tsx +539 -0
  48. package/src/MockApplication.tsx +53 -0
  49. package/src/Plugin.ts +78 -0
  50. package/src/PluginManager.ts +114 -0
  51. package/src/PluginSettingsManager.ts +182 -0
  52. package/src/RouterManager.tsx +239 -0
  53. package/src/WebSocketClient.ts +220 -0
  54. package/src/__tests__/app.test.tsx +141 -0
  55. package/src/components/BlankComponent.tsx +12 -0
  56. package/src/components/MainComponent.tsx +20 -0
  57. package/src/components/RouterBridge.tsx +38 -0
  58. package/src/components/RouterContextCleaner.tsx +26 -0
  59. package/src/components/index.ts +11 -0
  60. package/src/context.ts +14 -0
  61. package/src/hooks/index.ts +12 -0
  62. package/src/hooks/useApp.ts +16 -0
  63. package/src/hooks/usePlugin.ts +17 -0
  64. package/src/hooks/useRouter.ts +15 -0
  65. package/src/index.ts +15 -0
  66. package/src/utils/index.tsx +48 -0
  67. package/src/utils/remotePlugins.ts +140 -0
  68. package/src/utils/requirejs.ts +2164 -0
  69. package/src/utils/types.ts +375 -0
  70. package/tsconfig.json +7 -0
@@ -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 {};
@@ -0,0 +1,28 @@
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
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+ var types_exports = {};
24
+ module.exports = __toCommonJS(types_exports);
25
+ /** vim: et:ts=4:sw=4:sts=4
26
+ * @license RequireJS 2.3.6 Copyright jQuery Foundation and other contributors.
27
+ * Released under MIT license, https://github.com/requirejs/requirejs/blob/master/LICENSE
28
+ */
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@nocobase/client-v2",
3
+ "version": "2.0.0-alpha.20",
4
+ "license": "AGPL-3.0",
5
+ "main": "lib/index.js",
6
+ "module": "es/index.mjs",
7
+ "types": "es/index.d.ts",
8
+ "dependencies": {
9
+ "@nocobase/flow-engine": "2.0.0-alpha.20",
10
+ "@nocobase/sdk": "2.0.0-alpha.20",
11
+ "@nocobase/shared": "2.0.0-alpha.20",
12
+ "i18next": "^22.4.9",
13
+ "react-router-dom": "^6.30.1"
14
+ },
15
+ "gitHead": "af5ff4eaa490349420135405128da466d72ac74c"
16
+ }