@memberjunction/react-runtime 2.93.0 → 2.94.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/.turbo/turbo-build.log +6 -6
  2. package/CHANGELOG.md +16 -0
  3. package/README.md +180 -2
  4. package/dist/compiler/component-compiler.d.ts.map +1 -1
  5. package/dist/compiler/component-compiler.js +206 -57
  6. package/dist/compiler/component-compiler.js.map +1 -1
  7. package/dist/index.d.ts +2 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +13 -4
  10. package/dist/index.js.map +1 -1
  11. package/dist/registry/component-registry-service.d.ts +4 -3
  12. package/dist/registry/component-registry-service.d.ts.map +1 -1
  13. package/dist/registry/component-registry-service.js +27 -11
  14. package/dist/registry/component-registry-service.js.map +1 -1
  15. package/dist/registry/component-registry.d.ts +4 -3
  16. package/dist/registry/component-registry.d.ts.map +1 -1
  17. package/dist/registry/component-registry.js.map +1 -1
  18. package/dist/registry/component-resolver.d.ts +2 -1
  19. package/dist/registry/component-resolver.d.ts.map +1 -1
  20. package/dist/registry/component-resolver.js +42 -10
  21. package/dist/registry/component-resolver.js.map +1 -1
  22. package/dist/runtime/component-hierarchy.d.ts.map +1 -1
  23. package/dist/runtime/component-hierarchy.js +8 -2
  24. package/dist/runtime/component-hierarchy.js.map +1 -1
  25. package/dist/runtime/prop-builder.d.ts +2 -2
  26. package/dist/runtime/prop-builder.d.ts.map +1 -1
  27. package/dist/runtime/prop-builder.js +32 -14
  28. package/dist/runtime/prop-builder.js.map +1 -1
  29. package/dist/runtime.umd.js +1 -1
  30. package/dist/types/dependency-types.d.ts +62 -0
  31. package/dist/types/dependency-types.d.ts.map +1 -0
  32. package/dist/types/dependency-types.js +3 -0
  33. package/dist/types/dependency-types.js.map +1 -0
  34. package/dist/types/index.d.ts +8 -10
  35. package/dist/types/index.d.ts.map +1 -1
  36. package/dist/types/index.js +1 -0
  37. package/dist/types/index.js.map +1 -1
  38. package/dist/utilities/index.d.ts +1 -0
  39. package/dist/utilities/index.d.ts.map +1 -1
  40. package/dist/utilities/index.js +1 -0
  41. package/dist/utilities/index.js.map +1 -1
  42. package/dist/utilities/library-dependency-resolver.d.ts +19 -0
  43. package/dist/utilities/library-dependency-resolver.d.ts.map +1 -0
  44. package/dist/utilities/library-dependency-resolver.js +410 -0
  45. package/dist/utilities/library-dependency-resolver.js.map +1 -0
  46. package/dist/utilities/library-loader.d.ts +9 -0
  47. package/dist/utilities/library-loader.d.ts.map +1 -1
  48. package/dist/utilities/library-loader.js +143 -0
  49. package/dist/utilities/library-loader.js.map +1 -1
  50. package/package.json +5 -5
  51. package/src/compiler/component-compiler.ts +227 -77
  52. package/src/index.ts +18 -4
  53. package/src/registry/component-registry-service.ts +32 -14
  54. package/src/registry/component-registry.ts +8 -7
  55. package/src/registry/component-resolver.ts +51 -10
  56. package/src/runtime/component-hierarchy.ts +12 -4
  57. package/src/runtime/prop-builder.ts +38 -18
  58. package/src/types/dependency-types.ts +110 -0
  59. package/src/types/index.ts +17 -21
  60. package/src/utilities/index.ts +1 -0
  61. package/src/utilities/library-dependency-resolver.ts +603 -0
  62. package/src/utilities/library-loader.ts +252 -0
@@ -0,0 +1,62 @@
1
+ import { ComponentLibraryEntity } from '@memberjunction/core-entities';
2
+ export interface ParsedDependency {
3
+ name: string;
4
+ versionSpec: string;
5
+ }
6
+ export interface VersionRequirement {
7
+ library: string;
8
+ versionSpec: string;
9
+ requestedBy: string;
10
+ }
11
+ export interface ResolvedVersion {
12
+ library: string;
13
+ version: string;
14
+ satisfies: VersionRequirement[];
15
+ warnings?: string[];
16
+ }
17
+ export interface DependencyNode {
18
+ library: ComponentLibraryEntity;
19
+ dependencies: Map<string, string>;
20
+ dependents: Set<string>;
21
+ }
22
+ export interface DependencyGraph {
23
+ nodes: Map<string, DependencyNode>;
24
+ roots: Set<string>;
25
+ }
26
+ export interface LoadOrderResult {
27
+ success: boolean;
28
+ order?: ComponentLibraryEntity[];
29
+ cycles?: string[][];
30
+ errors?: string[];
31
+ warnings?: string[];
32
+ }
33
+ export type VersionRangeType = 'exact' | 'tilde' | 'caret' | 'range' | 'any';
34
+ export interface ParsedVersion {
35
+ major: number;
36
+ minor: number;
37
+ patch: number;
38
+ prerelease?: string;
39
+ build?: string;
40
+ }
41
+ export interface VersionRange {
42
+ type: VersionRangeType;
43
+ operator?: string;
44
+ version?: ParsedVersion;
45
+ raw: string;
46
+ }
47
+ export interface LoadedLibraryState {
48
+ name: string;
49
+ version: string;
50
+ globalVariable: string;
51
+ loadedAt: Date;
52
+ requestedBy: string[];
53
+ dependencies: string[];
54
+ }
55
+ export interface DependencyResolutionOptions {
56
+ allowPrerelease?: boolean;
57
+ preferLatest?: boolean;
58
+ strict?: boolean;
59
+ maxDepth?: number;
60
+ debug?: boolean;
61
+ }
62
+ //# sourceMappingURL=dependency-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependency-types.d.ts","sourceRoot":"","sources":["../../src/types/dependency-types.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAKvE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAKD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAKD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAKD,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,sBAAsB,CAAC;IAChC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,UAAU,EAAE,GA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AQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=dependency-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependency-types.js","sourceRoot":"","sources":["../../src/types/dependency-types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * @fileoverview Type definitions for library dependency management\n * @module @memberjunction/react-runtime/types\n */\n\nimport { ComponentLibraryEntity } from '@memberjunction/core-entities';\n\n/**\n * Represents a parsed dependency with name and version specification\n */\nexport interface ParsedDependency {\n name: string;\n versionSpec: string;\n}\n\n/**\n * Represents a version requirement for a library\n */\nexport interface VersionRequirement {\n library: string;\n versionSpec: string;\n requestedBy: string; // Which library requested this dependency\n}\n\n/**\n * Represents a resolved version after conflict resolution\n */\nexport interface ResolvedVersion {\n library: string;\n version: string;\n satisfies: VersionRequirement[];\n warnings?: string[];\n}\n\n/**\n * Node in the dependency graph\n */\nexport interface DependencyNode {\n library: ComponentLibraryEntity;\n dependencies: Map<string, string>; // dependency name -> version spec\n dependents: Set<string>; // libraries that depend on this one\n}\n\n/**\n * Dependency graph structure\n */\nexport interface DependencyGraph {\n nodes: Map<string, DependencyNode>;\n roots: Set<string>; // libraries with no dependents\n}\n\n/**\n * Result of determining load order\n */\nexport interface LoadOrderResult {\n success: boolean;\n order?: ComponentLibraryEntity[];\n cycles?: string[][];\n errors?: string[];\n warnings?: string[];\n}\n\n/**\n * Semver version range types\n */\nexport type VersionRangeType = 'exact' | 'tilde' | 'caret' | 'range' | 'any';\n\n/**\n * Parsed semver version\n */\nexport interface ParsedVersion {\n major: number;\n minor: number;\n patch: number;\n prerelease?: string;\n build?: string;\n}\n\n/**\n * Version range specification\n */\nexport interface VersionRange {\n type: VersionRangeType;\n operator?: string;\n version?: ParsedVersion;\n raw: string;\n}\n\n/**\n * Library load state tracking\n */\nexport interface LoadedLibraryState {\n name: string;\n version: string;\n globalVariable: string;\n loadedAt: Date;\n requestedBy: string[];\n dependencies: string[];\n}\n\n/**\n * Options for dependency resolution\n */\nexport interface DependencyResolutionOptions {\n allowPrerelease?: boolean;\n preferLatest?: boolean;\n strict?: boolean; // Fail on any version conflict\n maxDepth?: number; // Maximum dependency depth to prevent infinite recursion\n debug?: boolean;\n}"]}
@@ -1,7 +1,7 @@
1
1
  import { ComponentLibraryEntity } from '@memberjunction/core-entities';
2
- import { ComponentLibraryDependency, ComponentStyles } from '@memberjunction/interactive-component-types';
2
+ import { ComponentLibraryDependency, ComponentStyles, ComponentObject } from '@memberjunction/interactive-component-types';
3
3
  export interface CompiledComponent {
4
- component: any;
4
+ factory: (context: RuntimeContext, styles?: ComponentStyles) => ComponentObject;
5
5
  id: string;
6
6
  name: string;
7
7
  compiledAt: Date;
@@ -22,7 +22,7 @@ export interface CompileOptions {
22
22
  allLibraries: ComponentLibraryEntity[];
23
23
  }
24
24
  export interface RegistryEntry {
25
- component: any;
25
+ component: ComponentObject;
26
26
  metadata: ComponentMetadata;
27
27
  lastAccessed: Date;
28
28
  refCount: number;
@@ -46,17 +46,11 @@ export interface ComponentProps {
46
46
  data: any;
47
47
  userState: any;
48
48
  utilities: any;
49
- callbacks: ComponentCallbacks;
49
+ callbacks: any;
50
50
  components?: Record<string, any>;
51
51
  styles?: ComponentStyles;
52
52
  onStateChanged?: (stateUpdate: Record<string, any>) => void;
53
53
  }
54
- export interface ComponentCallbacks {
55
- RefreshData?: () => void;
56
- OpenEntityRecord?: (entityName: string, key: any) => void;
57
- UpdateUserState?: (state: any) => void;
58
- NotifyEvent?: (event: string, data: any) => void;
59
- }
60
54
  export interface CompilerConfig {
61
55
  babel: {
62
56
  presets: string[];
@@ -66,12 +60,14 @@ export interface CompilerConfig {
66
60
  sourceMaps: boolean;
67
61
  cache: boolean;
68
62
  maxCacheSize: number;
63
+ debug?: boolean;
69
64
  }
70
65
  export interface RegistryConfig {
71
66
  maxComponents: number;
72
67
  cleanupInterval: number;
73
68
  useLRU: boolean;
74
69
  enableNamespaces: boolean;
70
+ debug?: boolean;
75
71
  }
76
72
  export interface CompilationResult {
77
73
  success: boolean;
@@ -100,4 +96,6 @@ export interface ErrorBoundaryOptions {
100
96
  recovery?: 'retry' | 'reset' | 'none';
101
97
  }
102
98
  export * from './library-config';
99
+ export * from './dependency-types';
100
+ export { ComponentObject } from '@memberjunction/interactive-component-types';
103
101
  //# sourceMappingURL=index.d.ts.map
@@ -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,MAAM,6CAA6C,CAAC;AAK1G,MAAM,WAAW,iBAAiB;IAEhC,SAAS,EAAE,GAAG,CAAC;IAEf,EAAE,EAAE,MAAM,CAAC;IAEX,IAAI,EAAE,MAAM,CAAC;IAEb,UAAU,EAAE,IAAI,CAAC;IAEjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAKD,MAAM,WAAW,cAAc;IAE7B,aAAa,EAAE,MAAM,CAAC;IAEtB,aAAa,EAAE,MAAM,CAAC;IAEtB,MAAM,CAAC,EAAE,eAAe,CAAC;IAEzB,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAGxB,SAAS,CAAC,EAAE,0BAA0B,EAAE,CAAC;IAGzC,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAKtD,YAAY,EAAE,sBAAsB,EAAE,CAAC;CACxC;AAMD,MAAM,WAAW,aAAa;IAE5B,SAAS,EAAE,GAAG,CAAC;IAEf,QAAQ,E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AAc,kBAAkB,CAAC;AAGjC,cAAc,oBAAoB,CAAC;AAGnC,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC"}
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./library-config"), exports);
18
+ __exportStar(require("./dependency-types"), exports);
18
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA0OA,mDAAiC","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 } from '@memberjunction/interactive-component-types';\n\n/**\n * Represents a compiled React component with its metadata\n */\nexport interface CompiledComponent {\n /** The compiled React component function or class */\n component: any;\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 */\n component: any;\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: ComponentCallbacks;\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 * Callbacks available to React components\n */\nexport interface ComponentCallbacks {\n /** Request data refresh */\n RefreshData?: () => void;\n /** Open an entity record */\n OpenEntityRecord?: (entityName: string, key: any) => void;\n /** Update user state */\n UpdateUserState?: (state: any) => void;\n /** Notify of a custom event */\n NotifyEvent?: (event: string, data: 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}\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}\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';"]}
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';"]}
@@ -2,6 +2,7 @@ export * from './component-styles';
2
2
  export * from './standard-libraries';
3
3
  export * from './library-loader';
4
4
  export * from './library-registry';
5
+ export * from './library-dependency-resolver';
5
6
  export * from './component-error-analyzer';
6
7
  export * from './resource-manager';
7
8
  export * from './cache-manager';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAKA,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAKA,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
@@ -18,6 +18,7 @@ __exportStar(require("./component-styles"), exports);
18
18
  __exportStar(require("./standard-libraries"), exports);
19
19
  __exportStar(require("./library-loader"), exports);
20
20
  __exportStar(require("./library-registry"), exports);
21
+ __exportStar(require("./library-dependency-resolver"), exports);
21
22
  __exportStar(require("./component-error-analyzer"), exports);
22
23
  __exportStar(require("./resource-manager"), exports);
23
24
  __exportStar(require("./cache-manager"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAKA,qDAAmC;AACnC,uDAAqC;AACrC,mDAAiC;AACjC,qDAAmC;AACnC,6DAA2C;AAC3C,qDAAmC;AACnC,kDAAgC","sourcesContent":["/**\n * @fileoverview Utilities module exports\n * @module @memberjunction/react-runtime/utilities\n */\n\nexport * from './component-styles';\nexport * from './standard-libraries';\nexport * from './library-loader';\nexport * from './library-registry';\nexport * from './component-error-analyzer';\nexport * from './resource-manager';\nexport * from './cache-manager';"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAKA,qDAAmC;AACnC,uDAAqC;AACrC,mDAAiC;AACjC,qDAAmC;AACnC,gEAA8C;AAC9C,6DAA2C;AAC3C,qDAAmC;AACnC,kDAAgC","sourcesContent":["/**\n * @fileoverview Utilities module exports\n * @module @memberjunction/react-runtime/utilities\n */\n\nexport * from './component-styles';\nexport * from './standard-libraries';\nexport * from './library-loader';\nexport * from './library-registry';\nexport * from './library-dependency-resolver';\nexport * from './component-error-analyzer';\nexport * from './resource-manager';\nexport * from './cache-manager';"]}
@@ -0,0 +1,19 @@
1
+ import { ComponentLibraryEntity } from '@memberjunction/core-entities';
2
+ import { DependencyGraph, LoadOrderResult, ResolvedVersion, VersionRequirement, DependencyResolutionOptions } from '../types/dependency-types';
3
+ export declare class LibraryDependencyResolver {
4
+ private debug;
5
+ constructor(options?: DependencyResolutionOptions);
6
+ parseDependencies(json: string | null): Map<string, string>;
7
+ buildDependencyGraph(libraries: ComponentLibraryEntity[]): DependencyGraph;
8
+ detectCycles(graph: DependencyGraph): string[][];
9
+ topologicalSort(graph: DependencyGraph): ComponentLibraryEntity[];
10
+ private parseVersion;
11
+ private parseVersionRange;
12
+ private versionSatisfiesRange;
13
+ private compareVersions;
14
+ resolveVersionConflicts(requirements: VersionRequirement[], availableLibraries: ComponentLibraryEntity[]): ResolvedVersion;
15
+ getLoadOrder(requestedLibs: string[], allLibs: ComponentLibraryEntity[], options?: DependencyResolutionOptions): LoadOrderResult;
16
+ getDirectDependencies(library: ComponentLibraryEntity): Map<string, string>;
17
+ getTransitiveDependencies(libraryName: string, allLibs: ComponentLibraryEntity[], maxDepth?: number): Set<string>;
18
+ }
19
+ //# sourceMappingURL=library-dependency-resolver.d.ts.map
@@ -0,0 +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,EAAE,GAAG,eAAe;IAuC1E,YAAY,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,EAAE,EAAE;IA4ChD,eAAe,CAAC,KAAK,EAAE,eAAe,GAAG,sBAAsB,EAAE;IAmDjE,OAAO,CAAC,YAAY;IAoBpB,OAAO,CAAC,iBAAiB;IA6CzB,OAAO,CAAC,qBAAqB;IAmD7B,OAAO,CAAC,eAAe;IAqBvB,uBAAuB,CACrB,YAAY,EAAE,kBAAkB,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;IAwIlB,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"}
@@ -0,0 +1,410 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LibraryDependencyResolver = void 0;
4
+ class LibraryDependencyResolver {
5
+ constructor(options) {
6
+ this.debug = false;
7
+ this.debug = options?.debug || false;
8
+ }
9
+ parseDependencies(json) {
10
+ const dependencies = new Map();
11
+ if (!json || json.trim() === '') {
12
+ return dependencies;
13
+ }
14
+ try {
15
+ const parsed = JSON.parse(json);
16
+ if (typeof parsed === 'object' && parsed !== null) {
17
+ for (const [name, version] of Object.entries(parsed)) {
18
+ if (typeof version === 'string') {
19
+ dependencies.set(name, version);
20
+ }
21
+ }
22
+ }
23
+ }
24
+ catch (error) {
25
+ console.error('Failed to parse dependencies JSON:', error);
26
+ }
27
+ return dependencies;
28
+ }
29
+ buildDependencyGraph(libraries) {
30
+ const nodes = new Map();
31
+ const roots = new Set();
32
+ for (const library of libraries) {
33
+ const dependencies = this.parseDependencies(library.Dependencies);
34
+ nodes.set(library.Name, {
35
+ library,
36
+ dependencies,
37
+ dependents: new Set()
38
+ });
39
+ roots.add(library.Name);
40
+ }
41
+ for (const [name, node] of nodes) {
42
+ for (const [depName, depVersion] of node.dependencies) {
43
+ const depNode = nodes.get(depName);
44
+ if (depNode) {
45
+ roots.delete(depName);
46
+ depNode.dependents.add(name);
47
+ }
48
+ else if (this.debug) {
49
+ console.warn(`Dependency '${depName}' not found for library '${name}'`);
50
+ }
51
+ }
52
+ }
53
+ return { nodes, roots };
54
+ }
55
+ detectCycles(graph) {
56
+ const cycles = [];
57
+ const visited = new Set();
58
+ const recursionStack = new Set();
59
+ const path = [];
60
+ const detectCyclesUtil = (nodeName) => {
61
+ visited.add(nodeName);
62
+ recursionStack.add(nodeName);
63
+ path.push(nodeName);
64
+ const node = graph.nodes.get(nodeName);
65
+ if (node) {
66
+ for (const [depName] of node.dependencies) {
67
+ if (!visited.has(depName)) {
68
+ detectCyclesUtil(depName);
69
+ }
70
+ else if (recursionStack.has(depName)) {
71
+ const cycleStartIndex = path.indexOf(depName);
72
+ const cycle = [...path.slice(cycleStartIndex), depName];
73
+ cycles.push(cycle);
74
+ }
75
+ }
76
+ }
77
+ path.pop();
78
+ recursionStack.delete(nodeName);
79
+ };
80
+ for (const nodeName of graph.nodes.keys()) {
81
+ if (!visited.has(nodeName)) {
82
+ detectCyclesUtil(nodeName);
83
+ }
84
+ }
85
+ return cycles;
86
+ }
87
+ topologicalSort(graph) {
88
+ const result = [];
89
+ const visited = new Set();
90
+ const tempMarked = new Set();
91
+ const visit = (nodeName) => {
92
+ if (tempMarked.has(nodeName)) {
93
+ return false;
94
+ }
95
+ if (visited.has(nodeName)) {
96
+ return true;
97
+ }
98
+ tempMarked.add(nodeName);
99
+ const node = graph.nodes.get(nodeName);
100
+ if (node) {
101
+ for (const [depName] of node.dependencies) {
102
+ if (graph.nodes.has(depName)) {
103
+ if (!visit(depName)) {
104
+ return false;
105
+ }
106
+ }
107
+ }
108
+ result.push(node.library);
109
+ }
110
+ tempMarked.delete(nodeName);
111
+ visited.add(nodeName);
112
+ return true;
113
+ };
114
+ for (const nodeName of graph.nodes.keys()) {
115
+ if (!visited.has(nodeName)) {
116
+ if (!visit(nodeName)) {
117
+ console.error(`Cycle detected involving library: ${nodeName}`);
118
+ }
119
+ }
120
+ }
121
+ return result;
122
+ }
123
+ parseVersion(version) {
124
+ const match = version.match(/^(\d+)\.(\d+)\.(\d+)(?:-([^+]+))?(?:\+(.+))?$/);
125
+ if (!match) {
126
+ return null;
127
+ }
128
+ return {
129
+ major: parseInt(match[1], 10),
130
+ minor: parseInt(match[2], 10),
131
+ patch: parseInt(match[3], 10),
132
+ prerelease: match[4],
133
+ build: match[5]
134
+ };
135
+ }
136
+ parseVersionRange(spec) {
137
+ if (spec === '*' || spec === '' || spec === 'latest') {
138
+ return { type: 'any', raw: spec };
139
+ }
140
+ if (spec.startsWith('~')) {
141
+ const version = this.parseVersion(spec.substring(1));
142
+ return {
143
+ type: 'tilde',
144
+ version: version || undefined,
145
+ raw: spec
146
+ };
147
+ }
148
+ if (spec.startsWith('^')) {
149
+ const version = this.parseVersion(spec.substring(1));
150
+ return {
151
+ type: 'caret',
152
+ version: version || undefined,
153
+ raw: spec
154
+ };
155
+ }
156
+ const version = this.parseVersion(spec);
157
+ if (version) {
158
+ return {
159
+ type: 'exact',
160
+ version,
161
+ raw: spec
162
+ };
163
+ }
164
+ return { type: 'any', raw: spec };
165
+ }
166
+ versionSatisfiesRange(version, range) {
167
+ if (range.type === 'any') {
168
+ return true;
169
+ }
170
+ if (!range.version) {
171
+ return false;
172
+ }
173
+ const rangeVer = range.version;
174
+ switch (range.type) {
175
+ case 'exact':
176
+ return version.major === rangeVer.major &&
177
+ version.minor === rangeVer.minor &&
178
+ version.patch === rangeVer.patch;
179
+ case 'tilde':
180
+ if (version.major !== rangeVer.major)
181
+ return false;
182
+ if (version.minor !== rangeVer.minor)
183
+ return false;
184
+ return version.patch >= rangeVer.patch;
185
+ case 'caret':
186
+ if (rangeVer.major === 0) {
187
+ if (version.major !== 0)
188
+ return false;
189
+ if (rangeVer.minor === 0) {
190
+ return version.minor === 0 && version.patch === rangeVer.patch;
191
+ }
192
+ if (version.minor !== rangeVer.minor)
193
+ return false;
194
+ return version.patch >= rangeVer.patch;
195
+ }
196
+ if (version.major !== rangeVer.major)
197
+ return false;
198
+ if (version.minor < rangeVer.minor)
199
+ return false;
200
+ if (version.minor === rangeVer.minor) {
201
+ return version.patch >= rangeVer.patch;
202
+ }
203
+ return true;
204
+ default:
205
+ return false;
206
+ }
207
+ }
208
+ compareVersions(a, b) {
209
+ if (a.major !== b.major)
210
+ return a.major - b.major;
211
+ if (a.minor !== b.minor)
212
+ return a.minor - b.minor;
213
+ if (a.patch !== b.patch)
214
+ return a.patch - b.patch;
215
+ if (!a.prerelease && b.prerelease)
216
+ return 1;
217
+ if (a.prerelease && !b.prerelease)
218
+ return -1;
219
+ if (a.prerelease && b.prerelease) {
220
+ return a.prerelease.localeCompare(b.prerelease);
221
+ }
222
+ return 0;
223
+ }
224
+ resolveVersionConflicts(requirements, availableLibraries) {
225
+ if (requirements.length === 0) {
226
+ throw new Error('No version requirements provided');
227
+ }
228
+ const libraryName = requirements[0].library;
229
+ const warnings = [];
230
+ const availableVersions = availableLibraries
231
+ .filter(lib => lib.Name === libraryName && lib.Version)
232
+ .map(lib => ({
233
+ library: lib,
234
+ version: this.parseVersion(lib.Version)
235
+ }))
236
+ .filter(item => item.version !== null)
237
+ .sort((a, b) => this.compareVersions(b.version, a.version));
238
+ if (availableVersions.length === 0) {
239
+ throw new Error(`No versions available for library '${libraryName}'`);
240
+ }
241
+ const ranges = requirements.map(req => ({
242
+ ...req,
243
+ range: this.parseVersionRange(req.versionSpec)
244
+ }));
245
+ for (const { library, version } of availableVersions) {
246
+ let satisfiesAll = true;
247
+ const satisfiedRequirements = [];
248
+ for (const req of ranges) {
249
+ if (this.versionSatisfiesRange(version, req.range)) {
250
+ satisfiedRequirements.push(req);
251
+ }
252
+ else {
253
+ satisfiesAll = false;
254
+ warnings.push(`Version ${library.Version} does not satisfy '${req.versionSpec}' required by ${req.requestedBy}`);
255
+ break;
256
+ }
257
+ }
258
+ if (satisfiesAll) {
259
+ return {
260
+ library: libraryName,
261
+ version: library.Version,
262
+ satisfies: requirements,
263
+ warnings: warnings.length > 0 ? warnings : undefined
264
+ };
265
+ }
266
+ }
267
+ const latest = availableVersions[0];
268
+ warnings.push(`Could not find a version that satisfies all requirements. Using ${latest.library.Version}`);
269
+ return {
270
+ library: libraryName,
271
+ version: latest.library.Version,
272
+ satisfies: [],
273
+ warnings
274
+ };
275
+ }
276
+ getLoadOrder(requestedLibs, allLibs, options) {
277
+ const errors = [];
278
+ const warnings = [];
279
+ if (this.debug || options?.debug) {
280
+ console.log('🔍 Getting load order for:', requestedLibs);
281
+ }
282
+ const libMap = new Map();
283
+ for (const lib of allLibs) {
284
+ if (!libMap.has(lib.Name)) {
285
+ libMap.set(lib.Name, []);
286
+ }
287
+ libMap.get(lib.Name).push(lib);
288
+ }
289
+ const needed = new Set();
290
+ const toProcess = [...requestedLibs];
291
+ const processed = new Set();
292
+ const versionRequirements = new Map();
293
+ let depth = 0;
294
+ const maxDepth = options?.maxDepth || 10;
295
+ while (toProcess.length > 0 && depth < maxDepth) {
296
+ const current = toProcess.shift();
297
+ if (processed.has(current))
298
+ continue;
299
+ processed.add(current);
300
+ needed.add(current);
301
+ const libVersions = libMap.get(current);
302
+ if (!libVersions || libVersions.length === 0) {
303
+ errors.push(`Library '${current}' not found`);
304
+ continue;
305
+ }
306
+ const lib = libVersions[0];
307
+ const deps = this.parseDependencies(lib.Dependencies);
308
+ for (const [depName, depVersion] of deps) {
309
+ needed.add(depName);
310
+ if (!versionRequirements.has(depName)) {
311
+ versionRequirements.set(depName, []);
312
+ }
313
+ versionRequirements.get(depName).push({
314
+ library: depName,
315
+ versionSpec: depVersion,
316
+ requestedBy: current
317
+ });
318
+ if (!processed.has(depName)) {
319
+ toProcess.push(depName);
320
+ }
321
+ }
322
+ depth++;
323
+ }
324
+ if (depth >= maxDepth) {
325
+ warnings.push(`Maximum dependency depth (${maxDepth}) reached`);
326
+ }
327
+ const resolvedLibraries = [];
328
+ for (const libName of needed) {
329
+ const requirements = versionRequirements.get(libName) || [];
330
+ const versions = libMap.get(libName) || [];
331
+ if (versions.length === 0) {
332
+ errors.push(`Library '${libName}' not found`);
333
+ continue;
334
+ }
335
+ if (requirements.length > 0) {
336
+ try {
337
+ const resolved = this.resolveVersionConflicts(requirements, versions);
338
+ const selectedLib = versions.find(lib => lib.Version === resolved.version);
339
+ if (selectedLib) {
340
+ resolvedLibraries.push(selectedLib);
341
+ if (resolved.warnings) {
342
+ warnings.push(...resolved.warnings);
343
+ }
344
+ }
345
+ }
346
+ catch (error) {
347
+ errors.push(error.message);
348
+ resolvedLibraries.push(versions[0]);
349
+ }
350
+ }
351
+ else {
352
+ resolvedLibraries.push(versions[0]);
353
+ }
354
+ }
355
+ const graph = this.buildDependencyGraph(resolvedLibraries);
356
+ const cycles = this.detectCycles(graph);
357
+ if (cycles.length > 0) {
358
+ errors.push(`Circular dependencies detected: ${cycles.map(c => c.join(' -> ')).join(', ')}`);
359
+ return {
360
+ success: false,
361
+ cycles,
362
+ errors,
363
+ warnings: warnings.length > 0 ? warnings : undefined
364
+ };
365
+ }
366
+ const sorted = this.topologicalSort(graph);
367
+ if (this.debug || options?.debug) {
368
+ console.log('✅ Load order determined:', sorted.map(lib => `${lib.Name}@${lib.Version}`));
369
+ }
370
+ return {
371
+ success: errors.length === 0,
372
+ order: sorted,
373
+ errors: errors.length > 0 ? errors : undefined,
374
+ warnings: warnings.length > 0 ? warnings : undefined
375
+ };
376
+ }
377
+ getDirectDependencies(library) {
378
+ return this.parseDependencies(library.Dependencies);
379
+ }
380
+ getTransitiveDependencies(libraryName, allLibs, maxDepth = 10) {
381
+ const dependencies = new Set();
382
+ const toProcess = [libraryName];
383
+ const processed = new Set();
384
+ let depth = 0;
385
+ const libMap = new Map();
386
+ for (const lib of allLibs) {
387
+ libMap.set(lib.Name, lib);
388
+ }
389
+ while (toProcess.length > 0 && depth < maxDepth) {
390
+ const current = toProcess.shift();
391
+ if (processed.has(current))
392
+ continue;
393
+ processed.add(current);
394
+ const lib = libMap.get(current);
395
+ if (!lib)
396
+ continue;
397
+ const deps = this.parseDependencies(lib.Dependencies);
398
+ for (const [depName] of deps) {
399
+ dependencies.add(depName);
400
+ if (!processed.has(depName)) {
401
+ toProcess.push(depName);
402
+ }
403
+ }
404
+ depth++;
405
+ }
406
+ return dependencies;
407
+ }
408
+ }
409
+ exports.LibraryDependencyResolver = LibraryDependencyResolver;
410
+ //# sourceMappingURL=library-dependency-resolver.js.map