@memberjunction/react-runtime 2.93.0 → 2.95.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 +6 -6
- package/CHANGELOG.md +28 -0
- package/README.md +180 -2
- 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 +253 -61
- package/dist/compiler/component-compiler.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/dist/registry/component-registry-service.d.ts +6 -3
- package/dist/registry/component-registry-service.d.ts.map +1 -1
- package/dist/registry/component-registry-service.js +38 -11
- package/dist/registry/component-registry-service.js.map +1 -1
- package/dist/registry/component-registry.d.ts +6 -3
- 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 +2 -1
- package/dist/registry/component-resolver.d.ts.map +1 -1
- package/dist/registry/component-resolver.js +101 -14
- 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 +75 -13
- package/dist/runtime/component-hierarchy.js.map +1 -1
- package/dist/runtime/prop-builder.d.ts +2 -2
- package/dist/runtime/prop-builder.d.ts.map +1 -1
- package/dist/runtime/prop-builder.js +32 -14
- package/dist/runtime/prop-builder.js.map +1 -1
- package/dist/runtime.umd.js +1 -1
- package/dist/types/dependency-types.d.ts +62 -0
- package/dist/types/dependency-types.d.ts.map +1 -0
- package/dist/types/dependency-types.js +3 -0
- package/dist/types/dependency-types.js.map +1 -0
- package/dist/types/index.d.ts +8 -10
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/index.d.ts +1 -0
- package/dist/utilities/index.d.ts.map +1 -1
- package/dist/utilities/index.js +1 -0
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/library-dependency-resolver.d.ts +19 -0
- package/dist/utilities/library-dependency-resolver.d.ts.map +1 -0
- package/dist/utilities/library-dependency-resolver.js +419 -0
- package/dist/utilities/library-dependency-resolver.js.map +1 -0
- package/dist/utilities/library-loader.d.ts +9 -0
- package/dist/utilities/library-loader.d.ts.map +1 -1
- package/dist/utilities/library-loader.js +164 -0
- package/dist/utilities/library-loader.js.map +1 -1
- package/package.json +5 -5
- package/src/compiler/component-compiler.ts +280 -82
- package/src/index.ts +20 -5
- package/src/registry/component-registry-service.ts +53 -14
- package/src/registry/component-registry.ts +36 -7
- package/src/registry/component-resolver.ts +130 -16
- package/src/runtime/component-hierarchy.ts +101 -27
- package/src/runtime/prop-builder.ts +38 -18
- package/src/types/dependency-types.ts +110 -0
- package/src/types/index.ts +17 -21
- package/src/utilities/index.ts +1 -0
- package/src/utilities/library-dependency-resolver.ts +613 -0
- package/src/utilities/library-loader.ts +274 -0
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @module @memberjunction/react-runtime/runtime
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { ComponentStyles } from '@memberjunction/interactive-component-types';
|
|
8
|
-
import { ComponentProps
|
|
7
|
+
import { ComponentStyles, ComponentCallbacks } from '@memberjunction/interactive-component-types';
|
|
8
|
+
import { ComponentProps } from '../types';
|
|
9
9
|
import { Subject, debounceTime, Subscription } from 'rxjs';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -39,7 +39,10 @@ export function buildComponentProps(
|
|
|
39
39
|
data: any = {},
|
|
40
40
|
userState: any = {},
|
|
41
41
|
utilities: any = {},
|
|
42
|
-
callbacks: ComponentCallbacks = {
|
|
42
|
+
callbacks: ComponentCallbacks = {
|
|
43
|
+
OpenEntityRecord: () => {},
|
|
44
|
+
RegisterMethod: () => {}
|
|
45
|
+
},
|
|
43
46
|
components: Record<string, any> = {},
|
|
44
47
|
styles?: ComponentStyles,
|
|
45
48
|
options: PropBuilderOptions = {},
|
|
@@ -116,15 +119,19 @@ function deepEqual(obj1: any, obj2: any): boolean {
|
|
|
116
119
|
* @returns Normalized callbacks
|
|
117
120
|
*/
|
|
118
121
|
export function normalizeCallbacks(callbacks: any, debounceMs: number = 3000): ComponentCallbacks {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
122
|
+
// Provide default implementations for required callbacks
|
|
123
|
+
const normalized: ComponentCallbacks = {
|
|
124
|
+
OpenEntityRecord: callbacks?.OpenEntityRecord || (() => {}),
|
|
125
|
+
RegisterMethod: callbacks?.RegisterMethod || (() => {})
|
|
126
|
+
};
|
|
125
127
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
+
// Copy any additional callbacks that might exist
|
|
129
|
+
if (callbacks) {
|
|
130
|
+
Object.keys(callbacks).forEach(key => {
|
|
131
|
+
if (typeof callbacks[key] === 'function' && !normalized.hasOwnProperty(key)) {
|
|
132
|
+
(normalized as any)[key] = callbacks[key];
|
|
133
|
+
}
|
|
134
|
+
});
|
|
128
135
|
}
|
|
129
136
|
|
|
130
137
|
return normalized;
|
|
@@ -264,14 +271,20 @@ export function wrapCallbacksWithLogging(
|
|
|
264
271
|
callbacks: ComponentCallbacks,
|
|
265
272
|
componentName: string
|
|
266
273
|
): ComponentCallbacks {
|
|
267
|
-
const wrapped: ComponentCallbacks = {
|
|
274
|
+
const wrapped: ComponentCallbacks = {
|
|
275
|
+
OpenEntityRecord: callbacks?.OpenEntityRecord || (() => {}),
|
|
276
|
+
RegisterMethod: callbacks?.RegisterMethod || (() => {})
|
|
277
|
+
};
|
|
268
278
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
279
|
+
// Wrap any additional callbacks that might exist
|
|
280
|
+
Object.keys(callbacks).forEach(key => {
|
|
281
|
+
if (key !== 'OpenEntityRecord' && key !== 'RegisterMethod' && typeof (callbacks as any)[key] === 'function') {
|
|
282
|
+
(wrapped as any)[key] = (...args: any[]) => {
|
|
283
|
+
console.log(`[${componentName}] ${key} called with args:`, args);
|
|
284
|
+
return (callbacks as any)[key](...args);
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
});
|
|
275
288
|
|
|
276
289
|
if (callbacks.OpenEntityRecord) {
|
|
277
290
|
wrapped.OpenEntityRecord = (entityName: string, key: any) => {
|
|
@@ -280,6 +293,13 @@ export function wrapCallbacksWithLogging(
|
|
|
280
293
|
};
|
|
281
294
|
}
|
|
282
295
|
|
|
296
|
+
if (callbacks.RegisterMethod) {
|
|
297
|
+
wrapped.RegisterMethod = (methodName: any, handler: any) => {
|
|
298
|
+
console.log(`[${componentName}] RegisterMethod called for:`, methodName);
|
|
299
|
+
callbacks.RegisterMethod!(methodName, handler);
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
283
303
|
return wrapped;
|
|
284
304
|
}
|
|
285
305
|
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Type definitions for library dependency management
|
|
3
|
+
* @module @memberjunction/react-runtime/types
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ComponentLibraryEntity } from '@memberjunction/core-entities';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Represents a parsed dependency with name and version specification
|
|
10
|
+
*/
|
|
11
|
+
export interface ParsedDependency {
|
|
12
|
+
name: string;
|
|
13
|
+
versionSpec: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represents a version requirement for a library
|
|
18
|
+
*/
|
|
19
|
+
export interface VersionRequirement {
|
|
20
|
+
library: string;
|
|
21
|
+
versionSpec: string;
|
|
22
|
+
requestedBy: string; // Which library requested this dependency
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Represents a resolved version after conflict resolution
|
|
27
|
+
*/
|
|
28
|
+
export interface ResolvedVersion {
|
|
29
|
+
library: string;
|
|
30
|
+
version: string;
|
|
31
|
+
satisfies: VersionRequirement[];
|
|
32
|
+
warnings?: string[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Node in the dependency graph
|
|
37
|
+
*/
|
|
38
|
+
export interface DependencyNode {
|
|
39
|
+
library: ComponentLibraryEntity;
|
|
40
|
+
dependencies: Map<string, string>; // dependency name -> version spec
|
|
41
|
+
dependents: Set<string>; // libraries that depend on this one
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Dependency graph structure
|
|
46
|
+
*/
|
|
47
|
+
export interface DependencyGraph {
|
|
48
|
+
nodes: Map<string, DependencyNode>;
|
|
49
|
+
roots: Set<string>; // libraries with no dependents
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Result of determining load order
|
|
54
|
+
*/
|
|
55
|
+
export interface LoadOrderResult {
|
|
56
|
+
success: boolean;
|
|
57
|
+
order?: ComponentLibraryEntity[];
|
|
58
|
+
cycles?: string[][];
|
|
59
|
+
errors?: string[];
|
|
60
|
+
warnings?: string[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Semver version range types
|
|
65
|
+
*/
|
|
66
|
+
export type VersionRangeType = 'exact' | 'tilde' | 'caret' | 'range' | 'any';
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Parsed semver version
|
|
70
|
+
*/
|
|
71
|
+
export interface ParsedVersion {
|
|
72
|
+
major: number;
|
|
73
|
+
minor: number;
|
|
74
|
+
patch: number;
|
|
75
|
+
prerelease?: string;
|
|
76
|
+
build?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Version range specification
|
|
81
|
+
*/
|
|
82
|
+
export interface VersionRange {
|
|
83
|
+
type: VersionRangeType;
|
|
84
|
+
operator?: string;
|
|
85
|
+
version?: ParsedVersion;
|
|
86
|
+
raw: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Library load state tracking
|
|
91
|
+
*/
|
|
92
|
+
export interface LoadedLibraryState {
|
|
93
|
+
name: string;
|
|
94
|
+
version: string;
|
|
95
|
+
globalVariable: string;
|
|
96
|
+
loadedAt: Date;
|
|
97
|
+
requestedBy: string[];
|
|
98
|
+
dependencies: string[];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Options for dependency resolution
|
|
103
|
+
*/
|
|
104
|
+
export interface DependencyResolutionOptions {
|
|
105
|
+
allowPrerelease?: boolean;
|
|
106
|
+
preferLatest?: boolean;
|
|
107
|
+
strict?: boolean; // Fail on any version conflict
|
|
108
|
+
maxDepth?: number; // Maximum dependency depth to prevent infinite recursion
|
|
109
|
+
debug?: boolean;
|
|
110
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
|
|
7
7
|
import { UserInfo } from '@memberjunction/core';
|
|
8
8
|
import { ComponentLibraryEntity } from '@memberjunction/core-entities';
|
|
9
|
-
import { ComponentLibraryDependency, ComponentStyles } from '@memberjunction/interactive-component-types';
|
|
9
|
+
import { ComponentLibraryDependency, ComponentStyles, ComponentObject } from '@memberjunction/interactive-component-types';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Represents a compiled React component with its metadata
|
|
13
13
|
*/
|
|
14
14
|
export interface CompiledComponent {
|
|
15
|
-
/**
|
|
16
|
-
|
|
15
|
+
/** Factory function that creates a ComponentObject when called with context */
|
|
16
|
+
factory: (context: RuntimeContext, styles?: ComponentStyles, components?: Record<string, any>) => ComponentObject;
|
|
17
17
|
/** Unique identifier for the component */
|
|
18
18
|
id: string;
|
|
19
19
|
/** Original component name */
|
|
@@ -58,8 +58,8 @@ export interface CompileOptions {
|
|
|
58
58
|
* Registry entry for a compiled component
|
|
59
59
|
*/
|
|
60
60
|
export interface RegistryEntry {
|
|
61
|
-
/** The compiled component */
|
|
62
|
-
component:
|
|
61
|
+
/** The compiled component object with all methods */
|
|
62
|
+
component: ComponentObject;
|
|
63
63
|
/** Component metadata */
|
|
64
64
|
metadata: ComponentMetadata;
|
|
65
65
|
/** Last access time for LRU cache */
|
|
@@ -113,7 +113,7 @@ export interface ComponentProps {
|
|
|
113
113
|
/** Utility functions available to the component */
|
|
114
114
|
utilities: any;
|
|
115
115
|
/** Callback functions */
|
|
116
|
-
callbacks:
|
|
116
|
+
callbacks: any;
|
|
117
117
|
/** Child components available for use */
|
|
118
118
|
components?: Record<string, any>;
|
|
119
119
|
/** Component styles */
|
|
@@ -122,20 +122,6 @@ export interface ComponentProps {
|
|
|
122
122
|
onStateChanged?: (stateUpdate: Record<string, any>) => void;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
/**
|
|
126
|
-
* Callbacks available to React components
|
|
127
|
-
*/
|
|
128
|
-
export interface ComponentCallbacks {
|
|
129
|
-
/** Request data refresh */
|
|
130
|
-
RefreshData?: () => void;
|
|
131
|
-
/** Open an entity record */
|
|
132
|
-
OpenEntityRecord?: (entityName: string, key: any) => void;
|
|
133
|
-
/** Update user state */
|
|
134
|
-
UpdateUserState?: (state: any) => void;
|
|
135
|
-
/** Notify of a custom event */
|
|
136
|
-
NotifyEvent?: (event: string, data: any) => void;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
125
|
/**
|
|
140
126
|
* Configuration for the component compiler
|
|
141
127
|
*/
|
|
@@ -155,6 +141,8 @@ export interface CompilerConfig {
|
|
|
155
141
|
cache: boolean;
|
|
156
142
|
/** Maximum cache size */
|
|
157
143
|
maxCacheSize: number;
|
|
144
|
+
/** Enable debug logging */
|
|
145
|
+
debug?: boolean;
|
|
158
146
|
}
|
|
159
147
|
|
|
160
148
|
/**
|
|
@@ -169,6 +157,8 @@ export interface RegistryConfig {
|
|
|
169
157
|
useLRU: boolean;
|
|
170
158
|
/** Namespace isolation */
|
|
171
159
|
enableNamespaces: boolean;
|
|
160
|
+
/** Enable debug logging */
|
|
161
|
+
debug?: boolean;
|
|
172
162
|
}
|
|
173
163
|
|
|
174
164
|
/**
|
|
@@ -232,4 +222,10 @@ export interface ErrorBoundaryOptions {
|
|
|
232
222
|
}
|
|
233
223
|
|
|
234
224
|
// Export library configuration types
|
|
235
|
-
export * from './library-config';
|
|
225
|
+
export * from './library-config';
|
|
226
|
+
|
|
227
|
+
// Export dependency types
|
|
228
|
+
export * from './dependency-types';
|
|
229
|
+
|
|
230
|
+
// Re-export ComponentObject for convenience
|
|
231
|
+
export { ComponentObject } from '@memberjunction/interactive-component-types';
|
package/src/utilities/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './component-styles';
|
|
|
7
7
|
export * from './standard-libraries';
|
|
8
8
|
export * from './library-loader';
|
|
9
9
|
export * from './library-registry';
|
|
10
|
+
export * from './library-dependency-resolver';
|
|
10
11
|
export * from './component-error-analyzer';
|
|
11
12
|
export * from './resource-manager';
|
|
12
13
|
export * from './cache-manager';
|