@memberjunction/react-runtime 2.95.0 → 2.96.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.
Files changed (35) hide show
  1. package/.turbo/turbo-build.log +8 -8
  2. package/CHANGELOG.md +18 -0
  3. package/dist/compiler/component-compiler.d.ts.map +1 -1
  4. package/dist/compiler/component-compiler.js +57 -13
  5. package/dist/compiler/component-compiler.js.map +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +4 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/registry/component-registry-service.d.ts.map +1 -1
  11. package/dist/registry/component-registry-service.js +14 -6
  12. package/dist/registry/component-registry-service.js.map +1 -1
  13. package/dist/registry/component-resolver.d.ts.map +1 -1
  14. package/dist/registry/component-resolver.js +75 -35
  15. package/dist/registry/component-resolver.js.map +1 -1
  16. package/dist/runtime.umd.js +1 -1
  17. package/dist/utilities/core-libraries.d.ts +1 -2
  18. package/dist/utilities/core-libraries.d.ts.map +1 -1
  19. package/dist/utilities/core-libraries.js +55 -45
  20. package/dist/utilities/core-libraries.js.map +1 -1
  21. package/dist/utilities/library-dependency-resolver.d.ts.map +1 -1
  22. package/dist/utilities/library-dependency-resolver.js +26 -2
  23. package/dist/utilities/library-dependency-resolver.js.map +1 -1
  24. package/dist/utilities/library-loader.d.ts +4 -2
  25. package/dist/utilities/library-loader.d.ts.map +1 -1
  26. package/dist/utilities/library-loader.js +4 -4
  27. package/dist/utilities/library-loader.js.map +1 -1
  28. package/package.json +5 -5
  29. package/src/compiler/component-compiler.ts +70 -14
  30. package/src/index.ts +5 -0
  31. package/src/registry/component-registry-service.ts +15 -6
  32. package/src/registry/component-resolver.ts +75 -35
  33. package/src/utilities/core-libraries.ts +60 -46
  34. package/src/utilities/library-dependency-resolver.ts +31 -2
  35. package/src/utilities/library-loader.ts +6 -4
@@ -1,61 +1,75 @@
1
1
  import { ExternalLibraryConfig } from '../types/library-config';
2
2
 
3
3
  /**
4
- * Core runtime libraries required for the React runtime to function.
5
- * These are not plugin libraries and are always loaded.
4
+ * Get the React CDN URL based on debug mode
6
5
  */
7
- export const CORE_RUNTIME_LIBRARIES: ExternalLibraryConfig[] = [
8
- {
9
- id: 'react',
10
- name: 'react',
11
- displayName: 'React',
12
- category: 'runtime',
13
- globalVariable: 'React',
14
- version: '18.2.0',
15
- cdnUrl: 'https://unpkg.com/react@18.2.0/umd/react.production.min.js',
16
- description: 'React core library',
17
- isEnabled: true,
18
- isCore: true,
19
- isRuntimeOnly: true
20
- },
21
- {
22
- id: 'react-dom',
23
- name: 'react-dom',
24
- displayName: 'ReactDOM',
25
- category: 'runtime',
26
- globalVariable: 'ReactDOM',
27
- version: '18.2.0',
28
- cdnUrl: 'https://unpkg.com/react-dom@18.2.0/umd/react-dom.production.min.js',
29
- description: 'React DOM library',
30
- isEnabled: true,
31
- isCore: true,
32
- isRuntimeOnly: true
33
- },
34
- {
35
- id: 'babel-standalone',
36
- name: '@babel/standalone',
37
- displayName: 'Babel Standalone',
38
- category: 'runtime',
39
- globalVariable: 'Babel',
40
- version: '7.24.4',
41
- cdnUrl: 'https://unpkg.com/@babel/standalone@7.24.4/babel.min.js',
42
- description: 'Babel compiler for JSX transformation',
43
- isEnabled: true,
44
- isCore: true,
45
- isRuntimeOnly: true
46
- }
47
- ];
6
+ function getReactUrl(debug: boolean = false): string {
7
+ return debug
8
+ ? 'https://unpkg.com/react@18.2.0/umd/react.development.js'
9
+ : 'https://unpkg.com/react@18.2.0/umd/react.production.min.js';
10
+ }
11
+
12
+ /**
13
+ * Get the ReactDOM CDN URL based on debug mode
14
+ */
15
+ function getReactDOMUrl(debug: boolean = false): string {
16
+ return debug
17
+ ? 'https://unpkg.com/react-dom@18.2.0/umd/react-dom.development.js'
18
+ : 'https://unpkg.com/react-dom@18.2.0/umd/react-dom.production.min.js';
19
+ }
48
20
 
49
21
  /**
50
22
  * Get the core runtime libraries configuration
23
+ * @param debug Whether to use development builds for better error messages
51
24
  */
52
- export function getCoreRuntimeLibraries(): ExternalLibraryConfig[] {
53
- return CORE_RUNTIME_LIBRARIES;
25
+ export function getCoreRuntimeLibraries(debug: boolean = false): ExternalLibraryConfig[] {
26
+ return [
27
+ {
28
+ id: 'react',
29
+ name: 'react',
30
+ displayName: 'React',
31
+ category: 'runtime',
32
+ globalVariable: 'React',
33
+ version: '18.2.0',
34
+ cdnUrl: getReactUrl(debug),
35
+ description: 'React core library',
36
+ isEnabled: true,
37
+ isCore: true,
38
+ isRuntimeOnly: true
39
+ },
40
+ {
41
+ id: 'react-dom',
42
+ name: 'react-dom',
43
+ displayName: 'ReactDOM',
44
+ category: 'runtime',
45
+ globalVariable: 'ReactDOM',
46
+ version: '18.2.0',
47
+ cdnUrl: getReactDOMUrl(debug),
48
+ description: 'React DOM library',
49
+ isEnabled: true,
50
+ isCore: true,
51
+ isRuntimeOnly: true
52
+ },
53
+ {
54
+ id: 'babel-standalone',
55
+ name: '@babel/standalone',
56
+ displayName: 'Babel Standalone',
57
+ category: 'runtime',
58
+ globalVariable: 'Babel',
59
+ version: '7.24.4',
60
+ cdnUrl: 'https://unpkg.com/@babel/standalone@7.24.4/babel.min.js',
61
+ description: 'Babel compiler for JSX transformation',
62
+ isEnabled: true,
63
+ isCore: true,
64
+ isRuntimeOnly: true
65
+ }
66
+ ];
54
67
  }
55
68
 
56
69
  /**
57
70
  * Check if a library ID is a core runtime library
58
71
  */
59
72
  export function isCoreRuntimeLibrary(libraryId: string): boolean {
60
- return CORE_RUNTIME_LIBRARIES.some(lib => lib.id === libraryId);
73
+ const coreLibraries = getCoreRuntimeLibraries();
74
+ return coreLibraries.some((lib: ExternalLibraryConfig) => lib.id === libraryId);
61
75
  }
@@ -420,15 +420,33 @@ export class LibraryDependencyResolver {
420
420
  const errors: string[] = [];
421
421
  const warnings: string[] = [];
422
422
 
423
+ // Filter out null, undefined, and non-string values from requestedLibs
424
+ const validRequestedLibs = requestedLibs.filter(lib => {
425
+ if (!lib || typeof lib !== 'string') {
426
+ const warning = `Invalid library name: ${lib} (type: ${typeof lib})`;
427
+ warnings.push(warning);
428
+ if (this.debug || options?.debug) {
429
+ console.warn(`⚠️ ${warning}`);
430
+ }
431
+ return false;
432
+ }
433
+ return true;
434
+ });
435
+
423
436
  if (this.debug || options?.debug) {
424
437
  console.log('🔍 Getting load order for requested libraries:');
425
- console.log(' 📝 Requested:', requestedLibs);
438
+ console.log(' 📝 Requested (raw):', requestedLibs);
439
+ console.log(' 📝 Requested (valid):', validRequestedLibs);
426
440
  console.log(' 📚 Total available libraries:', allLibs.length);
427
441
  }
428
442
 
429
443
  // Build a map for quick lookup (case-insensitive)
430
444
  const libMap = new Map<string, ComponentLibraryEntity[]>();
431
445
  for (const lib of allLibs) {
446
+ if (!lib?.Name) {
447
+ warnings.push(`Library with missing name found in available libraries`);
448
+ continue;
449
+ }
432
450
  const key = lib.Name.toLowerCase();
433
451
  if (!libMap.has(key)) {
434
452
  libMap.set(key, []);
@@ -438,7 +456,7 @@ export class LibraryDependencyResolver {
438
456
 
439
457
  // Collect all libraries needed (requested + their dependencies)
440
458
  const needed = new Set<string>();
441
- const toProcess = [...requestedLibs];
459
+ const toProcess = [...validRequestedLibs];
442
460
  const processed = new Set<string>();
443
461
  const versionRequirements = new Map<string, VersionRequirement[]>();
444
462
  let depth = 0;
@@ -446,6 +464,17 @@ export class LibraryDependencyResolver {
446
464
 
447
465
  while (toProcess.length > 0 && depth < maxDepth) {
448
466
  const current = toProcess.shift()!;
467
+
468
+ // Extra safety check for null/undefined
469
+ if (!current || typeof current !== 'string') {
470
+ const warning = `Unexpected invalid library name during processing: ${current}`;
471
+ warnings.push(warning);
472
+ if (this.debug || options?.debug) {
473
+ console.warn(`⚠️ ${warning}`);
474
+ }
475
+ continue;
476
+ }
477
+
449
478
  if (processed.has(current)) continue;
450
479
 
451
480
  processed.add(current);
@@ -65,10 +65,12 @@ export class LibraryLoader {
65
65
  * This is the main method that should be used by test harness and Angular wrapper
66
66
  * @param config Optional full library configuration to replace the default
67
67
  * @param additionalLibraries Optional additional libraries to merge with the configuration
68
+ * @param options Optional options including debug mode flag
68
69
  */
69
70
  static async loadAllLibraries(
70
71
  config?: LibraryConfiguration,
71
- additionalLibraries?: ExternalLibraryConfig[]
72
+ additionalLibraries?: ExternalLibraryConfig[],
73
+ options?: { debug?: boolean }
72
74
  ): Promise<LibraryLoadResult> {
73
75
  if (config) {
74
76
  StandardLibraryManager.setConfiguration(config);
@@ -87,15 +89,15 @@ export class LibraryLoader {
87
89
  StandardLibraryManager.setConfiguration(mergedConfig);
88
90
  }
89
91
 
90
- return this.loadLibrariesFromConfig();
92
+ return this.loadLibrariesFromConfig(undefined, options?.debug);
91
93
  }
92
94
 
93
95
  /**
94
96
  * Load libraries based on the current configuration
95
97
  */
96
- static async loadLibrariesFromConfig(options?: ConfigLoadOptions): Promise<LibraryLoadResult> {
98
+ static async loadLibrariesFromConfig(options?: ConfigLoadOptions, debug?: boolean): Promise<LibraryLoadResult> {
97
99
  // Always load core runtime libraries first
98
- const coreLibraries = getCoreRuntimeLibraries();
100
+ const coreLibraries = getCoreRuntimeLibraries(debug);
99
101
  const corePromises = coreLibraries.map(lib =>
100
102
  this.loadScript(lib.cdnUrl, lib.globalVariable)
101
103
  );