@memberjunction/react-runtime 2.94.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.
- package/.turbo/turbo-build.log +9 -9
- package/CHANGELOG.md +30 -0
- package/dist/compiler/component-compiler.d.ts +1 -0
- package/dist/compiler/component-compiler.d.ts.map +1 -1
- package/dist/compiler/component-compiler.js +116 -29
- package/dist/compiler/component-compiler.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/registry/component-registry-service.d.ts +2 -0
- package/dist/registry/component-registry-service.d.ts.map +1 -1
- package/dist/registry/component-registry-service.js +25 -6
- package/dist/registry/component-registry-service.js.map +1 -1
- package/dist/registry/component-registry.d.ts +2 -0
- package/dist/registry/component-registry.d.ts.map +1 -1
- package/dist/registry/component-registry.js +17 -0
- 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 +101 -6
- package/dist/registry/component-resolver.js.map +1 -1
- package/dist/runtime/component-hierarchy.d.ts.map +1 -1
- package/dist/runtime/component-hierarchy.js +73 -17
- package/dist/runtime/component-hierarchy.js.map +1 -1
- package/dist/runtime.umd.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/core-libraries.d.ts +1 -2
- package/dist/utilities/core-libraries.d.ts.map +1 -1
- package/dist/utilities/core-libraries.js +55 -45
- package/dist/utilities/core-libraries.js.map +1 -1
- package/dist/utilities/library-dependency-resolver.d.ts.map +1 -1
- package/dist/utilities/library-dependency-resolver.js +42 -9
- package/dist/utilities/library-dependency-resolver.js.map +1 -1
- package/dist/utilities/library-loader.d.ts +4 -2
- package/dist/utilities/library-loader.d.ts.map +1 -1
- package/dist/utilities/library-loader.js +27 -6
- package/dist/utilities/library-loader.js.map +1 -1
- package/package.json +5 -5
- package/src/compiler/component-compiler.ts +135 -31
- package/src/index.ts +7 -1
- package/src/registry/component-registry-service.ts +36 -6
- package/src/registry/component-registry.ts +28 -0
- package/src/registry/component-resolver.ts +123 -10
- package/src/runtime/component-hierarchy.ts +97 -31
- package/src/types/index.ts +1 -1
- package/src/utilities/core-libraries.ts +60 -46
- package/src/utilities/library-dependency-resolver.ts +51 -12
- package/src/utilities/library-loader.ts +30 -6
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentLibraryEntity } from '@memberjunction/core-entities';
|
|
2
2
|
import { ComponentLibraryDependency, ComponentStyles, ComponentObject } from '@memberjunction/interactive-component-types';
|
|
3
3
|
export interface CompiledComponent {
|
|
4
|
-
factory: (context: RuntimeContext, styles?: ComponentStyles) => ComponentObject;
|
|
4
|
+
factory: (context: RuntimeContext, styles?: ComponentStyles, components?: Record<string, any>) => ComponentObject;
|
|
5
5
|
id: string;
|
|
6
6
|
name: string;
|
|
7
7
|
compiledAt: Date;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAK3H,MAAM,WAAW,iBAAiB;IAEhC,OAAO,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,eAAe,KAAK,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAK3H,MAAM,WAAW,iBAAiB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E,GAAG,CAAC;IAEX,QAAQ,CAAC,EAAE,GAAG,CAAC;IAEf,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEhC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC;AAKD,MAAM,WAAW,kBAAkB;IAEjC,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IAEzB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IAExB,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,KAAK,IAAI,CAAC;IAExD,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,KAAK,IAAI,CAAC;IAE1D,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAKD,MAAM,WAAW,oBAAoB;IAEnC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,KAAK,IAAI,CAAC;IAEjD,QAAQ,CAAC,EAAE,GAAG,CAAC;IAEf,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;CACvC;AAGD,cAAc,kBAAkB,CAAC;AAGjC,cAAc,oBAAoB,CAAC;AAGnC,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC"}
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAgOA,mDAAiC;AAGjC,qDAAmC","sourcesContent":["/**\n * @fileoverview Core type definitions for the MemberJunction React Runtime.\n * These types are platform-agnostic and can be used in any JavaScript environment.\n * @module @memberjunction/react-runtime/types\n */\n\nimport { UserInfo } from '@memberjunction/core';\nimport { ComponentLibraryEntity } from '@memberjunction/core-entities';\nimport { ComponentLibraryDependency, ComponentStyles, ComponentObject } from '@memberjunction/interactive-component-types';\n\n/**\n * Represents a compiled React component with its metadata\n */\nexport interface CompiledComponent {\n /** Factory function that creates a ComponentObject when called with context */\n factory: (context: RuntimeContext, styles?: ComponentStyles) => ComponentObject;\n /** Unique identifier for the component */\n id: string;\n /** Original component name */\n name: string;\n /** Compilation timestamp */\n compiledAt: Date;\n /** Any compilation warnings */\n warnings?: string[];\n}\n\n/**\n * Options for compiling a React component\n */\nexport interface CompileOptions {\n /** Component name for identification */\n componentName: string;\n /** Raw component code to compile */\n componentCode: string;\n /** Optional styles to inject */\n styles?: ComponentStyles;\n /** Whether to use production mode optimizations */\n production?: boolean;\n /** Custom Babel plugins to use */\n babelPlugins?: string[];\n /** Custom Babel presets to use */\n babelPresets?: string[];\n\n /** Library dependencies that the component requires */\n libraries?: ComponentLibraryDependency[];\n \n /** Child component dependencies that the component requires */\n dependencies?: Array<{ name: string; code?: string }>;\n\n /**\n * Required, metadata for all possible libraries allowed by the system\n */\n allLibraries: ComponentLibraryEntity[];\n}\n\n\n/**\n * Registry entry for a compiled component\n */\nexport interface RegistryEntry {\n /** The compiled component object with all methods */\n component: ComponentObject;\n /** Component metadata */\n metadata: ComponentMetadata;\n /** Last access time for LRU cache */\n lastAccessed: Date;\n /** Reference count for cleanup */\n refCount: number;\n}\n\n/**\n * Metadata about a registered component\n */\nexport interface ComponentMetadata {\n /** Unique component identifier */\n id: string;\n /** Component name */\n name: string;\n /** Component version */\n version: string;\n /** Namespace for organization */\n namespace: string;\n /** Registration timestamp */\n registeredAt: Date;\n /** Optional tags for categorization */\n tags?: string[];\n}\n\n/**\n * Error information from component execution\n */\nexport interface ComponentError {\n /** Error message */\n message: string;\n /** Error stack trace */\n stack?: string;\n /** Component name where error occurred */\n componentName: string;\n /** Error phase (compilation, render, etc.) */\n phase: 'compilation' | 'registration' | 'render' | 'runtime';\n /** Additional error details */\n details?: any;\n}\n\n/**\n * Props passed to React components\n */\nexport interface ComponentProps {\n /** Data object for the component */\n data: any;\n /** User-managed state */\n userState: any;\n /** Utility functions available to the component */\n utilities: any;\n /** Callback functions */\n callbacks: any;\n /** Child components available for use */\n components?: Record<string, any>;\n /** Component styles */\n styles?: ComponentStyles;\n /** Standard state change handler for controlled components */\n onStateChanged?: (stateUpdate: Record<string, any>) => void;\n}\n\n/**\n * Configuration for the component compiler\n */\nexport interface CompilerConfig {\n /** Babel configuration */\n babel: {\n /** Presets to use */\n presets: string[];\n /** Plugins to use */\n plugins: string[];\n };\n /** Whether to minify output */\n minify: boolean;\n /** Source map generation */\n sourceMaps: boolean;\n /** Cache compiled components */\n cache: boolean;\n /** Maximum cache size */\n maxCacheSize: number;\n /** Enable debug logging */\n debug?: boolean;\n}\n\n/**\n * Configuration for the component registry\n */\nexport interface RegistryConfig {\n /** Maximum number of components to keep in memory */\n maxComponents: number;\n /** Time in ms before removing unused components */\n cleanupInterval: number;\n /** Whether to use LRU eviction */\n useLRU: boolean;\n /** Namespace isolation */\n enableNamespaces: boolean;\n /** Enable debug logging */\n debug?: boolean;\n}\n\n/**\n * Result of a compilation operation\n */\nexport interface CompilationResult {\n /** Whether compilation succeeded */\n success: boolean;\n /** The compiled component if successful */\n component?: CompiledComponent;\n /** Error information if failed */\n error?: ComponentError;\n /** Compilation duration in ms */\n duration: number;\n /** Size of compiled code in bytes */\n size?: number;\n}\n\n/**\n * Runtime context for component execution\n */\nexport interface RuntimeContext {\n /** React library reference */\n React: any;\n /** ReactDOM library reference */\n ReactDOM?: any;\n /** Additional libraries available */\n libraries?: Record<string, any>;\n /** Global utilities */\n utilities?: Record<string, any>;\n}\n\n/**\n * Component lifecycle events\n */\nexport interface ComponentLifecycle {\n /** Called before component mounts */\n beforeMount?: () => void;\n /** Called after component mounts */\n afterMount?: () => void;\n /** Called before component updates */\n beforeUpdate?: (prevProps: any, nextProps: any) => void;\n /** Called after component updates */\n afterUpdate?: (prevProps: any, currentProps: any) => void;\n /** Called before component unmounts */\n beforeUnmount?: () => void;\n}\n\n/**\n * Options for creating an error boundary\n */\nexport interface ErrorBoundaryOptions {\n /** Custom error handler */\n onError?: (error: Error, errorInfo: any) => void;\n /** Fallback UI to render on error */\n fallback?: any;\n /** Whether to log errors */\n logErrors?: boolean;\n /** Error recovery strategy */\n recovery?: 'retry' | 'reset' | 'none';\n}\n\n// Export library configuration types\nexport * from './library-config';\n\n// Export dependency types\nexport * from './dependency-types';\n\n// Re-export ComponentObject for convenience\nexport { ComponentObject } from '@memberjunction/interactive-component-types';"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAgOA,mDAAiC;AAGjC,qDAAmC","sourcesContent":["/**\n * @fileoverview Core type definitions for the MemberJunction React Runtime.\n * These types are platform-agnostic and can be used in any JavaScript environment.\n * @module @memberjunction/react-runtime/types\n */\n\nimport { UserInfo } from '@memberjunction/core';\nimport { ComponentLibraryEntity } from '@memberjunction/core-entities';\nimport { ComponentLibraryDependency, ComponentStyles, ComponentObject } from '@memberjunction/interactive-component-types';\n\n/**\n * Represents a compiled React component with its metadata\n */\nexport interface CompiledComponent {\n /** Factory function that creates a ComponentObject when called with context */\n factory: (context: RuntimeContext, styles?: ComponentStyles, components?: Record<string, any>) => ComponentObject;\n /** Unique identifier for the component */\n id: string;\n /** Original component name */\n name: string;\n /** Compilation timestamp */\n compiledAt: Date;\n /** Any compilation warnings */\n warnings?: string[];\n}\n\n/**\n * Options for compiling a React component\n */\nexport interface CompileOptions {\n /** Component name for identification */\n componentName: string;\n /** Raw component code to compile */\n componentCode: string;\n /** Optional styles to inject */\n styles?: ComponentStyles;\n /** Whether to use production mode optimizations */\n production?: boolean;\n /** Custom Babel plugins to use */\n babelPlugins?: string[];\n /** Custom Babel presets to use */\n babelPresets?: string[];\n\n /** Library dependencies that the component requires */\n libraries?: ComponentLibraryDependency[];\n \n /** Child component dependencies that the component requires */\n dependencies?: Array<{ name: string; code?: string }>;\n\n /**\n * Required, metadata for all possible libraries allowed by the system\n */\n allLibraries: ComponentLibraryEntity[];\n}\n\n\n/**\n * Registry entry for a compiled component\n */\nexport interface RegistryEntry {\n /** The compiled component object with all methods */\n component: ComponentObject;\n /** Component metadata */\n metadata: ComponentMetadata;\n /** Last access time for LRU cache */\n lastAccessed: Date;\n /** Reference count for cleanup */\n refCount: number;\n}\n\n/**\n * Metadata about a registered component\n */\nexport interface ComponentMetadata {\n /** Unique component identifier */\n id: string;\n /** Component name */\n name: string;\n /** Component version */\n version: string;\n /** Namespace for organization */\n namespace: string;\n /** Registration timestamp */\n registeredAt: Date;\n /** Optional tags for categorization */\n tags?: string[];\n}\n\n/**\n * Error information from component execution\n */\nexport interface ComponentError {\n /** Error message */\n message: string;\n /** Error stack trace */\n stack?: string;\n /** Component name where error occurred */\n componentName: string;\n /** Error phase (compilation, render, etc.) */\n phase: 'compilation' | 'registration' | 'render' | 'runtime';\n /** Additional error details */\n details?: any;\n}\n\n/**\n * Props passed to React components\n */\nexport interface ComponentProps {\n /** Data object for the component */\n data: any;\n /** User-managed state */\n userState: any;\n /** Utility functions available to the component */\n utilities: any;\n /** Callback functions */\n callbacks: any;\n /** Child components available for use */\n components?: Record<string, any>;\n /** Component styles */\n styles?: ComponentStyles;\n /** Standard state change handler for controlled components */\n onStateChanged?: (stateUpdate: Record<string, any>) => void;\n}\n\n/**\n * Configuration for the component compiler\n */\nexport interface CompilerConfig {\n /** Babel configuration */\n babel: {\n /** Presets to use */\n presets: string[];\n /** Plugins to use */\n plugins: string[];\n };\n /** Whether to minify output */\n minify: boolean;\n /** Source map generation */\n sourceMaps: boolean;\n /** Cache compiled components */\n cache: boolean;\n /** Maximum cache size */\n maxCacheSize: number;\n /** Enable debug logging */\n debug?: boolean;\n}\n\n/**\n * Configuration for the component registry\n */\nexport interface RegistryConfig {\n /** Maximum number of components to keep in memory */\n maxComponents: number;\n /** Time in ms before removing unused components */\n cleanupInterval: number;\n /** Whether to use LRU eviction */\n useLRU: boolean;\n /** Namespace isolation */\n enableNamespaces: boolean;\n /** Enable debug logging */\n debug?: boolean;\n}\n\n/**\n * Result of a compilation operation\n */\nexport interface CompilationResult {\n /** Whether compilation succeeded */\n success: boolean;\n /** The compiled component if successful */\n component?: CompiledComponent;\n /** Error information if failed */\n error?: ComponentError;\n /** Compilation duration in ms */\n duration: number;\n /** Size of compiled code in bytes */\n size?: number;\n}\n\n/**\n * Runtime context for component execution\n */\nexport interface RuntimeContext {\n /** React library reference */\n React: any;\n /** ReactDOM library reference */\n ReactDOM?: any;\n /** Additional libraries available */\n libraries?: Record<string, any>;\n /** Global utilities */\n utilities?: Record<string, any>;\n}\n\n/**\n * Component lifecycle events\n */\nexport interface ComponentLifecycle {\n /** Called before component mounts */\n beforeMount?: () => void;\n /** Called after component mounts */\n afterMount?: () => void;\n /** Called before component updates */\n beforeUpdate?: (prevProps: any, nextProps: any) => void;\n /** Called after component updates */\n afterUpdate?: (prevProps: any, currentProps: any) => void;\n /** Called before component unmounts */\n beforeUnmount?: () => void;\n}\n\n/**\n * Options for creating an error boundary\n */\nexport interface ErrorBoundaryOptions {\n /** Custom error handler */\n onError?: (error: Error, errorInfo: any) => void;\n /** Fallback UI to render on error */\n fallback?: any;\n /** Whether to log errors */\n logErrors?: boolean;\n /** Error recovery strategy */\n recovery?: 'retry' | 'reset' | 'none';\n}\n\n// Export library configuration types\nexport * from './library-config';\n\n// Export dependency types\nexport * from './dependency-types';\n\n// Re-export ComponentObject for convenience\nexport { ComponentObject } from '@memberjunction/interactive-component-types';"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ExternalLibraryConfig } from '../types/library-config';
|
|
2
|
-
export declare
|
|
3
|
-
export declare function getCoreRuntimeLibraries(): ExternalLibraryConfig[];
|
|
2
|
+
export declare function getCoreRuntimeLibraries(debug?: boolean): ExternalLibraryConfig[];
|
|
4
3
|
export declare function isCoreRuntimeLibrary(libraryId: string): boolean;
|
|
5
4
|
//# sourceMappingURL=core-libraries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-libraries.d.ts","sourceRoot":"","sources":["../../src/utilities/core-libraries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"core-libraries.d.ts","sourceRoot":"","sources":["../../src/utilities/core-libraries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAwBhE,wBAAgB,uBAAuB,CAAC,KAAK,GAAE,OAAe,GAAG,qBAAqB,EAAE,CA0CvF;AAKD,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAG/D"}
|
|
@@ -1,53 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isCoreRuntimeLibrary = exports.getCoreRuntimeLibraries =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
3
|
+
exports.isCoreRuntimeLibrary = exports.getCoreRuntimeLibraries = void 0;
|
|
4
|
+
function getReactUrl(debug = false) {
|
|
5
|
+
return debug
|
|
6
|
+
? 'https://unpkg.com/react@18.2.0/umd/react.development.js'
|
|
7
|
+
: 'https://unpkg.com/react@18.2.0/umd/react.production.min.js';
|
|
8
|
+
}
|
|
9
|
+
function getReactDOMUrl(debug = false) {
|
|
10
|
+
return debug
|
|
11
|
+
? 'https://unpkg.com/react-dom@18.2.0/umd/react-dom.development.js'
|
|
12
|
+
: 'https://unpkg.com/react-dom@18.2.0/umd/react-dom.production.min.js';
|
|
13
|
+
}
|
|
14
|
+
function getCoreRuntimeLibraries(debug = false) {
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
id: 'react',
|
|
18
|
+
name: 'react',
|
|
19
|
+
displayName: 'React',
|
|
20
|
+
category: 'runtime',
|
|
21
|
+
globalVariable: 'React',
|
|
22
|
+
version: '18.2.0',
|
|
23
|
+
cdnUrl: getReactUrl(debug),
|
|
24
|
+
description: 'React core library',
|
|
25
|
+
isEnabled: true,
|
|
26
|
+
isCore: true,
|
|
27
|
+
isRuntimeOnly: true
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 'react-dom',
|
|
31
|
+
name: 'react-dom',
|
|
32
|
+
displayName: 'ReactDOM',
|
|
33
|
+
category: 'runtime',
|
|
34
|
+
globalVariable: 'ReactDOM',
|
|
35
|
+
version: '18.2.0',
|
|
36
|
+
cdnUrl: getReactDOMUrl(debug),
|
|
37
|
+
description: 'React DOM library',
|
|
38
|
+
isEnabled: true,
|
|
39
|
+
isCore: true,
|
|
40
|
+
isRuntimeOnly: true
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: 'babel-standalone',
|
|
44
|
+
name: '@babel/standalone',
|
|
45
|
+
displayName: 'Babel Standalone',
|
|
46
|
+
category: 'runtime',
|
|
47
|
+
globalVariable: 'Babel',
|
|
48
|
+
version: '7.24.4',
|
|
49
|
+
cdnUrl: 'https://unpkg.com/@babel/standalone@7.24.4/babel.min.js',
|
|
50
|
+
description: 'Babel compiler for JSX transformation',
|
|
51
|
+
isEnabled: true,
|
|
52
|
+
isCore: true,
|
|
53
|
+
isRuntimeOnly: true
|
|
54
|
+
}
|
|
55
|
+
];
|
|
47
56
|
}
|
|
48
57
|
exports.getCoreRuntimeLibraries = getCoreRuntimeLibraries;
|
|
49
58
|
function isCoreRuntimeLibrary(libraryId) {
|
|
50
|
-
|
|
59
|
+
const coreLibraries = getCoreRuntimeLibraries();
|
|
60
|
+
return coreLibraries.some((lib) => lib.id === libraryId);
|
|
51
61
|
}
|
|
52
62
|
exports.isCoreRuntimeLibrary = isCoreRuntimeLibrary;
|
|
53
63
|
//# sourceMappingURL=core-libraries.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-libraries.js","sourceRoot":"","sources":["../../src/utilities/core-libraries.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"core-libraries.js","sourceRoot":"","sources":["../../src/utilities/core-libraries.ts"],"names":[],"mappings":";;;AAKA,SAAS,WAAW,CAAC,QAAiB,KAAK;IACzC,OAAO,KAAK;QACV,CAAC,CAAC,yDAAyD;QAC3D,CAAC,CAAC,4DAA4D,CAAC;AACnE,CAAC;AAKD,SAAS,cAAc,CAAC,QAAiB,KAAK;IAC5C,OAAO,KAAK;QACV,CAAC,CAAC,iEAAiE;QACnE,CAAC,CAAC,oEAAoE,CAAC;AAC3E,CAAC;AAMD,SAAgB,uBAAuB,CAAC,QAAiB,KAAK;IAC5D,OAAO;QACL;YACE,EAAE,EAAE,OAAO;YACX,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,OAAO;YACpB,QAAQ,EAAE,SAAS;YACnB,cAAc,EAAE,OAAO;YACvB,OAAO,EAAE,QAAQ;YACjB,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC;YAC1B,WAAW,EAAE,oBAAoB;YACjC,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,IAAI;YACZ,aAAa,EAAE,IAAI;SACpB;QACD;YACE,EAAE,EAAE,WAAW;YACf,IAAI,EAAE,WAAW;YACjB,WAAW,EAAE,UAAU;YACvB,QAAQ,EAAE,SAAS;YACnB,cAAc,EAAE,UAAU;YAC1B,OAAO,EAAE,QAAQ;YACjB,MAAM,EAAE,cAAc,CAAC,KAAK,CAAC;YAC7B,WAAW,EAAE,mBAAmB;YAChC,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,IAAI;YACZ,aAAa,EAAE,IAAI;SACpB;QACD;YACE,EAAE,EAAE,kBAAkB;YACtB,IAAI,EAAE,mBAAmB;YACzB,WAAW,EAAE,kBAAkB;YAC/B,QAAQ,EAAE,SAAS;YACnB,cAAc,EAAE,OAAO;YACvB,OAAO,EAAE,QAAQ;YACjB,MAAM,EAAE,yDAAyD;YACjE,WAAW,EAAE,uCAAuC;YACpD,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,IAAI;YACZ,aAAa,EAAE,IAAI;SACpB;KACF,CAAC;AACJ,CAAC;AA1CD,0DA0CC;AAKD,SAAgB,oBAAoB,CAAC,SAAiB;IACpD,MAAM,aAAa,GAAG,uBAAuB,EAAE,CAAC;IAChD,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC,GAA0B,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC;AAClF,CAAC;AAHD,oDAGC","sourcesContent":["import { ExternalLibraryConfig } from '../types/library-config';\n\n/**\n * Get the React CDN URL based on debug mode\n */\nfunction getReactUrl(debug: boolean = false): string {\n return debug \n ? 'https://unpkg.com/react@18.2.0/umd/react.development.js'\n : 'https://unpkg.com/react@18.2.0/umd/react.production.min.js';\n}\n\n/**\n * Get the ReactDOM CDN URL based on debug mode\n */\nfunction getReactDOMUrl(debug: boolean = false): string {\n return debug\n ? 'https://unpkg.com/react-dom@18.2.0/umd/react-dom.development.js'\n : 'https://unpkg.com/react-dom@18.2.0/umd/react-dom.production.min.js';\n}\n\n/**\n * Get the core runtime libraries configuration\n * @param debug Whether to use development builds for better error messages\n */\nexport function getCoreRuntimeLibraries(debug: boolean = false): ExternalLibraryConfig[] {\n return [\n {\n id: 'react',\n name: 'react',\n displayName: 'React',\n category: 'runtime',\n globalVariable: 'React',\n version: '18.2.0',\n cdnUrl: getReactUrl(debug),\n description: 'React core library',\n isEnabled: true,\n isCore: true,\n isRuntimeOnly: true\n },\n {\n id: 'react-dom',\n name: 'react-dom',\n displayName: 'ReactDOM',\n category: 'runtime',\n globalVariable: 'ReactDOM',\n version: '18.2.0',\n cdnUrl: getReactDOMUrl(debug),\n description: 'React DOM library',\n isEnabled: true,\n isCore: true,\n isRuntimeOnly: true\n },\n {\n id: 'babel-standalone',\n name: '@babel/standalone',\n displayName: 'Babel Standalone',\n category: 'runtime',\n globalVariable: 'Babel',\n version: '7.24.4',\n cdnUrl: 'https://unpkg.com/@babel/standalone@7.24.4/babel.min.js',\n description: 'Babel compiler for JSX transformation',\n isEnabled: true,\n isCore: true,\n isRuntimeOnly: true\n }\n ];\n}\n\n/**\n * Check if a library ID is a core runtime library\n */\nexport function isCoreRuntimeLibrary(libraryId: string): boolean {\n const coreLibraries = getCoreRuntimeLibraries();\n return coreLibraries.some((lib: ExternalLibraryConfig) => lib.id === libraryId);\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library-dependency-resolver.d.ts","sourceRoot":"","sources":["../../src/utilities/library-dependency-resolver.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EACL,eAAe,EAEf,eAAe,EAGf,eAAe,EAGf,kBAAkB,EAClB,2BAA2B,EAC5B,MAAM,2BAA2B,CAAC;AAKnC,qBAAa,yBAAyB;IACpC,OAAO,CAAC,KAAK,CAAkB;gBAEnB,OAAO,CAAC,EAAE,2BAA2B;IASjD,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IA4B3D,oBAAoB,CAAC,SAAS,EAAE,sBAAsB,EAA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AAkB,EAAE,EAClC,kBAAkB,EAAE,sBAAsB,EAAE,GAC3C,eAAe;IA6ElB,YAAY,CACV,aAAa,EAAE,MAAM,EAAE,EACvB,OAAO,EAAE,sBAAsB,EAAE,EACjC,OAAO,CAAC,EAAE,2BAA2B,GACpC,eAAe;IA+KlB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAW3E,yBAAyB,CACvB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,sBAAsB,EAAE,EACjC,QAAQ,GAAE,MAAW,GACpB,GAAG,CAAC,MAAM,CAAC;CAiCf"}
|
|
@@ -276,35 +276,68 @@ class LibraryDependencyResolver {
|
|
|
276
276
|
getLoadOrder(requestedLibs, allLibs, options) {
|
|
277
277
|
const errors = [];
|
|
278
278
|
const warnings = [];
|
|
279
|
+
const validRequestedLibs = requestedLibs.filter(lib => {
|
|
280
|
+
if (!lib || typeof lib !== 'string') {
|
|
281
|
+
const warning = `Invalid library name: ${lib} (type: ${typeof lib})`;
|
|
282
|
+
warnings.push(warning);
|
|
283
|
+
if (this.debug || options?.debug) {
|
|
284
|
+
console.warn(`⚠️ ${warning}`);
|
|
285
|
+
}
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
return true;
|
|
289
|
+
});
|
|
279
290
|
if (this.debug || options?.debug) {
|
|
280
|
-
console.log('🔍 Getting load order for:'
|
|
291
|
+
console.log('🔍 Getting load order for requested libraries:');
|
|
292
|
+
console.log(' 📝 Requested (raw):', requestedLibs);
|
|
293
|
+
console.log(' 📝 Requested (valid):', validRequestedLibs);
|
|
294
|
+
console.log(' 📚 Total available libraries:', allLibs.length);
|
|
281
295
|
}
|
|
282
296
|
const libMap = new Map();
|
|
283
297
|
for (const lib of allLibs) {
|
|
284
|
-
if (!
|
|
285
|
-
|
|
298
|
+
if (!lib?.Name) {
|
|
299
|
+
warnings.push(`Library with missing name found in available libraries`);
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
const key = lib.Name.toLowerCase();
|
|
303
|
+
if (!libMap.has(key)) {
|
|
304
|
+
libMap.set(key, []);
|
|
286
305
|
}
|
|
287
|
-
libMap.get(
|
|
306
|
+
libMap.get(key).push(lib);
|
|
288
307
|
}
|
|
289
308
|
const needed = new Set();
|
|
290
|
-
const toProcess = [...
|
|
309
|
+
const toProcess = [...validRequestedLibs];
|
|
291
310
|
const processed = new Set();
|
|
292
311
|
const versionRequirements = new Map();
|
|
293
312
|
let depth = 0;
|
|
294
313
|
const maxDepth = options?.maxDepth || 10;
|
|
295
314
|
while (toProcess.length > 0 && depth < maxDepth) {
|
|
296
315
|
const current = toProcess.shift();
|
|
316
|
+
if (!current || typeof current !== 'string') {
|
|
317
|
+
const warning = `Unexpected invalid library name during processing: ${current}`;
|
|
318
|
+
warnings.push(warning);
|
|
319
|
+
if (this.debug || options?.debug) {
|
|
320
|
+
console.warn(`⚠️ ${warning}`);
|
|
321
|
+
}
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
297
324
|
if (processed.has(current))
|
|
298
325
|
continue;
|
|
299
326
|
processed.add(current);
|
|
300
327
|
needed.add(current);
|
|
301
|
-
const libVersions = libMap.get(current);
|
|
328
|
+
const libVersions = libMap.get(current.toLowerCase());
|
|
302
329
|
if (!libVersions || libVersions.length === 0) {
|
|
330
|
+
if (this.debug || options?.debug) {
|
|
331
|
+
console.log(` ❌ Library '${current}' not found in available libraries`);
|
|
332
|
+
}
|
|
303
333
|
errors.push(`Library '${current}' not found`);
|
|
304
334
|
continue;
|
|
305
335
|
}
|
|
306
336
|
const lib = libVersions[0];
|
|
307
337
|
const deps = this.parseDependencies(lib.Dependencies);
|
|
338
|
+
if ((this.debug || options?.debug) && deps.size > 0) {
|
|
339
|
+
console.log(` 📌 ${current} requires:`, Array.from(deps.entries()));
|
|
340
|
+
}
|
|
308
341
|
for (const [depName, depVersion] of deps) {
|
|
309
342
|
needed.add(depName);
|
|
310
343
|
if (!versionRequirements.has(depName)) {
|
|
@@ -327,7 +360,7 @@ class LibraryDependencyResolver {
|
|
|
327
360
|
const resolvedLibraries = [];
|
|
328
361
|
for (const libName of needed) {
|
|
329
362
|
const requirements = versionRequirements.get(libName) || [];
|
|
330
|
-
const versions = libMap.get(libName) || [];
|
|
363
|
+
const versions = libMap.get(libName.toLowerCase()) || [];
|
|
331
364
|
if (versions.length === 0) {
|
|
332
365
|
errors.push(`Library '${libName}' not found`);
|
|
333
366
|
continue;
|
|
@@ -384,14 +417,14 @@ class LibraryDependencyResolver {
|
|
|
384
417
|
let depth = 0;
|
|
385
418
|
const libMap = new Map();
|
|
386
419
|
for (const lib of allLibs) {
|
|
387
|
-
libMap.set(lib.Name, lib);
|
|
420
|
+
libMap.set(lib.Name.toLowerCase(), lib);
|
|
388
421
|
}
|
|
389
422
|
while (toProcess.length > 0 && depth < maxDepth) {
|
|
390
423
|
const current = toProcess.shift();
|
|
391
424
|
if (processed.has(current))
|
|
392
425
|
continue;
|
|
393
426
|
processed.add(current);
|
|
394
|
-
const lib = libMap.get(current);
|
|
427
|
+
const lib = libMap.get(current.toLowerCase());
|
|
395
428
|
if (!lib)
|
|
396
429
|
continue;
|
|
397
430
|
const deps = this.parseDependencies(lib.Dependencies);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library-dependency-resolver.js","sourceRoot":"","sources":["../../src/utilities/library-dependency-resolver.ts"],"names":[],"mappings":";;;AAuBA,MAAa,yBAAyB;IAGpC,YAAY,OAAqC;QAFzC,UAAK,GAAY,KAAK,CAAC;QAG7B,IAAI,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,KAAK,CAAC;IACvC,CAAC;IAOD,iBAAiB,CAAC,IAAmB;QACnC,MAAM,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;QAE/C,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAChC,OAAO,YAAY,CAAC;QACtB,C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AAC,GAAG;gBAAE,SAAS;YAEnB,MAAM,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YACtD,KAAK,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;gBAC7B,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAC1B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;oBAC5B,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAC1B,CAAC;YACH,CAAC;YAED,KAAK,EAAE,CAAC;QACV,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;CACF;AAnkBD,8DAmkBC","sourcesContent":["/**\n * @fileoverview Library dependency resolution utilities\n * Provides dependency graph construction, cycle detection, topological sorting, and version resolution\n * @module @memberjunction/react-runtime/utilities\n */\n\nimport { ComponentLibraryEntity } from '@memberjunction/core-entities';\nimport {\n DependencyGraph,\n DependencyNode,\n LoadOrderResult,\n ParsedDependency,\n ParsedVersion,\n ResolvedVersion,\n VersionRange,\n VersionRangeType,\n VersionRequirement,\n DependencyResolutionOptions\n} from '../types/dependency-types';\n\n/**\n * Resolves library dependencies and determines load order\n */\nexport class LibraryDependencyResolver {\n private debug: boolean = false;\n\n constructor(options?: DependencyResolutionOptions) {\n this.debug = options?.debug || false;\n }\n\n /**\n * Parse dependencies from JSON string\n * @param json - JSON string containing dependencies\n * @returns Map of library name to version specification\n */\n parseDependencies(json: string | null): Map<string, string> {\n const dependencies = new Map<string, string>();\n \n if (!json || json.trim() === '') {\n return dependencies;\n }\n\n try {\n const parsed = JSON.parse(json);\n if (typeof parsed === 'object' && parsed !== null) {\n for (const [name, version] of Object.entries(parsed)) {\n if (typeof version === 'string') {\n dependencies.set(name, version);\n }\n }\n }\n } catch (error) {\n console.error('Failed to parse dependencies JSON:', error);\n }\n\n return dependencies;\n }\n\n /**\n * Build a dependency graph from a collection of libraries\n * @param libraries - All available libraries\n * @returns Dependency graph structure\n */\n buildDependencyGraph(libraries: ComponentLibraryEntity[]): DependencyGraph {\n const nodes = new Map<string, DependencyNode>();\n const roots = new Set<string>();\n\n // First pass: create nodes for all libraries\n for (const library of libraries) {\n const dependencies = this.parseDependencies(library.Dependencies);\n nodes.set(library.Name, {\n library,\n dependencies,\n dependents: new Set()\n });\n // Initially assume all are roots\n roots.add(library.Name);\n }\n\n // Second pass: establish dependency relationships\n for (const [name, node] of nodes) {\n for (const [depName, depVersion] of node.dependencies) {\n const depNode = nodes.get(depName);\n if (depNode) {\n // This library depends on depName, so depName is not a root\n roots.delete(depName);\n // Add this library as a dependent of depName\n depNode.dependents.add(name);\n } else if (this.debug) {\n console.warn(`Dependency '${depName}' not found for library '${name}'`);\n }\n }\n }\n\n return { nodes, roots };\n }\n\n /**\n * Detect circular dependencies in the graph\n * @param graph - Dependency graph\n * @returns Array of cycles found\n */\n detectCycles(graph: DependencyGraph): string[][] {\n const cycles: string[][] = [];\n const visited = new Set<string>();\n const recursionStack = new Set<string>();\n const path: string[] = [];\n\n const detectCyclesUtil = (nodeName: string): void => {\n visited.add(nodeName);\n recursionStack.add(nodeName);\n path.push(nodeName);\n\n const node = graph.nodes.get(nodeName);\n if (node) {\n for (const [depName] of node.dependencies) {\n if (!visited.has(depName)) {\n detectCyclesUtil(depName);\n } else if (recursionStack.has(depName)) {\n // Found a cycle\n const cycleStartIndex = path.indexOf(depName);\n const cycle = [...path.slice(cycleStartIndex), depName];\n cycles.push(cycle);\n }\n }\n }\n\n path.pop();\n recursionStack.delete(nodeName);\n };\n\n // Check all nodes\n for (const nodeName of graph.nodes.keys()) {\n if (!visited.has(nodeName)) {\n detectCyclesUtil(nodeName);\n }\n }\n\n return cycles;\n }\n\n /**\n * Perform topological sort to determine load order\n * @param graph - Dependency graph\n * @returns Sorted array of libraries to load in order\n */\n topologicalSort(graph: DependencyGraph): ComponentLibraryEntity[] {\n const result: ComponentLibraryEntity[] = [];\n const visited = new Set<string>();\n const tempMarked = new Set<string>();\n\n const visit = (nodeName: string): boolean => {\n if (tempMarked.has(nodeName)) {\n // Cycle detected\n return false;\n }\n if (visited.has(nodeName)) {\n return true;\n }\n\n tempMarked.add(nodeName);\n const node = graph.nodes.get(nodeName);\n \n if (node) {\n // Visit dependencies first\n for (const [depName] of node.dependencies) {\n if (graph.nodes.has(depName)) {\n if (!visit(depName)) {\n return false;\n }\n }\n }\n result.push(node.library);\n }\n\n tempMarked.delete(nodeName);\n visited.add(nodeName);\n return true;\n };\n\n // Start with all nodes\n for (const nodeName of graph.nodes.keys()) {\n if (!visited.has(nodeName)) {\n if (!visit(nodeName)) {\n console.error(`Cycle detected involving library: ${nodeName}`);\n }\n }\n }\n\n return result;\n }\n\n /**\n * Parse a semver version string\n * @param version - Version string (e.g., \"1.2.3\")\n * @returns Parsed version object\n */\n private parseVersion(version: string): ParsedVersion | null {\n const match = version.match(/^(\\d+)\\.(\\d+)\\.(\\d+)(?:-([^+]+))?(?:\\+(.+))?$/);\n if (!match) {\n return null;\n }\n\n return {\n major: parseInt(match[1], 10),\n minor: parseInt(match[2], 10),\n patch: parseInt(match[3], 10),\n prerelease: match[4],\n build: match[5]\n };\n }\n\n /**\n * Parse a version specification into a range\n * @param spec - Version specification (e.g., \"^1.2.3\", \"~1.2.0\", \"1.2.3\")\n * @returns Parsed version range\n */\n private parseVersionRange(spec: string): VersionRange {\n if (spec === '*' || spec === '' || spec === 'latest') {\n return { type: 'any', raw: spec };\n }\n\n // Tilde range (~1.2.3)\n if (spec.startsWith('~')) {\n const version = this.parseVersion(spec.substring(1));\n return {\n type: 'tilde',\n version: version || undefined,\n raw: spec\n };\n }\n\n // Caret range (^1.2.3)\n if (spec.startsWith('^')) {\n const version = this.parseVersion(spec.substring(1));\n return {\n type: 'caret',\n version: version || undefined,\n raw: spec\n };\n }\n\n // Exact version\n const version = this.parseVersion(spec);\n if (version) {\n return {\n type: 'exact',\n version,\n raw: spec\n };\n }\n\n // Default to any if we can't parse\n return { type: 'any', raw: spec };\n }\n\n /**\n * Check if a version satisfies a version range\n * @param version - Version to check\n * @param range - Version range specification\n * @returns True if version satisfies range\n */\n private versionSatisfiesRange(version: ParsedVersion, range: VersionRange): boolean {\n if (range.type === 'any') {\n return true;\n }\n\n if (!range.version) {\n return false;\n }\n\n const rangeVer = range.version;\n\n switch (range.type) {\n case 'exact':\n return version.major === rangeVer.major &&\n version.minor === rangeVer.minor &&\n version.patch === rangeVer.patch;\n\n case 'tilde': // ~1.2.3 means >=1.2.3 <1.3.0\n if (version.major !== rangeVer.major) return false;\n if (version.minor !== rangeVer.minor) return false;\n return version.patch >= rangeVer.patch;\n\n case 'caret': // ^1.2.3 means >=1.2.3 <2.0.0 (for 1.x.x)\n if (rangeVer.major === 0) {\n // ^0.x.y behaves like ~0.x.y\n if (version.major !== 0) return false;\n if (rangeVer.minor === 0) {\n // ^0.0.x means exactly 0.0.x\n return version.minor === 0 && version.patch === rangeVer.patch;\n }\n // ^0.x.y means >=0.x.y <0.(x+1).0\n if (version.minor !== rangeVer.minor) return false;\n return version.patch >= rangeVer.patch;\n }\n // Normal caret for major > 0\n if (version.major !== rangeVer.major) return false;\n if (version.minor < rangeVer.minor) return false;\n if (version.minor === rangeVer.minor) {\n return version.patch >= rangeVer.patch;\n }\n return true;\n\n default:\n return false;\n }\n }\n\n /**\n * Compare two versions for sorting\n * @returns -1 if a < b, 0 if a === b, 1 if a > b\n */\n private compareVersions(a: ParsedVersion, b: ParsedVersion): number {\n if (a.major !== b.major) return a.major - b.major;\n if (a.minor !== b.minor) return a.minor - b.minor;\n if (a.patch !== b.patch) return a.patch - b.patch;\n \n // Handle prerelease versions\n if (!a.prerelease && b.prerelease) return 1; // a is newer\n if (a.prerelease && !b.prerelease) return -1; // b is newer\n if (a.prerelease && b.prerelease) {\n return a.prerelease.localeCompare(b.prerelease);\n }\n \n return 0;\n }\n\n /**\n * Resolve version conflicts using NPM-style resolution\n * @param requirements - Array of version requirements\n * @param availableLibraries - All available libraries to choose from\n * @returns Resolved version information\n */\n resolveVersionConflicts(\n requirements: VersionRequirement[],\n availableLibraries: ComponentLibraryEntity[]\n ): ResolvedVersion {\n if (requirements.length === 0) {\n throw new Error('No version requirements provided');\n }\n\n const libraryName = requirements[0].library;\n const warnings: string[] = [];\n\n // Find all available versions for this library\n const availableVersions = availableLibraries\n .filter(lib => lib.Name === libraryName && lib.Version)\n .map(lib => ({\n library: lib,\n version: this.parseVersion(lib.Version!)\n }))\n .filter(item => item.version !== null)\n .sort((a, b) => this.compareVersions(b.version!, a.version!)); // Sort descending\n\n if (availableVersions.length === 0) {\n throw new Error(`No versions available for library '${libraryName}'`);\n }\n\n // Parse all requirements\n const ranges = requirements.map(req => ({\n ...req,\n range: this.parseVersionRange(req.versionSpec)\n }));\n\n // Find the highest version that satisfies all requirements\n for (const { library, version } of availableVersions) {\n let satisfiesAll = true;\n const satisfiedRequirements: VersionRequirement[] = [];\n\n for (const req of ranges) {\n if (this.versionSatisfiesRange(version!, req.range)) {\n satisfiedRequirements.push(req);\n } else {\n satisfiesAll = false;\n warnings.push(\n `Version ${library.Version} does not satisfy '${req.versionSpec}' required by ${req.requestedBy}`\n );\n break;\n }\n }\n\n if (satisfiesAll) {\n return {\n library: libraryName,\n version: library.Version!,\n satisfies: requirements,\n warnings: warnings.length > 0 ? warnings : undefined\n };\n }\n }\n\n // No version satisfies all requirements\n // Return the latest version with warnings\n const latest = availableVersions[0];\n warnings.push(\n `Could not find a version that satisfies all requirements. Using ${latest.library.Version}`\n );\n\n return {\n library: libraryName,\n version: latest.library.Version!,\n satisfies: [],\n warnings\n };\n }\n\n /**\n * Get the load order for a set of requested libraries\n * @param requestedLibs - Library names requested\n * @param allLibs - All available libraries\n * @param options - Resolution options\n * @returns Load order result\n */\n getLoadOrder(\n requestedLibs: string[],\n allLibs: ComponentLibraryEntity[],\n options?: DependencyResolutionOptions\n ): LoadOrderResult {\n const errors: string[] = [];\n const warnings: string[] = [];\n\n if (this.debug || options?.debug) {\n console.log('🔍 Getting load order for:', requestedLibs);\n }\n\n // Build a map for quick lookup\n const libMap = new Map<string, ComponentLibraryEntity[]>();\n for (const lib of allLibs) {\n if (!libMap.has(lib.Name)) {\n libMap.set(lib.Name, []);\n }\n libMap.get(lib.Name)!.push(lib);\n }\n\n // Collect all libraries needed (requested + their dependencies)\n const needed = new Set<string>();\n const toProcess = [...requestedLibs];\n const processed = new Set<string>();\n const versionRequirements = new Map<string, VersionRequirement[]>();\n let depth = 0;\n const maxDepth = options?.maxDepth || 10;\n\n while (toProcess.length > 0 && depth < maxDepth) {\n const current = toProcess.shift()!;\n if (processed.has(current)) continue;\n\n processed.add(current);\n needed.add(current);\n\n // Find the library\n const libVersions = libMap.get(current);\n if (!libVersions || libVersions.length === 0) {\n errors.push(`Library '${current}' not found`);\n continue;\n }\n\n // For now, use the first version found (should be resolved properly)\n const lib = libVersions[0];\n const deps = this.parseDependencies(lib.Dependencies);\n\n // Process dependencies\n for (const [depName, depVersion] of deps) {\n needed.add(depName);\n \n // Track version requirements\n if (!versionRequirements.has(depName)) {\n versionRequirements.set(depName, []);\n }\n versionRequirements.get(depName)!.push({\n library: depName,\n versionSpec: depVersion,\n requestedBy: current\n });\n\n if (!processed.has(depName)) {\n toProcess.push(depName);\n }\n }\n\n depth++;\n }\n\n if (depth >= maxDepth) {\n warnings.push(`Maximum dependency depth (${maxDepth}) reached`);\n }\n\n // Resolve version conflicts for each library\n const resolvedLibraries: ComponentLibraryEntity[] = [];\n for (const libName of needed) {\n const requirements = versionRequirements.get(libName) || [];\n const versions = libMap.get(libName) || [];\n \n if (versions.length === 0) {\n errors.push(`Library '${libName}' not found`);\n continue;\n }\n\n if (requirements.length > 0) {\n try {\n const resolved = this.resolveVersionConflicts(requirements, versions);\n const selectedLib = versions.find(lib => lib.Version === resolved.version);\n if (selectedLib) {\n resolvedLibraries.push(selectedLib);\n if (resolved.warnings) {\n warnings.push(...resolved.warnings);\n }\n }\n } catch (error: any) {\n errors.push(error.message);\n // Use first available version as fallback\n resolvedLibraries.push(versions[0]);\n }\n } else {\n // No specific requirements, use the first (default) version\n resolvedLibraries.push(versions[0]);\n }\n }\n\n // Build dependency graph with resolved libraries\n const graph = this.buildDependencyGraph(resolvedLibraries);\n\n // Check for cycles\n const cycles = this.detectCycles(graph);\n if (cycles.length > 0) {\n errors.push(`Circular dependencies detected: ${cycles.map(c => c.join(' -> ')).join(', ')}`);\n return {\n success: false,\n cycles,\n errors,\n warnings: warnings.length > 0 ? warnings : undefined\n };\n }\n\n // Perform topological sort\n const sorted = this.topologicalSort(graph);\n\n if (this.debug || options?.debug) {\n console.log('✅ Load order determined:', sorted.map(lib => `${lib.Name}@${lib.Version}`));\n }\n\n return {\n success: errors.length === 0,\n order: sorted,\n errors: errors.length > 0 ? errors : undefined,\n warnings: warnings.length > 0 ? warnings : undefined\n };\n }\n\n /**\n * Get direct dependencies of a library\n * @param library - Library to get dependencies for\n * @returns Map of dependency names to version specs\n */\n getDirectDependencies(library: ComponentLibraryEntity): Map<string, string> {\n return this.parseDependencies(library.Dependencies);\n }\n\n /**\n * Get all transitive dependencies of a library\n * @param libraryName - Library name to analyze\n * @param allLibs - All available libraries\n * @param maxDepth - Maximum depth to traverse\n * @returns Set of all dependency names (including transitive)\n */\n getTransitiveDependencies(\n libraryName: string,\n allLibs: ComponentLibraryEntity[],\n maxDepth: number = 10\n ): Set<string> {\n const dependencies = new Set<string>();\n const toProcess = [libraryName];\n const processed = new Set<string>();\n let depth = 0;\n\n // Build lookup map\n const libMap = new Map<string, ComponentLibraryEntity>();\n for (const lib of allLibs) {\n libMap.set(lib.Name, lib);\n }\n\n while (toProcess.length > 0 && depth < maxDepth) {\n const current = toProcess.shift()!;\n if (processed.has(current)) continue;\n\n processed.add(current);\n const lib = libMap.get(current);\n if (!lib) continue;\n\n const deps = this.parseDependencies(lib.Dependencies);\n for (const [depName] of deps) {\n dependencies.add(depName);\n if (!processed.has(depName)) {\n toProcess.push(depName);\n }\n }\n\n depth++;\n }\n\n return dependencies;\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"library-dependency-resolver.js","sourceRoot":"","sources":["../../src/utilities/library-dependency-resolver.ts"],"names":[],"mappings":";;;AAuBA,MAAa,yBAAyB;IAGpC,YAAY,OAAqC;QAFzC,UAAK,GAAY,KAAK,CAAC;QAG7B,IAAI,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,KAAK,CAAC;IACvC,CAAC;IAOD,iBAAiB,CAAC,IAAmB;QACnC,MAAM,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;QAE/C,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAChC,OAAO,YAAY,CAAC;QACtB,CAAC;QAED,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAChC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gBAClD,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;oBACrD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;wBAChC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;oBAClC,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAC;QAC7D,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAOD,oBAAoB,CAAC,SAAmC;QACtD,MAAM,KAAK,GAAG,IAAI,GAAG,EAA0B,CAAC;QAChD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;QAGhC,KAAK,MAAM,OAAO,IAAI,SAAS,EAAE,CAAC;YAChC,MAAM,YAAY,GAAG,IAAI,CAAC,iBAAiB,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QACV,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;CACF;AA1mBD,8DA0mBC","sourcesContent":["/**\n * @fileoverview Library dependency resolution utilities\n * Provides dependency graph construction, cycle detection, topological sorting, and version resolution\n * @module @memberjunction/react-runtime/utilities\n */\n\nimport { ComponentLibraryEntity } from '@memberjunction/core-entities';\nimport {\n DependencyGraph,\n DependencyNode,\n LoadOrderResult,\n ParsedDependency,\n ParsedVersion,\n ResolvedVersion,\n VersionRange,\n VersionRangeType,\n VersionRequirement,\n DependencyResolutionOptions\n} from '../types/dependency-types';\n\n/**\n * Resolves library dependencies and determines load order\n */\nexport class LibraryDependencyResolver {\n private debug: boolean = false;\n\n constructor(options?: DependencyResolutionOptions) {\n this.debug = options?.debug || false;\n }\n\n /**\n * Parse dependencies from JSON string\n * @param json - JSON string containing dependencies\n * @returns Map of library name to version specification\n */\n parseDependencies(json: string | null): Map<string, string> {\n const dependencies = new Map<string, string>();\n \n if (!json || json.trim() === '') {\n return dependencies;\n }\n\n try {\n const parsed = JSON.parse(json);\n if (typeof parsed === 'object' && parsed !== null) {\n for (const [name, version] of Object.entries(parsed)) {\n if (typeof version === 'string') {\n dependencies.set(name, version);\n }\n }\n }\n } catch (error) {\n console.error('Failed to parse dependencies JSON:', error);\n }\n\n return dependencies;\n }\n\n /**\n * Build a dependency graph from a collection of libraries\n * @param libraries - All available libraries\n * @returns Dependency graph structure\n */\n buildDependencyGraph(libraries: ComponentLibraryEntity[]): DependencyGraph {\n const nodes = new Map<string, DependencyNode>();\n const roots = new Set<string>();\n\n // First pass: create nodes for all libraries\n for (const library of libraries) {\n const dependencies = this.parseDependencies(library.Dependencies);\n nodes.set(library.Name, {\n library,\n dependencies,\n dependents: new Set()\n });\n // Initially assume all are roots\n roots.add(library.Name);\n }\n\n // Second pass: establish dependency relationships\n for (const [name, node] of nodes) {\n for (const [depName, depVersion] of node.dependencies) {\n const depNode = nodes.get(depName);\n if (depNode) {\n // This library depends on depName, so depName is not a root\n roots.delete(depName);\n // Add this library as a dependent of depName\n depNode.dependents.add(name);\n } else if (this.debug) {\n console.warn(`Dependency '${depName}' not found for library '${name}'`);\n }\n }\n }\n\n return { nodes, roots };\n }\n\n /**\n * Detect circular dependencies in the graph\n * @param graph - Dependency graph\n * @returns Array of cycles found\n */\n detectCycles(graph: DependencyGraph): string[][] {\n const cycles: string[][] = [];\n const visited = new Set<string>();\n const recursionStack = new Set<string>();\n const path: string[] = [];\n\n const detectCyclesUtil = (nodeName: string): void => {\n visited.add(nodeName);\n recursionStack.add(nodeName);\n path.push(nodeName);\n\n const node = graph.nodes.get(nodeName);\n if (node) {\n for (const [depName] of node.dependencies) {\n if (!visited.has(depName)) {\n detectCyclesUtil(depName);\n } else if (recursionStack.has(depName)) {\n // Found a cycle\n const cycleStartIndex = path.indexOf(depName);\n const cycle = [...path.slice(cycleStartIndex), depName];\n cycles.push(cycle);\n }\n }\n }\n\n path.pop();\n recursionStack.delete(nodeName);\n };\n\n // Check all nodes\n for (const nodeName of graph.nodes.keys()) {\n if (!visited.has(nodeName)) {\n detectCyclesUtil(nodeName);\n }\n }\n\n return cycles;\n }\n\n /**\n * Perform topological sort to determine load order\n * @param graph - Dependency graph\n * @returns Sorted array of libraries to load in order\n */\n topologicalSort(graph: DependencyGraph): ComponentLibraryEntity[] {\n const result: ComponentLibraryEntity[] = [];\n const visited = new Set<string>();\n const tempMarked = new Set<string>();\n\n const visit = (nodeName: string): boolean => {\n if (tempMarked.has(nodeName)) {\n // Cycle detected\n return false;\n }\n if (visited.has(nodeName)) {\n return true;\n }\n\n tempMarked.add(nodeName);\n const node = graph.nodes.get(nodeName);\n \n if (node) {\n // Visit dependencies first\n for (const [depName] of node.dependencies) {\n if (graph.nodes.has(depName)) {\n if (!visit(depName)) {\n return false;\n }\n }\n }\n result.push(node.library);\n }\n\n tempMarked.delete(nodeName);\n visited.add(nodeName);\n return true;\n };\n\n // Start with all nodes\n for (const nodeName of graph.nodes.keys()) {\n if (!visited.has(nodeName)) {\n if (!visit(nodeName)) {\n console.error(`Cycle detected involving library: ${nodeName}`);\n }\n }\n }\n\n return result;\n }\n\n /**\n * Parse a semver version string\n * @param version - Version string (e.g., \"1.2.3\")\n * @returns Parsed version object\n */\n private parseVersion(version: string): ParsedVersion | null {\n const match = version.match(/^(\\d+)\\.(\\d+)\\.(\\d+)(?:-([^+]+))?(?:\\+(.+))?$/);\n if (!match) {\n return null;\n }\n\n return {\n major: parseInt(match[1], 10),\n minor: parseInt(match[2], 10),\n patch: parseInt(match[3], 10),\n prerelease: match[4],\n build: match[5]\n };\n }\n\n /**\n * Parse a version specification into a range\n * @param spec - Version specification (e.g., \"^1.2.3\", \"~1.2.0\", \"1.2.3\")\n * @returns Parsed version range\n */\n private parseVersionRange(spec: string): VersionRange {\n if (spec === '*' || spec === '' || spec === 'latest') {\n return { type: 'any', raw: spec };\n }\n\n // Tilde range (~1.2.3)\n if (spec.startsWith('~')) {\n const version = this.parseVersion(spec.substring(1));\n return {\n type: 'tilde',\n version: version || undefined,\n raw: spec\n };\n }\n\n // Caret range (^1.2.3)\n if (spec.startsWith('^')) {\n const version = this.parseVersion(spec.substring(1));\n return {\n type: 'caret',\n version: version || undefined,\n raw: spec\n };\n }\n\n // Exact version\n const version = this.parseVersion(spec);\n if (version) {\n return {\n type: 'exact',\n version,\n raw: spec\n };\n }\n\n // Default to any if we can't parse\n return { type: 'any', raw: spec };\n }\n\n /**\n * Check if a version satisfies a version range\n * @param version - Version to check\n * @param range - Version range specification\n * @returns True if version satisfies range\n */\n private versionSatisfiesRange(version: ParsedVersion, range: VersionRange): boolean {\n if (range.type === 'any') {\n return true;\n }\n\n if (!range.version) {\n return false;\n }\n\n const rangeVer = range.version;\n\n switch (range.type) {\n case 'exact':\n return version.major === rangeVer.major &&\n version.minor === rangeVer.minor &&\n version.patch === rangeVer.patch;\n\n case 'tilde': // ~1.2.3 means >=1.2.3 <1.3.0\n if (version.major !== rangeVer.major) return false;\n if (version.minor !== rangeVer.minor) return false;\n return version.patch >= rangeVer.patch;\n\n case 'caret': // ^1.2.3 means >=1.2.3 <2.0.0 (for 1.x.x)\n if (rangeVer.major === 0) {\n // ^0.x.y behaves like ~0.x.y\n if (version.major !== 0) return false;\n if (rangeVer.minor === 0) {\n // ^0.0.x means exactly 0.0.x\n return version.minor === 0 && version.patch === rangeVer.patch;\n }\n // ^0.x.y means >=0.x.y <0.(x+1).0\n if (version.minor !== rangeVer.minor) return false;\n return version.patch >= rangeVer.patch;\n }\n // Normal caret for major > 0\n if (version.major !== rangeVer.major) return false;\n if (version.minor < rangeVer.minor) return false;\n if (version.minor === rangeVer.minor) {\n return version.patch >= rangeVer.patch;\n }\n return true;\n\n default:\n return false;\n }\n }\n\n /**\n * Compare two versions for sorting\n * @returns -1 if a < b, 0 if a === b, 1 if a > b\n */\n private compareVersions(a: ParsedVersion, b: ParsedVersion): number {\n if (a.major !== b.major) return a.major - b.major;\n if (a.minor !== b.minor) return a.minor - b.minor;\n if (a.patch !== b.patch) return a.patch - b.patch;\n \n // Handle prerelease versions\n if (!a.prerelease && b.prerelease) return 1; // a is newer\n if (a.prerelease && !b.prerelease) return -1; // b is newer\n if (a.prerelease && b.prerelease) {\n return a.prerelease.localeCompare(b.prerelease);\n }\n \n return 0;\n }\n\n /**\n * Resolve version conflicts using NPM-style resolution\n * @param requirements - Array of version requirements\n * @param availableLibraries - All available libraries to choose from\n * @returns Resolved version information\n */\n resolveVersionConflicts(\n requirements: VersionRequirement[],\n availableLibraries: ComponentLibraryEntity[]\n ): ResolvedVersion {\n if (requirements.length === 0) {\n throw new Error('No version requirements provided');\n }\n\n const libraryName = requirements[0].library;\n const warnings: string[] = [];\n\n // Find all available versions for this library\n const availableVersions = availableLibraries\n .filter(lib => lib.Name === libraryName && lib.Version)\n .map(lib => ({\n library: lib,\n version: this.parseVersion(lib.Version!)\n }))\n .filter(item => item.version !== null)\n .sort((a, b) => this.compareVersions(b.version!, a.version!)); // Sort descending\n\n if (availableVersions.length === 0) {\n throw new Error(`No versions available for library '${libraryName}'`);\n }\n\n // Parse all requirements\n const ranges = requirements.map(req => ({\n ...req,\n range: this.parseVersionRange(req.versionSpec)\n }));\n\n // Find the highest version that satisfies all requirements\n for (const { library, version } of availableVersions) {\n let satisfiesAll = true;\n const satisfiedRequirements: VersionRequirement[] = [];\n\n for (const req of ranges) {\n if (this.versionSatisfiesRange(version!, req.range)) {\n satisfiedRequirements.push(req);\n } else {\n satisfiesAll = false;\n warnings.push(\n `Version ${library.Version} does not satisfy '${req.versionSpec}' required by ${req.requestedBy}`\n );\n break;\n }\n }\n\n if (satisfiesAll) {\n return {\n library: libraryName,\n version: library.Version!,\n satisfies: requirements,\n warnings: warnings.length > 0 ? warnings : undefined\n };\n }\n }\n\n // No version satisfies all requirements\n // Return the latest version with warnings\n const latest = availableVersions[0];\n warnings.push(\n `Could not find a version that satisfies all requirements. Using ${latest.library.Version}`\n );\n\n return {\n library: libraryName,\n version: latest.library.Version!,\n satisfies: [],\n warnings\n };\n }\n\n /**\n * Get the load order for a set of requested libraries\n * @param requestedLibs - Library names requested\n * @param allLibs - All available libraries\n * @param options - Resolution options\n * @returns Load order result\n */\n getLoadOrder(\n requestedLibs: string[],\n allLibs: ComponentLibraryEntity[],\n options?: DependencyResolutionOptions\n ): LoadOrderResult {\n const errors: string[] = [];\n const warnings: string[] = [];\n\n // Filter out null, undefined, and non-string values from requestedLibs\n const validRequestedLibs = requestedLibs.filter(lib => {\n if (!lib || typeof lib !== 'string') {\n const warning = `Invalid library name: ${lib} (type: ${typeof lib})`;\n warnings.push(warning);\n if (this.debug || options?.debug) {\n console.warn(`⚠️ ${warning}`);\n }\n return false;\n }\n return true;\n });\n\n if (this.debug || options?.debug) {\n console.log('🔍 Getting load order for requested libraries:');\n console.log(' 📝 Requested (raw):', requestedLibs);\n console.log(' 📝 Requested (valid):', validRequestedLibs);\n console.log(' 📚 Total available libraries:', allLibs.length);\n }\n\n // Build a map for quick lookup (case-insensitive)\n const libMap = new Map<string, ComponentLibraryEntity[]>();\n for (const lib of allLibs) {\n if (!lib?.Name) {\n warnings.push(`Library with missing name found in available libraries`);\n continue;\n }\n const key = lib.Name.toLowerCase();\n if (!libMap.has(key)) {\n libMap.set(key, []);\n }\n libMap.get(key)!.push(lib);\n }\n\n // Collect all libraries needed (requested + their dependencies)\n const needed = new Set<string>();\n const toProcess = [...validRequestedLibs];\n const processed = new Set<string>();\n const versionRequirements = new Map<string, VersionRequirement[]>();\n let depth = 0;\n const maxDepth = options?.maxDepth || 10;\n\n while (toProcess.length > 0 && depth < maxDepth) {\n const current = toProcess.shift()!;\n \n // Extra safety check for null/undefined\n if (!current || typeof current !== 'string') {\n const warning = `Unexpected invalid library name during processing: ${current}`;\n warnings.push(warning);\n if (this.debug || options?.debug) {\n console.warn(`⚠️ ${warning}`);\n }\n continue;\n }\n \n if (processed.has(current)) continue;\n\n processed.add(current);\n needed.add(current);\n\n // Find the library (case-insensitive lookup)\n const libVersions = libMap.get(current.toLowerCase());\n if (!libVersions || libVersions.length === 0) {\n if (this.debug || options?.debug) {\n console.log(` ❌ Library '${current}' not found in available libraries`);\n }\n errors.push(`Library '${current}' not found`);\n continue;\n }\n\n // For now, use the first version found (should be resolved properly)\n const lib = libVersions[0];\n const deps = this.parseDependencies(lib.Dependencies);\n \n if ((this.debug || options?.debug) && deps.size > 0) {\n console.log(` 📌 ${current} requires:`, Array.from(deps.entries()));\n }\n\n // Process dependencies\n for (const [depName, depVersion] of deps) {\n needed.add(depName);\n \n // Track version requirements\n if (!versionRequirements.has(depName)) {\n versionRequirements.set(depName, []);\n }\n versionRequirements.get(depName)!.push({\n library: depName,\n versionSpec: depVersion,\n requestedBy: current\n });\n\n if (!processed.has(depName)) {\n toProcess.push(depName);\n }\n }\n\n depth++;\n }\n\n if (depth >= maxDepth) {\n warnings.push(`Maximum dependency depth (${maxDepth}) reached`);\n }\n\n // Resolve version conflicts for each library\n const resolvedLibraries: ComponentLibraryEntity[] = [];\n for (const libName of needed) {\n const requirements = versionRequirements.get(libName) || [];\n const versions = libMap.get(libName.toLowerCase()) || [];\n \n if (versions.length === 0) {\n errors.push(`Library '${libName}' not found`);\n continue;\n }\n\n if (requirements.length > 0) {\n try {\n const resolved = this.resolveVersionConflicts(requirements, versions);\n const selectedLib = versions.find(lib => lib.Version === resolved.version);\n if (selectedLib) {\n resolvedLibraries.push(selectedLib);\n if (resolved.warnings) {\n warnings.push(...resolved.warnings);\n }\n }\n } catch (error: any) {\n errors.push(error.message);\n // Use first available version as fallback\n resolvedLibraries.push(versions[0]);\n }\n } else {\n // No specific requirements, use the first (default) version\n resolvedLibraries.push(versions[0]);\n }\n }\n\n // Build dependency graph with resolved libraries\n const graph = this.buildDependencyGraph(resolvedLibraries);\n\n // Check for cycles\n const cycles = this.detectCycles(graph);\n if (cycles.length > 0) {\n errors.push(`Circular dependencies detected: ${cycles.map(c => c.join(' -> ')).join(', ')}`);\n return {\n success: false,\n cycles,\n errors,\n warnings: warnings.length > 0 ? warnings : undefined\n };\n }\n\n // Perform topological sort\n const sorted = this.topologicalSort(graph);\n\n if (this.debug || options?.debug) {\n console.log('✅ Load order determined:', sorted.map(lib => `${lib.Name}@${lib.Version}`));\n }\n\n return {\n success: errors.length === 0,\n order: sorted,\n errors: errors.length > 0 ? errors : undefined,\n warnings: warnings.length > 0 ? warnings : undefined\n };\n }\n\n /**\n * Get direct dependencies of a library\n * @param library - Library to get dependencies for\n * @returns Map of dependency names to version specs\n */\n getDirectDependencies(library: ComponentLibraryEntity): Map<string, string> {\n return this.parseDependencies(library.Dependencies);\n }\n\n /**\n * Get all transitive dependencies of a library\n * @param libraryName - Library name to analyze\n * @param allLibs - All available libraries\n * @param maxDepth - Maximum depth to traverse\n * @returns Set of all dependency names (including transitive)\n */\n getTransitiveDependencies(\n libraryName: string,\n allLibs: ComponentLibraryEntity[],\n maxDepth: number = 10\n ): Set<string> {\n const dependencies = new Set<string>();\n const toProcess = [libraryName];\n const processed = new Set<string>();\n let depth = 0;\n\n // Build lookup map (case-insensitive)\n const libMap = new Map<string, ComponentLibraryEntity>();\n for (const lib of allLibs) {\n libMap.set(lib.Name.toLowerCase(), lib);\n }\n\n while (toProcess.length > 0 && depth < maxDepth) {\n const current = toProcess.shift()!;\n if (processed.has(current)) continue;\n\n processed.add(current);\n const lib = libMap.get(current.toLowerCase());\n if (!lib) continue;\n\n const deps = this.parseDependencies(lib.Dependencies);\n for (const [depName] of deps) {\n dependencies.add(depName);\n if (!processed.has(depName)) {\n toProcess.push(depName);\n }\n }\n\n depth++;\n }\n\n return dependencies;\n }\n}"]}
|
|
@@ -25,8 +25,10 @@ export declare class LibraryLoader {
|
|
|
25
25
|
private static loadedResources;
|
|
26
26
|
private static loadedLibraryStates;
|
|
27
27
|
private static dependencyResolver;
|
|
28
|
-
static loadAllLibraries(config?: LibraryConfiguration, additionalLibraries?: ExternalLibraryConfig[]
|
|
29
|
-
|
|
28
|
+
static loadAllLibraries(config?: LibraryConfiguration, additionalLibraries?: ExternalLibraryConfig[], options?: {
|
|
29
|
+
debug?: boolean;
|
|
30
|
+
}): Promise<LibraryLoadResult>;
|
|
31
|
+
static loadLibrariesFromConfig(options?: ConfigLoadOptions, debug?: boolean): Promise<LibraryLoadResult>;
|
|
30
32
|
static loadLibraries(options: LibraryLoadOptions): Promise<LibraryLoadResult>;
|
|
31
33
|
private static loadScript;
|
|
32
34
|
private static loadCSS;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library-loader.d.ts","sourceRoot":"","sources":["../../src/utilities/library-loader.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,iBAAiB,EAElB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,kBAAkB,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG/H,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAS5F,UAAU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AY,EAAE,MAAM,EAAE,EACtB,YAAY,EAAE,sBAAsB,EAAE,EACtC,WAAW,GAAE,MAAe,EAC5B,OAAO,CAAC,EAAE,2BAA2B,GACpC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAsH5B,MAAM,CAAC,sBAAsB,IAAI,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC;IAShE,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IASpD,MAAM,CAAC,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAGxE"}
|
|
@@ -7,7 +7,7 @@ const resource_manager_1 = require("./resource-manager");
|
|
|
7
7
|
const library_dependency_resolver_1 = require("./library-dependency-resolver");
|
|
8
8
|
const LIBRARY_LOADER_COMPONENT_ID = 'mj-react-runtime-library-loader-singleton';
|
|
9
9
|
class LibraryLoader {
|
|
10
|
-
static async loadAllLibraries(config, additionalLibraries) {
|
|
10
|
+
static async loadAllLibraries(config, additionalLibraries, options) {
|
|
11
11
|
if (config) {
|
|
12
12
|
standard_libraries_1.StandardLibraryManager.setConfiguration(config);
|
|
13
13
|
}
|
|
@@ -22,10 +22,10 @@ class LibraryLoader {
|
|
|
22
22
|
};
|
|
23
23
|
standard_libraries_1.StandardLibraryManager.setConfiguration(mergedConfig);
|
|
24
24
|
}
|
|
25
|
-
return this.loadLibrariesFromConfig();
|
|
25
|
+
return this.loadLibrariesFromConfig(undefined, options?.debug);
|
|
26
26
|
}
|
|
27
|
-
static async loadLibrariesFromConfig(options) {
|
|
28
|
-
const coreLibraries = (0, core_libraries_1.getCoreRuntimeLibraries)();
|
|
27
|
+
static async loadLibrariesFromConfig(options, debug) {
|
|
28
|
+
const coreLibraries = (0, core_libraries_1.getCoreRuntimeLibraries)(debug);
|
|
29
29
|
const corePromises = coreLibraries.map(lib => this.loadScript(lib.cdnUrl, lib.globalVariable));
|
|
30
30
|
const coreResults = await Promise.all(corePromises);
|
|
31
31
|
const React = coreResults.find((_, i) => coreLibraries[i].globalVariable === 'React');
|
|
@@ -283,18 +283,39 @@ class LibraryLoader {
|
|
|
283
283
|
const result = new Map();
|
|
284
284
|
if (debug) {
|
|
285
285
|
console.log(`📚 Loading libraries with dependencies:`, libraryNames);
|
|
286
|
+
console.log(` 📦 Total available libraries: ${allLibraries.length}`);
|
|
287
|
+
console.log(` 📋 Available library list:`, allLibraries.map(l => `${l.Name}@${l.Version}`));
|
|
286
288
|
}
|
|
287
289
|
const loadOrderResult = this.dependencyResolver.getLoadOrder(libraryNames, allLibraries, options);
|
|
288
290
|
if (!loadOrderResult.success) {
|
|
289
291
|
const errors = loadOrderResult.errors?.join(', ') || 'Unknown error';
|
|
290
292
|
throw new Error(`Failed to resolve dependencies: ${errors}`);
|
|
291
293
|
}
|
|
294
|
+
if (debug) {
|
|
295
|
+
console.log(` 📊 Dependency resolution result:`, {
|
|
296
|
+
success: loadOrderResult.success,
|
|
297
|
+
errors: loadOrderResult.errors || [],
|
|
298
|
+
warnings: loadOrderResult.warnings || []
|
|
299
|
+
});
|
|
300
|
+
if (loadOrderResult.order) {
|
|
301
|
+
console.log(` 🔄 Resolved dependencies for each library:`);
|
|
302
|
+
loadOrderResult.order.forEach(lib => {
|
|
303
|
+
const deps = this.dependencyResolver.parseDependencies(lib.Dependencies);
|
|
304
|
+
if (deps.size > 0) {
|
|
305
|
+
console.log(` • ${lib.Name}@${lib.Version} requires:`, Array.from(deps.entries()));
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
console.log(` • ${lib.Name}@${lib.Version} (no dependencies)`);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
292
313
|
if (loadOrderResult.warnings && debug) {
|
|
293
|
-
console.warn(
|
|
314
|
+
console.warn(` ⚠️ Warnings:`, loadOrderResult.warnings);
|
|
294
315
|
}
|
|
295
316
|
const loadOrder = loadOrderResult.order || [];
|
|
296
317
|
if (debug) {
|
|
297
|
-
console.log(
|
|
318
|
+
console.log(` 📋 Final load order:`, loadOrder.map(lib => `${lib.Name}@${lib.Version}`));
|
|
298
319
|
}
|
|
299
320
|
for (const library of loadOrder) {
|
|
300
321
|
if (this.loadedLibraryStates.has(library.Name)) {
|