@memberjunction/react-runtime 2.98.0 → 2.100.0
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 +15 -20
- package/CHANGELOG.md +26 -0
- package/README.md +171 -1
- package/dist/compiler/component-compiler.d.ts.map +1 -1
- package/dist/compiler/component-compiler.js +59 -8
- package/dist/compiler/component-compiler.js.map +1 -1
- package/dist/component-manager/component-manager.d.ts +39 -0
- package/dist/component-manager/component-manager.d.ts.map +1 -0
- package/dist/component-manager/component-manager.js +474 -0
- package/dist/component-manager/component-manager.js.map +1 -0
- package/dist/component-manager/index.d.ts +3 -0
- package/dist/component-manager/index.d.ts.map +1 -0
- package/dist/component-manager/index.js +6 -0
- package/dist/component-manager/index.js.map +1 -0
- package/dist/component-manager/types.d.ts +62 -0
- package/dist/component-manager/types.d.ts.map +1 -0
- package/dist/component-manager/types.js +3 -0
- package/dist/component-manager/types.js.map +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/dist/registry/component-registry-service.d.ts +16 -1
- package/dist/registry/component-registry-service.d.ts.map +1 -1
- package/dist/registry/component-registry-service.js +212 -10
- package/dist/registry/component-registry-service.js.map +1 -1
- package/dist/registry/component-registry.d.ts +1 -1
- package/dist/registry/component-registry.d.ts.map +1 -1
- package/dist/registry/component-registry.js.map +1 -1
- package/dist/registry/component-resolver.d.ts.map +1 -1
- package/dist/registry/component-resolver.js +122 -52
- package/dist/registry/component-resolver.js.map +1 -1
- package/dist/registry/index.d.ts +1 -1
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js.map +1 -1
- package/dist/runtime/component-hierarchy.d.ts +4 -0
- package/dist/runtime/component-hierarchy.d.ts.map +1 -1
- package/dist/runtime/component-hierarchy.js +127 -12
- package/dist/runtime/component-hierarchy.js.map +1 -1
- package/dist/runtime.umd.js +535 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/component-unwrapper.d.ts +7 -0
- package/dist/utilities/component-unwrapper.d.ts.map +1 -0
- package/dist/utilities/component-unwrapper.js +369 -0
- package/dist/utilities/component-unwrapper.js.map +1 -0
- package/dist/utilities/index.d.ts +1 -0
- package/dist/utilities/index.d.ts.map +1 -1
- package/dist/utilities/index.js +1 -0
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/library-loader.d.ts +3 -0
- package/dist/utilities/library-loader.d.ts.map +1 -1
- package/dist/utilities/library-loader.js +101 -17
- package/dist/utilities/library-loader.js.map +1 -1
- package/examples/component-registry-integration.ts +191 -0
- package/package.json +6 -5
- package/src/compiler/component-compiler.ts +101 -23
- package/src/component-manager/component-manager.ts +736 -0
- package/src/component-manager/index.ts +13 -0
- package/src/component-manager/types.ts +204 -0
- package/src/index.ts +37 -1
- package/src/registry/component-registry-service.ts +315 -18
- package/src/registry/component-registry.ts +1 -1
- package/src/registry/component-resolver.ts +159 -67
- package/src/registry/index.ts +1 -1
- package/src/runtime/component-hierarchy.ts +124 -13
- package/src/types/index.ts +2 -0
- package/src/utilities/component-unwrapper.ts +481 -0
- package/src/utilities/index.ts +2 -1
- package/src/utilities/library-loader.ts +155 -22
|
@@ -59,6 +59,11 @@ export class LibraryLoader {
|
|
|
59
59
|
private static loadedResources = new Map<string, LoadedResource>();
|
|
60
60
|
private static loadedLibraryStates = new Map<string, LoadedLibraryState>();
|
|
61
61
|
private static dependencyResolver = new LibraryDependencyResolver({ debug: false });
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Enable progressive delay for library initialization (useful for test harness)
|
|
65
|
+
*/
|
|
66
|
+
public static enableProgressiveDelay: boolean = false;
|
|
62
67
|
|
|
63
68
|
/**
|
|
64
69
|
* Load all standard libraries (core + UI + CSS)
|
|
@@ -255,32 +260,44 @@ export class LibraryLoader {
|
|
|
255
260
|
script.removeEventListener('error', onError);
|
|
256
261
|
};
|
|
257
262
|
|
|
258
|
-
const onLoad = () => {
|
|
263
|
+
const onLoad = async () => {
|
|
259
264
|
cleanup();
|
|
260
|
-
|
|
261
|
-
if
|
|
262
|
-
|
|
263
|
-
|
|
265
|
+
|
|
266
|
+
// Use progressive delay if enabled, otherwise use original behavior
|
|
267
|
+
if (LibraryLoader.enableProgressiveDelay) {
|
|
268
|
+
try {
|
|
269
|
+
const global = await LibraryLoader.waitForGlobalVariable(globalName, url, debug);
|
|
270
|
+
resolve(global);
|
|
271
|
+
} catch (error) {
|
|
272
|
+
reject(error);
|
|
264
273
|
}
|
|
265
|
-
resolve(global);
|
|
266
274
|
} else {
|
|
267
|
-
//
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
()
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
+
// Original behavior
|
|
276
|
+
const global = (window as any)[globalName];
|
|
277
|
+
if (global) {
|
|
278
|
+
if (debug) {
|
|
279
|
+
console.log(`✅ Library '${globalName}' loaded successfully from ${url}`);
|
|
280
|
+
}
|
|
281
|
+
resolve(global);
|
|
282
|
+
} else {
|
|
283
|
+
// Some libraries may take a moment to initialize
|
|
284
|
+
const timeoutId = resourceManager.setTimeout(
|
|
285
|
+
LIBRARY_LOADER_COMPONENT_ID,
|
|
286
|
+
() => {
|
|
287
|
+
const delayedGlobal = (window as any)[globalName];
|
|
288
|
+
if (delayedGlobal) {
|
|
289
|
+
if (debug) {
|
|
290
|
+
console.log(`✅ Library '${globalName}' loaded successfully (delayed initialization)`);
|
|
291
|
+
}
|
|
292
|
+
resolve(delayedGlobal);
|
|
293
|
+
} else {
|
|
294
|
+
reject(new Error(`${globalName} not found after script load`));
|
|
275
295
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
100,
|
|
282
|
-
{ url, globalName }
|
|
283
|
-
);
|
|
296
|
+
},
|
|
297
|
+
100,
|
|
298
|
+
{ url, globalName }
|
|
299
|
+
);
|
|
300
|
+
}
|
|
284
301
|
}
|
|
285
302
|
};
|
|
286
303
|
|
|
@@ -309,6 +326,100 @@ export class LibraryLoader {
|
|
|
309
326
|
return promise;
|
|
310
327
|
}
|
|
311
328
|
|
|
329
|
+
/**
|
|
330
|
+
* Check if a library global variable is properly initialized
|
|
331
|
+
* Generic check that works for any library
|
|
332
|
+
*/
|
|
333
|
+
private static isLibraryReady(globalVariable: any): boolean {
|
|
334
|
+
if (!globalVariable) {
|
|
335
|
+
return false;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// For functions, they're ready immediately
|
|
339
|
+
if (typeof globalVariable === 'function') {
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// For objects, check if they have properties (not an empty object)
|
|
344
|
+
if (typeof globalVariable === 'object') {
|
|
345
|
+
// Check for non-empty object with enumerable properties
|
|
346
|
+
const keys = Object.keys(globalVariable);
|
|
347
|
+
// Some libraries might have only non-enumerable properties,
|
|
348
|
+
// so also check for common indicators of initialization
|
|
349
|
+
return keys.length > 0 ||
|
|
350
|
+
Object.getOwnPropertyNames(globalVariable).length > 1 || // > 1 to exclude just constructor
|
|
351
|
+
globalVariable.constructor !== Object; // Has a custom constructor
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// For other types (string, number, etc.), consider them ready
|
|
355
|
+
return true;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Wait for a global variable to be available with progressive delays
|
|
360
|
+
* @param globalName The name of the global variable to wait for
|
|
361
|
+
* @param url The URL of the script (for debugging)
|
|
362
|
+
* @param debug Whether to log debug information
|
|
363
|
+
* @returns The global variable once it's available
|
|
364
|
+
*/
|
|
365
|
+
private static async waitForGlobalVariable(
|
|
366
|
+
globalName: string,
|
|
367
|
+
url: string,
|
|
368
|
+
debug: boolean = false
|
|
369
|
+
): Promise<any> {
|
|
370
|
+
const delays = [0, 100, 200, 300, 400]; // Total: 1000ms max delay
|
|
371
|
+
const maxAttempts = delays.length;
|
|
372
|
+
let totalDelay = 0;
|
|
373
|
+
|
|
374
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
375
|
+
// Wait for the specified delay (0ms on first attempt)
|
|
376
|
+
if (attempt > 0) {
|
|
377
|
+
const delay = delays[attempt];
|
|
378
|
+
if (debug) {
|
|
379
|
+
console.log(`⏳ Waiting ${delay}ms for ${globalName} to initialize (attempt ${attempt + 1}/${maxAttempts})...`);
|
|
380
|
+
}
|
|
381
|
+
await new Promise(resolve => {
|
|
382
|
+
resourceManager.setTimeout(
|
|
383
|
+
LIBRARY_LOADER_COMPONENT_ID,
|
|
384
|
+
() => resolve(undefined),
|
|
385
|
+
delay,
|
|
386
|
+
{ globalName, attempt }
|
|
387
|
+
);
|
|
388
|
+
});
|
|
389
|
+
totalDelay += delay;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// Check if the global variable exists
|
|
393
|
+
const global = (window as any)[globalName];
|
|
394
|
+
if (global) {
|
|
395
|
+
// Use generic library readiness check
|
|
396
|
+
const isReady = this.isLibraryReady(global);
|
|
397
|
+
|
|
398
|
+
if (isReady) {
|
|
399
|
+
if (debug) {
|
|
400
|
+
if (totalDelay > 0) {
|
|
401
|
+
console.log(`✅ ${globalName} ready after ${totalDelay}ms delay`);
|
|
402
|
+
} else {
|
|
403
|
+
console.log(`✅ Library '${globalName}' loaded successfully from ${url}`);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
return global;
|
|
407
|
+
} else if (debug && attempt < maxAttempts - 1) {
|
|
408
|
+
console.log(`🔄 ${globalName} exists but not fully initialized, will retry...`);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// Final check after all attempts
|
|
414
|
+
const finalGlobal = (window as any)[globalName];
|
|
415
|
+
if (finalGlobal) {
|
|
416
|
+
console.warn(`⚠️ ${globalName} loaded but may not be fully initialized after ${totalDelay}ms`);
|
|
417
|
+
return finalGlobal;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
throw new Error(`${globalName} not found after script load and ${totalDelay}ms delay`);
|
|
421
|
+
}
|
|
422
|
+
|
|
312
423
|
/**
|
|
313
424
|
* Load CSS from URL
|
|
314
425
|
*/
|
|
@@ -476,6 +587,17 @@ export class LibraryLoader {
|
|
|
476
587
|
continue;
|
|
477
588
|
}
|
|
478
589
|
|
|
590
|
+
// Check library status
|
|
591
|
+
if (library.Status) {
|
|
592
|
+
if (library.Status === 'Disabled') {
|
|
593
|
+
console.error(`🚫 ERROR: Library '${library.Name}' is DISABLED and should not be used`);
|
|
594
|
+
// Continue loading anyway per requirements
|
|
595
|
+
} else if (library.Status === 'Deprecated') {
|
|
596
|
+
console.warn(`⚠️ WARNING: Library '${library.Name}' is DEPRECATED. Consider using an alternative.`);
|
|
597
|
+
}
|
|
598
|
+
// Active status is fine, no message needed
|
|
599
|
+
}
|
|
600
|
+
|
|
479
601
|
if (debug) {
|
|
480
602
|
console.log(`📥 Loading '${library.Name}@${library.Version}'`);
|
|
481
603
|
}
|
|
@@ -604,6 +726,17 @@ export class LibraryLoader {
|
|
|
604
726
|
continue;
|
|
605
727
|
}
|
|
606
728
|
|
|
729
|
+
// Check library status
|
|
730
|
+
if (library.Status) {
|
|
731
|
+
if (library.Status === 'Disabled') {
|
|
732
|
+
console.error(`🚫 ERROR: Library '${library.Name}' is DISABLED and should not be used`);
|
|
733
|
+
// Continue loading anyway per requirements
|
|
734
|
+
} else if (library.Status === 'Deprecated') {
|
|
735
|
+
console.warn(`⚠️ WARNING: Library '${library.Name}' is DEPRECATED. Consider using an alternative.`);
|
|
736
|
+
}
|
|
737
|
+
// Active status is fine, no message needed
|
|
738
|
+
}
|
|
739
|
+
|
|
607
740
|
if (debug) {
|
|
608
741
|
console.log(`📥 Loading '${library.Name}@${library.Version}'`);
|
|
609
742
|
}
|