@memberjunction/react-runtime 6.2.0-edge.0 → 6.2.0-edge.1
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 +12 -12
- package/CHANGELOG.md +61 -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 +72 -72
- 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
|
@@ -60,7 +60,7 @@ export class ReactRootManager {
|
|
|
60
60
|
* @param componentId - Optional component ID for resource tracking
|
|
61
61
|
* @returns The root ID for future operations
|
|
62
62
|
*/
|
|
63
|
-
|
|
63
|
+
CreateRoot(
|
|
64
64
|
container: HTMLElement,
|
|
65
65
|
createRootFn: (container: HTMLElement) => any,
|
|
66
66
|
componentId?: string
|
|
@@ -83,7 +83,7 @@ export class ReactRootManager {
|
|
|
83
83
|
resourceManager.registerReactRoot(
|
|
84
84
|
componentId,
|
|
85
85
|
root,
|
|
86
|
-
() => this.
|
|
86
|
+
() => this.UnmountRoot(rootId)
|
|
87
87
|
);
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -99,6 +99,15 @@ export class ReactRootManager {
|
|
|
99
99
|
|
|
100
100
|
return rootId;
|
|
101
101
|
}
|
|
102
|
+
|
|
103
|
+
/** @deprecated Use {@link CreateRoot}. */
|
|
104
|
+
createRoot(
|
|
105
|
+
container: HTMLElement,
|
|
106
|
+
createRootFn: (container: HTMLElement) => any,
|
|
107
|
+
componentId?: string
|
|
108
|
+
): string {
|
|
109
|
+
return this.CreateRoot(container, createRootFn, componentId);
|
|
110
|
+
}
|
|
102
111
|
|
|
103
112
|
/**
|
|
104
113
|
* Safely render content to a React root
|
|
@@ -160,7 +169,7 @@ export class ReactRootManager {
|
|
|
160
169
|
* @param rootId - The root ID
|
|
161
170
|
* @param force - Force unmount even if rendering
|
|
162
171
|
*/
|
|
163
|
-
|
|
172
|
+
UnmountRoot(rootId: string, force: boolean = false): Promise<void> {
|
|
164
173
|
return new Promise((resolve) => {
|
|
165
174
|
const managedRoot = this.roots.get(rootId);
|
|
166
175
|
if (!managedRoot) {
|
|
@@ -205,12 +214,17 @@ export class ReactRootManager {
|
|
|
205
214
|
}
|
|
206
215
|
});
|
|
207
216
|
}
|
|
217
|
+
|
|
218
|
+
/** @deprecated Use {@link UnmountRoot}. */
|
|
219
|
+
unmountRoot(rootId: string, force: boolean = false): Promise<void> {
|
|
220
|
+
return this.UnmountRoot(rootId, force);
|
|
221
|
+
}
|
|
208
222
|
|
|
209
223
|
/**
|
|
210
224
|
* Unmount all roots associated with a component
|
|
211
225
|
* @param componentId - The component ID
|
|
212
226
|
*/
|
|
213
|
-
async
|
|
227
|
+
async UnmountComponentRoots(componentId: string): Promise<void> {
|
|
214
228
|
const rootIds: string[] = [];
|
|
215
229
|
|
|
216
230
|
for (const [rootId, managedRoot] of this.roots) {
|
|
@@ -219,7 +233,12 @@ export class ReactRootManager {
|
|
|
219
233
|
}
|
|
220
234
|
}
|
|
221
235
|
|
|
222
|
-
await Promise.all(rootIds.map(id => this.
|
|
236
|
+
await Promise.all(rootIds.map(id => this.UnmountRoot(id)));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** @deprecated Use {@link UnmountComponentRoots}. */
|
|
240
|
+
async unmountComponentRoots(componentId: string): Promise<void> {
|
|
241
|
+
return this.UnmountComponentRoots(componentId);
|
|
223
242
|
}
|
|
224
243
|
|
|
225
244
|
/**
|
|
@@ -227,14 +246,19 @@ export class ReactRootManager {
|
|
|
227
246
|
* @param rootId - The root ID
|
|
228
247
|
* @returns true if rendering
|
|
229
248
|
*/
|
|
230
|
-
|
|
249
|
+
IsRendering(rootId: string): boolean {
|
|
231
250
|
return this.renderingRoots.has(rootId);
|
|
232
251
|
}
|
|
252
|
+
|
|
253
|
+
/** @deprecated Use {@link IsRendering}. */
|
|
254
|
+
isRendering(rootId: string): boolean {
|
|
255
|
+
return this.IsRendering(rootId);
|
|
256
|
+
}
|
|
233
257
|
|
|
234
258
|
/**
|
|
235
259
|
* Get statistics about managed roots
|
|
236
260
|
*/
|
|
237
|
-
|
|
261
|
+
GetStats(): {
|
|
238
262
|
totalRoots: number;
|
|
239
263
|
renderingRoots: number;
|
|
240
264
|
pendingUnmounts: number;
|
|
@@ -246,20 +270,34 @@ export class ReactRootManager {
|
|
|
246
270
|
};
|
|
247
271
|
}
|
|
248
272
|
|
|
273
|
+
/** @deprecated Use {@link GetStats}. */
|
|
274
|
+
getStats(): {
|
|
275
|
+
totalRoots: number;
|
|
276
|
+
renderingRoots: number;
|
|
277
|
+
pendingUnmounts: number;
|
|
278
|
+
} {
|
|
279
|
+
return this.GetStats();
|
|
280
|
+
}
|
|
281
|
+
|
|
249
282
|
/**
|
|
250
283
|
* Clean up all roots (for testing or shutdown)
|
|
251
284
|
*/
|
|
252
|
-
async
|
|
285
|
+
async Cleanup(): Promise<void> {
|
|
253
286
|
// Invoke cleanup hooks before unmounting roots
|
|
254
287
|
this.invokeHooks('OnCleanup');
|
|
255
288
|
|
|
256
289
|
const allRootIds = Array.from(this.roots.keys());
|
|
257
|
-
await Promise.all(allRootIds.map(id => this.
|
|
290
|
+
await Promise.all(allRootIds.map(id => this.UnmountRoot(id, true)));
|
|
258
291
|
|
|
259
292
|
// Reset state so hooks fire again if runtime is re-initialized
|
|
260
293
|
this.firstRootCreated = false;
|
|
261
294
|
}
|
|
262
295
|
|
|
296
|
+
/** @deprecated Use {@link Cleanup}. */
|
|
297
|
+
async cleanup(): Promise<void> {
|
|
298
|
+
return this.Cleanup();
|
|
299
|
+
}
|
|
300
|
+
|
|
263
301
|
/**
|
|
264
302
|
* Safely invoke a lifecycle method on all registered hooks.
|
|
265
303
|
* Errors in individual hooks are caught and logged so one
|
|
@@ -280,4 +318,4 @@ export class ReactRootManager {
|
|
|
280
318
|
}
|
|
281
319
|
|
|
282
320
|
// Singleton instance
|
|
283
|
-
export const reactRootManager = new ReactRootManager();
|
|
321
|
+
export const reactRootManager = new ReactRootManager(); // case-violation-ok-legacy-back-compat: the PascalCase name is already taken in this scope
|
|
@@ -43,7 +43,7 @@ export class CacheManager<T = unknown> {
|
|
|
43
43
|
/**
|
|
44
44
|
* Set a value in the cache
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
Set(key: string, value: T, ttl?: number): void {
|
|
47
47
|
const size = this.estimateSize(value);
|
|
48
48
|
const entry: CacheEntry<T> = {
|
|
49
49
|
value,
|
|
@@ -83,22 +83,27 @@ export class CacheManager<T = unknown> {
|
|
|
83
83
|
const timeout = ttl || this.options.defaultTTL;
|
|
84
84
|
const timerId = setTimeout(() => {
|
|
85
85
|
this.timers.delete(key);
|
|
86
|
-
this.
|
|
86
|
+
this.Delete(key);
|
|
87
87
|
}, timeout);
|
|
88
88
|
this.timers.set(key, timerId);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
/** @deprecated Use {@link Set}. */
|
|
93
|
+
set(key: string, value: T, ttl?: number): void {
|
|
94
|
+
return this.Set(key, value, ttl);
|
|
95
|
+
}
|
|
96
|
+
|
|
92
97
|
/**
|
|
93
98
|
* Get a value from the cache
|
|
94
99
|
*/
|
|
95
|
-
|
|
100
|
+
Get(key: string): T | undefined {
|
|
96
101
|
const entry = this.cache.get(key);
|
|
97
102
|
if (!entry) return undefined;
|
|
98
103
|
|
|
99
104
|
// Check if expired
|
|
100
105
|
if (this.isExpired(entry)) {
|
|
101
|
-
this.
|
|
106
|
+
this.Delete(key);
|
|
102
107
|
return undefined;
|
|
103
108
|
}
|
|
104
109
|
|
|
@@ -107,25 +112,35 @@ export class CacheManager<T = unknown> {
|
|
|
107
112
|
return entry.value;
|
|
108
113
|
}
|
|
109
114
|
|
|
115
|
+
/** @deprecated Use {@link Get}. */
|
|
116
|
+
get(key: string): T | undefined {
|
|
117
|
+
return this.Get(key);
|
|
118
|
+
}
|
|
119
|
+
|
|
110
120
|
/**
|
|
111
121
|
* Check if a key exists and is not expired
|
|
112
122
|
*/
|
|
113
|
-
|
|
123
|
+
Has(key: string): boolean {
|
|
114
124
|
const entry = this.cache.get(key);
|
|
115
125
|
if (!entry) return false;
|
|
116
126
|
|
|
117
127
|
if (this.isExpired(entry)) {
|
|
118
|
-
this.
|
|
128
|
+
this.Delete(key);
|
|
119
129
|
return false;
|
|
120
130
|
}
|
|
121
131
|
|
|
122
132
|
return true;
|
|
123
133
|
}
|
|
124
134
|
|
|
135
|
+
/** @deprecated Use {@link Has}. */
|
|
136
|
+
has(key: string): boolean {
|
|
137
|
+
return this.Has(key);
|
|
138
|
+
}
|
|
139
|
+
|
|
125
140
|
/**
|
|
126
141
|
* Delete a key from the cache
|
|
127
142
|
*/
|
|
128
|
-
|
|
143
|
+
Delete(key: string): boolean {
|
|
129
144
|
const timer = this.timers.get(key);
|
|
130
145
|
if (timer !== undefined) {
|
|
131
146
|
clearTimeout(timer);
|
|
@@ -139,10 +154,15 @@ export class CacheManager<T = unknown> {
|
|
|
139
154
|
return false;
|
|
140
155
|
}
|
|
141
156
|
|
|
157
|
+
/** @deprecated Use {@link Delete}. */
|
|
158
|
+
delete(key: string): boolean {
|
|
159
|
+
return this.Delete(key);
|
|
160
|
+
}
|
|
161
|
+
|
|
142
162
|
/**
|
|
143
163
|
* Clear all entries
|
|
144
164
|
*/
|
|
145
|
-
|
|
165
|
+
Clear(): void {
|
|
146
166
|
for (const timer of this.timers.values()) {
|
|
147
167
|
clearTimeout(timer);
|
|
148
168
|
}
|
|
@@ -151,10 +171,15 @@ export class CacheManager<T = unknown> {
|
|
|
151
171
|
this.memoryUsage = 0;
|
|
152
172
|
}
|
|
153
173
|
|
|
174
|
+
/** @deprecated Use {@link Clear}. */
|
|
175
|
+
clear(): void {
|
|
176
|
+
return this.Clear();
|
|
177
|
+
}
|
|
178
|
+
|
|
154
179
|
/**
|
|
155
180
|
* Get cache statistics
|
|
156
181
|
*/
|
|
157
|
-
|
|
182
|
+
GetStats(): {
|
|
158
183
|
size: number;
|
|
159
184
|
memoryUsage: number;
|
|
160
185
|
maxSize: number;
|
|
@@ -168,16 +193,26 @@ export class CacheManager<T = unknown> {
|
|
|
168
193
|
};
|
|
169
194
|
}
|
|
170
195
|
|
|
196
|
+
/** @deprecated Use {@link GetStats}. */
|
|
197
|
+
getStats(): {
|
|
198
|
+
size: number;
|
|
199
|
+
memoryUsage: number;
|
|
200
|
+
maxSize: number;
|
|
201
|
+
maxMemory: number;
|
|
202
|
+
} {
|
|
203
|
+
return this.GetStats();
|
|
204
|
+
}
|
|
205
|
+
|
|
171
206
|
/**
|
|
172
207
|
* Manually trigger cleanup
|
|
173
208
|
*/
|
|
174
|
-
|
|
209
|
+
Cleanup(): number {
|
|
175
210
|
let removed = 0;
|
|
176
211
|
const now = Date.now();
|
|
177
212
|
|
|
178
213
|
for (const [key, entry] of this.cache) {
|
|
179
214
|
if (this.isExpired(entry, now)) {
|
|
180
|
-
this.
|
|
215
|
+
this.Delete(key);
|
|
181
216
|
removed++;
|
|
182
217
|
}
|
|
183
218
|
}
|
|
@@ -185,12 +220,22 @@ export class CacheManager<T = unknown> {
|
|
|
185
220
|
return removed;
|
|
186
221
|
}
|
|
187
222
|
|
|
223
|
+
/** @deprecated Use {@link Cleanup}. */
|
|
224
|
+
cleanup(): number {
|
|
225
|
+
return this.Cleanup();
|
|
226
|
+
}
|
|
227
|
+
|
|
188
228
|
/**
|
|
189
229
|
* Destroy the cache, cancel all entry timers, and stop the cleanup timer.
|
|
190
230
|
*/
|
|
191
|
-
|
|
231
|
+
Destroy(): void {
|
|
192
232
|
this.stopCleanupTimer();
|
|
193
|
-
this.
|
|
233
|
+
this.Clear();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** @deprecated Use {@link Destroy}. */
|
|
237
|
+
destroy(): void {
|
|
238
|
+
return this.Destroy();
|
|
194
239
|
}
|
|
195
240
|
|
|
196
241
|
/**
|
|
@@ -217,7 +262,7 @@ export class CacheManager<T = unknown> {
|
|
|
217
262
|
}
|
|
218
263
|
|
|
219
264
|
if (lruKey) {
|
|
220
|
-
this.
|
|
265
|
+
this.Delete(lruKey);
|
|
221
266
|
}
|
|
222
267
|
}
|
|
223
268
|
|
|
@@ -232,7 +277,7 @@ export class CacheManager<T = unknown> {
|
|
|
232
277
|
for (const [key, entry] of entries) {
|
|
233
278
|
if (freedMemory >= requiredSize) break;
|
|
234
279
|
freedMemory += entry.size || 0;
|
|
235
|
-
this.
|
|
280
|
+
this.Delete(key);
|
|
236
281
|
}
|
|
237
282
|
}
|
|
238
283
|
|
|
@@ -259,7 +304,7 @@ export class CacheManager<T = unknown> {
|
|
|
259
304
|
*/
|
|
260
305
|
private startCleanupTimer(): void {
|
|
261
306
|
this.cleanupTimer = setInterval(() => {
|
|
262
|
-
this.
|
|
307
|
+
this.Cleanup();
|
|
263
308
|
}, this.options.cleanupInterval);
|
|
264
309
|
}
|
|
265
310
|
|
|
@@ -95,7 +95,7 @@ export class ComponentErrorAnalyzer {
|
|
|
95
95
|
* @param errors Array of error messages
|
|
96
96
|
* @returns Array of failed component names
|
|
97
97
|
*/
|
|
98
|
-
static
|
|
98
|
+
static IdentifyFailedComponents(errors: string[]): string[] {
|
|
99
99
|
const failedComponents = new Set<string>();
|
|
100
100
|
|
|
101
101
|
for (const error of errors) {
|
|
@@ -106,12 +106,17 @@ export class ComponentErrorAnalyzer {
|
|
|
106
106
|
return Array.from(failedComponents);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
/** @deprecated Use {@link IdentifyFailedComponents}. */
|
|
110
|
+
static identifyFailedComponents(errors: string[]): string[] {
|
|
111
|
+
return this.IdentifyFailedComponents(errors);
|
|
112
|
+
}
|
|
113
|
+
|
|
109
114
|
/**
|
|
110
115
|
* Analyzes errors and returns detailed information about failures
|
|
111
116
|
* @param errors Array of error messages
|
|
112
117
|
* @returns Array of detailed failure information
|
|
113
118
|
*/
|
|
114
|
-
static
|
|
119
|
+
static AnalyzeComponentErrors(errors: string[]): FailedComponentInfo[] {
|
|
115
120
|
const failures: FailedComponentInfo[] = [];
|
|
116
121
|
|
|
117
122
|
for (const error of errors) {
|
|
@@ -131,6 +136,11 @@ export class ComponentErrorAnalyzer {
|
|
|
131
136
|
return Array.from(uniqueFailures.values());
|
|
132
137
|
}
|
|
133
138
|
|
|
139
|
+
/** @deprecated Use {@link AnalyzeComponentErrors}. */
|
|
140
|
+
static analyzeComponentErrors(errors: string[]): FailedComponentInfo[] {
|
|
141
|
+
return this.AnalyzeComponentErrors(errors);
|
|
142
|
+
}
|
|
143
|
+
|
|
134
144
|
/**
|
|
135
145
|
* Extract component names from a single error message
|
|
136
146
|
*/
|
|
@@ -291,7 +301,7 @@ export class ComponentErrorAnalyzer {
|
|
|
291
301
|
/**
|
|
292
302
|
* Format error analysis results for logging
|
|
293
303
|
*/
|
|
294
|
-
static
|
|
304
|
+
static FormatAnalysisResults(failures: FailedComponentInfo[]): string {
|
|
295
305
|
if (failures.length === 0) {
|
|
296
306
|
return 'No component failures detected';
|
|
297
307
|
}
|
|
@@ -312,4 +322,9 @@ export class ComponentErrorAnalyzer {
|
|
|
312
322
|
|
|
313
323
|
return result;
|
|
314
324
|
}
|
|
325
|
+
|
|
326
|
+
/** @deprecated Use {@link FormatAnalysisResults}. */
|
|
327
|
+
static formatAnalysisResults(failures: FailedComponentInfo[]): string {
|
|
328
|
+
return this.FormatAnalysisResults(failures);
|
|
329
|
+
}
|
|
315
330
|
}
|
|
@@ -24,7 +24,7 @@ import { ComponentSpec } from '@memberjunction/interactive-component-types';
|
|
|
24
24
|
* @param spec The root component spec.
|
|
25
25
|
* @returns A short version string of the form `v1a2b3c4d`.
|
|
26
26
|
*/
|
|
27
|
-
export function
|
|
27
|
+
export function GenerateComponentHierarchyHash(spec: ComponentSpec): string {
|
|
28
28
|
const codeStrings: string[] = [];
|
|
29
29
|
|
|
30
30
|
const collectCode = (s: ComponentSpec): void => {
|
|
@@ -52,3 +52,8 @@ export function generateComponentHierarchyHash(spec: ComponentSpec): string {
|
|
|
52
52
|
const hexHash = Math.abs(hash).toString(16).padStart(8, '0').substring(0, 8);
|
|
53
53
|
return `v${hexHash}`;
|
|
54
54
|
}
|
|
55
|
+
|
|
56
|
+
/** @deprecated Use {@link GenerateComponentHierarchyHash}. */
|
|
57
|
+
export function generateComponentHierarchyHash(spec: ComponentSpec): string {
|
|
58
|
+
return GenerateComponentHierarchyHash(spec);
|
|
59
|
+
}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import { ComponentStyles } from '@memberjunction/interactive-component-types';
|
|
22
|
-
import {
|
|
22
|
+
import { UnwrapLibraryComponent } from './component-unwrapper';
|
|
23
23
|
|
|
24
24
|
/** Relative luminance (0 = black, 1 = white) of a hex or rgb()/rgba() color; 1 if unparseable. */
|
|
25
25
|
function colorLuminance(color: string | undefined): number {
|
|
@@ -57,12 +57,12 @@ function radiusToNumber(radius: ComponentStyles['borders']['radius'] | undefined
|
|
|
57
57
|
* module (used only to read its `theme` algorithm namespace). Unmapped tokens are
|
|
58
58
|
* omitted so antd falls back to its own defaults.
|
|
59
59
|
*/
|
|
60
|
-
export function
|
|
60
|
+
export function BuildAntdThemeConfig(
|
|
61
61
|
styles: Partial<ComponentStyles> | undefined,
|
|
62
62
|
antdLib: unknown,
|
|
63
63
|
): Record<string, unknown> {
|
|
64
64
|
const colors = (styles?.colors || {}) as Record<string, string | undefined>;
|
|
65
|
-
const themeNS = antdLib ?
|
|
65
|
+
const themeNS = antdLib ? UnwrapLibraryComponent(antdLib, 'theme') : undefined;
|
|
66
66
|
const isDark = colorLuminance(colors['background']) < 0.5;
|
|
67
67
|
|
|
68
68
|
const token: Record<string, unknown> = {
|
|
@@ -94,6 +94,14 @@ export function buildAntdThemeConfig(
|
|
|
94
94
|
return config;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
/** @deprecated Use {@link BuildAntdThemeConfig}. */
|
|
98
|
+
export function buildAntdThemeConfig(
|
|
99
|
+
styles: Partial<ComponentStyles> | undefined,
|
|
100
|
+
antdLib: unknown,
|
|
101
|
+
): Record<string, unknown> {
|
|
102
|
+
return BuildAntdThemeConfig(styles, antdLib);
|
|
103
|
+
}
|
|
104
|
+
|
|
97
105
|
/**
|
|
98
106
|
* Wraps a React element in loaded component libraries' theme providers so their
|
|
99
107
|
* built-in components inherit the MJ theme (including dark mode). Currently themes
|
|
@@ -106,7 +114,7 @@ export function buildAntdThemeConfig(
|
|
|
106
114
|
* this one (antd merges nested configs), so this is safe alongside component-level
|
|
107
115
|
* theming.
|
|
108
116
|
*/
|
|
109
|
-
export function
|
|
117
|
+
export function WrapWithLibraryThemeProviders(
|
|
110
118
|
React: { createElement: (type: unknown, props: unknown, ...children: unknown[]) => unknown },
|
|
111
119
|
element: unknown,
|
|
112
120
|
libraries: Record<string, unknown> | undefined,
|
|
@@ -115,13 +123,23 @@ export function wrapWithLibraryThemeProviders(
|
|
|
115
123
|
const antdLib = libraries?.['antd'];
|
|
116
124
|
if (!antdLib) return element;
|
|
117
125
|
|
|
118
|
-
const ConfigProvider =
|
|
126
|
+
const ConfigProvider = UnwrapLibraryComponent(antdLib, 'ConfigProvider');
|
|
119
127
|
if (!ConfigProvider) return element;
|
|
120
128
|
|
|
121
129
|
try {
|
|
122
|
-
return React.createElement(ConfigProvider, { theme:
|
|
130
|
+
return React.createElement(ConfigProvider, { theme: BuildAntdThemeConfig(styles, antdLib) }, element);
|
|
123
131
|
} catch {
|
|
124
132
|
// Never let theming wrap break rendering — fall back to the unwrapped element.
|
|
125
133
|
return element;
|
|
126
134
|
}
|
|
127
135
|
}
|
|
136
|
+
|
|
137
|
+
/** @deprecated Use {@link WrapWithLibraryThemeProviders}. */
|
|
138
|
+
export function wrapWithLibraryThemeProviders(
|
|
139
|
+
React: { createElement: (type: unknown, props: unknown, ...children: unknown[]) => unknown },
|
|
140
|
+
element: unknown,
|
|
141
|
+
libraries: Record<string, unknown> | undefined,
|
|
142
|
+
styles: Partial<ComponentStyles> | undefined,
|
|
143
|
+
): unknown {
|
|
144
|
+
return WrapWithLibraryThemeProviders(React, element, libraries, styles);
|
|
145
|
+
}
|
|
@@ -150,7 +150,10 @@ export function SetupStyles(): ComponentStyles {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
// Also export with the original name for backward compatibility
|
|
153
|
-
export const
|
|
153
|
+
export const CreateDefaultComponentStyles = SetupStyles;
|
|
154
|
+
|
|
155
|
+
/** @deprecated Use {@link CreateDefaultComponentStyles}. */
|
|
156
|
+
export const createDefaultComponentStyles = CreateDefaultComponentStyles;
|
|
154
157
|
|
|
155
158
|
/**
|
|
156
159
|
* The `--mj-*` semantic token → `ComponentStyles` mapping used by the theme bridge.
|
|
@@ -262,7 +262,7 @@ function coreUnwrapLogic(library: any, exportName: string, debug: boolean = fals
|
|
|
262
262
|
* @param debug - Whether to log debug information
|
|
263
263
|
* @returns The unwrapped export or undefined if not found
|
|
264
264
|
*/
|
|
265
|
-
export function
|
|
265
|
+
export function UnwrapLibraryComponent(library: any, exportName: string, debug: boolean = false): any {
|
|
266
266
|
try {
|
|
267
267
|
return coreUnwrapLogic(library, exportName, debug);
|
|
268
268
|
} catch (error: any) {
|
|
@@ -273,6 +273,11 @@ export function unwrapLibraryComponent(library: any, exportName: string, debug:
|
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
|
|
276
|
+
/** @deprecated Use {@link UnwrapLibraryComponent}. */
|
|
277
|
+
export function unwrapLibraryComponent(library: any, exportName: string, debug: boolean = false): any {
|
|
278
|
+
return UnwrapLibraryComponent(library, exportName, debug);
|
|
279
|
+
}
|
|
280
|
+
|
|
276
281
|
/**
|
|
277
282
|
* Unwraps multiple exports from a UMD library using varargs
|
|
278
283
|
* Works with any type of export: components, utilities, objects, functions, etc.
|
|
@@ -280,7 +285,7 @@ export function unwrapLibraryComponent(library: any, exportName: string, debug:
|
|
|
280
285
|
* @param exportNames - Export names to unwrap (e.g., 'Button', 'utils', 'writeFile')
|
|
281
286
|
* @returns Object with export names as keys and unwrapped values as values
|
|
282
287
|
*/
|
|
283
|
-
export function
|
|
288
|
+
export function UnwrapLibraryComponents(
|
|
284
289
|
library: any,
|
|
285
290
|
...exportNames: string[]
|
|
286
291
|
): Record<string, any> {
|
|
@@ -370,6 +375,14 @@ export function unwrapLibraryComponents(
|
|
|
370
375
|
return components;
|
|
371
376
|
}
|
|
372
377
|
|
|
378
|
+
/** @deprecated Use {@link UnwrapLibraryComponents}. */
|
|
379
|
+
export function unwrapLibraryComponents(
|
|
380
|
+
library: any,
|
|
381
|
+
...exportNames: string[]
|
|
382
|
+
): Record<string, any> {
|
|
383
|
+
return UnwrapLibraryComponents(library, ...exportNames);
|
|
384
|
+
}
|
|
385
|
+
|
|
373
386
|
/**
|
|
374
387
|
* Auto-detects and unwraps all components from a library
|
|
375
388
|
* Uses PascalCase detection to identify likely component exports
|
|
@@ -377,7 +390,7 @@ export function unwrapLibraryComponents(
|
|
|
377
390
|
* @param debug - Whether to log debug information
|
|
378
391
|
* @returns Object with all detected components
|
|
379
392
|
*/
|
|
380
|
-
export function
|
|
393
|
+
export function UnwrapAllLibraryComponents(library: any, debug: boolean = false): Record<string, any> {
|
|
381
394
|
const components: Record<string, any> = {};
|
|
382
395
|
|
|
383
396
|
// Handle simple function/class case
|
|
@@ -473,9 +486,23 @@ export function unwrapAllLibraryComponents(library: any, debug: boolean = false)
|
|
|
473
486
|
return components;
|
|
474
487
|
}
|
|
475
488
|
|
|
489
|
+
/** @deprecated Use {@link UnwrapAllLibraryComponents}. */
|
|
490
|
+
export function unwrapAllLibraryComponents(library: any, debug: boolean = false): Record<string, any> {
|
|
491
|
+
return UnwrapAllLibraryComponents(library, debug);
|
|
492
|
+
}
|
|
493
|
+
|
|
476
494
|
// Legacy exports for backward compatibility
|
|
477
|
-
export const
|
|
478
|
-
|
|
479
|
-
|
|
495
|
+
export const UnwrapComponent = UnwrapLibraryComponent;
|
|
496
|
+
|
|
497
|
+
/** @deprecated Use {@link UnwrapComponent}. */
|
|
498
|
+
export const unwrapComponent = UnwrapComponent;
|
|
499
|
+
export const UnwrapComponents = (library: any, exportNames: string[], debug: boolean = false) => {
|
|
500
|
+
return UnwrapLibraryComponents(library, ...exportNames, debug as any);
|
|
480
501
|
};
|
|
481
|
-
|
|
502
|
+
|
|
503
|
+
/** @deprecated Use {@link UnwrapComponents}. */
|
|
504
|
+
export const unwrapComponents = UnwrapComponents;
|
|
505
|
+
export const UnwrapAllComponents = UnwrapAllLibraryComponents;
|
|
506
|
+
|
|
507
|
+
/** @deprecated Use {@link UnwrapAllComponents}. */
|
|
508
|
+
export const unwrapAllComponents = UnwrapAllComponents;
|
|
@@ -44,7 +44,7 @@ function getReactDOMFallbackUrl(debug: boolean = false): string {
|
|
|
44
44
|
* Get the core runtime libraries configuration
|
|
45
45
|
* @param debug Whether to use development builds for better error messages
|
|
46
46
|
*/
|
|
47
|
-
export function
|
|
47
|
+
export function GetCoreRuntimeLibraries(debug: boolean = false): ExternalLibraryConfig[] {
|
|
48
48
|
return [
|
|
49
49
|
{
|
|
50
50
|
id: 'react',
|
|
@@ -91,10 +91,20 @@ export function getCoreRuntimeLibraries(debug: boolean = false): ExternalLibrary
|
|
|
91
91
|
];
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
/** @deprecated Use {@link GetCoreRuntimeLibraries}. */
|
|
95
|
+
export function getCoreRuntimeLibraries(debug: boolean = false): ExternalLibraryConfig[] {
|
|
96
|
+
return GetCoreRuntimeLibraries(debug);
|
|
97
|
+
}
|
|
98
|
+
|
|
94
99
|
/**
|
|
95
100
|
* Check if a library ID is a core runtime library
|
|
96
101
|
*/
|
|
97
|
-
export function
|
|
98
|
-
const coreLibraries =
|
|
102
|
+
export function IsCoreRuntimeLibrary(libraryId: string): boolean {
|
|
103
|
+
const coreLibraries = GetCoreRuntimeLibraries();
|
|
99
104
|
return coreLibraries.some((lib: ExternalLibraryConfig) => lib.id === libraryId);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** @deprecated Use {@link IsCoreRuntimeLibrary}. */
|
|
108
|
+
export function isCoreRuntimeLibrary(libraryId: string): boolean {
|
|
109
|
+
return IsCoreRuntimeLibrary(libraryId);
|
|
100
110
|
}
|
|
@@ -86,7 +86,7 @@ function coerceToCompositeKey(key: EntityRecordKeyInput): CompositeKey | null {
|
|
|
86
86
|
* the global default, so a host on a non-default provider resolves against its own server.
|
|
87
87
|
* @param contextUser The acting user, for server-side callers.
|
|
88
88
|
*/
|
|
89
|
-
export async function
|
|
89
|
+
export async function ResolveEntityRecordKey(
|
|
90
90
|
entityName: string,
|
|
91
91
|
key: EntityRecordKeyInput,
|
|
92
92
|
provider: IMetadataProvider,
|
|
@@ -140,3 +140,13 @@ export async function resolveEntityRecordKey(
|
|
|
140
140
|
entity.PrimaryKeys.map((pk) => ({ FieldName: pk.Name, Value: row[pk.Name] }) as KeyValuePair)
|
|
141
141
|
);
|
|
142
142
|
}
|
|
143
|
+
|
|
144
|
+
/** @deprecated Use {@link ResolveEntityRecordKey}. */
|
|
145
|
+
export async function resolveEntityRecordKey(
|
|
146
|
+
entityName: string,
|
|
147
|
+
key: EntityRecordKeyInput,
|
|
148
|
+
provider: IMetadataProvider,
|
|
149
|
+
contextUser?: UserInfo
|
|
150
|
+
): Promise<CompositeKey | null> {
|
|
151
|
+
return ResolveEntityRecordKey(entityName, key, provider, contextUser);
|
|
152
|
+
}
|