@framework-m/plugin-sdk 0.2.3
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.
- package/LICENSE +202 -0
- package/dist/context/PluginRegistryContext.d.ts +23 -0
- package/dist/context/PluginRegistryContext.d.ts.map +1 -0
- package/dist/core/PluginRegistry.d.ts +130 -0
- package/dist/core/PluginRegistry.d.ts.map +1 -0
- package/dist/core/ServiceContainer.d.ts +31 -0
- package/dist/core/ServiceContainer.d.ts.map +1 -0
- package/dist/hooks/usePlugin.d.ts +3 -0
- package/dist/hooks/usePlugin.d.ts.map +1 -0
- package/dist/hooks/usePluginMenu.d.ts +3 -0
- package/dist/hooks/usePluginMenu.d.ts.map +1 -0
- package/dist/hooks/useService.d.ts +24 -0
- package/dist/hooks/useService.d.ts.map +1 -0
- package/dist/hooks/useWidgets.d.ts +3 -0
- package/dist/hooks/useWidgets.d.ts.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +594 -0
- package/dist/index.js.map +1 -0
- package/dist/types/plugin.d.ts +157 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 contributors (see contributors.json)
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { PluginRegistry } from '../core/PluginRegistry';
|
|
3
|
+
export declare const PluginRegistryContext: import('react').Context<PluginRegistry | null>;
|
|
4
|
+
export interface PluginRegistryProviderProps {
|
|
5
|
+
readonly children: ReactNode;
|
|
6
|
+
/** Optional pre-configured PluginRegistry instance */
|
|
7
|
+
readonly registry?: PluginRegistry;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Provider component that makes the PluginRegistry available to child components.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* const registry = new PluginRegistry();
|
|
15
|
+
* await registry.register(wmsPlugin);
|
|
16
|
+
*
|
|
17
|
+
* <PluginRegistryProvider registry={registry}>
|
|
18
|
+
* <App />
|
|
19
|
+
* </PluginRegistryProvider>
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function PluginRegistryProvider({ children, registry, }: PluginRegistryProviderProps): import("react/jsx-runtime").JSX.Element | null;
|
|
23
|
+
//# sourceMappingURL=PluginRegistryContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginRegistryContext.d.ts","sourceRoot":"","sources":["../../src/context/PluginRegistryContext.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,eAAO,MAAM,qBAAqB,gDAA6C,CAAC;AAEhF,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;CACpC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,QAAQ,EACR,QAAQ,GACT,EAAE,2BAA2B,kDAmB7B"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { FrameworkMPlugin, MenuItem, RouteDefinition, CompatibilityReport, PluginRegistryDiagnostic, PluginRegistryDiagnosticSeverity, PermissionChecker, Widget } from '../types/plugin';
|
|
2
|
+
import { ServiceContainer } from './ServiceContainer';
|
|
3
|
+
type PluginRegistryEvent = "plugin:registered" | "plugin:error";
|
|
4
|
+
type PluginRegistryEventPayloadMap = {
|
|
5
|
+
"plugin:registered": {
|
|
6
|
+
plugin: FrameworkMPlugin;
|
|
7
|
+
};
|
|
8
|
+
"plugin:error": {
|
|
9
|
+
plugin: FrameworkMPlugin;
|
|
10
|
+
error: unknown;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
type PluginRegistryEventHandler<E extends PluginRegistryEvent> = (payload: PluginRegistryEventPayloadMap[E]) => void;
|
|
14
|
+
/**
|
|
15
|
+
* SDK version — used for compatibility checking.
|
|
16
|
+
*/
|
|
17
|
+
export declare const SDK_VERSION = "0.1.0";
|
|
18
|
+
export declare class PluginRegistry {
|
|
19
|
+
private readonly plugins;
|
|
20
|
+
private menuCache;
|
|
21
|
+
private readonly serviceContainer;
|
|
22
|
+
private readonly routeOwners;
|
|
23
|
+
private readonly menuNameOwners;
|
|
24
|
+
private readonly menuRouteOwners;
|
|
25
|
+
private readonly serviceOwners;
|
|
26
|
+
private diagnostics;
|
|
27
|
+
private permissionChecker;
|
|
28
|
+
private readonly eventListeners;
|
|
29
|
+
/**
|
|
30
|
+
* Register a plugin with the registry.
|
|
31
|
+
*
|
|
32
|
+
* validates that the plugin has name and version, checks collisions,
|
|
33
|
+
* stores it, registers any services into the ServiceContainer,
|
|
34
|
+
* and invalidates the menu cache.
|
|
35
|
+
*
|
|
36
|
+
* @throws Error if plugin has no name or version
|
|
37
|
+
*/
|
|
38
|
+
register(plugin: FrameworkMPlugin): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Get merged menu tree from all plugins.
|
|
41
|
+
*
|
|
42
|
+
* Collects all MenuItem entries, groups them by `module` (default: "Other"),
|
|
43
|
+
* optionally sub-groups by `category`, and sorts by `order`.
|
|
44
|
+
* Result is cached until a new plugin is registered.
|
|
45
|
+
*/
|
|
46
|
+
getMenu(): MenuItem[];
|
|
47
|
+
/**
|
|
48
|
+
* Get aggregated routes from all plugins.
|
|
49
|
+
*/
|
|
50
|
+
getRoutes(): RouteDefinition[];
|
|
51
|
+
/**
|
|
52
|
+
* Get a specific plugin by name.
|
|
53
|
+
*/
|
|
54
|
+
getPlugin(name: string): FrameworkMPlugin | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Get all registered plugins.
|
|
57
|
+
*/
|
|
58
|
+
getAllPlugins(): FrameworkMPlugin[];
|
|
59
|
+
/**
|
|
60
|
+
* Get the service container for DI.
|
|
61
|
+
*/
|
|
62
|
+
getServiceContainer(): ServiceContainer;
|
|
63
|
+
/**
|
|
64
|
+
* Unregister a plugin by name and run cleanup lifecycle if provided.
|
|
65
|
+
*/
|
|
66
|
+
unregister(pluginName: string): Promise<boolean>;
|
|
67
|
+
/**
|
|
68
|
+
* Resolve a service instance from the registry-level DI container.
|
|
69
|
+
*/
|
|
70
|
+
getService<T = unknown>(name: string): Promise<T>;
|
|
71
|
+
/**
|
|
72
|
+
* Aggregate all widgets contributed by registered plugins.
|
|
73
|
+
*/
|
|
74
|
+
getWidgets(): Widget[];
|
|
75
|
+
/**
|
|
76
|
+
* Configure a permission checker used by consumer hooks.
|
|
77
|
+
*/
|
|
78
|
+
setPermissionChecker(checker: PermissionChecker | null): void;
|
|
79
|
+
/**
|
|
80
|
+
* Get the configured permission checker.
|
|
81
|
+
*/
|
|
82
|
+
getPermissionChecker(): PermissionChecker | null;
|
|
83
|
+
/**
|
|
84
|
+
* Subscribe to plugin lifecycle events.
|
|
85
|
+
*/
|
|
86
|
+
on<E extends PluginRegistryEvent>(event: E, handler: PluginRegistryEventHandler<E>): () => void;
|
|
87
|
+
/**
|
|
88
|
+
* Get emitted diagnostics.
|
|
89
|
+
*/
|
|
90
|
+
getDiagnostics(severity?: PluginRegistryDiagnosticSeverity): PluginRegistryDiagnostic[];
|
|
91
|
+
/**
|
|
92
|
+
* Clear diagnostics.
|
|
93
|
+
*/
|
|
94
|
+
clearDiagnostics(): void;
|
|
95
|
+
/**
|
|
96
|
+
* Check compatibility of all registered plugins.
|
|
97
|
+
*
|
|
98
|
+
* Returns a report of all plugins with their compatibility status:
|
|
99
|
+
* - SDK version compatibility
|
|
100
|
+
* - Peer plugin dependency satisfaction
|
|
101
|
+
*/
|
|
102
|
+
checkCompatibility(): CompatibilityReport[];
|
|
103
|
+
/**
|
|
104
|
+
* Simple semver compatibility check.
|
|
105
|
+
* Checks if `current` satisfies `>=required`.
|
|
106
|
+
*/
|
|
107
|
+
private checkSemverCompat;
|
|
108
|
+
private validateRegistration;
|
|
109
|
+
private validateSdkCompatibility;
|
|
110
|
+
private validateDuplicatePlugin;
|
|
111
|
+
private validateRouteCollisions;
|
|
112
|
+
private validateMenuCollisions;
|
|
113
|
+
private validateServiceCollisions;
|
|
114
|
+
private addDiagnostic;
|
|
115
|
+
/**
|
|
116
|
+
* Merge flat menu items into a grouped tree:
|
|
117
|
+
* Module → (optional) Category → Items
|
|
118
|
+
*
|
|
119
|
+
* Items without a `module` are placed under "Other".
|
|
120
|
+
*/
|
|
121
|
+
private mergeMenus;
|
|
122
|
+
private getModuleIcon;
|
|
123
|
+
private rebuildIndexesAndServices;
|
|
124
|
+
private registerPluginServices;
|
|
125
|
+
private registerPluginRoutes;
|
|
126
|
+
private registerPluginMenuItems;
|
|
127
|
+
private emit;
|
|
128
|
+
}
|
|
129
|
+
export {};
|
|
130
|
+
//# sourceMappingURL=PluginRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginRegistry.d.ts","sourceRoot":"","sources":["../../src/core/PluginRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EACxB,gCAAgC,EAChC,iBAAiB,EACjB,MAAM,EACP,MAAM,iBAAiB,CAAC;A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er {
|
|
3
|
+
private readonly factories;
|
|
4
|
+
private readonly instances;
|
|
5
|
+
/**
|
|
6
|
+
* Register a service factory.
|
|
7
|
+
*
|
|
8
|
+
* @param name — unique service name
|
|
9
|
+
* @param factory — factory function (sync or async)
|
|
10
|
+
*/
|
|
11
|
+
register<T>(name: string, factory: ServiceFactory<T>): void;
|
|
12
|
+
/**
|
|
13
|
+
* Get a service by name. Lazily instantiates on first call (singleton).
|
|
14
|
+
*
|
|
15
|
+
* @throws Error if service is not registered
|
|
16
|
+
*/
|
|
17
|
+
get<T = unknown>(name: string): Promise<T>;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a service is registered.
|
|
20
|
+
*/
|
|
21
|
+
has(name: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Get all registered service names.
|
|
24
|
+
*/
|
|
25
|
+
getAll(): string[];
|
|
26
|
+
/**
|
|
27
|
+
* Clear all registered factories and cached instances.
|
|
28
|
+
*/
|
|
29
|
+
clear(): void;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=ServiceContainer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServiceContainer.d.ts","sourceRoot":"","sources":["../../src/core/ServiceContainer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqC;IAC/D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA8B;IAExD;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI;IAM3D;;;;OAIG;IACG,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAiBhD;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B;;OAEG;IACH,MAAM,IAAI,MAAM,EAAE;IAIlB;;OAEG;IACH,KAAK,IAAI,IAAI;CAId"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePlugin.d.ts","sourceRoot":"","sources":["../../src/hooks/usePlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAQpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePluginMenu.d.ts","sourceRoot":"","sources":["../../src/hooks/usePluginMenu.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAkChD,wBAAgB,aAAa,IAAI,QAAQ,EAAE,CAoC1C"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useService — React hook for accessing a service from the ServiceContainer.
|
|
3
|
+
*
|
|
4
|
+
* Returns the service instance (lazily loaded), loading state, and error.
|
|
5
|
+
* Must be used within a PluginRegistryProvider.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* function WarehouseDashboard() {
|
|
10
|
+
* const { service, isLoading, error } = useService<WarehouseService>("warehouseService");
|
|
11
|
+
* if (isLoading) return <Spinner />;
|
|
12
|
+
* if (error) return <Error message={error.message} />;
|
|
13
|
+
* return <div>{service.getWarehouses()}</div>;
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
interface UseServiceResult<T> {
|
|
18
|
+
service: T | null;
|
|
19
|
+
isLoading: boolean;
|
|
20
|
+
error: Error | null;
|
|
21
|
+
}
|
|
22
|
+
export declare function useService<T = unknown>(name: string): UseServiceResult<T>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=useService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useService.d.ts","sourceRoot":"","sources":["../../src/hooks/useService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,UAAU,gBAAgB,CAAC,CAAC;IAC1B,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED,wBAAgB,UAAU,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAwCzE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWidgets.d.ts","sourceRoot":"","sources":["../../src/hooks/useWidgets.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAsB9C,wBAAgB,UAAU,IAAI,MAAM,EAAE,CAoCrC"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var p=Object.defineProperty;var P=(r,e,t)=>e in r?p(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var u=(r,e,t)=>P(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react/jsx-runtime"),a=require("react");class v{constructor(){u(this,"factories",new Map);u(this,"instances",new Map)}register(e,t){this.factories.set(e,t),this.instances.delete(e)}async get(e){if(this.instances.has(e))return this.instances.get(e);const t=this.factories.get(e);if(!t)throw new Error(`Service "${e}" is not registered`);const i=await Promise.resolve(t());return this.instances.set(e,i),i}has(e){return this.factories.has(e)}getAll(){return Array.from(this.factories.keys())}clear(){this.factories.clear(),this.instances.clear()}}const d="0.1.0",f={Sales:"shopping-cart",Inventory:"package",HR:"users",Finance:"dollar-sign",Core:"settings",Other:"folder"};function C(){const r=globalThis.__FRAMEWORK_M_PLUGIN_DEBUG__;if(typeof r=="boolean")return r;if(typeof r=="string")return["1","true","yes","on"].includes(r.toLowerCase());const e=globalThis.process;if(e!=null&&e.env){const t=e.env.FRAMEWORK_M_PLUGIN_DEBUG;if(typeof t=="string")return["1","true","yes","on"].includes(t.toLowerCase())}return!1}const O={debug(r,...e){C()&&console.debug(`[PluginRegistry] ${r}`,...e)}};class w{constructor(){u(this,"plugins",new Map);u(this,"menuCache",null);u(this,"serviceContainer",new v);u(this,"routeOwners",new Map);u(this,"menuNameOwners",new Map);u(this,"menuRouteOwners",new Map);u(this,"serviceOwners",new Map);u(this,"diagnostics",[]);u(this,"permissionChecker",null);u(this,"eventListeners",{"plugin:registered":new Set,"plugin:error":new Set})}async register(e){if(!e.name||!e.version)throw new Error("Plugin must have name and version");const t=this.validateRegistration(e),i=t.filter(o=>o.severity==="error");if(i.length>0){const o=new Error(`Plugin "${e.name}" registration failed: ${i.map(c=>c.message).join("; ")}`);throw this.emit("plugin:error",{plugin:e,error:o}),o}const s=this.plugins.get(e.name);this.plugins.set(e.name,e),this.rebuildIndexesAndServices(),this.menuCache=null;try{e.onInit&&await Promise.resolve(e.onInit())}catch(o){throw s?this.plugins.set(e.name,s):this.plugins.delete(e.name),this.rebuildIndexesAndServices(),this.menuCache=null,this.emit("plugin:error",{plugin:e,error:o}),o}s!=null&&s.onDestroy&&s!==e&&await Promise.resolve(s.onDestroy()),this.emit("plugin:registered",{plugin:e});const n=t.filter(o=>o.severity==="warning");n.length>0&&O.debug(`Registered plugin "${e.name}" with warnings`,n)}getMenu(){if(this.menuCache)return this.menuCache;const e=[];for(const t of this.plugins.values())t.menu&&e.push(...t.menu);return e.length===0?(this.menuCache=[],this.menuCache):(this.menuCache=this.mergeMenus(e),this.menuCache)}getRoutes(){const e=[];for(const t of this.plugins.values())t.routes&&e.push(...t.routes);return e}getPlugin(e){return this.plugins.get(e)}getAllPlugins(){return Array.from(this.plugins.values())}getServiceContainer(){return this.serviceContainer}async unregister(e){const t=this.plugins.get(e);return t?(this.plugins.delete(e),this.rebuildIndexesAndServices(),this.menuCache=null,t.onDestroy&&await Promise.resolve(t.onDestroy()),!0):!1}async getService(e){return this.serviceContainer.get(e)}getWidgets(){const e=[];for(const t of this.plugins.values())t.widgets&&e.push(...t.widgets);return e}setPermissionChecker(e){this.permissionChecker=e}getPermissionChecker(){return this.permissionChecker}on(e,t){return this.eventListeners[e].add(t),()=>{this.eventListeners[e].delete(t)}}getDiagnostics(e){return e?this.diagnostics.filter(t=>t.severity===e):[...this.diagnostics]}clearDiagnostics(){this.diagnostics=[]}checkCompatibility(){const e=[];for(const t of this.plugins.values()){const i={name:t.name,version:t.version,sdkCompatible:!0,missingPeerPlugins:[]};if(t.minSdkVersion&&(i.sdkCompatible=this.checkSemverCompat(d,t.minSdkVersion)),t.peerPlugins)for(const s of t.peerPlugins)this.plugins.has(s)||i.missingPeerPlugins.push(s);e.push(i)}return e}checkSemverCompat(e,t){const i=t.replace(/^>=?/,""),[s,n=0,o=0]=e.split(".").map(Number),[c,l=0,m=0]=i.split(".").map(Number);return s!==c?s>c:n!==l?n>l:o>=m}validateRegistration(e){return[...this.validateSdkCompatibility(e),...this.validateDuplicatePlugin(e),...this.validateRouteCollisions(e),...this.validateMenuCollisions(e),...this.validateServiceCollisions(e)]}validateSdkCompatibility(e){const t=[];return e.minSdkVersion&&(this.checkSemverCompat(d,e.minSdkVersion)||t.push(this.addDiagnostic({code:"SDK_INCOMPATIBLE",severity:"warning",message:`Plugin ${e.name} requires SDK >=${e.minSdkVersion}, current SDK is ${d}. Plugin may not work correctly.`,pluginName:e.name,key:e.minSdkVersion}))),t}validateDuplicatePlugin(e){const t=[];return this.plugins.has(e.name)&&t.push(this.addDiagnostic({code:"PLUGIN_DUPLICATE",severity:"warning",message:`Plugin ${e.name} is already registered and will be replaced`,pluginName:e.name,conflictingPluginName:e.name,key:e.name})),t}validateRouteCollisions(e){const t=[],i=new Set;for(const s of e.routes??[]){if(i.has(s.path)){t.push(this.addDiagnostic({code:"ROUTE_COLLISION",severity:"error",message:`Duplicate route path "${s.path}" inside plugin ${e.name}`,pluginName:e.name,conflictingPluginName:e.name,key:s.path}));continue}i.add(s.path);const n=this.routeOwners.get(s.path);n&&n!==e.name&&t.push(this.addDiagnostic({code:"ROUTE_COLLISION",severity:"error",message:`Route path "${s.path}" from plugin ${e.name} conflicts with plugin ${n}`,pluginName:e.name,conflictingPluginName:n,key:s.path}))}return t}validateMenuCollisions(e){const t=[],i=new Set,s=new Set;for(const n of e.menu??[]){if(i.has(n.name))t.push(this.addDiagnostic({code:"MENU_NAME_COLLISION",severity:"error",message:`Duplicate menu name "${n.name}" inside plugin ${e.name}`,pluginName:e.name,conflictingPluginName:e.name,key:n.name}));else{i.add(n.name);const o=this.menuNameOwners.get(n.name);o&&o!==e.name&&t.push(this.addDiagnostic({code:"MENU_NAME_COLLISION",severity:"error",message:`Menu name "${n.name}" from plugin ${e.name} conflicts with plugin ${o}`,pluginName:e.name,conflictingPluginName:o,key:n.name}))}if(s.has(n.route))t.push(this.addDiagnostic({code:"MENU_ROUTE_COLLISION",severity:"error",message:`Duplicate menu route "${n.route}" inside plugin ${e.name}`,pluginName:e.name,conflictingPluginName:e.name,key:n.route}));else{s.add(n.route);const o=this.menuRouteOwners.get(n.route);o&&o!==e.name&&t.push(this.addDiagnostic({code:"MENU_ROUTE_COLLISION",severity:"error",message:`Menu route "${n.route}" from plugin ${e.name} conflicts with plugin ${o}`,pluginName:e.name,conflictingPluginName:o,key:n.route}))}}return t}validateServiceCollisions(e){const t=[],i=new Set;for(const s of Object.keys(e.services??{})){if(i.has(s)){t.push(this.addDiagnostic({code:"SERVICE_COLLISION",severity:"error",message:`Duplicate service "${s}" inside plugin ${e.name}`,pluginName:e.name,conflictingPluginName:e.name,key:s}));continue}i.add(s);const n=this.serviceOwners.get(s);n&&n!==e.name&&t.push(this.addDiagnostic({code:"SERVICE_COLLISION",severity:"error",message:`Service "${s}" from plugin ${e.name} conflicts with plugin ${n}`,pluginName:e.name,conflictingPluginName:n,key:s}))}return t}addDiagnostic(e){const t={...e,timestamp:new Date().toISOString()};return this.diagnostics.push(t),t}mergeMenus(e){var i;const t=new Map;for(const s of e){const n=s.module||"Other";t.has(n)||t.set(n,{name:n.toLowerCase(),label:n,route:`/${n.toLowerCase()}`,icon:this.getModuleIcon(n),order:s.order,children:[]});const o=t.get(n);if(s.order!==void 0&&(o.order===void 0||s.order<o.order)&&(o.order=s.order),s.category){let c=(i=o.children)==null?void 0:i.find(l=>l.label===s.category);c||(c={name:s.category.toLowerCase(),label:s.category,route:`/${n.toLowerCase()}/${s.category.toLowerCase()}`,children:[]},o.children.push(c)),c.children.push(s)}else o.children.push(s)}return Array.from(t.values()).sort((s,n)=>(s.order??999)-(n.order??999))}getModuleIcon(e){return f[e]||f.Other}rebuildIndexesAndServices(){this.routeOwners.clear(),this.menuNameOwners.clear(),this.menuRouteOwners.clear(),this.serviceOwners.clear(),this.serviceContainer.clear();for(const e of this.plugins.values())this.registerPluginServices(e),this.registerPluginRoutes(e),this.registerPluginMenuItems(e)}registerPluginServices(e){for(const[t,i]of Object.entries(e.services??{}))this.serviceContainer.register(t,i),this.serviceOwners.set(t,e.name)}registerPluginRoutes(e){for(const t of e.routes??[])this.routeOwners.set(t.path,e.name)}registerPluginMenuItems(e){for(const t of e.menu??[])this.menuNameOwners.set(t.name,e.name),this.menuRouteOwners.set(t.route,e.name)}emit(e,t){for(const i of this.eventListeners[e])i(t)}}const g=a.createContext(null);function N({children:r,registry:e}){const[t]=a.useState(()=>e??new w),[i,s]=a.useState(!1);return a.useEffect(()=>{s(!0)},[]),i?S.jsx(g.Provider,{value:t,children:r}):null}async function y(r,e){const t=[];for(const i of r){if(i.hidden||i.permissions&&i.permissions.length>0&&!await Promise.resolve(e(i.permissions)))continue;const s=i.children?await y(i.children,e):void 0;i.children&&((s==null?void 0:s.length)??0)===0||t.push({...i,children:s})}return t}function M(){const r=a.useContext(g),[e,t]=a.useState([]);if(!r)throw new Error("usePluginMenu must be used within PluginRegistryProvider");return a.useEffect(()=>{let i=!1;return(async()=>{const n=r.getMenu(),o=r.getPermissionChecker();if(!o){i||t(n.filter(l=>!l.hidden));return}const c=await y(n,o);i||t(c)})(),()=>{i=!0}},[r]),e}function R(r){const e=a.useContext(g);if(!e)throw new Error("usePlugin must be used within PluginRegistryProvider");return a.useMemo(()=>e.getPlugin(r),[e,r])}function I(r){const e=a.useContext(g);if(!e)throw new Error("useService must be used within PluginRegistryProvider");const[t,i]=a.useState(null),[s,n]=a.useState(!0),[o,c]=a.useState(null),l=a.useMemo(()=>e.getService(r),[e,r]);return a.useEffect(()=>{let m=!1;return n(!0),c(null),l.then(h=>{m||(i(h),n(!1))}).catch(h=>{m||(c(h instanceof Error?h:new Error(String(h))),n(!1))}),()=>{m=!0}},[l]),{service:t,isLoading:s,error:o}}async function E(r,e){const t=[];for(const i of r)i.permissions&&i.permissions.length>0&&!await Promise.resolve(e(i.permissions))||t.push(i);return t}function k(){const r=a.useContext(g),[e,t]=a.useState([]);if(!r)throw new Error("useWidgets must be used within PluginRegistryProvider");return a.useEffect(()=>{let i=!1;return(async()=>{const n=r.getWidgets(),o=r.getPermissionChecker();if(!o){i||t(n);return}const c=await E(n,o);i||t(c)})(),()=>{i=!0}},[r]),e}exports.PluginRegistry=w;exports.PluginRegistryContext=g;exports.PluginRegistryProvider=N;exports.SDK_VERSION=d;exports.ServiceContainer=v;exports.usePlugin=R;exports.usePluginMenu=M;exports.useService=I;exports.useWidgets=k;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/core/ServiceContainer.ts","../src/core/PluginRegistry.ts","../src/context/PluginRegistryContext.tsx","../src/hooks/usePluginMenu.ts","../src/hooks/usePlugin.ts","../src/hooks/useService.ts","../src/hooks/useWidgets.ts"],"sourcesContent":["/**\n * ServiceContainer — Simple dependency injection for plugin services.\n *\n * Services are registered as factories and lazily instantiated as singletons\n * on first `get()` call. Supports both sync and async factories.\n *\n * @example\n * ```ts\n * const container = new ServiceContainer();\n * container.register(\"warehouseService\", () => new WarehouseService());\n * const svc = await container.get<WarehouseService>(\"warehouseService\");\n * ```\n */\n\nimport type { ServiceFactory } from \"../types/plugin\";\n\nexport class ServiceContainer {\n private readonly factories = new Map<string, ServiceFactory>();\n private readonly instances = new Map<string, unknown>();\n\n /**\n * Register a service factory.\n *\n * @param name — unique service name\n * @param factory — factory function (sync or async)\n */\n register<T>(name: string, factory: ServiceFactory<T>): void {\n this.factories.set(name, factory as ServiceFactory);\n // Clear cached instance if re-registering\n this.instances.delete(name);\n }\n\n /**\n * Get a service by name. Lazily instantiates on first call (singleton).\n *\n * @throws Error if service is not registered\n */\n async get<T = unknown>(name: string): Promise<T> {\n // Return cached singleton\n if (this.instances.has(name)) {\n return this.instances.get(name) as T;\n }\n\n const factory = this.factories.get(name);\n if (!factory) {\n throw new Error(`Service \"${name}\" is not registered`);\n }\n\n // Create instance (may be async)\n const instance = await Promise.resolve(factory());\n this.instances.set(name, instance);\n return instance as T;\n }\n\n /**\n * Check if a service is registered.\n */\n has(name: string): boolean {\n return this.factories.has(name);\n }\n\n /**\n * Get all registered service names.\n */\n getAll(): string[] {\n return Array.from(this.factories.keys());\n }\n\n /**\n * Clear all registered factories and cached instances.\n */\n clear(): void {\n this.factories.clear();\n this.instances.clear();\n }\n}\n","/**\n * PluginRegistry — Central registry for Framework M plugins.\n *\n * Handles plugin registration, menu merging (by module/category),\n * route aggregation, and service container population.\n *\n * Per ADR-0008: this is the core runtime that the shell app bootstraps\n * and provides to all components via React Context.\n */\n\nimport type {\n FrameworkMPlugin,\n MenuItem,\n RouteDefinition,\n CompatibilityReport,\n PluginRegistryDiagnostic,\n PluginRegistryDiagnosticSeverity,\n PermissionChecker,\n Widget,\n} from \"../types/plugin\";\nimport { ServiceContainer } from \"./ServiceContainer\";\n\ntype PluginRegistryEvent = \"plugin:registered\" | \"plugin:error\";\n\ntype PluginRegistryEventPayloadMap = {\n \"plugin:registered\": { plugin: FrameworkMPlugin };\n \"plugin:error\": { plugin: FrameworkMPlugin; error: unknown };\n};\n\ntype PluginRegistryEventHandler<E extends PluginRegistryEvent> = (\n payload: PluginRegistryEventPayloadMap[E],\n) => void;\n\n/**\n * SDK version — used for compatibility checking.\n */\nexport const SDK_VERSION = \"0.1.0\";\n\n/**\n * Default icon mapping for well-known module names.\n */\nconst MODULE_ICONS: Record<string, string> = {\n Sales: \"shopping-cart\",\n Inventory: \"package\",\n HR: \"users\",\n Finance: \"dollar-sign\",\n Core: \"settings\",\n Other: \"folder\",\n};\n\nfunction isDebugEnabled(): boolean {\n const globalFlag = (globalThis as { __FRAMEWORK_M_PLUGIN_DEBUG__?: unknown })\n .__FRAMEWORK_M_PLUGIN_DEBUG__;\n if (typeof globalFlag === \"boolean\") {\n return globalFlag;\n }\n if (typeof globalFlag === \"string\") {\n return [\"1\", \"true\", \"yes\", \"on\"].includes(globalFlag.toLowerCase());\n }\n\n const processRef = (\n globalThis as { process?: { env?: Record<string, string | undefined> } }\n ).process;\n if (processRef?.env) {\n const envFlag = processRef.env.FRAMEWORK_M_PLUGIN_DEBUG;\n if (typeof envFlag === \"string\") {\n return [\"1\", \"true\", \"yes\", \"on\"].includes(envFlag.toLowerCase());\n }\n }\n\n return false;\n}\n\nconst registryLogger = {\n debug(message: string, ...args: unknown[]) {\n if (isDebugEnabled()) {\n console.debug(`[PluginRegistry] ${message}`, ...args);\n }\n },\n};\n\nexport class PluginRegistry {\n private readonly plugins = new Map<string, FrameworkMPlugin>();\n private menuCache: MenuItem[] | null = null;\n private readonly serviceContainer = new ServiceContainer();\n private readonly routeOwners = new Map<string, string>();\n private readonly menuNameOwners = new Map<string, string>();\n private readonly menuRouteOwners = new Map<string, string>();\n private readonly serviceOwners = new Map<string, string>();\n private diagnostics: PluginRegistryDiagnostic[] = [];\n private permissionChecker: PermissionChecker | null = null;\n private readonly eventListeners: {\n [E in PluginRegistryEvent]: Set<PluginRegistryEventHandler<E>>;\n } = {\n \"plugin:registered\": new Set(),\n \"plugin:error\": new Set(),\n };\n\n /**\n * Register a plugin with the registry.\n *\n * validates that the plugin has name and version, checks collisions,\n * stores it, registers any services into the ServiceContainer,\n * and invalidates the menu cache.\n *\n * @throws Error if plugin has no name or version\n */\n async register(plugin: FrameworkMPlugin): Promise<void> {\n if (!plugin.name || !plugin.version) {\n throw new Error(\"Plugin must have name and version\");\n }\n\n const diagnostics = this.validateRegistration(plugin);\n const errors = diagnostics.filter(d => d.severity === \"error\");\n\n if (errors.length > 0) {\n const error = new Error(\n `Plugin \"${plugin.name}\" registration failed: ${errors.map(d => d.message).join(\"; \")}`,\n );\n this.emit(\"plugin:error\", { plugin, error });\n throw error;\n }\n\n const previous = this.plugins.get(plugin.name);\n this.plugins.set(plugin.name, plugin);\n this.rebuildIndexesAndServices();\n\n // Invalidate menu cache\n this.menuCache = null;\n\n try {\n if (plugin.onInit) {\n await Promise.resolve(plugin.onInit());\n }\n } catch (error) {\n if (previous) {\n this.plugins.set(plugin.name, previous);\n } else {\n this.plugins.delete(plugin.name);\n }\n this.rebuildIndexesAndServices();\n this.menuCache = null;\n this.emit(\"plugin:error\", { plugin, error });\n throw error;\n }\n\n if (previous?.onDestroy && previous !== plugin) {\n await Promise.resolve(previous.onDestroy());\n }\n\n this.emit(\"plugin:registered\", { plugin });\n\n const warnings = diagnostics.filter(d => d.severity === \"warning\");\n if (warnings.length > 0) {\n registryLogger.debug(\n `Registered plugin \"${plugin.name}\" with warnings`,\n warnings,\n );\n }\n }\n\n /**\n * Get merged menu tree from all plugins.\n *\n * Collects all MenuItem entries, groups them by `module` (default: \"Other\"),\n * optionally sub-groups by `category`, and sorts by `order`.\n * Result is cached until a new plugin is registered.\n */\n getMenu(): MenuItem[] {\n if (this.menuCache) return this.menuCache;\n\n const allMenus: MenuItem[] = [];\n\n for (const plugin of this.plugins.values()) {\n if (plugin.menu) {\n allMenus.push(...plugin.menu);\n }\n }\n\n if (allMenus.length === 0) {\n this.menuCache = [];\n return this.menuCache;\n }\n\n this.menuCache = this.mergeMenus(allMenus);\n return this.menuCache;\n }\n\n /**\n * Get aggregated routes from all plugins.\n */\n getRoutes(): RouteDefinition[] {\n const routes: RouteDefinition[] = [];\n for (const plugin of this.plugins.values()) {\n if (plugin.routes) {\n routes.push(...plugin.routes);\n }\n }\n return routes;\n }\n\n /**\n * Get a specific plugin by name.\n */\n getPlugin(name: string): FrameworkMPlugin | undefined {\n return this.plugins.get(name);\n }\n\n /**\n * Get all registered plugins.\n */\n getAllPlugins(): FrameworkMPlugin[] {\n return Array.from(this.plugins.values());\n }\n\n /**\n * Get the service container for DI.\n */\n getServiceContainer(): ServiceContainer {\n return this.serviceContainer;\n }\n\n /**\n * Unregister a plugin by name and run cleanup lifecycle if provided.\n */\n async unregister(pluginName: string): Promise<boolean> {\n const plugin = this.plugins.get(pluginName);\n if (!plugin) {\n return false;\n }\n\n this.plugins.delete(pluginName);\n this.rebuildIndexesAndServices();\n this.menuCache = null;\n\n if (plugin.onDestroy) {\n await Promise.resolve(plugin.onDestroy());\n }\n\n return true;\n }\n\n /**\n * Resolve a service instance from the registry-level DI container.\n */\n async getService<T = unknown>(name: string): Promise<T> {\n return this.serviceContainer.get<T>(name);\n }\n\n /**\n * Aggregate all widgets contributed by registered plugins.\n */\n getWidgets(): Widget[] {\n const widgets: Widget[] = [];\n for (const plugin of this.plugins.values()) {\n if (plugin.widgets) {\n widgets.push(...plugin.widgets);\n }\n }\n return widgets;\n }\n\n /**\n * Configure a permission checker used by consumer hooks.\n */\n setPermissionChecker(checker: PermissionChecker | null): void {\n this.permissionChecker = checker;\n }\n\n /**\n * Get the configured permission checker.\n */\n getPermissionChecker(): PermissionChecker | null {\n return this.permissionChecker;\n }\n\n /**\n * Subscribe to plugin lifecycle events.\n */\n on<E extends PluginRegistryEvent>(\n event: E,\n handler: PluginRegistryEventHandler<E>,\n ): () => void {\n this.eventListeners[event].add(\n handler as unknown as PluginRegistryEventHandler<PluginRegistryEvent>,\n );\n return () => {\n this.eventListeners[event].delete(\n handler as unknown as PluginRegistryEventHandler<PluginRegistryEvent>,\n );\n };\n }\n\n /**\n * Get emitted diagnostics.\n */\n getDiagnostics(\n severity?: PluginRegistryDiagnosticSeverity,\n ): PluginRegistryDiagnostic[] {\n if (!severity) {\n return [...this.diagnostics];\n }\n return this.diagnostics.filter(d => d.severity === severity);\n }\n\n /**\n * Clear diagnostics.\n */\n clearDiagnostics(): void {\n this.diagnostics = [];\n }\n\n // -------------------------------------------------------------------------\n // Version Compatibility\n // -------------------------------------------------------------------------\n\n /**\n * Check compatibility of all registered plugins.\n *\n * Returns a report of all plugins with their compatibility status:\n * - SDK version compatibility\n * - Peer plugin dependency satisfaction\n */\n checkCompatibility(): CompatibilityReport[] {\n const reports: CompatibilityReport[] = [];\n\n for (const plugin of this.plugins.values()) {\n const report: CompatibilityReport = {\n name: plugin.name,\n version: plugin.version,\n sdkCompatible: true,\n missingPeerPlugins: [],\n };\n\n // Check SDK version\n if (plugin.minSdkVersion) {\n report.sdkCompatible = this.checkSemverCompat(\n SDK_VERSION,\n plugin.minSdkVersion,\n );\n }\n\n // Check peer plugins\n if (plugin.peerPlugins) {\n for (const peerName of plugin.peerPlugins) {\n if (!this.plugins.has(peerName)) {\n report.missingPeerPlugins.push(peerName);\n }\n }\n }\n\n reports.push(report);\n }\n\n return reports;\n }\n\n // -------------------------------------------------------------------------\n // Private helpers\n // -------------------------------------------------------------------------\n\n /**\n * Simple semver compatibility check.\n * Checks if `current` satisfies `>=required`.\n */\n private checkSemverCompat(current: string, required: string): boolean {\n const clean = required.replace(/^>=?/, \"\");\n const [cMajor, cMinor = 0, cPatch = 0] = current.split(\".\").map(Number);\n const [rMajor, rMinor = 0, rPatch = 0] = clean.split(\".\").map(Number);\n\n if (cMajor !== rMajor) return cMajor > rMajor;\n if (cMinor !== rMinor) return cMinor > rMinor;\n return cPatch >= rPatch;\n }\n\n private validateRegistration(\n plugin: FrameworkMPlugin,\n ): PluginRegistryDiagnostic[] {\n return [\n ...this.validateSdkCompatibility(plugin),\n ...this.validateDuplicatePlugin(plugin),\n ...this.validateRouteCollisions(plugin),\n ...this.validateMenuCollisions(plugin),\n ...this.validateServiceCollisions(plugin),\n ];\n }\n\n private validateSdkCompatibility(\n plugin: FrameworkMPlugin,\n ): PluginRegistryDiagnostic[] {\n const diagnostics: PluginRegistryDiagnostic[] = [];\n\n if (plugin.minSdkVersion) {\n const compatible = this.checkSemverCompat(\n SDK_VERSION,\n plugin.minSdkVersion,\n );\n if (!compatible) {\n diagnostics.push(\n this.addDiagnostic({\n code: \"SDK_INCOMPATIBLE\",\n severity: \"warning\",\n message:\n `Plugin ${plugin.name} requires SDK >=${plugin.minSdkVersion}, ` +\n `current SDK is ${SDK_VERSION}. Plugin may not work correctly.`,\n pluginName: plugin.name,\n key: plugin.minSdkVersion,\n }),\n );\n }\n }\n\n return diagnostics;\n }\n\n private validateDuplicatePlugin(\n plugin: FrameworkMPlugin,\n ): PluginRegistryDiagnostic[] {\n const diagnostics: PluginRegistryDiagnostic[] = [];\n\n if (this.plugins.has(plugin.name)) {\n diagnostics.push(\n this.addDiagnostic({\n code: \"PLUGIN_DUPLICATE\",\n severity: \"warning\",\n message: `Plugin ${plugin.name} is already registered and will be replaced`,\n pluginName: plugin.name,\n conflictingPluginName: plugin.name,\n key: plugin.name,\n }),\n );\n }\n\n return diagnostics;\n }\n\n private validateRouteCollisions(\n plugin: FrameworkMPlugin,\n ): PluginRegistryDiagnostic[] {\n const diagnostics: PluginRegistryDiagnostic[] = [];\n\n const seenRoutePaths = new Set<string>();\n for (const route of plugin.routes ?? []) {\n if (seenRoutePaths.has(route.path)) {\n diagnostics.push(\n this.addDiagnostic({\n code: \"ROUTE_COLLISION\",\n severity: \"error\",\n message: `Duplicate route path \"${route.path}\" inside plugin ${plugin.name}`,\n pluginName: plugin.name,\n conflictingPluginName: plugin.name,\n key: route.path,\n }),\n );\n continue;\n }\n\n seenRoutePaths.add(route.path);\n const existingRouteOwner = this.routeOwners.get(route.path);\n if (existingRouteOwner && existingRouteOwner !== plugin.name) {\n diagnostics.push(\n this.addDiagnostic({\n code: \"ROUTE_COLLISION\",\n severity: \"error\",\n message:\n `Route path \"${route.path}\" from plugin ${plugin.name} ` +\n `conflicts with plugin ${existingRouteOwner}`,\n pluginName: plugin.name,\n conflictingPluginName: existingRouteOwner,\n key: route.path,\n }),\n );\n }\n }\n\n return diagnostics;\n }\n\n private validateMenuCollisions(\n plugin: FrameworkMPlugin,\n ): PluginRegistryDiagnostic[] {\n const diagnostics: PluginRegistryDiagnostic[] = [];\n\n const seenMenuNames = new Set<string>();\n const seenMenuRoutes = new Set<string>();\n for (const item of plugin.menu ?? []) {\n if (seenMenuNames.has(item.name)) {\n diagnostics.push(\n this.addDiagnostic({\n code: \"MENU_NAME_COLLISION\",\n severity: \"error\",\n message: `Duplicate menu name \"${item.name}\" inside plugin ${plugin.name}`,\n pluginName: plugin.name,\n conflictingPluginName: plugin.name,\n key: item.name,\n }),\n );\n } else {\n seenMenuNames.add(item.name);\n const existingNameOwner = this.menuNameOwners.get(item.name);\n if (existingNameOwner && existingNameOwner !== plugin.name) {\n diagnostics.push(\n this.addDiagnostic({\n code: \"MENU_NAME_COLLISION\",\n severity: \"error\",\n message:\n `Menu name \"${item.name}\" from plugin ${plugin.name} ` +\n `conflicts with plugin ${existingNameOwner}`,\n pluginName: plugin.name,\n conflictingPluginName: existingNameOwner,\n key: item.name,\n }),\n );\n }\n }\n\n if (seenMenuRoutes.has(item.route)) {\n diagnostics.push(\n this.addDiagnostic({\n code: \"MENU_ROUTE_COLLISION\",\n severity: \"error\",\n message: `Duplicate menu route \"${item.route}\" inside plugin ${plugin.name}`,\n pluginName: plugin.name,\n conflictingPluginName: plugin.name,\n key: item.route,\n }),\n );\n } else {\n seenMenuRoutes.add(item.route);\n const existingRouteOwner = this.menuRouteOwners.get(item.route);\n if (existingRouteOwner && existingRouteOwner !== plugin.name) {\n diagnostics.push(\n this.addDiagnostic({\n code: \"MENU_ROUTE_COLLISION\",\n severity: \"error\",\n message:\n `Menu route \"${item.route}\" from plugin ${plugin.name} ` +\n `conflicts with plugin ${existingRouteOwner}`,\n pluginName: plugin.name,\n conflictingPluginName: existingRouteOwner,\n key: item.route,\n }),\n );\n }\n }\n }\n\n return diagnostics;\n }\n\n private validateServiceCollisions(\n plugin: FrameworkMPlugin,\n ): PluginRegistryDiagnostic[] {\n const diagnostics: PluginRegistryDiagnostic[] = [];\n\n const seenServiceNames = new Set<string>();\n for (const serviceName of Object.keys(plugin.services ?? {})) {\n if (seenServiceNames.has(serviceName)) {\n diagnostics.push(\n this.addDiagnostic({\n code: \"SERVICE_COLLISION\",\n severity: \"error\",\n message: `Duplicate service \"${serviceName}\" inside plugin ${plugin.name}`,\n pluginName: plugin.name,\n conflictingPluginName: plugin.name,\n key: serviceName,\n }),\n );\n continue;\n }\n\n seenServiceNames.add(serviceName);\n const existingServiceOwner = this.serviceOwners.get(serviceName);\n if (existingServiceOwner && existingServiceOwner !== plugin.name) {\n diagnostics.push(\n this.addDiagnostic({\n code: \"SERVICE_COLLISION\",\n severity: \"error\",\n message:\n `Service \"${serviceName}\" from plugin ${plugin.name} ` +\n `conflicts with plugin ${existingServiceOwner}`,\n pluginName: plugin.name,\n conflictingPluginName: existingServiceOwner,\n key: serviceName,\n }),\n );\n }\n }\n\n return diagnostics;\n }\n\n private addDiagnostic(\n diagnostic: Omit<PluginRegistryDiagnostic, \"timestamp\">,\n ): PluginRegistryDiagnostic {\n const fullDiagnostic: PluginRegistryDiagnostic = {\n ...diagnostic,\n timestamp: new Date().toISOString(),\n };\n this.diagnostics.push(fullDiagnostic);\n return fullDiagnostic;\n }\n\n /**\n * Merge flat menu items into a grouped tree:\n * Module → (optional) Category → Items\n *\n * Items without a `module` are placed under \"Other\".\n */\n private mergeMenus(items: MenuItem[]): MenuItem[] {\n const moduleMap = new Map<string, MenuItem>();\n\n for (const item of items) {\n const moduleName = item.module || \"Other\";\n\n if (!moduleMap.has(moduleName)) {\n moduleMap.set(moduleName, {\n name: moduleName.toLowerCase(),\n label: moduleName,\n route: `/${moduleName.toLowerCase()}`,\n icon: this.getModuleIcon(moduleName),\n order: item.order,\n children: [],\n });\n }\n\n const moduleGroup = moduleMap.get(moduleName)!;\n\n // Track lowest order value for module-level sorting\n if (item.order !== undefined) {\n if (moduleGroup.order === undefined || item.order < moduleGroup.order) {\n moduleGroup.order = item.order;\n }\n }\n\n if (item.category) {\n // Find or create category sub-group\n let categoryGroup = moduleGroup.children?.find(\n c => c.label === item.category,\n );\n\n if (!categoryGroup) {\n categoryGroup = {\n name: item.category.toLowerCase(),\n label: item.category,\n route: `/${moduleName.toLowerCase()}/${item.category.toLowerCase()}`,\n children: [],\n };\n moduleGroup.children!.push(categoryGroup);\n }\n\n categoryGroup.children!.push(item);\n } else {\n // No category — add directly to module\n moduleGroup.children!.push(item);\n }\n }\n\n // Sort module groups by order (lower first, undefined last)\n return Array.from(moduleMap.values()).sort(\n (a, b) => (a.order ?? 999) - (b.order ?? 999),\n );\n }\n\n private getModuleIcon(moduleName: string): string {\n return MODULE_ICONS[moduleName] || MODULE_ICONS.Other;\n }\n\n private rebuildIndexesAndServices(): void {\n this.routeOwners.clear();\n this.menuNameOwners.clear();\n this.menuRouteOwners.clear();\n this.serviceOwners.clear();\n this.serviceContainer.clear();\n\n for (const plugin of this.plugins.values()) {\n this.registerPluginServices(plugin);\n this.registerPluginRoutes(plugin);\n this.registerPluginMenuItems(plugin);\n }\n }\n\n private registerPluginServices(plugin: FrameworkMPlugin): void {\n for (const [name, factory] of Object.entries(plugin.services ?? {})) {\n this.serviceContainer.register(name, factory);\n this.serviceOwners.set(name, plugin.name);\n }\n }\n\n private registerPluginRoutes(plugin: FrameworkMPlugin): void {\n for (const route of plugin.routes ?? []) {\n this.routeOwners.set(route.path, plugin.name);\n }\n }\n\n private registerPluginMenuItems(plugin: FrameworkMPlugin): void {\n for (const item of plugin.menu ?? []) {\n this.menuNameOwners.set(item.name, plugin.name);\n this.menuRouteOwners.set(item.route, plugin.name);\n }\n }\n\n private emit<E extends PluginRegistryEvent>(\n event: E,\n payload: PluginRegistryEventPayloadMap[E],\n ): void {\n for (const handler of this.eventListeners[event]) {\n handler(payload as never);\n }\n }\n}\n","/**\n * PluginRegistryContext — React context for the PluginRegistry.\n *\n * Provides the PluginRegistry to all child components via React Context.\n * Must wrap any component that uses usePluginMenu(), usePlugin(), or useService().\n */\n\nimport { createContext, useEffect, useState, type ReactNode } from \"react\";\nimport { PluginRegistry } from \"../core/PluginRegistry\";\n\nexport const PluginRegistryContext = createContext<PluginRegistry | null>(null);\n\nexport interface PluginRegistryProviderProps {\n readonly children: ReactNode;\n /** Optional pre-configured PluginRegistry instance */\n readonly registry?: PluginRegistry;\n}\n\n/**\n * Provider component that makes the PluginRegistry available to child components.\n *\n * @example\n * ```tsx\n * const registry = new PluginRegistry();\n * await registry.register(wmsPlugin);\n *\n * <PluginRegistryProvider registry={registry}>\n * <App />\n * </PluginRegistryProvider>\n * ```\n */\nexport function PluginRegistryProvider({\n children,\n registry,\n}: PluginRegistryProviderProps) {\n const [registryInstance] = useState<PluginRegistry>(\n () => registry ?? new PluginRegistry(),\n );\n const [isReady, setIsReady] = useState(false);\n\n useEffect(() => {\n setIsReady(true);\n }, []);\n\n if (!isReady) {\n return null;\n }\n\n return (\n <PluginRegistryContext.Provider value={registryInstance}>\n {children}\n </PluginRegistryContext.Provider>\n );\n}\n","/**\n * usePluginMenu — React hook for accessing the merged menu tree.\n *\n * Returns the merged MenuItem[] from all registered plugins.\n * Must be used within a PluginRegistryProvider.\n *\n * @example\n * ```tsx\n * function Sidebar() {\n * const menu = usePluginMenu();\n * return <nav>{menu.map(m => <ModuleGroup key={m.name} {...m} />)}</nav>;\n * }\n * ```\n */\n\nimport { useContext, useEffect, useState } from \"react\";\nimport { PluginRegistryContext } from \"../context/PluginRegistryContext\";\nimport type { MenuItem } from \"../types/plugin\";\n\nasync function filterMenuByPermissions(\n items: MenuItem[],\n checker: (permissions: string[]) => boolean | Promise<boolean>,\n): Promise<MenuItem[]> {\n const filtered: MenuItem[] = [];\n\n for (const item of items) {\n if (item.hidden) {\n continue;\n }\n\n if (item.permissions && item.permissions.length > 0) {\n const allowed = await Promise.resolve(checker(item.permissions));\n if (!allowed) {\n continue;\n }\n }\n\n const children = item.children\n ? await filterMenuByPermissions(item.children, checker)\n : undefined;\n\n if (item.children && (children?.length ?? 0) === 0) {\n continue;\n }\n\n filtered.push({ ...item, children });\n }\n\n return filtered;\n}\n\nexport function usePluginMenu(): MenuItem[] {\n const registry = useContext(PluginRegistryContext);\n const [menu, setMenu] = useState<MenuItem[]>([]);\n\n if (!registry) {\n throw new Error(\"usePluginMenu must be used within PluginRegistryProvider\");\n }\n\n useEffect(() => {\n let cancelled = false;\n\n const load = async () => {\n const source = registry.getMenu();\n const checker = registry.getPermissionChecker();\n\n if (!checker) {\n if (!cancelled) {\n setMenu(source.filter(item => !item.hidden));\n }\n return;\n }\n\n const filtered = await filterMenuByPermissions(source, checker);\n if (!cancelled) {\n setMenu(filtered);\n }\n };\n\n void load();\n\n return () => {\n cancelled = true;\n };\n }, [registry]);\n\n return menu;\n}\n","/**\n * usePlugin — React hook for accessing a specific plugin by name.\n *\n * Returns the FrameworkMPlugin or undefined if not found.\n * Must be used within a PluginRegistryProvider.\n *\n * @example\n * ```tsx\n * function WMSStatus() {\n * const wms = usePlugin(\"wms\");\n * if (!wms) return <p>WMS not installed</p>;\n * return <p>WMS v{wms.version}</p>;\n * }\n * ```\n */\n\nimport { useContext, useMemo } from \"react\";\nimport { PluginRegistryContext } from \"../context/PluginRegistryContext\";\nimport type { FrameworkMPlugin } from \"../types/plugin\";\n\nexport function usePlugin(name: string): FrameworkMPlugin | undefined {\n const registry = useContext(PluginRegistryContext);\n\n if (!registry) {\n throw new Error(\"usePlugin must be used within PluginRegistryProvider\");\n }\n\n return useMemo(() => registry.getPlugin(name), [registry, name]);\n}\n","/**\n * useService — React hook for accessing a service from the ServiceContainer.\n *\n * Returns the service instance (lazily loaded), loading state, and error.\n * Must be used within a PluginRegistryProvider.\n *\n * @example\n * ```tsx\n * function WarehouseDashboard() {\n * const { service, isLoading, error } = useService<WarehouseService>(\"warehouseService\");\n * if (isLoading) return <Spinner />;\n * if (error) return <Error message={error.message} />;\n * return <div>{service.getWarehouses()}</div>;\n * }\n * ```\n */\n\nimport { useContext, useEffect, useMemo, useState } from \"react\";\nimport { PluginRegistryContext } from \"../context/PluginRegistryContext\";\n\ninterface UseServiceResult<T> {\n service: T | null;\n isLoading: boolean;\n error: Error | null;\n}\n\nexport function useService<T = unknown>(name: string): UseServiceResult<T> {\n const registry = useContext(PluginRegistryContext);\n\n if (!registry) {\n throw new Error(\"useService must be used within PluginRegistryProvider\");\n }\n\n const [service, setService] = useState<T | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const servicePromise = useMemo(\n () => registry.getService<T>(name),\n [registry, name],\n );\n\n useEffect(() => {\n let cancelled = false;\n setIsLoading(true);\n setError(null);\n\n servicePromise\n .then(instance => {\n if (!cancelled) {\n setService(instance);\n setIsLoading(false);\n }\n })\n .catch((err: unknown) => {\n if (!cancelled) {\n setError(err instanceof Error ? err : new Error(String(err)));\n setIsLoading(false);\n }\n });\n\n return () => {\n cancelled = true;\n };\n }, [servicePromise]);\n\n return { service, isLoading, error };\n}\n","/**\n * useWidgets — React hook for accessing plugin-provided dashboard widgets.\n */\n\nimport { useContext, useEffect, useState } from \"react\";\nimport { PluginRegistryContext } from \"../context/PluginRegistryContext\";\nimport type { Widget } from \"../types/plugin\";\n\nasync function filterWidgetsByPermissions(\n widgets: Widget[],\n checker: (permissions: string[]) => boolean | Promise<boolean>,\n): Promise<Widget[]> {\n const filtered: Widget[] = [];\n\n for (const widget of widgets) {\n if (widget.permissions && widget.permissions.length > 0) {\n const allowed = await Promise.resolve(checker(widget.permissions));\n if (!allowed) {\n continue;\n }\n }\n\n filtered.push(widget);\n }\n\n return filtered;\n}\n\nexport function useWidgets(): Widget[] {\n const registry = useContext(PluginRegistryContext);\n const [widgets, setWidgets] = useState<Widget[]>([]);\n\n if (!registry) {\n throw new Error(\"useWidgets must be used within PluginRegistryProvider\");\n }\n\n useEffect(() => {\n let cancelled = false;\n\n const load = async () => {\n const source = registry.getWidgets();\n const checker = registry.getPermissionChecker();\n\n if (!checker) {\n if (!cancelled) {\n setWidgets(source);\n }\n return;\n }\n\n const filtered = await filterWidgetsByPermissions(source, checker);\n if (!cancelled) {\n setWidgets(filtered);\n }\n };\n\n void load();\n\n return () => {\n cancelled = true;\n };\n }, [registry]);\n\n return widgets;\n}\n"],"names":["ServiceContainer","__publicField","name","factory","instance","SDK_VERSION","MODULE_ICONS","isDebugEnabled","globalFlag","processRef","envFlag","registryLogger","message","args","PluginRegistry","plugin","diagnostics","errors","d","error","previous","warnings","allMenus","routes","pluginName","widgets","checker","event","handler","severity","reports","report","peerName","current","required","clean","cMajor","cMinor","cPatch","rMajor","rMinor","rPatch","seenRoutePaths","route","existingRouteOwner","seenMenuNames","seenMenuRoutes","item","existingNameOwner","seenServiceNames","serviceName","existingServiceOwner","diagnostic","fullDiagnostic","items","moduleMap","moduleName","moduleGroup","categoryGroup","_a","c","a","b","payload","PluginRegistryContext","createContext","PluginRegistryProvider","children","registry","registryInstance","useState","isReady","setIsReady","useEffect","filterMenuByPermissions","filtered","usePluginMenu","useContext","menu","setMenu","cancelled","source","usePlugin","useMemo","useService","service","setService","isLoading","setIsLoading","setError","servicePromise","err","filterWidgetsByPermissions","widget","useWidgets","setWidgets"],"mappings":"4SAgBO,MAAMA,CAAiB,CAAvB,cACYC,EAAA,qBAAgB,KAChBA,EAAA,qBAAgB,KAQjC,SAAYC,EAAcC,EAAkC,CAC1D,KAAK,UAAU,IAAID,EAAMC,CAAyB,EAElD,KAAK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|
|
|
1
|
+
/**
|
|
2
|
+
* @framework-m/plugin-sdk
|
|
3
|
+
*
|
|
4
|
+
* Plugin infrastructure and runtime for Framework M multi-app composition.
|
|
5
|
+
*
|
|
6
|
+
* This package provides the contract, registry, DI container, and React hooks
|
|
7
|
+
* that enable multiple apps to compose into a single UI.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { PluginRegistry, PluginRegistryProvider, usePluginMenu } from "@framework-m/plugin-sdk";
|
|
12
|
+
*
|
|
13
|
+
* const registry = new PluginRegistry();
|
|
14
|
+
* await registry.register(wmsPlugin);
|
|
15
|
+
*
|
|
16
|
+
* function App() {
|
|
17
|
+
* return (
|
|
18
|
+
* <PluginRegistryProvider registry={registry}>
|
|
19
|
+
* <Sidebar />
|
|
20
|
+
* </PluginRegistryProvider>
|
|
21
|
+
* );
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* function Sidebar() {
|
|
25
|
+
* const menu = usePluginMenu();
|
|
26
|
+
* return <nav>{menu.map(m => <div key={m.name}>{m.label}</div>)}</nav>;
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export type { MenuItem, RouteDefinition, ServiceFactory, PermissionChecker, Provider, DocTypeExtension, Widget, FrameworkMPlugin, CompatibilityReport, PluginRegistryDiagnostic, PluginRegistryDiagnosticSeverity, } from './types/plugin';
|
|
31
|
+
export { PluginRegistry, SDK_VERSION } from './core/PluginRegistry';
|
|
32
|
+
export { ServiceContainer } from './core/ServiceContainer';
|
|
33
|
+
export { PluginRegistryContext, PluginRegistryProvider, } from './context/PluginRegistryContext';
|
|
34
|
+
export type { PluginRegistryProviderProps } from './context/PluginRegistryContext';
|
|
35
|
+
export { usePluginMenu } from './hooks/usePluginMenu';
|
|
36
|
+
export { usePlugin } from './hooks/usePlugin';
|
|
37
|
+
export { useService } from './hooks/useService';
|
|
38
|
+
export { useWidgets } from './hooks/useWidgets';
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|