@memberjunction/react-runtime 6.2.0-edge.0 → 6.2.0-edge.2
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/.turbo/turbo-build.log +14 -14
- package/CHANGELOG.md +93 -0
- package/dist/compiler/babel-config.d.ts +14 -0
- package/dist/compiler/babel-config.d.ts.map +1 -1
- package/dist/compiler/babel-config.js +12 -3
- package/dist/compiler/babel-config.js.map +1 -1
- package/dist/compiler/component-compiler.d.ts +5 -0
- package/dist/compiler/component-compiler.d.ts.map +1 -1
- package/dist/compiler/component-compiler.js +24 -9
- package/dist/compiler/component-compiler.js.map +1 -1
- package/dist/compiler/index.d.ts +1 -1
- package/dist/compiler/index.d.ts.map +1 -1
- package/dist/compiler/index.js +1 -1
- package/dist/compiler/index.js.map +1 -1
- package/dist/component-manager/component-manager.d.ts +8 -0
- package/dist/component-manager/component-manager.d.ts.map +1 -1
- package/dist/component-manager/component-manager.js +18 -6
- package/dist/component-manager/component-manager.js.map +1 -1
- package/dist/index.d.ts +21 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -10
- package/dist/index.js.map +1 -1
- package/dist/registry/component-registry-service.d.ts +18 -0
- package/dist/registry/component-registry-service.d.ts.map +1 -1
- package/dist/registry/component-registry-service.js +65 -23
- package/dist/registry/component-registry-service.js.map +1 -1
- package/dist/registry/component-registry.d.ts +24 -1
- package/dist/registry/component-registry.d.ts.map +1 -1
- package/dist/registry/component-registry.js +74 -23
- package/dist/registry/component-registry.js.map +1 -1
- package/dist/registry/component-resolver.d.ts +10 -0
- package/dist/registry/component-resolver.d.ts.map +1 -1
- package/dist/registry/component-resolver.js +30 -9
- package/dist/registry/component-resolver.js.map +1 -1
- package/dist/registry/registry-provider.js.map +1 -1
- package/dist/runtime/component-hierarchy.d.ts +15 -0
- package/dist/runtime/component-hierarchy.d.ts.map +1 -1
- package/dist/runtime/component-hierarchy.js +28 -10
- package/dist/runtime/component-hierarchy.js.map +1 -1
- package/dist/runtime/error-boundary.d.ts +4 -0
- package/dist/runtime/error-boundary.d.ts.map +1 -1
- package/dist/runtime/error-boundary.js +50 -20
- package/dist/runtime/error-boundary.js.map +1 -1
- package/dist/runtime/index.d.ts +3 -3
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +3 -3
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/prop-builder.d.ts +8 -0
- package/dist/runtime/prop-builder.d.ts.map +1 -1
- package/dist/runtime/prop-builder.js +39 -11
- package/dist/runtime/prop-builder.js.map +1 -1
- package/dist/runtime/react-root-manager.d.ts +10 -0
- package/dist/runtime/react-root-manager.d.ts.map +1 -1
- package/dist/runtime/react-root-manager.js +27 -9
- package/dist/runtime/react-root-manager.js.map +1 -1
- package/dist/runtime.umd.js +194 -125
- package/dist/utilities/cache-manager.d.ts +13 -0
- package/dist/utilities/cache-manager.d.ts.map +1 -1
- package/dist/utilities/cache-manager.js +40 -16
- package/dist/utilities/cache-manager.js.map +1 -1
- package/dist/utilities/component-error-analyzer.d.ts +3 -0
- package/dist/utilities/component-error-analyzer.d.ts.map +1 -1
- package/dist/utilities/component-error-analyzer.js +12 -3
- package/dist/utilities/component-error-analyzer.js.map +1 -1
- package/dist/utilities/component-hash.d.ts +1 -0
- package/dist/utilities/component-hash.d.ts.map +1 -1
- package/dist/utilities/component-hash.js +4 -1
- package/dist/utilities/component-hash.js.map +1 -1
- package/dist/utilities/component-library-theming.d.ts +4 -0
- package/dist/utilities/component-library-theming.d.ts.map +1 -1
- package/dist/utilities/component-library-theming.js +12 -6
- package/dist/utilities/component-library-theming.js.map +1 -1
- package/dist/utilities/component-styles.d.ts +1 -0
- package/dist/utilities/component-styles.d.ts.map +1 -1
- package/dist/utilities/component-styles.js +2 -1
- package/dist/utilities/component-styles.js.map +1 -1
- package/dist/utilities/component-unwrapper.d.ts +8 -2
- package/dist/utilities/component-unwrapper.d.ts.map +1 -1
- package/dist/utilities/component-unwrapper.js +19 -7
- package/dist/utilities/component-unwrapper.js.map +1 -1
- package/dist/utilities/core-libraries.d.ts +2 -0
- package/dist/utilities/core-libraries.d.ts.map +1 -1
- package/dist/utilities/core-libraries.js +9 -3
- package/dist/utilities/core-libraries.js.map +1 -1
- package/dist/utilities/entity-record-key.d.ts +1 -0
- package/dist/utilities/entity-record-key.d.ts.map +1 -1
- package/dist/utilities/entity-record-key.js +4 -1
- package/dist/utilities/entity-record-key.js.map +1 -1
- package/dist/utilities/library-dependency-resolver.d.ts +8 -0
- package/dist/utilities/library-dependency-resolver.d.ts.map +1 -1
- package/dist/utilities/library-dependency-resolver.js +39 -15
- package/dist/utilities/library-dependency-resolver.js.map +1 -1
- package/dist/utilities/library-loader.d.ts +12 -0
- package/dist/utilities/library-loader.d.ts.map +1 -1
- package/dist/utilities/library-loader.js +46 -16
- package/dist/utilities/library-loader.js.map +1 -1
- package/dist/utilities/library-registry.d.ts +5 -0
- package/dist/utilities/library-registry.d.ts.map +1 -1
- package/dist/utilities/library-registry.js +20 -5
- package/dist/utilities/library-registry.js.map +1 -1
- package/dist/utilities/resource-manager.d.ts +19 -0
- package/dist/utilities/resource-manager.d.ts.map +1 -1
- package/dist/utilities/resource-manager.js +63 -18
- package/dist/utilities/resource-manager.js.map +1 -1
- package/dist/utilities/runtime-utilities.d.ts +9 -7
- package/dist/utilities/runtime-utilities.d.ts.map +1 -1
- package/dist/utilities/runtime-utilities.js +22 -16
- package/dist/utilities/runtime-utilities.js.map +1 -1
- package/dist/utilities/standard-libraries.d.ts +10 -0
- package/dist/utilities/standard-libraries.d.ts.map +1 -1
- package/dist/utilities/standard-libraries.js +40 -10
- package/dist/utilities/standard-libraries.js.map +1 -1
- package/dist/utilities/user-state.d.ts +5 -0
- package/dist/utilities/user-state.d.ts.map +1 -1
- package/dist/utilities/user-state.js +20 -5
- package/dist/utilities/user-state.js.map +1 -1
- package/package.json +7 -7
- package/src/__tests__/error-boundary.test.ts +80 -0
- package/src/__tests__/runtime-utilities-factory.test.ts +4 -4
- package/src/__tests__/user-state.test.ts +44 -44
- package/src/compiler/babel-config.ts +18 -3
- package/src/compiler/component-compiler.ts +34 -9
- package/src/compiler/index.ts +3 -3
- package/src/component-manager/component-manager.ts +36 -6
- package/src/index.ts +35 -21
- package/src/registry/component-registry-service.ts +126 -23
- package/src/registry/component-registry.ts +122 -24
- package/src/registry/component-resolver.ts +51 -9
- package/src/registry/registry-provider.ts +40 -40
- package/src/runtime/component-hierarchy.ts +61 -10
- package/src/runtime/error-boundary.ts +77 -22
- package/src/runtime/index.ts +16 -16
- package/src/runtime/prop-builder.ts +69 -11
- package/src/runtime/react-root-manager.ts +48 -10
- package/src/utilities/cache-manager.ts +61 -16
- package/src/utilities/component-error-analyzer.ts +18 -3
- package/src/utilities/component-hash.ts +6 -1
- package/src/utilities/component-library-theming.ts +24 -6
- package/src/utilities/component-styles.ts +4 -1
- package/src/utilities/component-unwrapper.ts +34 -7
- package/src/utilities/core-libraries.ts +13 -3
- package/src/utilities/entity-record-key.ts +11 -1
- package/src/utilities/library-dependency-resolver.ts +66 -15
- package/src/utilities/library-loader.ts +81 -17
- package/src/utilities/library-registry.ts +30 -5
- package/src/utilities/resource-manager.ts +126 -19
- package/src/utilities/runtime-utilities.ts +26 -16
- package/src/utilities/standard-libraries.ts +60 -10
- package/src/utilities/user-state.ts +40 -5
|
@@ -6,15 +6,18 @@ const DEFAULT_REGISTRY_CONFIG = {
|
|
|
6
6
|
enableNamespaces: true
|
|
7
7
|
};
|
|
8
8
|
export class ComponentRegistry {
|
|
9
|
+
get registryId() {
|
|
10
|
+
return this.RegistryId;
|
|
11
|
+
}
|
|
9
12
|
constructor(config) {
|
|
10
13
|
this.config = { ...DEFAULT_REGISTRY_CONFIG, ...config };
|
|
11
14
|
this.registry = new Map();
|
|
12
|
-
this.
|
|
15
|
+
this.RegistryId = `component-registry-${Date.now()}`;
|
|
13
16
|
if (this.config.cleanupInterval > 0) {
|
|
14
17
|
this.startCleanupTimer();
|
|
15
18
|
}
|
|
16
19
|
}
|
|
17
|
-
|
|
20
|
+
Register(name, component, namespace = 'Global', version = 'v1', contentHash, tags) {
|
|
18
21
|
const id = this.generateRegistryKey(name, namespace, version, contentHash);
|
|
19
22
|
const metadata = {
|
|
20
23
|
id,
|
|
@@ -36,7 +39,10 @@ export class ComponentRegistry {
|
|
|
36
39
|
this.registry.set(id, entry);
|
|
37
40
|
return metadata;
|
|
38
41
|
}
|
|
39
|
-
|
|
42
|
+
register(name, component, namespace = 'Global', version = 'v1', contentHash, tags) {
|
|
43
|
+
return this.Register(name, component, namespace, version, contentHash, tags);
|
|
44
|
+
}
|
|
45
|
+
Get(name, namespace = 'Global', version, contentHash) {
|
|
40
46
|
const id = this.resolveLookupKey(name, namespace, version, contentHash);
|
|
41
47
|
if (!id)
|
|
42
48
|
return undefined;
|
|
@@ -48,17 +54,26 @@ export class ComponentRegistry {
|
|
|
48
54
|
}
|
|
49
55
|
return undefined;
|
|
50
56
|
}
|
|
51
|
-
|
|
57
|
+
get(name, namespace = 'Global', version, contentHash) {
|
|
58
|
+
return this.Get(name, namespace, version, contentHash);
|
|
59
|
+
}
|
|
60
|
+
Has(name, namespace = 'Global', version, contentHash) {
|
|
52
61
|
const id = this.resolveLookupKey(name, namespace, version, contentHash);
|
|
53
62
|
return id ? this.registry.has(id) : false;
|
|
54
63
|
}
|
|
55
|
-
|
|
64
|
+
has(name, namespace = 'Global', version, contentHash) {
|
|
65
|
+
return this.Has(name, namespace, version, contentHash);
|
|
66
|
+
}
|
|
67
|
+
Unregister(name, namespace = 'Global', version, contentHash) {
|
|
56
68
|
const id = this.resolveLookupKey(name, namespace, version, contentHash);
|
|
57
69
|
if (!id)
|
|
58
70
|
return false;
|
|
59
71
|
return this.registry.delete(id);
|
|
60
72
|
}
|
|
61
|
-
|
|
73
|
+
unregister(name, namespace = 'Global', version, contentHash) {
|
|
74
|
+
return this.Unregister(name, namespace, version, contentHash);
|
|
75
|
+
}
|
|
76
|
+
GetNamespace(namespace) {
|
|
62
77
|
const components = [];
|
|
63
78
|
for (const entry of this.registry.values()) {
|
|
64
79
|
if (entry.metadata.namespace === namespace) {
|
|
@@ -67,7 +82,10 @@ export class ComponentRegistry {
|
|
|
67
82
|
}
|
|
68
83
|
return components;
|
|
69
84
|
}
|
|
70
|
-
|
|
85
|
+
getNamespace(namespace) {
|
|
86
|
+
return this.GetNamespace(namespace);
|
|
87
|
+
}
|
|
88
|
+
GetAll(namespace = 'Global', version = 'v1') {
|
|
71
89
|
const components = {};
|
|
72
90
|
for (const entry of this.registry.values()) {
|
|
73
91
|
if (entry.metadata.namespace === namespace && entry.metadata.version === version) {
|
|
@@ -76,14 +94,20 @@ export class ComponentRegistry {
|
|
|
76
94
|
}
|
|
77
95
|
return components;
|
|
78
96
|
}
|
|
79
|
-
|
|
97
|
+
getAll(namespace = 'Global', version = 'v1') {
|
|
98
|
+
return this.GetAll(namespace, version);
|
|
99
|
+
}
|
|
100
|
+
GetNamespaces() {
|
|
80
101
|
const namespaces = new Set();
|
|
81
102
|
for (const entry of this.registry.values()) {
|
|
82
103
|
namespaces.add(entry.metadata.namespace);
|
|
83
104
|
}
|
|
84
105
|
return Array.from(namespaces);
|
|
85
106
|
}
|
|
86
|
-
|
|
107
|
+
getNamespaces() {
|
|
108
|
+
return this.GetNamespaces();
|
|
109
|
+
}
|
|
110
|
+
GetByTags(tags) {
|
|
87
111
|
const components = [];
|
|
88
112
|
for (const entry of this.registry.values()) {
|
|
89
113
|
if (entry.metadata.tags?.some(tag => tags.includes(tag))) {
|
|
@@ -92,7 +116,10 @@ export class ComponentRegistry {
|
|
|
92
116
|
}
|
|
93
117
|
return components;
|
|
94
118
|
}
|
|
95
|
-
|
|
119
|
+
getByTags(tags) {
|
|
120
|
+
return this.GetByTags(tags);
|
|
121
|
+
}
|
|
122
|
+
Release(name, namespace = 'Global', version, contentHash) {
|
|
96
123
|
const id = this.resolveLookupKey(name, namespace, version, contentHash);
|
|
97
124
|
if (!id)
|
|
98
125
|
return;
|
|
@@ -101,10 +128,16 @@ export class ComponentRegistry {
|
|
|
101
128
|
entry.refCount--;
|
|
102
129
|
}
|
|
103
130
|
}
|
|
104
|
-
|
|
131
|
+
release(name, namespace = 'Global', version, contentHash) {
|
|
132
|
+
return this.Release(name, namespace, version, contentHash);
|
|
133
|
+
}
|
|
134
|
+
Clear() {
|
|
105
135
|
this.registry.clear();
|
|
106
136
|
}
|
|
107
|
-
|
|
137
|
+
clear() {
|
|
138
|
+
return this.Clear();
|
|
139
|
+
}
|
|
140
|
+
ClearNamespace(namespace = 'Global') {
|
|
108
141
|
const toRemove = [];
|
|
109
142
|
for (const [key, entry] of this.registry) {
|
|
110
143
|
if (entry.metadata.namespace === namespace) {
|
|
@@ -116,15 +149,24 @@ export class ComponentRegistry {
|
|
|
116
149
|
}
|
|
117
150
|
return toRemove.length;
|
|
118
151
|
}
|
|
119
|
-
|
|
152
|
+
clearNamespace(namespace = 'Global') {
|
|
153
|
+
return this.ClearNamespace(namespace);
|
|
154
|
+
}
|
|
155
|
+
ForceClear() {
|
|
120
156
|
this.stopCleanupTimer();
|
|
121
157
|
this.registry.clear();
|
|
122
158
|
console.log('🧹 Registry force cleared - all components removed');
|
|
123
159
|
}
|
|
124
|
-
|
|
160
|
+
forceClear() {
|
|
161
|
+
return this.ForceClear();
|
|
162
|
+
}
|
|
163
|
+
Size() {
|
|
125
164
|
return this.registry.size;
|
|
126
165
|
}
|
|
127
|
-
|
|
166
|
+
size() {
|
|
167
|
+
return this.Size();
|
|
168
|
+
}
|
|
169
|
+
Cleanup(force = false) {
|
|
128
170
|
const toRemove = [];
|
|
129
171
|
const now = Date.now();
|
|
130
172
|
for (const [id, entry] of this.registry) {
|
|
@@ -139,7 +181,10 @@ export class ComponentRegistry {
|
|
|
139
181
|
}
|
|
140
182
|
return toRemove.length;
|
|
141
183
|
}
|
|
142
|
-
|
|
184
|
+
cleanup(force = false) {
|
|
185
|
+
return this.Cleanup(force);
|
|
186
|
+
}
|
|
187
|
+
GetStats() {
|
|
143
188
|
let totalRefCount = 0;
|
|
144
189
|
let oldest;
|
|
145
190
|
let newest;
|
|
@@ -154,16 +199,22 @@ export class ComponentRegistry {
|
|
|
154
199
|
}
|
|
155
200
|
return {
|
|
156
201
|
totalComponents: this.registry.size,
|
|
157
|
-
namespaces: this.
|
|
202
|
+
namespaces: this.GetNamespaces().length,
|
|
158
203
|
totalRefCount,
|
|
159
204
|
oldestComponent: oldest,
|
|
160
205
|
newestComponent: newest
|
|
161
206
|
};
|
|
162
207
|
}
|
|
163
|
-
|
|
208
|
+
getStats() {
|
|
209
|
+
return this.GetStats();
|
|
210
|
+
}
|
|
211
|
+
Destroy() {
|
|
164
212
|
this.stopCleanupTimer();
|
|
165
|
-
this.
|
|
166
|
-
resourceManager.cleanupComponent(this.
|
|
213
|
+
this.Clear();
|
|
214
|
+
resourceManager.cleanupComponent(this.RegistryId);
|
|
215
|
+
}
|
|
216
|
+
destroy() {
|
|
217
|
+
return this.Destroy();
|
|
167
218
|
}
|
|
168
219
|
generateRegistryKey(name, namespace, version, contentHash) {
|
|
169
220
|
const base = this.config.enableNamespaces ? `${namespace}::${name}@${version}` : `${name}@${version}`;
|
|
@@ -223,13 +274,13 @@ export class ComponentRegistry {
|
|
|
223
274
|
}
|
|
224
275
|
}
|
|
225
276
|
startCleanupTimer() {
|
|
226
|
-
this.cleanupTimer = resourceManager.setInterval(this.
|
|
227
|
-
this.
|
|
277
|
+
this.cleanupTimer = resourceManager.setInterval(this.RegistryId, () => {
|
|
278
|
+
this.Cleanup();
|
|
228
279
|
}, this.config.cleanupInterval, { purpose: 'component-registry-cleanup' });
|
|
229
280
|
}
|
|
230
281
|
stopCleanupTimer() {
|
|
231
282
|
if (this.cleanupTimer) {
|
|
232
|
-
resourceManager.clearInterval(this.
|
|
283
|
+
resourceManager.clearInterval(this.RegistryId, this.cleanupTimer);
|
|
233
284
|
this.cleanupTimer = undefined;
|
|
234
285
|
}
|
|
235
286
|
}
|
|
@@ -1 +1 @@
|
|
|
1
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AAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAKO,QAAQ;QACd,IAAI,MAA0B,CAAC;QAC/B,IAAI,OAAyB,CAAC;QAE9B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAEzC,IAAI,KAAK,CAAC,QAAQ,GAAG,CAAC;gBAAE,SAAS;YAEjC,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC,YAAY,GAAG,OAAO,EAAE,CAAC;gBAC7C,OAAO,GAAG,KAAK,CAAC,YAAY,CAAC;gBAC7B,MAAM,GAAG,GAAG,CAAC;YACf,CAAC;QACH,CAAC;QAED,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAKO,iBAAiB;QACvB,IAAI,CAAC,YAAY,GAAG,eAAe,CAAC,WAAW,CAC7C,IAAI,CAAC,UAAU,EACf,GAAG,EAAE;YACH,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,CAAC,EACD,IAAI,CAAC,MAAM,CAAC,eAAe,EAC3B,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAC1C,CAAC;IACJ,CAAC;IAKO,gBAAgB;QACtB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,eAAe,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAsB,CAAC,CAAC;YAC5E,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAChC,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * @fileoverview Platform-agnostic component registry for managing compiled React components.\n * Provides storage, retrieval, and lifecycle management for components with namespace support.\n * @module @memberjunction/react-runtime/registry\n */\n\nimport { \n RegistryEntry, \n ComponentMetadata, \n RegistryConfig \n} from '../types';\nimport { ComponentObject } from '@memberjunction/interactive-component-types';\nimport { resourceManager } from '../utilities/resource-manager';\n\n/**\n * Default registry configuration\n */\nconst DEFAULT_REGISTRY_CONFIG: RegistryConfig = {\n maxComponents: 1000,\n cleanupInterval: 60000, // 1 minute\n useLRU: true,\n enableNamespaces: true\n};\n\n/**\n * Platform-agnostic component registry.\n * Manages compiled React components with namespace isolation and lifecycle management.\n */\nexport class ComponentRegistry {\n private registry: Map<string, RegistryEntry>;\n private config: RegistryConfig;\n private cleanupTimer?: NodeJS.Timeout | number;\n public readonly registryId: string;\n \n /**\n * Creates a new ComponentRegistry instance\n * @param config - Optional registry configuration\n */\n constructor(config?: Partial<RegistryConfig>) {\n this.config = { ...DEFAULT_REGISTRY_CONFIG, ...config };\n this.registry = new Map();\n this.registryId = `component-registry-${Date.now()}`;\n \n // Start cleanup timer if configured\n if (this.config.cleanupInterval > 0) {\n this.startCleanupTimer();\n }\n }\n\n /**\n * Registers a compiled component\n * @param name - Component name\n * @param component - Compiled component object\n * @param namespace - Component namespace (default: 'Global')\n * @param version - Component version (default: 'v1')\n * @param contentHash - Optional content fingerprint. When provided, the entry\n * is keyed by `(name, namespace, version, contentHash)` so multiple specs\n * that share `(name, namespace, version)` but carry different `code` (e.g.\n * a registry-reference stub vs. an inline-code Studio export of the same\n * artifact) coexist in the cache instead of clobbering each other.\n * @param tags - Optional tags for categorization\n * @returns The registered component's metadata\n */\n register(\n name: string,\n component: ComponentObject,\n namespace: string = 'Global',\n version: string = 'v1',\n contentHash?: string,\n tags?: string[]\n ): ComponentMetadata {\n const id = this.generateRegistryKey(name, namespace, version, contentHash);\n\n // Create metadata\n const metadata: ComponentMetadata = {\n id,\n name,\n version,\n namespace,\n registeredAt: new Date(),\n tags\n };\n\n // Create registry entry\n const entry: RegistryEntry = {\n component,\n metadata,\n lastAccessed: new Date(),\n refCount: 0\n };\n\n // Check capacity\n if (this.registry.size >= this.config.maxComponents && this.config.useLRU) {\n this.evictLRU();\n }\n\n // Store in registry\n this.registry.set(id, entry);\n\n return metadata;\n }\n\n /**\n * Gets a component from the registry\n * @param name - Component name\n * @param namespace - Component namespace\n * @param version - Component version\n * @param contentHash - Optional content fingerprint. When provided, looks up\n * the exact `(name, namespace, version, contentHash)` entry. When omitted,\n * falls back to the most recently registered entry matching the other keys\n * (existing behavior).\n * @returns The component object if found, undefined otherwise\n */\n get(name: string, namespace: string = 'Global', version?: string, contentHash?: string): ComponentObject | undefined {\n const id = this.resolveLookupKey(name, namespace, version, contentHash);\n\n if (!id) return undefined;\n\n const entry = this.registry.get(id);\n if (entry) {\n // Update access time and increment ref count\n entry.lastAccessed = new Date();\n entry.refCount++;\n return entry.component;\n }\n\n return undefined;\n }\n\n /**\n * Checks if a component exists in the registry\n * @param name - Component name\n * @param namespace - Component namespace\n * @param version - Component version\n * @param contentHash - Optional content fingerprint (see {@link get})\n * @returns true if the component exists\n */\n has(name: string, namespace: string = 'Global', version?: string, contentHash?: string): boolean {\n const id = this.resolveLookupKey(name, namespace, version, contentHash);\n return id ? this.registry.has(id) : false;\n }\n\n /**\n * Removes a component from the registry\n * @param name - Component name\n * @param namespace - Component namespace\n * @param version - Component version\n * @param contentHash - Optional content fingerprint (see {@link get})\n * @returns true if the component was removed\n */\n unregister(name: string, namespace: string = 'Global', version?: string, contentHash?: string): boolean {\n const id = this.resolveLookupKey(name, namespace, version, contentHash);\n if (!id) return false;\n return this.registry.delete(id);\n }\n\n /**\n * Gets all components in a namespace\n * @param namespace - Namespace to query\n * @returns Array of components in the namespace\n */\n getNamespace(namespace: string): ComponentMetadata[] {\n const components: ComponentMetadata[] = [];\n \n for (const entry of this.registry.values()) {\n if (entry.metadata.namespace === namespace) {\n components.push(entry.metadata);\n }\n }\n\n return components;\n }\n\n /**\n * Gets all components in a namespace and version as a map\n * @param namespace - Namespace to query (default: 'Global')\n * @param version - Version to query (default: 'v1')\n * @returns Object mapping component names to component objects\n */\n getAll(namespace: string = 'Global', version: string = 'v1'): Record<string, ComponentObject> {\n const components: Record<string, ComponentObject> = {};\n \n for (const entry of this.registry.values()) {\n if (entry.metadata.namespace === namespace && entry.metadata.version === version) {\n components[entry.metadata.name] = entry.component;\n }\n }\n\n return components;\n }\n\n /**\n * Gets all registered namespaces\n * @returns Array of unique namespace names\n */\n getNamespaces(): string[] {\n const namespaces = new Set<string>();\n \n for (const entry of this.registry.values()) {\n namespaces.add(entry.metadata.namespace);\n }\n\n return Array.from(namespaces);\n }\n\n /**\n * Gets components by tags\n * @param tags - Tags to search for\n * @returns Array of components matching any of the tags\n */\n getByTags(tags: string[]): ComponentMetadata[] {\n const components: ComponentMetadata[] = [];\n \n for (const entry of this.registry.values()) {\n if (entry.metadata.tags?.some(tag => tags.includes(tag))) {\n components.push(entry.metadata);\n }\n }\n\n return components;\n }\n\n /**\n * Decrements reference count for a component\n * @param name - Component name\n * @param namespace - Component namespace\n * @param version - Component version\n * @param contentHash - Optional content fingerprint (see {@link get})\n */\n release(name: string, namespace: string = 'Global', version?: string, contentHash?: string): void {\n const id = this.resolveLookupKey(name, namespace, version, contentHash);\n if (!id) return;\n\n const entry = this.registry.get(id);\n if (entry && entry.refCount > 0) {\n entry.refCount--;\n }\n }\n\n /**\n * Clears all components from the registry\n */\n clear(): void {\n this.registry.clear();\n }\n\n /**\n * Clear all components in a specific namespace\n * @param namespace - Namespace to clear (default: 'Global')\n * @returns Number of components removed\n */\n clearNamespace(namespace: string = 'Global'): number {\n const toRemove: string[] = [];\n for (const [key, entry] of this.registry) {\n if (entry.metadata.namespace === namespace) {\n toRemove.push(key);\n }\n }\n for (const key of toRemove) {\n this.registry.delete(key);\n }\n return toRemove.length;\n }\n\n /**\n * Force clear all components and reset registry\n * Used for development/testing scenarios\n */\n forceClear(): void {\n this.stopCleanupTimer();\n this.registry.clear();\n console.log('🧹 Registry force cleared - all components removed');\n }\n\n /**\n * Gets the current size of the registry\n * @returns Number of registered components\n */\n size(): number {\n return this.registry.size;\n }\n\n /**\n * Performs cleanup of unused components\n * @param force - Force cleanup regardless of reference count\n * @returns Number of components removed\n */\n cleanup(force: boolean = false): number {\n const toRemove: string[] = [];\n const now = Date.now();\n\n for (const [id, entry] of this.registry) {\n // Remove if no references and hasn't been accessed recently\n const timeSinceAccess = now - entry.lastAccessed.getTime();\n const isUnused = entry.refCount === 0 && timeSinceAccess > this.config.cleanupInterval;\n\n if (force || isUnused) {\n toRemove.push(id);\n }\n }\n\n for (const id of toRemove) {\n this.registry.delete(id);\n }\n\n return toRemove.length;\n }\n\n /**\n * Gets registry statistics\n * @returns Object containing registry stats\n */\n getStats(): {\n totalComponents: number;\n namespaces: number;\n totalRefCount: number;\n oldestComponent?: Date;\n newestComponent?: Date;\n } {\n let totalRefCount = 0;\n let oldest: Date | undefined;\n let newest: Date | undefined;\n\n for (const entry of this.registry.values()) {\n totalRefCount += entry.refCount;\n \n if (!oldest || entry.metadata.registeredAt < oldest) {\n oldest = entry.metadata.registeredAt;\n }\n \n if (!newest || entry.metadata.registeredAt > newest) {\n newest = entry.metadata.registeredAt;\n }\n }\n\n return {\n totalComponents: this.registry.size,\n namespaces: this.getNamespaces().length,\n totalRefCount,\n oldestComponent: oldest,\n newestComponent: newest\n };\n }\n\n /**\n * Destroys the registry and cleans up resources\n */\n destroy(): void {\n this.stopCleanupTimer();\n this.clear();\n // Clean up any resources associated with this registry\n resourceManager.cleanupComponent(this.registryId);\n }\n\n /**\n * Generates a unique registry key. When `contentHash` is supplied, it is\n * appended so two specs that share `(name, namespace, version)` but have\n * different code body don't collide.\n */\n private generateRegistryKey(name: string, namespace: string, version: string, contentHash?: string): string {\n const base = this.config.enableNamespaces ? `${namespace}::${name}@${version}` : `${name}@${version}`;\n return contentHash ? `${base}#${contentHash}` : base;\n }\n\n /**\n * Resolves a lookup to an exact internal key. Centralizes the four\n * lookup-shape variants used by `get`, `has`, `unregister`, and `release`:\n *\n * - hash + version → exact hash-suffixed key\n * - version only → latest entry matching `(name, namespace, version)` across all hashes\n * - hash only → no version → fall back to latest version (hash isn't enough alone)\n * - neither → latest entry matching `(name, namespace)`\n */\n private resolveLookupKey(name: string, namespace: string, version?: string, contentHash?: string): string | undefined {\n if (version && contentHash) {\n return this.generateRegistryKey(name, namespace, version, contentHash);\n }\n if (version) {\n return this.findLatestForVersion(name, namespace, version);\n }\n return this.findLatestVersion(name, namespace);\n }\n\n /**\n * Find the most recently registered entry whose metadata matches\n * `(name, namespace, version)`. Different content hashes for the same\n * version are scanned and the newest by `registeredAt` wins.\n */\n private findLatestForVersion(name: string, namespace: string, version: string): string | undefined {\n let latestKey: string | undefined;\n let latestDate: Date | undefined;\n\n for (const [key, entry] of this.registry) {\n if (entry.metadata.name === name &&\n entry.metadata.namespace === namespace &&\n entry.metadata.version === version) {\n if (!latestDate || entry.metadata.registeredAt > latestDate) {\n latestDate = entry.metadata.registeredAt;\n latestKey = key;\n }\n }\n }\n\n return latestKey;\n }\n\n /**\n * Finds the latest version of a component\n * @param name - Component name\n * @param namespace - Component namespace\n * @returns Registry key of latest version or undefined\n */\n private findLatestVersion(name: string, namespace: string): string | undefined {\n let latestKey: string | undefined;\n let latestDate: Date | undefined;\n\n for (const [key, entry] of this.registry) {\n if (entry.metadata.name === name &&\n entry.metadata.namespace === namespace) {\n if (!latestDate || entry.metadata.registeredAt > latestDate) {\n latestDate = entry.metadata.registeredAt;\n latestKey = key;\n }\n }\n }\n\n return latestKey;\n }\n\n /**\n * Evicts the least recently used component\n */\n private evictLRU(): void {\n let lruKey: string | undefined;\n let lruTime: Date | undefined;\n\n for (const [key, entry] of this.registry) {\n // Skip components with active references\n if (entry.refCount > 0) continue;\n\n if (!lruTime || entry.lastAccessed < lruTime) {\n lruTime = entry.lastAccessed;\n lruKey = key;\n }\n }\n\n if (lruKey) {\n this.registry.delete(lruKey);\n }\n }\n\n /**\n * Starts the automatic cleanup timer\n */\n private startCleanupTimer(): void {\n this.cleanupTimer = resourceManager.setInterval(\n this.registryId,\n () => {\n this.cleanup();\n },\n this.config.cleanupInterval,\n { purpose: 'component-registry-cleanup' }\n );\n }\n\n /**\n * Stops the automatic cleanup timer\n */\n private stopCleanupTimer(): void {\n if (this.cleanupTimer) {\n resourceManager.clearInterval(this.registryId, this.cleanupTimer as number);\n this.cleanupTimer = undefined;\n }\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"component-registry.js","sourceRoot":"","sources":["../../src/registry/component-registry.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAKhE,MAAM,uBAAuB,GAAmB;IAC9C,aAAa,EAAE,IAAI;IACnB,eAAe,EAAE,KAAK;IACtB,MAAM,EAAE,IAAI;IACZ,gBAAgB,EAAE,IAAI;CACvB,CAAC;AAMF,MAAM,OAAO,iBAAiB;IAO5B,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAMD,YAAY,MAAgC;QAC1C,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,uBAAuB,EAAE,GAAG,MAAM,EAAE,CAAC;QACxD,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,sBAAsB,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QAGrD,IAAI,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,EAAE,CAAC;YACpC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC3B,CAAC;IACH,CAAC;IAgBD,QAAQ,CACN,IAAY,EACZ,SAA0B,EAC1B,YAAoB,QAAQ,EAC5B,UAAkB,IAAI,EACtB,WAAoB,EACpB,IAAe;QAEf,MAAM,EAAE,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;QAG3E,MAAM,QAAQ,GAAsB;YAClC,EAAE;YACF,IAAI;YACJ,OAAO;YACP,SAAS;YACT,YAAY,EAAE,IAAI,IAAI,EAAE;YACxB,IAAI;SACL,CAAC;QAGF,MAAM,KAAK,GAAkB;YAC3B,SAAS;YACT,QAAQ;YACR,YAAY,EA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M,EAAE,CAAC;YACX,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAKO,iBAAiB;QACvB,IAAI,CAAC,YAAY,GAAG,eAAe,CAAC,WAAW,CAC7C,IAAI,CAAC,UAAU,EACf,GAAG,EAAE;YACH,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,CAAC,EACD,IAAI,CAAC,MAAM,CAAC,eAAe,EAC3B,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAC1C,CAAC;IACJ,CAAC;IAKO,gBAAgB;QACtB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,eAAe,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAsB,CAAC,CAAC;YAC5E,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAChC,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * @fileoverview Platform-agnostic component registry for managing compiled React components.\n * Provides storage, retrieval, and lifecycle management for components with namespace support.\n * @module @memberjunction/react-runtime/registry\n */\n\nimport { \n RegistryEntry, \n ComponentMetadata, \n RegistryConfig \n} from '../types';\nimport { ComponentObject } from '@memberjunction/interactive-component-types';\nimport { resourceManager } from '../utilities/resource-manager';\n\n/**\n * Default registry configuration\n */\nconst DEFAULT_REGISTRY_CONFIG: RegistryConfig = {\n maxComponents: 1000,\n cleanupInterval: 60000, // 1 minute\n useLRU: true,\n enableNamespaces: true\n};\n\n/**\n * Platform-agnostic component registry.\n * Manages compiled React components with namespace isolation and lifecycle management.\n */\nexport class ComponentRegistry {\n private registry: Map<string, RegistryEntry>;\n private config: RegistryConfig;\n private cleanupTimer?: NodeJS.Timeout | number;\n public readonly RegistryId: string;\n\n /** @deprecated Use {@link RegistryId}. */\n public get registryId(): string {\n return this.RegistryId;\n }\n \n /**\n * Creates a new ComponentRegistry instance\n * @param config - Optional registry configuration\n */\n constructor(config?: Partial<RegistryConfig>) {\n this.config = { ...DEFAULT_REGISTRY_CONFIG, ...config };\n this.registry = new Map();\n this.RegistryId = `component-registry-${Date.now()}`;\n \n // Start cleanup timer if configured\n if (this.config.cleanupInterval > 0) {\n this.startCleanupTimer();\n }\n }\n\n /**\n * Registers a compiled component\n * @param name - Component name\n * @param component - Compiled component object\n * @param namespace - Component namespace (default: 'Global')\n * @param version - Component version (default: 'v1')\n * @param contentHash - Optional content fingerprint. When provided, the entry\n * is keyed by `(name, namespace, version, contentHash)` so multiple specs\n * that share `(name, namespace, version)` but carry different `code` (e.g.\n * a registry-reference stub vs. an inline-code Studio export of the same\n * artifact) coexist in the cache instead of clobbering each other.\n * @param tags - Optional tags for categorization\n * @returns The registered component's metadata\n */\n Register(\n name: string,\n component: ComponentObject,\n namespace: string = 'Global',\n version: string = 'v1',\n contentHash?: string,\n tags?: string[]\n ): ComponentMetadata {\n const id = this.generateRegistryKey(name, namespace, version, contentHash);\n\n // Create metadata\n const metadata: ComponentMetadata = {\n id,\n name,\n version,\n namespace,\n registeredAt: new Date(),\n tags\n };\n\n // Create registry entry\n const entry: RegistryEntry = {\n component,\n metadata,\n lastAccessed: new Date(),\n refCount: 0\n };\n\n // Check capacity\n if (this.registry.size >= this.config.maxComponents && this.config.useLRU) {\n this.evictLRU();\n }\n\n // Store in registry\n this.registry.set(id, entry);\n\n return metadata;\n }\n\n /** @deprecated Use {@link Register}. */\n register(\n name: string,\n component: ComponentObject,\n namespace: string = 'Global',\n version: string = 'v1',\n contentHash?: string,\n tags?: string[]\n ): ComponentMetadata {\n return this.Register(name, component, namespace, version, contentHash, tags);\n }\n\n /**\n * Gets a component from the registry\n * @param name - Component name\n * @param namespace - Component namespace\n * @param version - Component version\n * @param contentHash - Optional content fingerprint. When provided, looks up\n * the exact `(name, namespace, version, contentHash)` entry. When omitted,\n * falls back to the most recently registered entry matching the other keys\n * (existing behavior).\n * @returns The component object if found, undefined otherwise\n */\n Get(name: string, namespace: string = 'Global', version?: string, contentHash?: string): ComponentObject | undefined {\n const id = this.resolveLookupKey(name, namespace, version, contentHash);\n\n if (!id) return undefined;\n\n const entry = this.registry.get(id);\n if (entry) {\n // Update access time and increment ref count\n entry.lastAccessed = new Date();\n entry.refCount++;\n return entry.component;\n }\n\n return undefined;\n }\n\n /** @deprecated Use {@link Get}. */\n get(name: string, namespace: string = 'Global', version?: string, contentHash?: string): ComponentObject | undefined {\n return this.Get(name, namespace, version, contentHash);\n }\n\n /**\n * Checks if a component exists in the registry\n * @param name - Component name\n * @param namespace - Component namespace\n * @param version - Component version\n * @param contentHash - Optional content fingerprint (see {@link get})\n * @returns true if the component exists\n */\n Has(name: string, namespace: string = 'Global', version?: string, contentHash?: string): boolean {\n const id = this.resolveLookupKey(name, namespace, version, contentHash);\n return id ? this.registry.has(id) : false;\n }\n\n /** @deprecated Use {@link Has}. */\n has(name: string, namespace: string = 'Global', version?: string, contentHash?: string): boolean {\n return this.Has(name, namespace, version, contentHash);\n }\n\n /**\n * Removes a component from the registry\n * @param name - Component name\n * @param namespace - Component namespace\n * @param version - Component version\n * @param contentHash - Optional content fingerprint (see {@link get})\n * @returns true if the component was removed\n */\n Unregister(name: string, namespace: string = 'Global', version?: string, contentHash?: string): boolean {\n const id = this.resolveLookupKey(name, namespace, version, contentHash);\n if (!id) return false;\n return this.registry.delete(id);\n }\n\n /** @deprecated Use {@link Unregister}. */\n unregister(name: string, namespace: string = 'Global', version?: string, contentHash?: string): boolean {\n return this.Unregister(name, namespace, version, contentHash);\n }\n\n /**\n * Gets all components in a namespace\n * @param namespace - Namespace to query\n * @returns Array of components in the namespace\n */\n GetNamespace(namespace: string): ComponentMetadata[] {\n const components: ComponentMetadata[] = [];\n \n for (const entry of this.registry.values()) {\n if (entry.metadata.namespace === namespace) {\n components.push(entry.metadata);\n }\n }\n\n return components;\n }\n\n /** @deprecated Use {@link GetNamespace}. */\n getNamespace(namespace: string): ComponentMetadata[] {\n return this.GetNamespace(namespace);\n }\n\n /**\n * Gets all components in a namespace and version as a map\n * @param namespace - Namespace to query (default: 'Global')\n * @param version - Version to query (default: 'v1')\n * @returns Object mapping component names to component objects\n */\n GetAll(namespace: string = 'Global', version: string = 'v1'): Record<string, ComponentObject> {\n const components: Record<string, ComponentObject> = {};\n \n for (const entry of this.registry.values()) {\n if (entry.metadata.namespace === namespace && entry.metadata.version === version) {\n components[entry.metadata.name] = entry.component;\n }\n }\n\n return components;\n }\n\n /** @deprecated Use {@link GetAll}. */\n getAll(namespace: string = 'Global', version: string = 'v1'): Record<string, ComponentObject> {\n return this.GetAll(namespace, version);\n }\n\n /**\n * Gets all registered namespaces\n * @returns Array of unique namespace names\n */\n GetNamespaces(): string[] {\n const namespaces = new Set<string>();\n \n for (const entry of this.registry.values()) {\n namespaces.add(entry.metadata.namespace);\n }\n\n return Array.from(namespaces);\n }\n\n /** @deprecated Use {@link GetNamespaces}. */\n getNamespaces(): string[] {\n return this.GetNamespaces();\n }\n\n /**\n * Gets components by tags\n * @param tags - Tags to search for\n * @returns Array of components matching any of the tags\n */\n GetByTags(tags: string[]): ComponentMetadata[] {\n const components: ComponentMetadata[] = [];\n \n for (const entry of this.registry.values()) {\n if (entry.metadata.tags?.some(tag => tags.includes(tag))) {\n components.push(entry.metadata);\n }\n }\n\n return components;\n }\n\n /** @deprecated Use {@link GetByTags}. */\n getByTags(tags: string[]): ComponentMetadata[] {\n return this.GetByTags(tags);\n }\n\n /**\n * Decrements reference count for a component\n * @param name - Component name\n * @param namespace - Component namespace\n * @param version - Component version\n * @param contentHash - Optional content fingerprint (see {@link get})\n */\n Release(name: string, namespace: string = 'Global', version?: string, contentHash?: string): void {\n const id = this.resolveLookupKey(name, namespace, version, contentHash);\n if (!id) return;\n\n const entry = this.registry.get(id);\n if (entry && entry.refCount > 0) {\n entry.refCount--;\n }\n }\n\n /** @deprecated Use {@link Release}. */\n release(name: string, namespace: string = 'Global', version?: string, contentHash?: string): void {\n return this.Release(name, namespace, version, contentHash);\n }\n\n /**\n * Clears all components from the registry\n */\n Clear(): void {\n this.registry.clear();\n }\n\n /** @deprecated Use {@link Clear}. */\n clear(): void {\n return this.Clear();\n }\n\n /**\n * Clear all components in a specific namespace\n * @param namespace - Namespace to clear (default: 'Global')\n * @returns Number of components removed\n */\n ClearNamespace(namespace: string = 'Global'): number {\n const toRemove: string[] = [];\n for (const [key, entry] of this.registry) {\n if (entry.metadata.namespace === namespace) {\n toRemove.push(key);\n }\n }\n for (const key of toRemove) {\n this.registry.delete(key);\n }\n return toRemove.length;\n }\n\n /** @deprecated Use {@link ClearNamespace}. */\n clearNamespace(namespace: string = 'Global'): number {\n return this.ClearNamespace(namespace);\n }\n\n /**\n * Force clear all components and reset registry\n * Used for development/testing scenarios\n */\n ForceClear(): void {\n this.stopCleanupTimer();\n this.registry.clear();\n console.log('🧹 Registry force cleared - all components removed');\n }\n\n /** @deprecated Use {@link ForceClear}. */\n forceClear(): void {\n return this.ForceClear();\n }\n\n /**\n * Gets the current size of the registry\n * @returns Number of registered components\n */\n Size(): number {\n return this.registry.size;\n }\n\n /** @deprecated Use {@link Size}. */\n size(): number {\n return this.Size();\n }\n\n /**\n * Performs cleanup of unused components\n * @param force - Force cleanup regardless of reference count\n * @returns Number of components removed\n */\n Cleanup(force: boolean = false): number {\n const toRemove: string[] = [];\n const now = Date.now();\n\n for (const [id, entry] of this.registry) {\n // Remove if no references and hasn't been accessed recently\n const timeSinceAccess = now - entry.lastAccessed.getTime();\n const isUnused = entry.refCount === 0 && timeSinceAccess > this.config.cleanupInterval;\n\n if (force || isUnused) {\n toRemove.push(id);\n }\n }\n\n for (const id of toRemove) {\n this.registry.delete(id);\n }\n\n return toRemove.length;\n }\n\n /** @deprecated Use {@link Cleanup}. */\n cleanup(force: boolean = false): number {\n return this.Cleanup(force);\n }\n\n /**\n * Gets registry statistics\n * @returns Object containing registry stats\n */\n GetStats(): {\n totalComponents: number;\n namespaces: number;\n totalRefCount: number;\n oldestComponent?: Date;\n newestComponent?: Date;\n } {\n let totalRefCount = 0;\n let oldest: Date | undefined;\n let newest: Date | undefined;\n\n for (const entry of this.registry.values()) {\n totalRefCount += entry.refCount;\n \n if (!oldest || entry.metadata.registeredAt < oldest) {\n oldest = entry.metadata.registeredAt;\n }\n \n if (!newest || entry.metadata.registeredAt > newest) {\n newest = entry.metadata.registeredAt;\n }\n }\n\n return {\n totalComponents: this.registry.size,\n namespaces: this.GetNamespaces().length,\n totalRefCount,\n oldestComponent: oldest,\n newestComponent: newest\n };\n }\n\n /** @deprecated Use {@link GetStats}. */\n getStats(): {\n totalComponents: number;\n namespaces: number;\n totalRefCount: number;\n oldestComponent?: Date;\n newestComponent?: Date;\n } {\n return this.GetStats();\n }\n\n /**\n * Destroys the registry and cleans up resources\n */\n Destroy(): void {\n this.stopCleanupTimer();\n this.Clear();\n // Clean up any resources associated with this registry\n resourceManager.cleanupComponent(this.RegistryId);\n }\n\n /** @deprecated Use {@link Destroy}. */\n destroy(): void {\n return this.Destroy();\n }\n\n /**\n * Generates a unique registry key. When `contentHash` is supplied, it is\n * appended so two specs that share `(name, namespace, version)` but have\n * different code body don't collide.\n */\n private generateRegistryKey(name: string, namespace: string, version: string, contentHash?: string): string {\n const base = this.config.enableNamespaces ? `${namespace}::${name}@${version}` : `${name}@${version}`;\n return contentHash ? `${base}#${contentHash}` : base;\n }\n\n /**\n * Resolves a lookup to an exact internal key. Centralizes the four\n * lookup-shape variants used by `get`, `has`, `unregister`, and `release`:\n *\n * - hash + version → exact hash-suffixed key\n * - version only → latest entry matching `(name, namespace, version)` across all hashes\n * - hash only → no version → fall back to latest version (hash isn't enough alone)\n * - neither → latest entry matching `(name, namespace)`\n */\n private resolveLookupKey(name: string, namespace: string, version?: string, contentHash?: string): string | undefined {\n if (version && contentHash) {\n return this.generateRegistryKey(name, namespace, version, contentHash);\n }\n if (version) {\n return this.findLatestForVersion(name, namespace, version);\n }\n return this.findLatestVersion(name, namespace);\n }\n\n /**\n * Find the most recently registered entry whose metadata matches\n * `(name, namespace, version)`. Different content hashes for the same\n * version are scanned and the newest by `registeredAt` wins.\n */\n private findLatestForVersion(name: string, namespace: string, version: string): string | undefined {\n let latestKey: string | undefined;\n let latestDate: Date | undefined;\n\n for (const [key, entry] of this.registry) {\n if (entry.metadata.name === name &&\n entry.metadata.namespace === namespace &&\n entry.metadata.version === version) {\n if (!latestDate || entry.metadata.registeredAt > latestDate) {\n latestDate = entry.metadata.registeredAt;\n latestKey = key;\n }\n }\n }\n\n return latestKey;\n }\n\n /**\n * Finds the latest version of a component\n * @param name - Component name\n * @param namespace - Component namespace\n * @returns Registry key of latest version or undefined\n */\n private findLatestVersion(name: string, namespace: string): string | undefined {\n let latestKey: string | undefined;\n let latestDate: Date | undefined;\n\n for (const [key, entry] of this.registry) {\n if (entry.metadata.name === name &&\n entry.metadata.namespace === namespace) {\n if (!latestDate || entry.metadata.registeredAt > latestDate) {\n latestDate = entry.metadata.registeredAt;\n latestKey = key;\n }\n }\n }\n\n return latestKey;\n }\n\n /**\n * Evicts the least recently used component\n */\n private evictLRU(): void {\n let lruKey: string | undefined;\n let lruTime: Date | undefined;\n\n for (const [key, entry] of this.registry) {\n // Skip components with active references\n if (entry.refCount > 0) continue;\n\n if (!lruTime || entry.lastAccessed < lruTime) {\n lruTime = entry.lastAccessed;\n lruKey = key;\n }\n }\n\n if (lruKey) {\n this.registry.delete(lruKey);\n }\n }\n\n /**\n * Starts the automatic cleanup timer\n */\n private startCleanupTimer(): void {\n this.cleanupTimer = resourceManager.setInterval(\n this.RegistryId,\n () => {\n this.Cleanup();\n },\n this.config.cleanupInterval,\n { purpose: 'component-registry-cleanup' }\n );\n }\n\n /**\n * Stops the automatic cleanup timer\n */\n private stopCleanupTimer(): void {\n if (this.cleanupTimer) {\n resourceManager.clearInterval(this.RegistryId, this.cleanupTimer as number);\n this.cleanupTimer = undefined;\n }\n }\n}"]}
|
|
@@ -15,19 +15,29 @@ export declare class ComponentResolver {
|
|
|
15
15
|
private componentEngine;
|
|
16
16
|
private debug;
|
|
17
17
|
constructor(registry: ComponentRegistry, compiler?: ComponentCompiler, runtimeContext?: RuntimeContext, debug?: boolean);
|
|
18
|
+
ResolveComponents(spec: ComponentSpec, namespace?: string, contextUser?: UserInfo): Promise<ResolvedComponents>;
|
|
18
19
|
resolveComponents(spec: ComponentSpec, namespace?: string, contextUser?: UserInfo): Promise<ResolvedComponents>;
|
|
19
20
|
private resolveComponentHierarchy;
|
|
21
|
+
Cleanup(): void;
|
|
20
22
|
cleanup(): void;
|
|
23
|
+
ValidateDependencies(spec: ComponentSpec, namespace?: string): string[];
|
|
21
24
|
validateDependencies(spec: ComponentSpec, namespace?: string): string[];
|
|
22
25
|
private checkDependencies;
|
|
26
|
+
GetDependencyGraph(spec: ComponentSpec): Map<string, string[]>;
|
|
23
27
|
getDependencyGraph(spec: ComponentSpec): Map<string, string[]>;
|
|
24
28
|
private buildDependencyGraph;
|
|
29
|
+
GetLoadOrder(spec: ComponentSpec): string[];
|
|
25
30
|
getLoadOrder(spec: ComponentSpec): string[];
|
|
26
31
|
private topologicalSortDFS;
|
|
32
|
+
ResolveInOrder(spec: ComponentSpec, namespace?: string): Array<{
|
|
33
|
+
name: string;
|
|
34
|
+
component: any;
|
|
35
|
+
}>;
|
|
27
36
|
resolveInOrder(spec: ComponentSpec, namespace?: string): Array<{
|
|
28
37
|
name: string;
|
|
29
38
|
component: any;
|
|
30
39
|
}>;
|
|
40
|
+
FlattenComponentSpecs(spec: ComponentSpec): ComponentSpec[];
|
|
31
41
|
flattenComponentSpecs(spec: ComponentSpec): ComponentSpec[];
|
|
32
42
|
private collectComponentSpecs;
|
|
33
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-resolver.d.ts","sourceRoot":"","sources":["../../src/registry/component-resolver.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,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AAE,GAAG,CAAC;KAChB,CAAC;IAeF,cAAc,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,GAAE,MAAiB,GAAG,KAAK,CAAC;QACvE,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,GAAG,CAAC;KAChB,CAAC;IASF,qBAAqB,CAAC,IAAI,EAAE,aAAa,GAAG,aAAa,EAAE;IAU3D,qBAAqB,CAAC,IAAI,EAAE,aAAa,GAAG,aAAa,EAAE;IAU3D,OAAO,CAAC,qBAAqB;CAe9B"}
|
|
@@ -16,7 +16,7 @@ export class ComponentResolver {
|
|
|
16
16
|
this.registryService = ComponentRegistryService.getInstance(compiler, runtimeContext, debug);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
async
|
|
19
|
+
async ResolveComponents(spec, namespace = 'Global', contextUser) {
|
|
20
20
|
console.log(`🚀 [ComponentResolver] Starting component resolution for: ${spec.name}`);
|
|
21
21
|
console.log(`📋 [ComponentResolver] Root component spec:`, {
|
|
22
22
|
name: spec.name,
|
|
@@ -85,6 +85,9 @@ export class ComponentResolver {
|
|
|
85
85
|
}
|
|
86
86
|
return unwrapped;
|
|
87
87
|
}
|
|
88
|
+
async resolveComponents(spec, namespace = 'Global', contextUser) {
|
|
89
|
+
return this.ResolveComponents(spec, namespace, contextUser);
|
|
90
|
+
}
|
|
88
91
|
async resolveComponentHierarchy(spec, resolved, namespace, visited = new Set(), contextUser) {
|
|
89
92
|
const componentId = `${spec.namespace || namespace}/${spec.name}@${spec.version || 'latest'}`;
|
|
90
93
|
if (resolved[spec.name]) {
|
|
@@ -243,19 +246,25 @@ export class ComponentResolver {
|
|
|
243
246
|
}
|
|
244
247
|
}
|
|
245
248
|
}
|
|
246
|
-
|
|
249
|
+
Cleanup() {
|
|
247
250
|
if (this.registryService) {
|
|
248
251
|
if (this.debug) {
|
|
249
252
|
console.log(`Cleaning up resolver: ${this.resolverInstanceId}`);
|
|
250
253
|
}
|
|
251
254
|
}
|
|
252
255
|
}
|
|
253
|
-
|
|
256
|
+
cleanup() {
|
|
257
|
+
return this.Cleanup();
|
|
258
|
+
}
|
|
259
|
+
ValidateDependencies(spec, namespace = 'Global') {
|
|
254
260
|
const missing = [];
|
|
255
261
|
const checked = new Set();
|
|
256
262
|
this.checkDependencies(spec, namespace, missing, checked);
|
|
257
263
|
return missing;
|
|
258
264
|
}
|
|
265
|
+
validateDependencies(spec, namespace = 'Global') {
|
|
266
|
+
return this.ValidateDependencies(spec, namespace);
|
|
267
|
+
}
|
|
259
268
|
checkDependencies(spec, namespace, missing, checked) {
|
|
260
269
|
if (checked.has(spec.name))
|
|
261
270
|
return;
|
|
@@ -268,12 +277,15 @@ export class ComponentResolver {
|
|
|
268
277
|
this.checkDependencies(child, namespace, missing, checked);
|
|
269
278
|
}
|
|
270
279
|
}
|
|
271
|
-
|
|
280
|
+
GetDependencyGraph(spec) {
|
|
272
281
|
const graph = new Map();
|
|
273
282
|
const visited = new Set();
|
|
274
283
|
this.buildDependencyGraph(spec, graph, visited);
|
|
275
284
|
return graph;
|
|
276
285
|
}
|
|
286
|
+
getDependencyGraph(spec) {
|
|
287
|
+
return this.GetDependencyGraph(spec);
|
|
288
|
+
}
|
|
277
289
|
buildDependencyGraph(spec, graph, visited) {
|
|
278
290
|
if (visited.has(spec.name))
|
|
279
291
|
return;
|
|
@@ -285,8 +297,8 @@ export class ComponentResolver {
|
|
|
285
297
|
this.buildDependencyGraph(child, graph, visited);
|
|
286
298
|
}
|
|
287
299
|
}
|
|
288
|
-
|
|
289
|
-
const graph = this.
|
|
300
|
+
GetLoadOrder(spec) {
|
|
301
|
+
const graph = this.GetDependencyGraph(spec);
|
|
290
302
|
const visited = new Set();
|
|
291
303
|
const stack = [];
|
|
292
304
|
for (const node of graph.keys()) {
|
|
@@ -296,6 +308,9 @@ export class ComponentResolver {
|
|
|
296
308
|
}
|
|
297
309
|
return stack.reverse();
|
|
298
310
|
}
|
|
311
|
+
getLoadOrder(spec) {
|
|
312
|
+
return this.GetLoadOrder(spec);
|
|
313
|
+
}
|
|
299
314
|
topologicalSortDFS(node, graph, visited, stack) {
|
|
300
315
|
visited.add(node);
|
|
301
316
|
const dependencies = graph.get(node) || [];
|
|
@@ -306,8 +321,8 @@ export class ComponentResolver {
|
|
|
306
321
|
}
|
|
307
322
|
stack.push(node);
|
|
308
323
|
}
|
|
309
|
-
|
|
310
|
-
const loadOrder = this.
|
|
324
|
+
ResolveInOrder(spec, namespace = 'Global') {
|
|
325
|
+
const loadOrder = this.GetLoadOrder(spec);
|
|
311
326
|
const resolved = [];
|
|
312
327
|
for (const name of loadOrder) {
|
|
313
328
|
const component = this.registry.get(name, namespace);
|
|
@@ -317,12 +332,18 @@ export class ComponentResolver {
|
|
|
317
332
|
}
|
|
318
333
|
return resolved;
|
|
319
334
|
}
|
|
320
|
-
|
|
335
|
+
resolveInOrder(spec, namespace = 'Global') {
|
|
336
|
+
return this.ResolveInOrder(spec, namespace);
|
|
337
|
+
}
|
|
338
|
+
FlattenComponentSpecs(spec) {
|
|
321
339
|
const flattened = [];
|
|
322
340
|
const visited = new Set();
|
|
323
341
|
this.collectComponentSpecs(spec, flattened, visited);
|
|
324
342
|
return flattened;
|
|
325
343
|
}
|
|
344
|
+
flattenComponentSpecs(spec) {
|
|
345
|
+
return this.FlattenComponentSpecs(spec);
|
|
346
|
+
}
|
|
326
347
|
collectComponentSpecs(spec, collected, visited) {
|
|
327
348
|
if (visited.has(spec.name))
|
|
328
349
|
return;
|