@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
|
@@ -33,7 +33,7 @@ export class LibraryDependencyResolver {
|
|
|
33
33
|
* @param json - JSON string containing dependencies
|
|
34
34
|
* @returns Map of library name to version specification
|
|
35
35
|
*/
|
|
36
|
-
|
|
36
|
+
ParseDependencies(json: string | null): Map<string, string> {
|
|
37
37
|
const dependencies = new Map<string, string>();
|
|
38
38
|
|
|
39
39
|
if (!json || json.trim() === '') {
|
|
@@ -56,18 +56,23 @@ export class LibraryDependencyResolver {
|
|
|
56
56
|
return dependencies;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
/** @deprecated Use {@link ParseDependencies}. */
|
|
60
|
+
parseDependencies(json: string | null): Map<string, string> {
|
|
61
|
+
return this.ParseDependencies(json);
|
|
62
|
+
}
|
|
63
|
+
|
|
59
64
|
/**
|
|
60
65
|
* Build a dependency graph from a collection of libraries
|
|
61
66
|
* @param libraries - All available libraries
|
|
62
67
|
* @returns Dependency graph structure
|
|
63
68
|
*/
|
|
64
|
-
|
|
69
|
+
BuildDependencyGraph(libraries: MJComponentLibraryEntity[]): DependencyGraph {
|
|
65
70
|
const nodes = new Map<string, DependencyNode>();
|
|
66
71
|
const roots = new Set<string>();
|
|
67
72
|
|
|
68
73
|
// First pass: create nodes for all libraries
|
|
69
74
|
for (const library of libraries) {
|
|
70
|
-
const dependencies = this.
|
|
75
|
+
const dependencies = this.ParseDependencies(library.Dependencies);
|
|
71
76
|
nodes.set(library.Name, {
|
|
72
77
|
library,
|
|
73
78
|
dependencies,
|
|
@@ -95,12 +100,17 @@ export class LibraryDependencyResolver {
|
|
|
95
100
|
return { nodes, roots };
|
|
96
101
|
}
|
|
97
102
|
|
|
103
|
+
/** @deprecated Use {@link BuildDependencyGraph}. */
|
|
104
|
+
buildDependencyGraph(libraries: MJComponentLibraryEntity[]): DependencyGraph {
|
|
105
|
+
return this.BuildDependencyGraph(libraries);
|
|
106
|
+
}
|
|
107
|
+
|
|
98
108
|
/**
|
|
99
109
|
* Detect circular dependencies in the graph
|
|
100
110
|
* @param graph - Dependency graph
|
|
101
111
|
* @returns Array of cycles found
|
|
102
112
|
*/
|
|
103
|
-
|
|
113
|
+
DetectCycles(graph: DependencyGraph): string[][] {
|
|
104
114
|
const cycles: string[][] = [];
|
|
105
115
|
const visited = new Set<string>();
|
|
106
116
|
const recursionStack = new Set<string>();
|
|
@@ -139,12 +149,17 @@ export class LibraryDependencyResolver {
|
|
|
139
149
|
return cycles;
|
|
140
150
|
}
|
|
141
151
|
|
|
152
|
+
/** @deprecated Use {@link DetectCycles}. */
|
|
153
|
+
detectCycles(graph: DependencyGraph): string[][] {
|
|
154
|
+
return this.DetectCycles(graph);
|
|
155
|
+
}
|
|
156
|
+
|
|
142
157
|
/**
|
|
143
158
|
* Perform topological sort to determine load order
|
|
144
159
|
* @param graph - Dependency graph
|
|
145
160
|
* @returns Sorted array of libraries to load in order
|
|
146
161
|
*/
|
|
147
|
-
|
|
162
|
+
TopologicalSort(graph: DependencyGraph): MJComponentLibraryEntity[] {
|
|
148
163
|
const result: MJComponentLibraryEntity[] = [];
|
|
149
164
|
const visited = new Set<string>();
|
|
150
165
|
const tempMarked = new Set<string>();
|
|
@@ -190,6 +205,11 @@ export class LibraryDependencyResolver {
|
|
|
190
205
|
return result;
|
|
191
206
|
}
|
|
192
207
|
|
|
208
|
+
/** @deprecated Use {@link TopologicalSort}. */
|
|
209
|
+
topologicalSort(graph: DependencyGraph): MJComponentLibraryEntity[] {
|
|
210
|
+
return this.TopologicalSort(graph);
|
|
211
|
+
}
|
|
212
|
+
|
|
193
213
|
/**
|
|
194
214
|
* Parse a semver version string
|
|
195
215
|
* @param version - Version string (e.g., "1.2.3")
|
|
@@ -332,7 +352,7 @@ export class LibraryDependencyResolver {
|
|
|
332
352
|
* @param availableLibraries - All available libraries to choose from
|
|
333
353
|
* @returns Resolved version information
|
|
334
354
|
*/
|
|
335
|
-
|
|
355
|
+
ResolveVersionConflicts(
|
|
336
356
|
requirements: VersionRequirement[],
|
|
337
357
|
availableLibraries: MJComponentLibraryEntity[]
|
|
338
358
|
): ResolvedVersion {
|
|
@@ -405,6 +425,14 @@ export class LibraryDependencyResolver {
|
|
|
405
425
|
};
|
|
406
426
|
}
|
|
407
427
|
|
|
428
|
+
/** @deprecated Use {@link ResolveVersionConflicts}. */
|
|
429
|
+
resolveVersionConflicts(
|
|
430
|
+
requirements: VersionRequirement[],
|
|
431
|
+
availableLibraries: MJComponentLibraryEntity[]
|
|
432
|
+
): ResolvedVersion {
|
|
433
|
+
return this.ResolveVersionConflicts(requirements, availableLibraries);
|
|
434
|
+
}
|
|
435
|
+
|
|
408
436
|
/**
|
|
409
437
|
* Get the load order for a set of requested libraries
|
|
410
438
|
* @param requestedLibs - Library names requested
|
|
@@ -412,7 +440,7 @@ export class LibraryDependencyResolver {
|
|
|
412
440
|
* @param options - Resolution options
|
|
413
441
|
* @returns Load order result
|
|
414
442
|
*/
|
|
415
|
-
|
|
443
|
+
GetLoadOrder(
|
|
416
444
|
requestedLibs: string[],
|
|
417
445
|
allLibs: MJComponentLibraryEntity[],
|
|
418
446
|
options?: DependencyResolutionOptions
|
|
@@ -492,7 +520,7 @@ export class LibraryDependencyResolver {
|
|
|
492
520
|
|
|
493
521
|
// For now, use the first version found (should be resolved properly)
|
|
494
522
|
const lib = libVersions[0];
|
|
495
|
-
const deps = this.
|
|
523
|
+
const deps = this.ParseDependencies(lib.Dependencies);
|
|
496
524
|
|
|
497
525
|
if ((this.debug || options?.debug) && deps.size > 0) {
|
|
498
526
|
console.log(` 📌 ${current} requires:`, Array.from(deps.entries()));
|
|
@@ -537,7 +565,7 @@ export class LibraryDependencyResolver {
|
|
|
537
565
|
|
|
538
566
|
if (requirements.length > 0) {
|
|
539
567
|
try {
|
|
540
|
-
const resolved = this.
|
|
568
|
+
const resolved = this.ResolveVersionConflicts(requirements, versions);
|
|
541
569
|
const selectedLib = versions.find(lib => lib.Version === resolved.version);
|
|
542
570
|
if (selectedLib) {
|
|
543
571
|
resolvedLibraries.push(selectedLib);
|
|
@@ -557,10 +585,10 @@ export class LibraryDependencyResolver {
|
|
|
557
585
|
}
|
|
558
586
|
|
|
559
587
|
// Build dependency graph with resolved libraries
|
|
560
|
-
const graph = this.
|
|
588
|
+
const graph = this.BuildDependencyGraph(resolvedLibraries);
|
|
561
589
|
|
|
562
590
|
// Check for cycles
|
|
563
|
-
const cycles = this.
|
|
591
|
+
const cycles = this.DetectCycles(graph);
|
|
564
592
|
if (cycles.length > 0) {
|
|
565
593
|
errors.push(`Circular dependencies detected: ${cycles.map(c => c.join(' -> ')).join(', ')}`);
|
|
566
594
|
return {
|
|
@@ -572,7 +600,7 @@ export class LibraryDependencyResolver {
|
|
|
572
600
|
}
|
|
573
601
|
|
|
574
602
|
// Perform topological sort
|
|
575
|
-
const sorted = this.
|
|
603
|
+
const sorted = this.TopologicalSort(graph);
|
|
576
604
|
|
|
577
605
|
if (this.debug || options?.debug) {
|
|
578
606
|
console.log('✅ Load order determined:', sorted.map(lib => `${lib.Name}@${lib.Version}`));
|
|
@@ -586,13 +614,27 @@ export class LibraryDependencyResolver {
|
|
|
586
614
|
};
|
|
587
615
|
}
|
|
588
616
|
|
|
617
|
+
/** @deprecated Use {@link GetLoadOrder}. */
|
|
618
|
+
getLoadOrder(
|
|
619
|
+
requestedLibs: string[],
|
|
620
|
+
allLibs: MJComponentLibraryEntity[],
|
|
621
|
+
options?: DependencyResolutionOptions
|
|
622
|
+
): LoadOrderResult {
|
|
623
|
+
return this.GetLoadOrder(requestedLibs, allLibs, options);
|
|
624
|
+
}
|
|
625
|
+
|
|
589
626
|
/**
|
|
590
627
|
* Get direct dependencies of a library
|
|
591
628
|
* @param library - Library to get dependencies for
|
|
592
629
|
* @returns Map of dependency names to version specs
|
|
593
630
|
*/
|
|
631
|
+
GetDirectDependencies(library: MJComponentLibraryEntity): Map<string, string> {
|
|
632
|
+
return this.ParseDependencies(library.Dependencies);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/** @deprecated Use {@link GetDirectDependencies}. */
|
|
594
636
|
getDirectDependencies(library: MJComponentLibraryEntity): Map<string, string> {
|
|
595
|
-
return this.
|
|
637
|
+
return this.GetDirectDependencies(library);
|
|
596
638
|
}
|
|
597
639
|
|
|
598
640
|
/**
|
|
@@ -602,7 +644,7 @@ export class LibraryDependencyResolver {
|
|
|
602
644
|
* @param maxDepth - Maximum depth to traverse
|
|
603
645
|
* @returns Set of all dependency names (including transitive)
|
|
604
646
|
*/
|
|
605
|
-
|
|
647
|
+
GetTransitiveDependencies(
|
|
606
648
|
libraryName: string,
|
|
607
649
|
allLibs: MJComponentLibraryEntity[],
|
|
608
650
|
maxDepth: number = 10
|
|
@@ -626,7 +668,7 @@ export class LibraryDependencyResolver {
|
|
|
626
668
|
const lib = libMap.get(current.toLowerCase());
|
|
627
669
|
if (!lib) continue;
|
|
628
670
|
|
|
629
|
-
const deps = this.
|
|
671
|
+
const deps = this.ParseDependencies(lib.Dependencies);
|
|
630
672
|
for (const [depName] of deps) {
|
|
631
673
|
dependencies.add(depName);
|
|
632
674
|
if (!processed.has(depName)) {
|
|
@@ -639,4 +681,13 @@ export class LibraryDependencyResolver {
|
|
|
639
681
|
|
|
640
682
|
return dependencies;
|
|
641
683
|
}
|
|
684
|
+
|
|
685
|
+
/** @deprecated Use {@link GetTransitiveDependencies}. */
|
|
686
|
+
getTransitiveDependencies(
|
|
687
|
+
libraryName: string,
|
|
688
|
+
allLibs: MJComponentLibraryEntity[],
|
|
689
|
+
maxDepth: number = 10
|
|
690
|
+
): Set<string> {
|
|
691
|
+
return this.GetTransitiveDependencies(libraryName, allLibs, maxDepth);
|
|
692
|
+
}
|
|
642
693
|
}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
StandardLibraryManager
|
|
10
10
|
} from './standard-libraries';
|
|
11
11
|
import { LibraryConfiguration, ExternalLibraryConfig, LibraryLoadOptions as ConfigLoadOptions } from '../types/library-config';
|
|
12
|
-
import {
|
|
12
|
+
import { GetCoreRuntimeLibraries, IsCoreRuntimeLibrary } from './core-libraries';
|
|
13
13
|
import { resourceManager } from './resource-manager';
|
|
14
14
|
import { MJComponentLibraryEntity } from '@memberjunction/core-entities';
|
|
15
15
|
import { LibraryDependencyResolver } from './library-dependency-resolver';
|
|
@@ -63,7 +63,7 @@ export class LibraryLoader {
|
|
|
63
63
|
/**
|
|
64
64
|
* Enable progressive delay for library initialization (useful for test harness)
|
|
65
65
|
*/
|
|
66
|
-
public static enableProgressiveDelay: boolean = false;
|
|
66
|
+
public static enableProgressiveDelay: boolean = false; // case-violation-ok-legacy-back-compat: object literals are assigned to this class, so an accessor stub changes what they must supply
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* Inject `<link rel="preload" as="script">` tags for core runtime libraries
|
|
@@ -77,10 +77,10 @@ export class LibraryLoader {
|
|
|
77
77
|
*
|
|
78
78
|
* @param debug Whether to preload development builds (default: false = production)
|
|
79
79
|
*/
|
|
80
|
-
static
|
|
80
|
+
static PreloadCoreScripts(debug: boolean = false): void {
|
|
81
81
|
if (typeof document === 'undefined') return; // SSR guard
|
|
82
82
|
|
|
83
|
-
const coreLibraries =
|
|
83
|
+
const coreLibraries = GetCoreRuntimeLibraries(debug);
|
|
84
84
|
for (const lib of coreLibraries) {
|
|
85
85
|
// Skip if already preloaded or loaded
|
|
86
86
|
if (document.querySelector(`link[href="${lib.cdnUrl}"]`) ||
|
|
@@ -97,6 +97,11 @@ export class LibraryLoader {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
/** @deprecated Use {@link PreloadCoreScripts}. */
|
|
101
|
+
static preloadCoreScripts(debug: boolean = false): void {
|
|
102
|
+
return this.PreloadCoreScripts(debug);
|
|
103
|
+
}
|
|
104
|
+
|
|
100
105
|
/**
|
|
101
106
|
* Load all standard libraries (core + UI + CSS)
|
|
102
107
|
* This is the main method that should be used by test harness and Angular wrapper
|
|
@@ -104,7 +109,7 @@ export class LibraryLoader {
|
|
|
104
109
|
* @param additionalLibraries Optional additional libraries to merge with the configuration
|
|
105
110
|
* @param options Optional options including debug mode flag
|
|
106
111
|
*/
|
|
107
|
-
static async
|
|
112
|
+
static async LoadAllLibraries(
|
|
108
113
|
config?: LibraryConfiguration,
|
|
109
114
|
additionalLibraries?: ExternalLibraryConfig[],
|
|
110
115
|
options?: { debug?: boolean }
|
|
@@ -126,20 +131,29 @@ export class LibraryLoader {
|
|
|
126
131
|
StandardLibraryManager.setConfiguration(mergedConfig);
|
|
127
132
|
}
|
|
128
133
|
|
|
129
|
-
return this.
|
|
134
|
+
return this.LoadLibrariesFromConfig(undefined, options?.debug);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** @deprecated Use {@link LoadAllLibraries}. */
|
|
138
|
+
static async loadAllLibraries(
|
|
139
|
+
config?: LibraryConfiguration,
|
|
140
|
+
additionalLibraries?: ExternalLibraryConfig[],
|
|
141
|
+
options?: { debug?: boolean }
|
|
142
|
+
): Promise<LibraryLoadResult> {
|
|
143
|
+
return this.LoadAllLibraries(config, additionalLibraries, options);
|
|
130
144
|
}
|
|
131
145
|
|
|
132
146
|
/**
|
|
133
147
|
* Load libraries based on the current configuration
|
|
134
148
|
*/
|
|
135
|
-
static async
|
|
149
|
+
static async LoadLibrariesFromConfig(options?: ConfigLoadOptions, debug?: boolean): Promise<LibraryLoadResult> {
|
|
136
150
|
// Load core runtime libraries in dependency order.
|
|
137
151
|
// ReactDOM's UMD factory captures `window.React` at execution time,
|
|
138
152
|
// so React MUST execute before ReactDOM. Loading them in parallel with
|
|
139
153
|
// async scripts causes an intermittent race condition where ReactDOM
|
|
140
154
|
// executes first and gets `undefined` for React, permanently breaking
|
|
141
155
|
// `createRoot` on that object instance.
|
|
142
|
-
const coreLibraries =
|
|
156
|
+
const coreLibraries = GetCoreRuntimeLibraries(debug);
|
|
143
157
|
const reactLib = coreLibraries.find(lib => lib.globalVariable === 'React');
|
|
144
158
|
const reactDOMLib = coreLibraries.find(lib => lib.globalVariable === 'ReactDOM');
|
|
145
159
|
const babelLib = coreLibraries.find(lib => lib.globalVariable === 'Babel');
|
|
@@ -190,7 +204,7 @@ export class LibraryLoader {
|
|
|
190
204
|
const enabledLibraries = StandardLibraryManager.getEnabledLibraries();
|
|
191
205
|
|
|
192
206
|
// Filter out any core runtime libraries from plugin configuration
|
|
193
|
-
let pluginLibraries = enabledLibraries.filter(lib => !
|
|
207
|
+
let pluginLibraries = enabledLibraries.filter(lib => !IsCoreRuntimeLibrary(lib.id));
|
|
194
208
|
|
|
195
209
|
// Apply options filters if provided
|
|
196
210
|
if (options) {
|
|
@@ -233,6 +247,11 @@ export class LibraryLoader {
|
|
|
233
247
|
};
|
|
234
248
|
}
|
|
235
249
|
|
|
250
|
+
/** @deprecated Use {@link LoadLibrariesFromConfig}. */
|
|
251
|
+
static async loadLibrariesFromConfig(options?: ConfigLoadOptions, debug?: boolean): Promise<LibraryLoadResult> {
|
|
252
|
+
return this.LoadLibrariesFromConfig(options, debug);
|
|
253
|
+
}
|
|
254
|
+
|
|
236
255
|
/**
|
|
237
256
|
* Load libraries with specific options (backward compatibility)
|
|
238
257
|
* @deprecated Use loadLibrariesFromConfig instead
|
|
@@ -254,7 +273,7 @@ export class LibraryLoader {
|
|
|
254
273
|
categoriesToLoad.push('ui');
|
|
255
274
|
}
|
|
256
275
|
|
|
257
|
-
const result = await this.
|
|
276
|
+
const result = await this.LoadLibrariesFromConfig({
|
|
258
277
|
categories: categoriesToLoad
|
|
259
278
|
});
|
|
260
279
|
|
|
@@ -634,14 +653,19 @@ export class LibraryLoader {
|
|
|
634
653
|
/**
|
|
635
654
|
* Get all loaded resources (for cleanup)
|
|
636
655
|
*/
|
|
637
|
-
static
|
|
656
|
+
static GetLoadedResources(): Map<string, LoadedResource> {
|
|
638
657
|
return this.loadedResources;
|
|
639
658
|
}
|
|
640
659
|
|
|
660
|
+
/** @deprecated Use {@link GetLoadedResources}. */
|
|
661
|
+
static getLoadedResources(): Map<string, LoadedResource> {
|
|
662
|
+
return this.GetLoadedResources();
|
|
663
|
+
}
|
|
664
|
+
|
|
641
665
|
/**
|
|
642
666
|
* Clear loaded resources cache and cleanup DOM elements
|
|
643
667
|
*/
|
|
644
|
-
static
|
|
668
|
+
static ClearCache(): void {
|
|
645
669
|
// Remove all script and link elements we added
|
|
646
670
|
this.loadedResources.forEach((resource, url) => {
|
|
647
671
|
if (resource.element && resource.element.parentNode) {
|
|
@@ -656,6 +680,11 @@ export class LibraryLoader {
|
|
|
656
680
|
resourceManager.cleanupComponent(LIBRARY_LOADER_COMPONENT_ID);
|
|
657
681
|
}
|
|
658
682
|
|
|
683
|
+
/** @deprecated Use {@link ClearCache}. */
|
|
684
|
+
static clearCache(): void {
|
|
685
|
+
return this.ClearCache();
|
|
686
|
+
}
|
|
687
|
+
|
|
659
688
|
/**
|
|
660
689
|
* Load a library with its dependencies
|
|
661
690
|
* @param libraryName - Name of the library to load
|
|
@@ -664,7 +693,7 @@ export class LibraryLoader {
|
|
|
664
693
|
* @param options - Dependency resolution options
|
|
665
694
|
* @returns Promise resolving to the loaded library global object
|
|
666
695
|
*/
|
|
667
|
-
static async
|
|
696
|
+
static async LoadLibraryWithDependencies(
|
|
668
697
|
libraryName: string,
|
|
669
698
|
allLibraries: MJComponentLibraryEntity[],
|
|
670
699
|
requestedBy: string = 'user',
|
|
@@ -781,6 +810,16 @@ export class LibraryLoader {
|
|
|
781
810
|
return (window as any)[targetLibrary.GlobalVariable];
|
|
782
811
|
}
|
|
783
812
|
|
|
813
|
+
/** @deprecated Use {@link LoadLibraryWithDependencies}. */
|
|
814
|
+
static async loadLibraryWithDependencies(
|
|
815
|
+
libraryName: string,
|
|
816
|
+
allLibraries: MJComponentLibraryEntity[],
|
|
817
|
+
requestedBy: string = 'user',
|
|
818
|
+
options?: DependencyResolutionOptions
|
|
819
|
+
): Promise<any> {
|
|
820
|
+
return this.LoadLibraryWithDependencies(libraryName, allLibraries, requestedBy, options);
|
|
821
|
+
}
|
|
822
|
+
|
|
784
823
|
/**
|
|
785
824
|
* Load multiple libraries with dependency resolution
|
|
786
825
|
* @param libraryNames - Names of libraries to load
|
|
@@ -789,7 +828,7 @@ export class LibraryLoader {
|
|
|
789
828
|
* @param options - Dependency resolution options
|
|
790
829
|
* @returns Map of library names to their loaded global objects
|
|
791
830
|
*/
|
|
792
|
-
static async
|
|
831
|
+
static async LoadLibrariesWithDependencies(
|
|
793
832
|
libraryNames: string[],
|
|
794
833
|
allLibraries: MJComponentLibraryEntity[],
|
|
795
834
|
requestedBy: string = 'user',
|
|
@@ -918,29 +957,54 @@ export class LibraryLoader {
|
|
|
918
957
|
return result;
|
|
919
958
|
}
|
|
920
959
|
|
|
960
|
+
/** @deprecated Use {@link LoadLibrariesWithDependencies}. */
|
|
961
|
+
static async loadLibrariesWithDependencies(
|
|
962
|
+
libraryNames: string[],
|
|
963
|
+
allLibraries: MJComponentLibraryEntity[],
|
|
964
|
+
requestedBy: string = 'user',
|
|
965
|
+
options?: DependencyResolutionOptions
|
|
966
|
+
): Promise<Map<string, any>> {
|
|
967
|
+
return this.LoadLibrariesWithDependencies(libraryNames, allLibraries, requestedBy, options);
|
|
968
|
+
}
|
|
969
|
+
|
|
921
970
|
/**
|
|
922
971
|
* Get information about loaded libraries
|
|
923
972
|
* @returns Map of loaded library states
|
|
924
973
|
*/
|
|
925
|
-
static
|
|
974
|
+
static GetLoadedLibraryStates(): Map<string, LoadedLibraryState> {
|
|
926
975
|
return new Map(this.loadedLibraryStates);
|
|
927
976
|
}
|
|
928
977
|
|
|
978
|
+
/** @deprecated Use {@link GetLoadedLibraryStates}. */
|
|
979
|
+
static getLoadedLibraryStates(): Map<string, LoadedLibraryState> {
|
|
980
|
+
return this.GetLoadedLibraryStates();
|
|
981
|
+
}
|
|
982
|
+
|
|
929
983
|
/**
|
|
930
984
|
* Check if a library is loaded
|
|
931
985
|
* @param libraryName - Name of the library
|
|
932
986
|
* @returns True if the library is loaded
|
|
933
987
|
*/
|
|
934
|
-
static
|
|
988
|
+
static IsLibraryLoaded(libraryName: string): boolean {
|
|
935
989
|
return this.loadedLibraryStates.has(libraryName);
|
|
936
990
|
}
|
|
937
991
|
|
|
992
|
+
/** @deprecated Use {@link IsLibraryLoaded}. */
|
|
993
|
+
static isLibraryLoaded(libraryName: string): boolean {
|
|
994
|
+
return this.IsLibraryLoaded(libraryName);
|
|
995
|
+
}
|
|
996
|
+
|
|
938
997
|
/**
|
|
939
998
|
* Get the version of a loaded library
|
|
940
999
|
* @param libraryName - Name of the library
|
|
941
1000
|
* @returns Version string or undefined if not loaded
|
|
942
1001
|
*/
|
|
943
|
-
static
|
|
1002
|
+
static GetLoadedLibraryVersion(libraryName: string): string | undefined {
|
|
944
1003
|
return this.loadedLibraryStates.get(libraryName)?.version;
|
|
945
1004
|
}
|
|
1005
|
+
|
|
1006
|
+
/** @deprecated Use {@link GetLoadedLibraryVersion}. */
|
|
1007
|
+
static getLoadedLibraryVersion(libraryName: string): string | undefined {
|
|
1008
|
+
return this.GetLoadedLibraryVersion(libraryName);
|
|
1009
|
+
}
|
|
946
1010
|
}
|
|
@@ -77,20 +77,25 @@ export class LibraryRegistry {
|
|
|
77
77
|
/**
|
|
78
78
|
* Get library definition by name
|
|
79
79
|
*/
|
|
80
|
-
static
|
|
80
|
+
static GetLibrary(name: string): LibraryDefinition | undefined {
|
|
81
81
|
if (!this._configured)
|
|
82
82
|
throw new Error("LibraryRegistry is not configured, call LibraryRegistry.Config() before using!");
|
|
83
83
|
|
|
84
84
|
return this.libraries.get(name?.trim().toLowerCase());
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
/** @deprecated Use {@link GetLibrary}. */
|
|
88
|
+
static getLibrary(name: string): LibraryDefinition | undefined {
|
|
89
|
+
return this.GetLibrary(name);
|
|
90
|
+
}
|
|
91
|
+
|
|
87
92
|
/**
|
|
88
93
|
* Get CDN URL for a library
|
|
89
94
|
* @param name Library name
|
|
90
95
|
* @param version Optional version (uses default if not specified)
|
|
91
96
|
* @returns CDN URL or undefined if library/version not found
|
|
92
97
|
*/
|
|
93
|
-
static
|
|
98
|
+
static GetCdnUrl(name: string, version?: string): string | undefined {
|
|
94
99
|
if (!this._configured)
|
|
95
100
|
throw new Error("LibraryRegistry is not configured, call LibraryRegistry.Config() before using!");
|
|
96
101
|
|
|
@@ -101,22 +106,32 @@ export class LibraryRegistry {
|
|
|
101
106
|
return library.versions[targetVersion]?.cdnUrl;
|
|
102
107
|
}
|
|
103
108
|
|
|
109
|
+
/** @deprecated Use {@link GetCdnUrl}. */
|
|
110
|
+
static getCdnUrl(name: string, version?: string): string | undefined {
|
|
111
|
+
return this.GetCdnUrl(name, version);
|
|
112
|
+
}
|
|
113
|
+
|
|
104
114
|
/**
|
|
105
115
|
* Check if a library is approved
|
|
106
116
|
*/
|
|
107
|
-
static
|
|
117
|
+
static IsApproved(name: string): boolean {
|
|
108
118
|
if (!this._configured)
|
|
109
119
|
throw new Error("LibraryRegistry is not configured, call LibraryRegistry.Config() before using!");
|
|
110
120
|
|
|
111
121
|
return this.libraries.has(name?.trim().toLowerCase());
|
|
112
122
|
}
|
|
113
123
|
|
|
124
|
+
/** @deprecated Use {@link IsApproved}. */
|
|
125
|
+
static isApproved(name: string): boolean {
|
|
126
|
+
return this.IsApproved(name);
|
|
127
|
+
}
|
|
128
|
+
|
|
114
129
|
/**
|
|
115
130
|
* Resolve library version based on semver-like pattern
|
|
116
131
|
* For now, just returns exact match or default
|
|
117
132
|
* TODO: Implement proper semver resolution
|
|
118
133
|
*/
|
|
119
|
-
static
|
|
134
|
+
static ResolveVersion(name: string, versionPattern?: string): string | undefined {
|
|
120
135
|
if (!this._configured)
|
|
121
136
|
throw new Error("LibraryRegistry is not configured, call LibraryRegistry.Config() before using!");
|
|
122
137
|
|
|
@@ -135,15 +150,25 @@ export class LibraryRegistry {
|
|
|
135
150
|
return library.defaultVersion;
|
|
136
151
|
}
|
|
137
152
|
|
|
153
|
+
/** @deprecated Use {@link ResolveVersion}. */
|
|
154
|
+
static resolveVersion(name: string, versionPattern?: string): string | undefined {
|
|
155
|
+
return this.ResolveVersion(name, versionPattern);
|
|
156
|
+
}
|
|
157
|
+
|
|
138
158
|
/**
|
|
139
159
|
* Add a library to the registry (for future extensibility)
|
|
140
160
|
* This would typically be called during app initialization
|
|
141
161
|
* with libraries loaded from a database
|
|
142
162
|
*/
|
|
143
|
-
static
|
|
163
|
+
static RegisterLibrary(definition: LibraryDefinition): void {
|
|
144
164
|
if (!this._configured)
|
|
145
165
|
throw new Error("LibraryRegistry is not configured, call LibraryRegistry.Config() before using!");
|
|
146
166
|
|
|
147
167
|
this.libraries.set(definition.name?.trim().toLowerCase(), definition);
|
|
148
168
|
}
|
|
169
|
+
|
|
170
|
+
/** @deprecated Use {@link RegisterLibrary}. */
|
|
171
|
+
static registerLibrary(definition: LibraryDefinition): void {
|
|
172
|
+
return this.RegisterLibrary(definition);
|
|
173
|
+
}
|
|
149
174
|
}
|