@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,375 @@
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
+ /* istanbul ignore file */
11
+ /** vim: et:ts=4:sw=4:sts=4
12
+ * @license RequireJS 2.3.6 Copyright jQuery Foundation and other contributors.
13
+ * Released under MIT license, https://github.com/requirejs/requirejs/blob/master/LICENSE
14
+ */
15
+ //Not using strict: uneven strict support in browsers, #392, and causes
16
+ //problems with requirejs.exec()/transpiler plugins that may not be strict.
17
+ /*jslint regexp: true, nomen: true, sloppy: true */
18
+ /*global window, navigator, document, importScripts, setTimeout, opera */
19
+
20
+ interface RequireModule {
21
+ /** */
22
+ config(): {};
23
+ }
24
+
25
+ interface RequireMap {
26
+ /** */
27
+ prefix: string;
28
+
29
+ /** */
30
+ name: string;
31
+
32
+ /** */
33
+ parentMap: RequireMap;
34
+
35
+ /** */
36
+ url: string;
37
+
38
+ /** */
39
+ originalName: string;
40
+
41
+ /** */
42
+ fullName: string;
43
+ }
44
+
45
+ interface RequireError extends Error {
46
+ /**
47
+ * The error ID that maps to an ID on a web page.
48
+ */
49
+ requireType: string;
50
+
51
+ /**
52
+ * Required modules.
53
+ */
54
+ requireModules: string[] | null;
55
+
56
+ /**
57
+ * The original error, if there is one (might be null).
58
+ */
59
+ originalError: Error;
60
+ }
61
+
62
+ interface RequireShim {
63
+ /**
64
+ * List of dependencies.
65
+ */
66
+ deps?: string[] | undefined;
67
+
68
+ /**
69
+ * Name the module will be exported as.
70
+ */
71
+ exports?: string | undefined;
72
+
73
+ /**
74
+ * Initialize function with all dependcies passed in,
75
+ * if the function returns a value then that value is used
76
+ * as the module export value instead of the object
77
+ * found via the 'exports' string.
78
+ * @param dependencies
79
+ * @return
80
+ */
81
+ init?: ((...dependencies: any[]) => any) | undefined;
82
+ }
83
+
84
+ interface RequireConfig {
85
+ /**
86
+ * The root path to use for all module lookups.
87
+ */
88
+ baseUrl?: string | undefined;
89
+
90
+ /**
91
+ * Path mappings for module names not found directly under
92
+ * baseUrl.
93
+ */
94
+ paths?: { [key: string]: any } | undefined;
95
+
96
+ /**
97
+ * Dictionary of Shim's.
98
+ * Can be of type RequireShim or string[] of dependencies
99
+ */
100
+ shim?: { [key: string]: RequireShim | string[] } | undefined;
101
+
102
+ /**
103
+ * For the given module prefix, instead of loading the
104
+ * module with the given ID, substitude a different
105
+ * module ID.
106
+ *
107
+ * @example
108
+ * requirejs.config({
109
+ * map: {
110
+ * 'some/newmodule': {
111
+ * 'foo': 'foo1.2'
112
+ * },
113
+ * 'some/oldmodule': {
114
+ * 'foo': 'foo1.0'
115
+ * }
116
+ * }
117
+ * });
118
+ */
119
+ map?:
120
+ | {
121
+ [id: string]: {
122
+ [id: string]: string;
123
+ };
124
+ }
125
+ | undefined;
126
+
127
+ /**
128
+ * Allows pointing multiple module IDs to a module ID that contains a bundle of modules.
129
+ *
130
+ * @example
131
+ * requirejs.config({
132
+ * bundles: {
133
+ * 'primary': ['main', 'util', 'text', 'text!template.html'],
134
+ * 'secondary': ['text!secondary.html']
135
+ * }
136
+ * });
137
+ */
138
+ bundles?: { [key: string]: string[] } | undefined;
139
+
140
+ /**
141
+ * AMD configurations, use module.config() to access in
142
+ * define() functions
143
+ */
144
+ config?: { [id: string]: {} } | undefined;
145
+
146
+ /**
147
+ * Configures loading modules from CommonJS packages.
148
+ */
149
+ packages?: {} | undefined;
150
+
151
+ /**
152
+ * The number of seconds to wait before giving up on loading
153
+ * a script. The default is 7 seconds.
154
+ */
155
+ waitSeconds?: number | undefined;
156
+
157
+ /**
158
+ * A name to give to a loading context. This allows require.js
159
+ * to load multiple versions of modules in a page, as long as
160
+ * each top-level require call specifies a unique context string.
161
+ */
162
+ context?: string | undefined;
163
+
164
+ /**
165
+ * An array of dependencies to load.
166
+ */
167
+ deps?: string[] | undefined;
168
+
169
+ /**
170
+ * A function to pass to require that should be require after
171
+ * deps have been loaded.
172
+ * @param modules
173
+ */
174
+ callback?: ((...modules: any[]) => void) | undefined;
175
+
176
+ /**
177
+ * If set to true, an error will be thrown if a script loads
178
+ * that does not call define() or have shim exports string
179
+ * value that can be checked.
180
+ */
181
+ enforceDefine?: boolean | undefined;
182
+
183
+ /**
184
+ * If set to true, document.createElementNS() will be used
185
+ * to create script elements.
186
+ */
187
+ xhtml?: boolean | undefined;
188
+
189
+ /**
190
+ * Extra query string arguments appended to URLs that RequireJS
191
+ * uses to fetch resources. Most useful to cache bust when
192
+ * the browser or server is not configured correctly.
193
+ *
194
+ * As of RequireJS 2.2.0, urlArgs can be a function. If a
195
+ * function, it will receive the module ID and the URL as
196
+ * parameters, and it should return a string that will be added
197
+ * to the end of the URL. Return an empty string if no args.
198
+ * Be sure to take care of adding the '?' or '&' depending on
199
+ * the existing state of the URL.
200
+ *
201
+ * @example
202
+ *
203
+ * urlArgs: "bust=" + (new Date()).getTime()
204
+ *
205
+ * @example
206
+ *
207
+ * requirejs.config({
208
+ * urlArgs: function(id, url) {
209
+ * var args = 'v=1';
210
+ * if (url.indexOf('view.html') !== -1) {
211
+ * args = 'v=2'
212
+ * }
213
+ *
214
+ * return (url.indexOf('?') === -1 ? '?' : '&') + args;
215
+ * }
216
+ * });
217
+ */
218
+ urlArgs?: string | ((id: string, url: string) => string) | undefined;
219
+
220
+ /**
221
+ * Specify the value for the type="" attribute used for script
222
+ * tags inserted into the document by RequireJS. Default is
223
+ * "text/javascript". To use Firefox's JavasScript 1.8
224
+ * features, use "text/javascript;version=1.8".
225
+ */
226
+ scriptType?: string | undefined;
227
+
228
+ /**
229
+ * If set to true, skips the data-main attribute scanning done
230
+ * to start module loading. Useful if RequireJS is embedded in
231
+ * a utility library that may interact with other RequireJS
232
+ * library on the page, and the embedded version should not do
233
+ * data-main loading.
234
+ */
235
+ skipDataMain?: boolean | undefined;
236
+
237
+ /**
238
+ * Allow extending requirejs to support Subresource Integrity
239
+ * (SRI).
240
+ */
241
+ onNodeCreated?:
242
+ | ((node: HTMLScriptElement, config: RequireConfig, moduleName: string, url: string) => void)
243
+ | undefined;
244
+ }
245
+
246
+ export interface Require {
247
+ /**
248
+ * Configure require.js
249
+ */
250
+ config(config: RequireConfig): Require;
251
+
252
+ /**
253
+ * CommonJS require call
254
+ * @param module Module to load
255
+ * @return The loaded module
256
+ */
257
+ (module: string): any;
258
+
259
+ /**
260
+ * Start the main app logic.
261
+ * Callback is optional.
262
+ * Can alternatively use deps and callback.
263
+ * @param modules Required modules to load.
264
+ */
265
+ (modules: string[]): void;
266
+
267
+ /**
268
+ * @see Require()
269
+ * @param ready Called when required modules are ready.
270
+ */
271
+ (modules: string[], ready: Function): void;
272
+
273
+ /**
274
+ * @see http://requirejs.org/docs/api.html#errbacks
275
+ * @param ready Called when required modules are ready.
276
+ */
277
+ (modules: string[], ready: Function, errback: Function): void;
278
+
279
+ /**
280
+ * Generate URLs from require module
281
+ * @param module Module to URL
282
+ * @return URL string
283
+ */
284
+ toUrl(module: string): string;
285
+
286
+ /**
287
+ * Returns true if the module has already been loaded and defined.
288
+ * @param module Module to check
289
+ */
290
+ defined(module: string): boolean;
291
+
292
+ /**
293
+ * Returns true if the module has already been requested or is in the process of loading and should be available at some point.
294
+ * @param module Module to check
295
+ */
296
+ specified(module: string): boolean;
297
+
298
+ /**
299
+ * On Error override
300
+ * @param err
301
+ */
302
+ onError(err: RequireError, errback?: (err: RequireError) => void): void;
303
+
304
+ /**
305
+ * Undefine a module
306
+ * @param module Module to undefine.
307
+ */
308
+ undef(module: string): void;
309
+
310
+ /**
311
+ * Semi-private function, overload in special instance of undef()
312
+ */
313
+ onResourceLoad(context: Object, map: RequireMap, depArray: RequireMap[]): void;
314
+ }
315
+
316
+ export interface RequireDefine {
317
+ /**
318
+ * Define Simple Name/Value Pairs
319
+ * @param config Dictionary of Named/Value pairs for the config.
320
+ */
321
+ (config: { [key: string]: any }): void;
322
+
323
+ /**
324
+ * Define function.
325
+ * @param func: The function module.
326
+ */
327
+ (func: () => any): void;
328
+
329
+ /**
330
+ * Define function with dependencies.
331
+ * @param deps List of dependencies module IDs.
332
+ * @param ready Callback function when the dependencies are loaded.
333
+ * callback param deps module dependencies
334
+ * callback return module definition
335
+ */
336
+ (deps: string[], ready: Function): void;
337
+
338
+ /**
339
+ * Define module with simplified CommonJS wrapper.
340
+ * @param ready
341
+ * callback require requirejs instance
342
+ * callback exports exports object
343
+ * callback module module
344
+ * callback return module definition
345
+ */
346
+ (ready: (require: Require, exports: { [key: string]: any }, module: RequireModule) => any): void;
347
+
348
+ /**
349
+ * Define a module with a name and dependencies.
350
+ * @param name The name of the module.
351
+ * @param deps List of dependencies module IDs.
352
+ * @param ready Callback function when the dependencies are loaded.
353
+ * callback deps module dependencies
354
+ * callback return module definition
355
+ */
356
+ (name: string, deps: string[], ready: Function): void;
357
+
358
+ /**
359
+ * Define a module with a name.
360
+ * @param name The name of the module.
361
+ * @param ready Callback function when the dependencies are loaded.
362
+ * callback return module definition
363
+ */
364
+ (name: string, ready: Function): void;
365
+
366
+ /**
367
+ * Used to allow a clear indicator that a global define function (as needed for script src browser loading) conforms
368
+ * to the AMD API, any global define function SHOULD have a property called "amd" whose value is an object.
369
+ * This helps avoid conflict with any other existing JavaScript code that could have defined a define() function
370
+ * that does not conform to the AMD API.
371
+ * define.amd.jQuery is specific to jQuery and indicates that the loader is able to account for multiple version
372
+ * of jQuery being loaded simultaneously.
373
+ */
374
+ amd: Object;
375
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "target": "ESNext",
5
+ "module": "ESNext"
6
+ }
7
+ }