@memberjunction/ng-react 2.92.0 → 2.93.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/dist/lib/components/mj-react-component.component.d.ts +1 -5
- package/dist/lib/components/mj-react-component.component.js +30 -88
- package/dist/lib/components/mj-react-component.component.js.map +1 -1
- package/dist/lib/services/angular-adapter.service.js +2 -2
- package/dist/lib/services/angular-adapter.service.js.map +1 -1
- package/dist/lib/utilities/runtime-utilities.d.ts +1 -0
- package/dist/lib/utilities/runtime-utilities.js +63 -2
- package/dist/lib/utilities/runtime-utilities.js.map +1 -1
- package/package.json +4 -4
|
@@ -83,13 +83,9 @@ export declare class MJReactComponent implements AfterViewInit, OnDestroy {
|
|
|
83
83
|
*/
|
|
84
84
|
private generateComponentHash;
|
|
85
85
|
/**
|
|
86
|
-
* Resolve components
|
|
86
|
+
* Resolve components using the runtime's resolver
|
|
87
87
|
*/
|
|
88
88
|
private resolveComponentsWithVersion;
|
|
89
|
-
/**
|
|
90
|
-
* Log existing versions of components in registry (for debugging)
|
|
91
|
-
*/
|
|
92
|
-
private logExistingVersions;
|
|
93
89
|
/**
|
|
94
90
|
* Register all components in the hierarchy
|
|
95
91
|
*/
|
|
@@ -196,113 +196,55 @@ export class MJReactComponent {
|
|
|
196
196
|
return `v${hexHash}`;
|
|
197
197
|
}
|
|
198
198
|
/**
|
|
199
|
-
* Resolve components
|
|
199
|
+
* Resolve components using the runtime's resolver
|
|
200
200
|
*/
|
|
201
|
-
resolveComponentsWithVersion(spec, version, namespace = 'Global') {
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
visited.add(s.name);
|
|
211
|
-
// Get component with specific version
|
|
212
|
-
const component = registry.get(s.name, namespace, version);
|
|
213
|
-
if (component) {
|
|
214
|
-
resolved[s.name] = component;
|
|
215
|
-
console.log(` Resolved ${s.name}@${version}`);
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
console.warn(` ⚠️ Component not found: ${s.name}@${version}`);
|
|
219
|
-
}
|
|
220
|
-
// Process dependencies
|
|
221
|
-
if (s.dependencies) {
|
|
222
|
-
for (const dep of s.dependencies) {
|
|
223
|
-
resolveHierarchy(dep, visited);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
console.log(`Resolving components with version ${version}:`);
|
|
228
|
-
resolveHierarchy(spec);
|
|
201
|
+
async resolveComponentsWithVersion(spec, version, namespace = 'Global') {
|
|
202
|
+
const resolver = this.adapter.getResolver();
|
|
203
|
+
// Debug: Log what dependencies we're trying to resolve
|
|
204
|
+
console.log(`Resolving components for ${spec.name}. Dependencies:`, spec.dependencies);
|
|
205
|
+
// Use the runtime's resolver which now handles registry-based components
|
|
206
|
+
const resolved = await resolver.resolveComponents(spec, namespace, Metadata.Provider.CurrentUser // Pass current user context for database operations
|
|
207
|
+
);
|
|
208
|
+
console.log(`Resolved ${Object.keys(resolved).length} components for version ${version}:`, Object.keys(resolved));
|
|
229
209
|
return resolved;
|
|
230
210
|
}
|
|
231
|
-
/**
|
|
232
|
-
* Log existing versions of components in registry (for debugging)
|
|
233
|
-
*/
|
|
234
|
-
logExistingVersions(spec, namespace = 'Global') {
|
|
235
|
-
const registry = this.adapter.getRegistry();
|
|
236
|
-
// Check for existing versions of this component
|
|
237
|
-
const namespaceComponents = registry.getNamespace(namespace);
|
|
238
|
-
const componentVersions = namespaceComponents.filter(c => c.name === spec.name);
|
|
239
|
-
// Log existing versions for awareness
|
|
240
|
-
if (componentVersions.length > 0) {
|
|
241
|
-
console.log(` Found ${componentVersions.length} existing version(s) of ${spec.name}:`);
|
|
242
|
-
componentVersions.forEach(comp => {
|
|
243
|
-
console.log(` - ${comp.name}@${comp.version}`);
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
// Recursively check dependencies
|
|
247
|
-
if (spec.dependencies) {
|
|
248
|
-
for (const dep of spec.dependencies) {
|
|
249
|
-
const depVersions = namespaceComponents.filter(c => c.name === dep.name);
|
|
250
|
-
if (depVersions.length > 0) {
|
|
251
|
-
console.log(` Found ${depVersions.length} existing version(s) of ${dep.name}:`);
|
|
252
|
-
depVersions.forEach(comp => {
|
|
253
|
-
console.log(` - ${comp.name}@${comp.version}`);
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
211
|
/**
|
|
260
212
|
* Register all components in the hierarchy
|
|
261
213
|
*/
|
|
262
214
|
async registerComponentHierarchy() {
|
|
263
|
-
//
|
|
264
|
-
const version = this.generateComponentHash(this.component);
|
|
215
|
+
// Use semantic version from spec or generate hash-based version for uniqueness
|
|
216
|
+
const version = this.component.version || this.generateComponentHash(this.component);
|
|
265
217
|
this.componentVersion = version; // Store for use in resolver
|
|
266
|
-
console.log(
|
|
267
|
-
|
|
268
|
-
// Log existing versions (don't clear - allow multiple versions to coexist)
|
|
269
|
-
this.logExistingVersions(this.component);
|
|
270
|
-
// Check if this exact version already exists to avoid re-registration
|
|
218
|
+
console.log(`Registering ${this.component.name}@${version}`);
|
|
219
|
+
// Check if already registered to avoid duplication
|
|
271
220
|
const registry = this.adapter.getRegistry();
|
|
272
|
-
const existingComponent = registry.get(this.component.name, 'Global', version);
|
|
221
|
+
const existingComponent = registry.get(this.component.name, this.component.namespace || 'Global', version);
|
|
273
222
|
if (existingComponent) {
|
|
274
|
-
console.log(`
|
|
223
|
+
console.log(`Component ${this.component.name}@${version} already registered`);
|
|
275
224
|
return;
|
|
276
225
|
}
|
|
277
|
-
//
|
|
278
|
-
const registrar = new ComponentHierarchyRegistrar(this.adapter.getCompiler(), this.adapter.getRegistry(), this.adapter.getRuntimeContext());
|
|
226
|
+
// Initialize metadata engine
|
|
279
227
|
await ComponentMetadataEngine.Instance.Config(false, Metadata.Provider.CurrentUser);
|
|
280
|
-
//
|
|
228
|
+
// Use the runtime's hierarchy registrar
|
|
229
|
+
const registrar = new ComponentHierarchyRegistrar(this.adapter.getCompiler(), this.adapter.getRegistry(), this.adapter.getRuntimeContext());
|
|
230
|
+
// Register with proper configuration
|
|
281
231
|
const result = await registrar.registerHierarchy(this.component, {
|
|
282
|
-
styles: this.styles,
|
|
283
|
-
namespace: 'Global',
|
|
284
|
-
version: version,
|
|
285
|
-
allowOverride: false, //
|
|
232
|
+
styles: this.styles,
|
|
233
|
+
namespace: this.component.namespace || 'Global',
|
|
234
|
+
version: version,
|
|
235
|
+
allowOverride: false, // Each version is unique
|
|
286
236
|
allLibraries: ComponentMetadataEngine.Instance.ComponentLibraries
|
|
287
237
|
});
|
|
288
|
-
// Check for errors
|
|
289
238
|
if (!result.success) {
|
|
290
|
-
const
|
|
291
|
-
throw new Error(`Component registration failed: ${
|
|
239
|
+
const errors = result.errors.map(e => e.error).join(', ');
|
|
240
|
+
throw new Error(`Component registration failed: ${errors}`);
|
|
292
241
|
}
|
|
293
|
-
|
|
294
|
-
console.log(`✅ Successfully registered ${result.registeredComponents.length} components with version ${version}:`);
|
|
295
|
-
result.registeredComponents.forEach(name => {
|
|
296
|
-
console.log(` - ${name}@${version}`);
|
|
297
|
-
});
|
|
298
|
-
// Also log current registry stats
|
|
299
|
-
const stats = this.adapter.getRegistry().getStats();
|
|
300
|
-
console.log(`📊 Registry stats: ${stats.totalComponents} total components in ${stats.namespaces} namespace(s)\n`);
|
|
242
|
+
console.log(`Registered ${result.registeredComponents.length} components`);
|
|
301
243
|
}
|
|
302
244
|
/**
|
|
303
245
|
* Render the React component
|
|
304
246
|
*/
|
|
305
|
-
renderComponent() {
|
|
247
|
+
async renderComponent() {
|
|
306
248
|
// Don't render if component is being destroyed
|
|
307
249
|
if (this.isDestroying) {
|
|
308
250
|
return;
|
|
@@ -321,8 +263,8 @@ export class MJReactComponent {
|
|
|
321
263
|
}
|
|
322
264
|
this.isRendering = true;
|
|
323
265
|
const { React } = context;
|
|
324
|
-
//
|
|
325
|
-
const components = this.resolveComponentsWithVersion(this.component, this.componentVersion);
|
|
266
|
+
// Resolve components with the correct version using runtime's resolver
|
|
267
|
+
const components = await this.resolveComponentsWithVersion(this.component, this.componentVersion);
|
|
326
268
|
// Create callbacks once per component instance
|
|
327
269
|
if (!this.currentCallbacks) {
|
|
328
270
|
this.currentCallbacks = this.createCallbacks();
|
|
@@ -576,5 +518,5 @@ export class MJReactComponent {
|
|
|
576
518
|
type: ViewChild,
|
|
577
519
|
args: ['container', { read: ElementRef, static: true }]
|
|
578
520
|
}] }); })();
|
|
579
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MJReactComponent, { className: "MJReactComponent", filePath: "lib/components/mj-react-component.component.ts", lineNumber:
|
|
521
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MJReactComponent, { className: "MJReactComponent", filePath: "lib/components/mj-react-component.component.ts", lineNumber: 127 }); })();
|
|
580
522
|
//# sourceMappingURL=mj-react-component.component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mj-react-component.component.js","sourceRoot":"","sources":["../../../src/lib/components/mj-react-component.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,SAAS,EACT,KAAK,EACL,MAAM,EACN,YAAY,EACZ,SAAS,EACT,UAAU,EAGV,uBAAuB,EACvB,iBAAiB,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAa,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAuC,MAAM,6CAA6C,CAAC;AACjH,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAEL,mBAAmB,EACnB,2BAA2B,EAE3B,eAAe,EACf,gBAAgB,EAEhB,WAAW,EACZ,MAAM,+BAA+B,CAAC;AACvC,OAAO,E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B,MAAM;YAEqD,SAAS;kBAApE,SAAS;mBAAC,WAAW,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE;;kFArD/C,gBAAgB","sourcesContent":["/**\n * @fileoverview Angular component that hosts React components with proper memory management.\n * Provides a bridge between Angular and React ecosystems in MemberJunction applications.\n * @module @memberjunction/ng-react\n */\n\nimport {\n Component,\n Input,\n Output,\n EventEmitter,\n ViewChild,\n ElementRef,\n AfterViewInit,\n OnDestroy,\n ChangeDetectionStrategy,\n ChangeDetectorRef\n} from '@angular/core';\nimport { Subject, takeUntil } from 'rxjs';\nimport { ComponentSpec, ComponentCallbacks, ComponentStyles } from '@memberjunction/interactive-component-types';\nimport { ReactBridgeService } from '../services/react-bridge.service';\nimport { AngularAdapterService } from '../services/angular-adapter.service';\nimport { \n buildComponentProps,\n createErrorBoundary,\n ComponentHierarchyRegistrar,\n HierarchyRegistrationResult,\n resourceManager,\n reactRootManager,\n ResolvedComponents,\n SetupStyles\n} from '@memberjunction/react-runtime';\nimport { createRuntimeUtilities } from '../utilities/runtime-utilities';\nimport { LogError, CompositeKey, KeyValuePair, Metadata, RunView } from '@memberjunction/core';\nimport { ComponentMetadataEngine } from '@memberjunction/core-entities';\n\n/**\n * Event emitted by React components\n */\nexport interface ReactComponentEvent {\n type: string;\n payload: any;\n}\n\n/**\n * State change event emitted when component state updates\n */\nexport interface StateChangeEvent {\n path: string;\n value: any;\n}\n\n/**\n * User settings changed event emitted when component saves user preferences\n */\nexport interface UserSettingsChangedEvent {\n settings: Record<string, any>;\n componentName?: string;\n timestamp: Date;\n}\n\n/**\n * Angular component that hosts React components with proper memory management.\n * This component provides a bridge between Angular and React, allowing React components\n * to be used seamlessly within Angular applications.\n */\n@Component({\n selector: 'mj-react-component',\n template: `\n <div class=\"react-component-wrapper\">\n <div #container class=\"react-component-container\" [class.loading]=\"!isInitialized\"></div>\n @if (!isInitialized && !hasError) {\n <div class=\"loading-overlay\">\n <div class=\"loading-spinner\">\n <i class=\"fa-solid fa-spinner fa-spin\"></i>\n </div>\n <div class=\"loading-text\">Loading component...</div>\n </div>\n }\n </div>\n `,\n styles: [`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n }\n .react-component-wrapper {\n position: relative;\n width: 100%;\n height: 100%;\n }\n .react-component-container {\n width: 100%;\n height: 100%;\n transition: opacity 0.3s ease;\n }\n .react-component-container.loading {\n opacity: 0;\n }\n .loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n background-color: rgba(255, 255, 255, 0.9);\n z-index: 1;\n }\n .loading-spinner {\n font-size: 48px;\n color: #5B4FE9;\n margin-bottom: 16px;\n }\n .loading-text {\n font-family: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", Roboto, sans-serif;\n font-size: 14px;\n color: #64748B;\n margin-top: 8px;\n }\n `],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class MJReactComponent implements AfterViewInit, OnDestroy {\n @Input() component!: ComponentSpec;\n \n // Auto-initialize utilities if not provided\n private _utilities: any;\n @Input()\n set utilities(value: any) {\n this._utilities = value;\n }\n get utilities(): any {\n // Lazy initialization - only create default utilities when needed\n if (!this._utilities) {\n const runtimeUtils = createRuntimeUtilities();\n this._utilities = runtimeUtils.buildUtilities();\n console.log('MJReactComponent: Auto-initialized utilities using createRuntimeUtilities()');\n }\n return this._utilities;\n }\n \n // Auto-initialize styles if not provided\n private _styles?: Partial<ComponentStyles>;\n @Input()\n set styles(value: Partial<ComponentStyles> | undefined) {\n this._styles = value;\n }\n get styles(): Partial<ComponentStyles> {\n // Lazy initialization - only create default styles when needed\n if (!this._styles) {\n this._styles = SetupStyles();\n console.log('MJReactComponent: Auto-initialized styles using SetupStyles()');\n }\n return this._styles;\n }\n \n private _savedUserSettings: any = {};\n @Input()\n set savedUserSettings(value: any) {\n this._savedUserSettings = value || {};\n // Re-render if component is initialized\n if (this.isInitialized) {\n this.renderComponent();\n }\n }\n get savedUserSettings(): any {\n return this._savedUserSettings;\n }\n \n @Output() stateChange = new EventEmitter<StateChangeEvent>();\n @Output() componentEvent = new EventEmitter<ReactComponentEvent>();\n @Output() refreshData = new EventEmitter<void>();\n @Output() openEntityRecord = new EventEmitter<{ entityName: string; key: CompositeKey }>();\n @Output() userSettingsChanged = new EventEmitter<UserSettingsChangedEvent>();\n \n @ViewChild('container', { read: ElementRef, static: true }) container!: ElementRef<HTMLDivElement>;\n \n private reactRootId: string | null = null;\n private compiledComponent: any = null;\n private destroyed$ = new Subject<void>();\n private currentCallbacks: ComponentCallbacks | null = null;\n isInitialized = false;\n private isRendering = false;\n private pendingRender = false;\n private isDestroying = false;\n private componentId: string;\n private componentVersion: string = ''; // Store the version for resolver\n hasError = false;\n\n constructor(\n private reactBridge: ReactBridgeService,\n private adapter: AngularAdapterService,\n private cdr: ChangeDetectorRef\n ) {\n // Generate unique component ID for resource tracking\n this.componentId = `mj-react-component-${Date.now()}-${Math.random()}`;\n }\n\n async ngAfterViewInit() {\n // Trigger change detection to show loading state\n this.cdr.detectChanges();\n await this.initializeComponent();\n }\n\n ngOnDestroy() {\n // Set destroying flag immediately\n this.isDestroying = true;\n \n // Cancel any pending renders\n this.pendingRender = false;\n \n this.destroyed$.next();\n this.destroyed$.complete();\n this.cleanup();\n }\n\n\n /**\n * Initialize the React component\n */\n private async initializeComponent() {\n try {\n // Ensure React is loaded\n await this.reactBridge.getReactContext();\n \n // Wait for React to be fully ready (handles first-load delay)\n await this.reactBridge.waitForReactReady();\n \n // Register component hierarchy\n await this.registerComponentHierarchy();\n \n // Compile main component with its library dependencies\n await ComponentMetadataEngine.Instance.Config(false, Metadata.Provider.CurrentUser);\n const result = await this.adapter.compileComponent({\n componentName: this.component.name,\n componentCode: this.component.code,\n styles: this.styles as ComponentStyles,\n libraries: this.component.libraries, // Pass library dependencies from ComponentSpec\n allLibraries: ComponentMetadataEngine.Instance.ComponentLibraries\n });\n\n if (!result.success) {\n throw new Error(result.error?.message || 'Component compilation failed');\n }\n\n // Get runtime context and execute component factory\n const context = this.adapter.getRuntimeContext();\n \n // Call the factory function to get the component wrapper\n // result.component is a CompiledComponent object with a 'component' property that's the factory\n const componentWrapper = result.component!.component(context, this.styles);\n \n // Validate the component wrapper structure\n if (!componentWrapper || typeof componentWrapper !== 'object') {\n throw new Error(`Invalid component wrapper returned for ${this.component.name}: ${typeof componentWrapper}`);\n }\n \n if (!componentWrapper.component) {\n throw new Error(`Component wrapper missing 'component' property for ${this.component.name}`);\n }\n \n if (typeof componentWrapper.component !== 'function') {\n throw new Error(`Component is not a function for ${this.component.name}: ${typeof componentWrapper.component}`);\n }\n \n this.compiledComponent = componentWrapper;\n \n // Create managed React root\n const reactContext = this.reactBridge.getCurrentContext();\n if (!reactContext) {\n throw new Error('React context not available');\n }\n \n this.reactRootId = reactRootManager.createRoot(\n this.container.nativeElement,\n (container: HTMLElement) => reactContext.ReactDOM.createRoot(container),\n this.componentId\n );\n \n // Initial render\n this.renderComponent();\n this.isInitialized = true;\n \n // Trigger change detection since we're using OnPush\n this.cdr.detectChanges();\n \n } catch (error) {\n this.hasError = true;\n LogError(`Failed to initialize React component: ${error}`);\n this.componentEvent.emit({\n type: 'error',\n payload: {\n error: error instanceof Error ? error.message : String(error),\n source: 'initialization'\n }\n });\n // Trigger change detection to show error state\n this.cdr.detectChanges();\n }\n }\n\n /**\n * Generate a hash from component code for versioning\n * Uses a simple hash function that's fast and sufficient for version differentiation\n */\n private generateComponentHash(spec: ComponentSpec): string {\n // Collect all code from the component hierarchy\n const codeStrings: string[] = [];\n \n const collectCode = (s: ComponentSpec) => {\n if (s.code) {\n codeStrings.push(s.code);\n }\n if (s.dependencies) {\n for (const dep of s.dependencies) {\n collectCode(dep);\n }\n }\n };\n \n collectCode(spec);\n \n // Generate hash from concatenated code\n const fullCode = codeStrings.join('|');\n let hash = 0;\n for (let i = 0; i < fullCode.length; i++) {\n const char = fullCode.charCodeAt(i);\n hash = ((hash << 5) - hash) + char;\n hash = hash & hash; // Convert to 32bit integer\n }\n \n // Convert to hex string and take first 8 characters for readability\n const hexHash = Math.abs(hash).toString(16).padStart(8, '0').substring(0, 8);\n return `v${hexHash}`;\n }\n\n /**\n * Resolve components with specific version\n */\n private resolveComponentsWithVersion(spec: ComponentSpec, version: string, namespace: string = 'Global'): ResolvedComponents {\n const resolved: ResolvedComponents = {};\n const registry = this.adapter.getRegistry();\n \n const resolveHierarchy = (s: ComponentSpec, visited: Set<string> = new Set()) => {\n // Prevent circular dependencies\n if (visited.has(s.name)) {\n console.warn(`Circular dependency detected for component: ${s.name}`);\n return;\n }\n visited.add(s.name);\n \n // Get component with specific version\n const component = registry.get(s.name, namespace, version);\n if (component) {\n resolved[s.name] = component;\n console.log(` Resolved ${s.name}@${version}`);\n } else {\n console.warn(` ⚠️ Component not found: ${s.name}@${version}`);\n }\n \n // Process dependencies\n if (s.dependencies) {\n for (const dep of s.dependencies) {\n resolveHierarchy(dep, visited);\n }\n }\n };\n \n console.log(`Resolving components with version ${version}:`);\n resolveHierarchy(spec);\n \n return resolved;\n }\n\n /**\n * Log existing versions of components in registry (for debugging)\n */\n private logExistingVersions(spec: ComponentSpec, namespace: string = 'Global'): void {\n const registry = this.adapter.getRegistry();\n \n // Check for existing versions of this component\n const namespaceComponents = registry.getNamespace(namespace);\n const componentVersions = namespaceComponents.filter(c => c.name === spec.name);\n \n // Log existing versions for awareness\n if (componentVersions.length > 0) {\n console.log(` Found ${componentVersions.length} existing version(s) of ${spec.name}:`);\n componentVersions.forEach(comp => {\n console.log(` - ${comp.name}@${comp.version}`);\n });\n }\n \n // Recursively check dependencies\n if (spec.dependencies) {\n for (const dep of spec.dependencies) {\n const depVersions = namespaceComponents.filter(c => c.name === dep.name);\n if (depVersions.length > 0) {\n console.log(` Found ${depVersions.length} existing version(s) of ${dep.name}:`);\n depVersions.forEach(comp => {\n console.log(` - ${comp.name}@${comp.version}`);\n });\n }\n }\n }\n }\n\n /**\n * Register all components in the hierarchy\n */\n private async registerComponentHierarchy() {\n // Generate unique version based on component code hash\n const version = this.generateComponentHash(this.component);\n this.componentVersion = version; // Store for use in resolver\n \n console.log(`\\n🔄 Registering component hierarchy for ${this.component.name}`);\n console.log(` Version: ${version}`);\n \n // Log existing versions (don't clear - allow multiple versions to coexist)\n this.logExistingVersions(this.component);\n \n // Check if this exact version already exists to avoid re-registration\n const registry = this.adapter.getRegistry();\n const existingComponent = registry.get(this.component.name, 'Global', version);\n if (existingComponent) {\n console.log(` ℹ️ Version ${version} already registered - skipping registration`);\n return;\n }\n \n // Create the hierarchy registrar with adapter's compiler and registry\n const registrar = new ComponentHierarchyRegistrar(\n this.adapter.getCompiler(),\n this.adapter.getRegistry(),\n this.adapter.getRuntimeContext()\n );\n \n await ComponentMetadataEngine.Instance.Config(false, Metadata.Provider.CurrentUser);\n // Register the entire hierarchy with hash-based version\n const result: HierarchyRegistrationResult = await registrar.registerHierarchy(\n this.component,\n {\n styles: this.styles as any, // Skip components use SkipComponentStyles which is a superset\n namespace: 'Global',\n version: version, // Use hash-based version instead of hardcoded 'v1'\n allowOverride: false, // Don't override - each version is unique\n allLibraries: ComponentMetadataEngine.Instance.ComponentLibraries\n }\n );\n \n // Check for errors\n if (!result.success) {\n const errorMessages = result.errors.map(e => \n `${e.componentName}: ${e.error}`\n );\n throw new Error(`Component registration failed: ${errorMessages.join(', ')}`);\n }\n \n // Log registered components for debugging\n console.log(`✅ Successfully registered ${result.registeredComponents.length} components with version ${version}:`);\n result.registeredComponents.forEach(name => {\n console.log(` - ${name}@${version}`);\n });\n \n // Also log current registry stats\n const stats = this.adapter.getRegistry().getStats();\n console.log(`📊 Registry stats: ${stats.totalComponents} total components in ${stats.namespaces} namespace(s)\\n`);\n }\n\n /**\n * Render the React component\n */\n private renderComponent() {\n // Don't render if component is being destroyed\n if (this.isDestroying) {\n return;\n }\n \n if (!this.compiledComponent || !this.reactRootId) {\n return;\n }\n\n // Prevent concurrent renders\n if (this.isRendering) {\n this.pendingRender = true;\n return;\n }\n\n const context = this.reactBridge.getCurrentContext();\n if (!context) {\n return;\n }\n\n this.isRendering = true;\n const { React } = context;\n \n // Manually resolve components with the correct version\n const components = this.resolveComponentsWithVersion(this.component, this.componentVersion);\n \n // Create callbacks once per component instance\n if (!this.currentCallbacks) {\n this.currentCallbacks = this.createCallbacks();\n }\n \n // Build props with savedUserSettings pattern\n const props = {\n utilities: this.utilities, // Now uses getter which auto-initializes if needed\n callbacks: this.currentCallbacks,\n components,\n styles: this.styles as any,\n savedUserSettings: this._savedUserSettings,\n onSaveUserSettings: this.handleSaveUserSettings.bind(this)\n };\n\n // Validate component before creating element\n if (!this.compiledComponent.component) {\n LogError(`Component is undefined for ${this.component.name} during render`);\n return;\n }\n\n // Create error boundary\n const ErrorBoundary = createErrorBoundary(React, {\n onError: this.handleReactError.bind(this),\n logErrors: true,\n recovery: 'retry'\n });\n\n // Create element with error boundary\n const element = React.createElement(\n ErrorBoundary,\n null,\n React.createElement(this.compiledComponent.component, props)\n );\n\n // Render with timeout protection using resource manager\n const timeoutId = resourceManager.setTimeout(\n this.componentId,\n () => {\n // Check if still rendering and not destroyed\n if (this.isRendering && !this.isDestroying) {\n this.componentEvent.emit({\n type: 'error',\n payload: {\n error: 'Component render timeout - possible infinite loop detected',\n source: 'render'\n }\n });\n }\n },\n 5000,\n { purpose: 'render-timeout-protection' }\n );\n\n // Use managed React root for rendering\n reactRootManager.render(\n this.reactRootId,\n element,\n () => {\n // Clear the timeout as render completed\n resourceManager.clearTimeout(this.componentId, timeoutId);\n \n // Don't update state if component is destroyed\n if (this.isDestroying) {\n return;\n }\n \n this.isRendering = false;\n \n // If there was a pending render request, execute it now\n if (this.pendingRender) {\n this.pendingRender = false;\n this.renderComponent();\n }\n }\n );\n }\n\n /**\n * Create callbacks for the React component\n */\n private createCallbacks(): ComponentCallbacks {\n return {\n OpenEntityRecord: async (entityName: string, key: CompositeKey) => {\n let keyToUse: CompositeKey | null = null;\n if (key instanceof Array) {\n keyToUse = CompositeKey.FromKeyValuePairs(key);\n }\n else if (typeof key === 'object' && !!key.GetValueByFieldName) {\n keyToUse = key as CompositeKey;\n }\n else if (typeof key === 'object') {\n //} && !!key.FieldName && !!key.Value) {\n // possible that have an object that is a simple key/value pair with\n // FieldName and value properties\n const keyAny = key as any;\n if (keyAny.FieldName && keyAny.Value) {\n keyToUse = CompositeKey.FromKeyValuePairs([keyAny as KeyValuePair]);\n }\n }\n if (keyToUse) {\n // now in some cases we have key/value pairs that the component we are hosting\n // use, but are not the pkey, so if that is the case, we'll run a quick view to try\n // and get the pkey so that we can emit the openEntityRecord call with the pkey\n const md = new Metadata();\n const e = md.EntityByName(entityName);\n let shouldRunView = false;\n // now check each key in the keyToUse to see if it is a pkey\n for (const singleKey of keyToUse.KeyValuePairs) {\n const field = e.Fields.find(f => f.Name.trim().toLowerCase() === singleKey.FieldName.trim().toLowerCase());\n if (!field) {\n // if we get here this is a problem, the component has given us a non-matching field, this shouldn't ever happen\n // but if it doesn't log warning to console and exit\n console.warn(`Non-matching field found for key: ${JSON.stringify(keyToUse)}`);\n return;\n }\n else if (!field.IsPrimaryKey) {\n // if we get here that means we have a non-pkey so we'll want to do a lookup via a RunView\n // to get the actual pkey value\n shouldRunView = true;\n break;\n }\n }\n\n // if we get here and shouldRunView is true, we need to run a view using the info provided\n // by our contained component to get the pkey\n if (shouldRunView) {\n const rv = new RunView();\n const result = await rv.RunView({\n EntityName: entityName,\n ExtraFilter: keyToUse.ToWhereClause()\n })\n if (result && result.Success && result.Results.length > 0) {\n // we have a match, use the first row and update our keyToUse\n const kvPairs: KeyValuePair[] = [];\n e.PrimaryKeys.forEach(pk => {\n kvPairs.push(\n {\n FieldName: pk.Name,\n Value: result.Results[0][pk.Name]\n }\n )\n })\n keyToUse = CompositeKey.FromKeyValuePairs(kvPairs);\n }\n }\n\n this.openEntityRecord.emit({ entityName, key: keyToUse });\n } \n } \n };\n }\n\n /**\n * Handle React component errors\n */\n private handleReactError(error: any, errorInfo?: any) {\n LogError(`React component error: ${error?.toString() || 'Unknown error'}`, errorInfo);\n this.componentEvent.emit({\n type: 'error',\n payload: {\n error: error?.toString() || 'Unknown error',\n errorInfo,\n source: 'react'\n }\n });\n }\n\n /**\n * Handle onSaveUserSettings from components\n * This implements the SavedUserSettings pattern\n */\n private handleSaveUserSettings(newSettings: Record<string, any>) {\n // Just bubble the event up to parent containers for persistence\n // We don't need to store anything here\n this.userSettingsChanged.emit({\n settings: newSettings,\n componentName: this.component?.name,\n timestamp: new Date()\n });\n \n // DO NOT re-render the component!\n // The component already has the correct state - it's the one that told us about the change.\n // Re-rendering would cause unnecessary DOM updates and visual flashing.\n }\n\n /**\n * Clean up resources\n */\n private cleanup() {\n // Clean up all resources managed by resource manager\n resourceManager.cleanupComponent(this.componentId);\n \n // Clean up prop builder subscriptions\n if (this.currentCallbacks) {\n this.currentCallbacks = null;\n }\n \n // Unmount React root using managed unmount\n if (this.reactRootId) {\n // Force stop rendering flags\n this.isRendering = false;\n this.pendingRender = false;\n \n // This will handle waiting for render completion if needed\n reactRootManager.unmountRoot(this.reactRootId);\n this.reactRootId = null;\n }\n\n // Clear references\n this.compiledComponent = null;\n this.isInitialized = false;\n\n // Trigger registry cleanup\n this.adapter.getRegistry().cleanup();\n }\n\n /**\n * Public method to refresh the component\n * @deprecated Components manage their own state and data now\n */\n refresh() {\n // Just trigger a re-render if needed\n this.renderComponent();\n }\n\n /**\n * Public method to update state programmatically\n * @param path - State path to update\n * @param value - New value\n * @deprecated Components manage their own state now\n */\n updateState(path: string, value: any) {\n // Just emit the event, don't manage state here\n this.stateChange.emit({ path, value });\n }\n\n}"]}
|
|
1
|
+
{"version":3,"file":"mj-react-component.component.js","sourceRoot":"","sources":["../../../src/lib/components/mj-react-component.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,SAAS,EACT,KAAK,EACL,MAAM,EACN,YAAY,EACZ,SAAS,EACT,UAAU,EAGV,uBAAuB,EACvB,iBA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yF;YACzF,yEAAmC;YAQrC,iBAAM;;YAT8C,cAAgC;YAAhC,6CAAgC;YAClF,eAOC;YAPD,8DAOC;;;iFAiDM,gBAAgB;cA7D5B,SAAS;2BACE,oBAAoB,YACpB;;;;;;;;;;;;GAYT,mBA6CgB,uBAAuB,CAAC,MAAM;uHAGtC,SAAS;kBAAjB,KAAK;YAKF,SAAS;kBADZ,KAAK;YAiBF,MAAM;kBADT,KAAK;YAeF,iBAAiB;kBADpB,KAAK;YAYI,WAAW;kBAApB,MAAM;YACG,cAAc;kBAAvB,MAAM;YACG,WAAW;kBAApB,MAAM;YACG,gBAAgB;kBAAzB,MAAM;YACG,mBAAmB;kBAA5B,MAAM;YAEqD,SAAS;kBAApE,SAAS;mBAAC,WAAW,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE;;kFArD/C,gBAAgB","sourcesContent":["/**\n * @fileoverview Angular component that hosts React components with proper memory management.\n * Provides a bridge between Angular and React ecosystems in MemberJunction applications.\n * @module @memberjunction/ng-react\n */\n\nimport {\n Component,\n Input,\n Output,\n EventEmitter,\n ViewChild,\n ElementRef,\n AfterViewInit,\n OnDestroy,\n ChangeDetectionStrategy,\n ChangeDetectorRef\n} from '@angular/core';\nimport { Subject, takeUntil } from 'rxjs';\nimport { ComponentSpec, ComponentCallbacks, ComponentStyles } from '@memberjunction/interactive-component-types';\nimport { ReactBridgeService } from '../services/react-bridge.service';\nimport { AngularAdapterService } from '../services/angular-adapter.service';\nimport { \n buildComponentProps,\n createErrorBoundary,\n ComponentHierarchyRegistrar,\n resourceManager,\n reactRootManager,\n ResolvedComponents,\n SetupStyles\n} from '@memberjunction/react-runtime';\nimport { createRuntimeUtilities } from '../utilities/runtime-utilities';\nimport { LogError, CompositeKey, KeyValuePair, Metadata, RunView } from '@memberjunction/core';\nimport { ComponentMetadataEngine } from '@memberjunction/core-entities';\n\n/**\n * Event emitted by React components\n */\nexport interface ReactComponentEvent {\n type: string;\n payload: any;\n}\n\n/**\n * State change event emitted when component state updates\n */\nexport interface StateChangeEvent {\n path: string;\n value: any;\n}\n\n/**\n * User settings changed event emitted when component saves user preferences\n */\nexport interface UserSettingsChangedEvent {\n settings: Record<string, any>;\n componentName?: string;\n timestamp: Date;\n}\n\n/**\n * Angular component that hosts React components with proper memory management.\n * This component provides a bridge between Angular and React, allowing React components\n * to be used seamlessly within Angular applications.\n */\n@Component({\n selector: 'mj-react-component',\n template: `\n <div class=\"react-component-wrapper\">\n <div #container class=\"react-component-container\" [class.loading]=\"!isInitialized\"></div>\n @if (!isInitialized && !hasError) {\n <div class=\"loading-overlay\">\n <div class=\"loading-spinner\">\n <i class=\"fa-solid fa-spinner fa-spin\"></i>\n </div>\n <div class=\"loading-text\">Loading component...</div>\n </div>\n }\n </div>\n `,\n styles: [`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n }\n .react-component-wrapper {\n position: relative;\n width: 100%;\n height: 100%;\n }\n .react-component-container {\n width: 100%;\n height: 100%;\n transition: opacity 0.3s ease;\n }\n .react-component-container.loading {\n opacity: 0;\n }\n .loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n background-color: rgba(255, 255, 255, 0.9);\n z-index: 1;\n }\n .loading-spinner {\n font-size: 48px;\n color: #5B4FE9;\n margin-bottom: 16px;\n }\n .loading-text {\n font-family: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", Roboto, sans-serif;\n font-size: 14px;\n color: #64748B;\n margin-top: 8px;\n }\n `],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class MJReactComponent implements AfterViewInit, OnDestroy {\n @Input() component!: ComponentSpec;\n \n // Auto-initialize utilities if not provided\n private _utilities: any;\n @Input()\n set utilities(value: any) {\n this._utilities = value;\n }\n get utilities(): any {\n // Lazy initialization - only create default utilities when needed\n if (!this._utilities) {\n const runtimeUtils = createRuntimeUtilities();\n this._utilities = runtimeUtils.buildUtilities();\n console.log('MJReactComponent: Auto-initialized utilities using createRuntimeUtilities()');\n }\n return this._utilities;\n }\n \n // Auto-initialize styles if not provided\n private _styles?: Partial<ComponentStyles>;\n @Input()\n set styles(value: Partial<ComponentStyles> | undefined) {\n this._styles = value;\n }\n get styles(): Partial<ComponentStyles> {\n // Lazy initialization - only create default styles when needed\n if (!this._styles) {\n this._styles = SetupStyles();\n console.log('MJReactComponent: Auto-initialized styles using SetupStyles()');\n }\n return this._styles;\n }\n \n private _savedUserSettings: any = {};\n @Input()\n set savedUserSettings(value: any) {\n this._savedUserSettings = value || {};\n // Re-render if component is initialized\n if (this.isInitialized) {\n this.renderComponent();\n }\n }\n get savedUserSettings(): any {\n return this._savedUserSettings;\n }\n \n @Output() stateChange = new EventEmitter<StateChangeEvent>();\n @Output() componentEvent = new EventEmitter<ReactComponentEvent>();\n @Output() refreshData = new EventEmitter<void>();\n @Output() openEntityRecord = new EventEmitter<{ entityName: string; key: CompositeKey }>();\n @Output() userSettingsChanged = new EventEmitter<UserSettingsChangedEvent>();\n \n @ViewChild('container', { read: ElementRef, static: true }) container!: ElementRef<HTMLDivElement>;\n \n private reactRootId: string | null = null;\n private compiledComponent: any = null;\n private destroyed$ = new Subject<void>();\n private currentCallbacks: ComponentCallbacks | null = null;\n isInitialized = false;\n private isRendering = false;\n private pendingRender = false;\n private isDestroying = false;\n private componentId: string;\n private componentVersion: string = ''; // Store the version for resolver\n hasError = false;\n\n constructor(\n private reactBridge: ReactBridgeService,\n private adapter: AngularAdapterService,\n private cdr: ChangeDetectorRef\n ) {\n // Generate unique component ID for resource tracking\n this.componentId = `mj-react-component-${Date.now()}-${Math.random()}`;\n }\n\n async ngAfterViewInit() {\n // Trigger change detection to show loading state\n this.cdr.detectChanges();\n await this.initializeComponent();\n }\n\n ngOnDestroy() {\n // Set destroying flag immediately\n this.isDestroying = true;\n \n // Cancel any pending renders\n this.pendingRender = false;\n \n this.destroyed$.next();\n this.destroyed$.complete();\n this.cleanup();\n }\n\n\n /**\n * Initialize the React component\n */\n private async initializeComponent() {\n try {\n // Ensure React is loaded\n await this.reactBridge.getReactContext();\n \n // Wait for React to be fully ready (handles first-load delay)\n await this.reactBridge.waitForReactReady();\n \n // Register component hierarchy\n await this.registerComponentHierarchy();\n \n // Compile main component with its library dependencies\n await ComponentMetadataEngine.Instance.Config(false, Metadata.Provider.CurrentUser);\n const result = await this.adapter.compileComponent({\n componentName: this.component.name,\n componentCode: this.component.code,\n styles: this.styles as ComponentStyles,\n libraries: this.component.libraries, // Pass library dependencies from ComponentSpec\n allLibraries: ComponentMetadataEngine.Instance.ComponentLibraries\n });\n\n if (!result.success) {\n throw new Error(result.error?.message || 'Component compilation failed');\n }\n\n // Get runtime context and execute component factory\n const context = this.adapter.getRuntimeContext();\n \n // Call the factory function to get the component wrapper\n // result.component is a CompiledComponent object with a 'component' property that's the factory\n const componentWrapper = result.component!.component(context, this.styles);\n \n // Validate the component wrapper structure\n if (!componentWrapper || typeof componentWrapper !== 'object') {\n throw new Error(`Invalid component wrapper returned for ${this.component.name}: ${typeof componentWrapper}`);\n }\n \n if (!componentWrapper.component) {\n throw new Error(`Component wrapper missing 'component' property for ${this.component.name}`);\n }\n \n if (typeof componentWrapper.component !== 'function') {\n throw new Error(`Component is not a function for ${this.component.name}: ${typeof componentWrapper.component}`);\n }\n \n this.compiledComponent = componentWrapper;\n \n // Create managed React root\n const reactContext = this.reactBridge.getCurrentContext();\n if (!reactContext) {\n throw new Error('React context not available');\n }\n \n this.reactRootId = reactRootManager.createRoot(\n this.container.nativeElement,\n (container: HTMLElement) => reactContext.ReactDOM.createRoot(container),\n this.componentId\n );\n \n // Initial render\n this.renderComponent();\n this.isInitialized = true;\n \n // Trigger change detection since we're using OnPush\n this.cdr.detectChanges();\n \n } catch (error) {\n this.hasError = true;\n LogError(`Failed to initialize React component: ${error}`);\n this.componentEvent.emit({\n type: 'error',\n payload: {\n error: error instanceof Error ? error.message : String(error),\n source: 'initialization'\n }\n });\n // Trigger change detection to show error state\n this.cdr.detectChanges();\n }\n }\n\n /**\n * Generate a hash from component code for versioning\n * Uses a simple hash function that's fast and sufficient for version differentiation\n */\n private generateComponentHash(spec: ComponentSpec): string {\n // Collect all code from the component hierarchy\n const codeStrings: string[] = [];\n \n const collectCode = (s: ComponentSpec) => {\n if (s.code) {\n codeStrings.push(s.code);\n }\n if (s.dependencies) {\n for (const dep of s.dependencies) {\n collectCode(dep);\n }\n }\n };\n \n collectCode(spec);\n \n // Generate hash from concatenated code\n const fullCode = codeStrings.join('|');\n let hash = 0;\n for (let i = 0; i < fullCode.length; i++) {\n const char = fullCode.charCodeAt(i);\n hash = ((hash << 5) - hash) + char;\n hash = hash & hash; // Convert to 32bit integer\n }\n \n // Convert to hex string and take first 8 characters for readability\n const hexHash = Math.abs(hash).toString(16).padStart(8, '0').substring(0, 8);\n return `v${hexHash}`;\n }\n\n /**\n * Resolve components using the runtime's resolver\n */\n private async resolveComponentsWithVersion(spec: ComponentSpec, version: string, namespace: string = 'Global'): Promise<ResolvedComponents> {\n const resolver = this.adapter.getResolver();\n \n // Debug: Log what dependencies we're trying to resolve\n console.log(`Resolving components for ${spec.name}. Dependencies:`, spec.dependencies);\n \n // Use the runtime's resolver which now handles registry-based components\n const resolved = await resolver.resolveComponents(\n spec, \n namespace,\n Metadata.Provider.CurrentUser // Pass current user context for database operations\n );\n \n console.log(`Resolved ${Object.keys(resolved).length} components for version ${version}:`, Object.keys(resolved));\n return resolved;\n }\n\n\n /**\n * Register all components in the hierarchy\n */\n private async registerComponentHierarchy() {\n // Use semantic version from spec or generate hash-based version for uniqueness\n const version = this.component.version || this.generateComponentHash(this.component);\n this.componentVersion = version; // Store for use in resolver\n \n console.log(`Registering ${this.component.name}@${version}`);\n \n // Check if already registered to avoid duplication\n const registry = this.adapter.getRegistry();\n const existingComponent = registry.get(this.component.name, this.component.namespace || 'Global', version);\n if (existingComponent) {\n console.log(`Component ${this.component.name}@${version} already registered`);\n return;\n }\n \n // Initialize metadata engine\n await ComponentMetadataEngine.Instance.Config(false, Metadata.Provider.CurrentUser);\n \n // Use the runtime's hierarchy registrar\n const registrar = new ComponentHierarchyRegistrar(\n this.adapter.getCompiler(),\n this.adapter.getRegistry(),\n this.adapter.getRuntimeContext()\n );\n \n // Register with proper configuration\n const result = await registrar.registerHierarchy(\n this.component,\n {\n styles: this.styles as ComponentStyles,\n namespace: this.component.namespace || 'Global',\n version: version,\n allowOverride: false, // Each version is unique\n allLibraries: ComponentMetadataEngine.Instance.ComponentLibraries\n }\n );\n \n if (!result.success) {\n const errors = result.errors.map(e => e.error).join(', ');\n throw new Error(`Component registration failed: ${errors}`);\n }\n \n console.log(`Registered ${result.registeredComponents.length} components`);\n }\n\n /**\n * Render the React component\n */\n private async renderComponent() {\n // Don't render if component is being destroyed\n if (this.isDestroying) {\n return;\n }\n \n if (!this.compiledComponent || !this.reactRootId) {\n return;\n }\n\n // Prevent concurrent renders\n if (this.isRendering) {\n this.pendingRender = true;\n return;\n }\n\n const context = this.reactBridge.getCurrentContext();\n if (!context) {\n return;\n }\n\n this.isRendering = true;\n const { React } = context;\n \n // Resolve components with the correct version using runtime's resolver\n const components = await this.resolveComponentsWithVersion(this.component, this.componentVersion);\n \n // Create callbacks once per component instance\n if (!this.currentCallbacks) {\n this.currentCallbacks = this.createCallbacks();\n }\n \n // Build props with savedUserSettings pattern\n const props = {\n utilities: this.utilities, // Now uses getter which auto-initializes if needed\n callbacks: this.currentCallbacks,\n components,\n styles: this.styles as any,\n savedUserSettings: this._savedUserSettings,\n onSaveUserSettings: this.handleSaveUserSettings.bind(this)\n };\n\n // Validate component before creating element\n if (!this.compiledComponent.component) {\n LogError(`Component is undefined for ${this.component.name} during render`);\n return;\n }\n\n // Create error boundary\n const ErrorBoundary = createErrorBoundary(React, {\n onError: this.handleReactError.bind(this),\n logErrors: true,\n recovery: 'retry'\n });\n\n // Create element with error boundary\n const element = React.createElement(\n ErrorBoundary,\n null,\n React.createElement(this.compiledComponent.component, props)\n );\n\n // Render with timeout protection using resource manager\n const timeoutId = resourceManager.setTimeout(\n this.componentId,\n () => {\n // Check if still rendering and not destroyed\n if (this.isRendering && !this.isDestroying) {\n this.componentEvent.emit({\n type: 'error',\n payload: {\n error: 'Component render timeout - possible infinite loop detected',\n source: 'render'\n }\n });\n }\n },\n 5000,\n { purpose: 'render-timeout-protection' }\n );\n\n // Use managed React root for rendering\n reactRootManager.render(\n this.reactRootId,\n element,\n () => {\n // Clear the timeout as render completed\n resourceManager.clearTimeout(this.componentId, timeoutId);\n \n // Don't update state if component is destroyed\n if (this.isDestroying) {\n return;\n }\n \n this.isRendering = false;\n \n // If there was a pending render request, execute it now\n if (this.pendingRender) {\n this.pendingRender = false;\n this.renderComponent();\n }\n }\n );\n }\n\n /**\n * Create callbacks for the React component\n */\n private createCallbacks(): ComponentCallbacks {\n return {\n OpenEntityRecord: async (entityName: string, key: CompositeKey) => {\n let keyToUse: CompositeKey | null = null;\n if (key instanceof Array) {\n keyToUse = CompositeKey.FromKeyValuePairs(key);\n }\n else if (typeof key === 'object' && !!key.GetValueByFieldName) {\n keyToUse = key as CompositeKey;\n }\n else if (typeof key === 'object') {\n //} && !!key.FieldName && !!key.Value) {\n // possible that have an object that is a simple key/value pair with\n // FieldName and value properties\n const keyAny = key as any;\n if (keyAny.FieldName && keyAny.Value) {\n keyToUse = CompositeKey.FromKeyValuePairs([keyAny as KeyValuePair]);\n }\n }\n if (keyToUse) {\n // now in some cases we have key/value pairs that the component we are hosting\n // use, but are not the pkey, so if that is the case, we'll run a quick view to try\n // and get the pkey so that we can emit the openEntityRecord call with the pkey\n const md = new Metadata();\n const e = md.EntityByName(entityName);\n let shouldRunView = false;\n // now check each key in the keyToUse to see if it is a pkey\n for (const singleKey of keyToUse.KeyValuePairs) {\n const field = e.Fields.find(f => f.Name.trim().toLowerCase() === singleKey.FieldName.trim().toLowerCase());\n if (!field) {\n // if we get here this is a problem, the component has given us a non-matching field, this shouldn't ever happen\n // but if it doesn't log warning to console and exit\n console.warn(`Non-matching field found for key: ${JSON.stringify(keyToUse)}`);\n return;\n }\n else if (!field.IsPrimaryKey) {\n // if we get here that means we have a non-pkey so we'll want to do a lookup via a RunView\n // to get the actual pkey value\n shouldRunView = true;\n break;\n }\n }\n\n // if we get here and shouldRunView is true, we need to run a view using the info provided\n // by our contained component to get the pkey\n if (shouldRunView) {\n const rv = new RunView();\n const result = await rv.RunView({\n EntityName: entityName,\n ExtraFilter: keyToUse.ToWhereClause()\n })\n if (result && result.Success && result.Results.length > 0) {\n // we have a match, use the first row and update our keyToUse\n const kvPairs: KeyValuePair[] = [];\n e.PrimaryKeys.forEach(pk => {\n kvPairs.push(\n {\n FieldName: pk.Name,\n Value: result.Results[0][pk.Name]\n }\n )\n })\n keyToUse = CompositeKey.FromKeyValuePairs(kvPairs);\n }\n }\n\n this.openEntityRecord.emit({ entityName, key: keyToUse });\n } \n } \n };\n }\n\n /**\n * Handle React component errors\n */\n private handleReactError(error: any, errorInfo?: any) {\n LogError(`React component error: ${error?.toString() || 'Unknown error'}`, errorInfo);\n this.componentEvent.emit({\n type: 'error',\n payload: {\n error: error?.toString() || 'Unknown error',\n errorInfo,\n source: 'react'\n }\n });\n }\n\n /**\n * Handle onSaveUserSettings from components\n * This implements the SavedUserSettings pattern\n */\n private handleSaveUserSettings(newSettings: Record<string, any>) {\n // Just bubble the event up to parent containers for persistence\n // We don't need to store anything here\n this.userSettingsChanged.emit({\n settings: newSettings,\n componentName: this.component?.name,\n timestamp: new Date()\n });\n \n // DO NOT re-render the component!\n // The component already has the correct state - it's the one that told us about the change.\n // Re-rendering would cause unnecessary DOM updates and visual flashing.\n }\n\n /**\n * Clean up resources\n */\n private cleanup() {\n // Clean up all resources managed by resource manager\n resourceManager.cleanupComponent(this.componentId);\n \n // Clean up prop builder subscriptions\n if (this.currentCallbacks) {\n this.currentCallbacks = null;\n }\n \n // Unmount React root using managed unmount\n if (this.reactRootId) {\n // Force stop rendering flags\n this.isRendering = false;\n this.pendingRender = false;\n \n // This will handle waiting for render completion if needed\n reactRootManager.unmountRoot(this.reactRootId);\n this.reactRootId = null;\n }\n\n // Clear references\n this.compiledComponent = null;\n this.isInitialized = false;\n\n // Trigger registry cleanup\n this.adapter.getRegistry().cleanup();\n }\n\n /**\n * Public method to refresh the component\n * @deprecated Components manage their own state and data now\n */\n refresh() {\n // Just trigger a re-render if needed\n this.renderComponent();\n }\n\n /**\n * Public method to update state programmatically\n * @param path - State path to update\n * @param value - New value\n * @deprecated Components manage their own state now\n */\n updateState(path: string, value: any) {\n // Just emit the event, don't manage state here\n this.stateChange.emit({ path, value });\n }\n\n}"]}
|
|
@@ -38,7 +38,7 @@ export class AngularAdapterService {
|
|
|
38
38
|
// Add any Angular-specific utilities here
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
// Create the React runtime
|
|
41
|
+
// Create the React runtime with runtime context for registry support
|
|
42
42
|
this.runtime = createReactRuntime(ecosystem.Babel, {
|
|
43
43
|
compiler: {
|
|
44
44
|
cache: true,
|
|
@@ -50,7 +50,7 @@ export class AngularAdapterService {
|
|
|
50
50
|
useLRU: true,
|
|
51
51
|
enableNamespaces: true
|
|
52
52
|
}
|
|
53
|
-
});
|
|
53
|
+
}, this.runtimeContext);
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* Get the component compiler
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-adapter.service.js","sourceRoot":"","sources":["../../../src/lib/services/angular-adapter.service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAIL,kBAAkB,EAKnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;;;AAGnD;;;GAGG;AAEH,MAAM,OAAO,qBAAqB;IAShC,YAAoB,YAAiC;QAAjC,i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CAAC,cAAc,EAAE,SAAS,EAAE,KAAK,IAAK,MAAc,CAAC,KAAK,CAAC;IACxE,CAAC;IAED;;;;;OAKG;IACH,YAAY,CAAC,IAAY,EAAE,QAAiB;QAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,CAAC;QAED,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE;gBACnC,OAAO,EAAE,CAAC,OAAO,CAAC;gBAClB,QAAQ,EAAE,QAAQ,IAAI,eAAe;aACtC,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,4BAA4B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;sFAxOU,qBAAqB;uEAArB,qBAAqB,WAArB,qBAAqB,mBADR,MAAM;;iFACnB,qBAAqB;cADjC,UAAU;eAAC,EAAE,UAAU,EAAE,MAAM,EAAE","sourcesContent":["/**\n * @fileoverview Angular adapter service that bridges the React runtime with Angular.\n * Provides Angular-specific functionality for the platform-agnostic React runtime.\n * @module @memberjunction/ng-react\n */\n\nimport { Injectable } from '@angular/core';\nimport { \n ComponentCompiler,\n ComponentRegistry,\n ComponentResolver,\n createReactRuntime,\n CompileOptions,\n RuntimeContext,\n ExternalLibraryConfig,\n LibraryConfiguration\n} from '@memberjunction/react-runtime';\nimport { ScriptLoaderService } from './script-loader.service';\nimport { DEFAULT_STYLES } from '../default-styles';\nimport { ComponentStyles } from '@memberjunction/interactive-component-types';\n\n/**\n * Angular-specific adapter for the React runtime.\n * Manages the integration between Angular services and the platform-agnostic React runtime.\n */\n@Injectable({ providedIn: 'root' })\nexport class AngularAdapterService {\n private runtime?: {\n compiler: ComponentCompiler;\n registry: ComponentRegistry;\n resolver: ComponentResolver;\n version: string;\n };\n private runtimeContext?: RuntimeContext;\n\n constructor(private scriptLoader: ScriptLoaderService) {}\n\n /**\n * Initialize the React runtime with Angular-specific configuration\n * @param config Optional library configuration\n * @param additionalLibraries Optional additional libraries to merge\n * @returns Promise resolving when runtime is ready\n */\n async initialize(\n config?: LibraryConfiguration,\n additionalLibraries?: ExternalLibraryConfig[]\n ): Promise<void> {\n if (this.runtime) {\n return; // Already initialized\n }\n\n // Load React ecosystem with optional additional libraries\n const ecosystem = await this.scriptLoader.loadReactEcosystem(config, additionalLibraries);\n \n // Create runtime context\n this.runtimeContext = {\n React: ecosystem.React,\n ReactDOM: ecosystem.ReactDOM,\n libraries: ecosystem.libraries,\n utilities: {\n // Add any Angular-specific utilities here\n }\n };\n\n // Create the React runtime\n this.runtime = createReactRuntime(ecosystem.Babel, {\n compiler: {\n cache: true,\n maxCacheSize: 100\n },\n registry: {\n maxComponents: 1000,\n cleanupInterval: 60000,\n useLRU: true,\n enableNamespaces: true\n }\n });\n }\n\n /**\n * Get the component compiler\n * @returns Component compiler instance\n */\n getCompiler(): ComponentCompiler {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.compiler;\n }\n\n /**\n * Get the component registry\n * @returns Component registry instance\n */\n getRegistry(): ComponentRegistry {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.registry;\n }\n\n /**\n * Get the component resolver\n * @returns Component resolver instance\n */\n getResolver(): ComponentResolver {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.resolver;\n }\n\n /**\n * Get the runtime context\n * @returns Runtime context with React and libraries\n */\n getRuntimeContext(): RuntimeContext {\n if (!this.runtimeContext) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtimeContext;\n }\n\n\n /**\n * Compile a component with Angular-specific defaults\n * @param options - Compilation options\n * @returns Promise resolving to compilation result\n */\n async compileComponent(options: CompileOptions) {\n // Validate options before initialization\n if (!options) {\n throw new Error(\n 'Angular adapter error: No compilation options provided.\\n' +\n 'This usually means the component spec is null or undefined.\\n' +\n 'Please check that:\\n' +\n '1. Your component data is loaded properly\\n' +\n '2. The component spec has \"name\" and \"code\" properties\\n' +\n '3. The component input is not undefined'\n );\n }\n\n if (!options.componentName || options.componentName.trim() === '') {\n throw new Error(\n 'Angular adapter error: Component name is missing or empty.\\n' +\n `Received options: ${JSON.stringify(options, null, 2)}\\n` +\n 'Make sure your component spec includes a \"name\" property.'\n );\n }\n\n if (!options.componentCode || options.componentCode.trim() === '') {\n throw new Error(\n `Angular adapter error: Component code is missing or empty for component \"${options.componentName}\".\\n` +\n 'Make sure your component spec includes a \"code\" property with the React component source.'\n );\n }\n\n await this.initialize();\n \n // Apply default styles if not provided\n const optionsWithDefaults = {\n ...options,\n styles: options.styles || DEFAULT_STYLES\n };\n\n return this.runtime!.compiler.compile(optionsWithDefaults);\n }\n\n /**\n * Register a component in the registry\n * @param name - Component name\n * @param component - Compiled component\n * @param namespace - Component namespace\n * @param version - Component version\n * @returns Component metadata\n */\n registerComponent(\n name: string,\n component: any,\n namespace: string = 'Global',\n version: string = 'v1'\n ) {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.registry.register(name, component, namespace, version);\n }\n\n /**\n * Get a component from the registry\n * @param name - Component name\n * @param namespace - Component namespace\n * @param version - Component version\n * @returns Component if found\n */\n getComponent(name: string, namespace: string = 'Global', version?: string) {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.registry.get(name, namespace, version);\n }\n\n /**\n * Check if runtime is initialized\n * @returns true if initialized\n */\n isInitialized(): boolean {\n return !!this.runtime && !!this.runtimeContext;\n }\n\n /**\n * Get runtime version\n * @returns Runtime version string\n */\n getVersion(): string {\n return this.runtime?.version || 'unknown';\n }\n\n /**\n * Clean up resources\n */\n destroy(): void {\n if (this.runtime) {\n this.runtime.registry.destroy();\n this.runtime = undefined;\n this.runtimeContext = undefined;\n }\n }\n\n /**\n * Get Babel instance for direct use\n * @returns Babel instance\n */\n getBabel(): any {\n return this.runtimeContext?.libraries?.Babel || (window as any).Babel;\n }\n\n /**\n * Transpile JSX code directly\n * @param code - JSX code to transpile\n * @param filename - Optional filename for better error messages\n * @returns Transpiled JavaScript code\n */\n transpileJSX(code: string, filename?: string): string {\n const babel = this.getBabel();\n if (!babel) {\n throw new Error('Babel not loaded. Initialize the runtime first.');\n }\n\n try {\n const result = babel.transform(code, {\n presets: ['react'],\n filename: filename || 'component.jsx'\n });\n return result.code;\n } catch (error: any) {\n throw new Error(`Failed to transpile JSX: ${error.message}`);\n }\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"angular-adapter.service.js","sourceRoot":"","sources":["../../../src/lib/services/angular-adapter.service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAIL,kBAAkB,EAKnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;;;AAGnD;;;GAGG;AAEH,MAAM,OAAO,qBAAqB;IAShC,YAAoB,YAAiC;QAAjC,iBAAY,GAAZ,YAAY,CAAqB;IAAG,CAAC;IAEzD;;;;;OAKG;IACH,KAAK,CAAC,UAAU,CACd,MAA6B,EAC7B,mBAA6C;QAE7C,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO,CAAC,sBAAsB;QAChC,CAAC;QAED,0DAA0D;QAC1D,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;QAE1F,yBAAyB;QACzB,IAAI,CAAC,cAAc,GAAG;YACpB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,CAAC,SAAS,CAAC,IAAI,EAAE;gBACnC,OAAO,EAAE,CAAC,OAAO,CAAC;gBAClB,QAAQ,EAAE,QAAQ,IAAI,eAAe;aACtC,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,4BAA4B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;sFAxOU,qBAAqB;uEAArB,qBAAqB,WAArB,qBAAqB,mBADR,MAAM;;iFACnB,qBAAqB;cADjC,UAAU;eAAC,EAAE,UAAU,EAAE,MAAM,EAAE","sourcesContent":["/**\n * @fileoverview Angular adapter service that bridges the React runtime with Angular.\n * Provides Angular-specific functionality for the platform-agnostic React runtime.\n * @module @memberjunction/ng-react\n */\n\nimport { Injectable } from '@angular/core';\nimport { \n ComponentCompiler,\n ComponentRegistry,\n ComponentResolver,\n createReactRuntime,\n CompileOptions,\n RuntimeContext,\n ExternalLibraryConfig,\n LibraryConfiguration\n} from '@memberjunction/react-runtime';\nimport { ScriptLoaderService } from './script-loader.service';\nimport { DEFAULT_STYLES } from '../default-styles';\nimport { ComponentStyles } from '@memberjunction/interactive-component-types';\n\n/**\n * Angular-specific adapter for the React runtime.\n * Manages the integration between Angular services and the platform-agnostic React runtime.\n */\n@Injectable({ providedIn: 'root' })\nexport class AngularAdapterService {\n private runtime?: {\n compiler: ComponentCompiler;\n registry: ComponentRegistry;\n resolver: ComponentResolver;\n version: string;\n };\n private runtimeContext?: RuntimeContext;\n\n constructor(private scriptLoader: ScriptLoaderService) {}\n\n /**\n * Initialize the React runtime with Angular-specific configuration\n * @param config Optional library configuration\n * @param additionalLibraries Optional additional libraries to merge\n * @returns Promise resolving when runtime is ready\n */\n async initialize(\n config?: LibraryConfiguration,\n additionalLibraries?: ExternalLibraryConfig[]\n ): Promise<void> {\n if (this.runtime) {\n return; // Already initialized\n }\n\n // Load React ecosystem with optional additional libraries\n const ecosystem = await this.scriptLoader.loadReactEcosystem(config, additionalLibraries);\n \n // Create runtime context\n this.runtimeContext = {\n React: ecosystem.React,\n ReactDOM: ecosystem.ReactDOM,\n libraries: ecosystem.libraries,\n utilities: {\n // Add any Angular-specific utilities here\n }\n };\n\n // Create the React runtime with runtime context for registry support\n this.runtime = createReactRuntime(ecosystem.Babel, {\n compiler: {\n cache: true,\n maxCacheSize: 100\n },\n registry: {\n maxComponents: 1000,\n cleanupInterval: 60000,\n useLRU: true,\n enableNamespaces: true\n }\n }, this.runtimeContext);\n }\n\n /**\n * Get the component compiler\n * @returns Component compiler instance\n */\n getCompiler(): ComponentCompiler {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.compiler;\n }\n\n /**\n * Get the component registry\n * @returns Component registry instance\n */\n getRegistry(): ComponentRegistry {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.registry;\n }\n\n /**\n * Get the component resolver\n * @returns Component resolver instance\n */\n getResolver(): ComponentResolver {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.resolver;\n }\n\n /**\n * Get the runtime context\n * @returns Runtime context with React and libraries\n */\n getRuntimeContext(): RuntimeContext {\n if (!this.runtimeContext) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtimeContext;\n }\n\n\n /**\n * Compile a component with Angular-specific defaults\n * @param options - Compilation options\n * @returns Promise resolving to compilation result\n */\n async compileComponent(options: CompileOptions) {\n // Validate options before initialization\n if (!options) {\n throw new Error(\n 'Angular adapter error: No compilation options provided.\\n' +\n 'This usually means the component spec is null or undefined.\\n' +\n 'Please check that:\\n' +\n '1. Your component data is loaded properly\\n' +\n '2. The component spec has \"name\" and \"code\" properties\\n' +\n '3. The component input is not undefined'\n );\n }\n\n if (!options.componentName || options.componentName.trim() === '') {\n throw new Error(\n 'Angular adapter error: Component name is missing or empty.\\n' +\n `Received options: ${JSON.stringify(options, null, 2)}\\n` +\n 'Make sure your component spec includes a \"name\" property.'\n );\n }\n\n if (!options.componentCode || options.componentCode.trim() === '') {\n throw new Error(\n `Angular adapter error: Component code is missing or empty for component \"${options.componentName}\".\\n` +\n 'Make sure your component spec includes a \"code\" property with the React component source.'\n );\n }\n\n await this.initialize();\n \n // Apply default styles if not provided\n const optionsWithDefaults = {\n ...options,\n styles: options.styles || DEFAULT_STYLES\n };\n\n return this.runtime!.compiler.compile(optionsWithDefaults);\n }\n\n /**\n * Register a component in the registry\n * @param name - Component name\n * @param component - Compiled component\n * @param namespace - Component namespace\n * @param version - Component version\n * @returns Component metadata\n */\n registerComponent(\n name: string,\n component: any,\n namespace: string = 'Global',\n version: string = 'v1'\n ) {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.registry.register(name, component, namespace, version);\n }\n\n /**\n * Get a component from the registry\n * @param name - Component name\n * @param namespace - Component namespace\n * @param version - Component version\n * @returns Component if found\n */\n getComponent(name: string, namespace: string = 'Global', version?: string) {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.registry.get(name, namespace, version);\n }\n\n /**\n * Check if runtime is initialized\n * @returns true if initialized\n */\n isInitialized(): boolean {\n return !!this.runtime && !!this.runtimeContext;\n }\n\n /**\n * Get runtime version\n * @returns Runtime version string\n */\n getVersion(): string {\n return this.runtime?.version || 'unknown';\n }\n\n /**\n * Clean up resources\n */\n destroy(): void {\n if (this.runtime) {\n this.runtime.registry.destroy();\n this.runtime = undefined;\n this.runtimeContext = undefined;\n }\n }\n\n /**\n * Get Babel instance for direct use\n * @returns Babel instance\n */\n getBabel(): any {\n return this.runtimeContext?.libraries?.Babel || (window as any).Babel;\n }\n\n /**\n * Transpile JSX code directly\n * @param code - JSX code to transpile\n * @param filename - Optional filename for better error messages\n * @returns Transpiled JavaScript code\n */\n transpileJSX(code: string, filename?: string): string {\n const babel = this.getBabel();\n if (!babel) {\n throw new Error('Babel not loaded. Initialize the runtime first.');\n }\n\n try {\n const result = babel.transform(code, {\n presets: ['react'],\n filename: filename || 'component.jsx'\n });\n return result.code;\n } catch (error: any) {\n throw new Error(`Failed to transpile JSX: ${error.message}`);\n }\n }\n}"]}
|
|
@@ -18,6 +18,7 @@ export declare class RuntimeUtilities {
|
|
|
18
18
|
* Sets up the utilities object - copied from skip-chat implementation
|
|
19
19
|
*/
|
|
20
20
|
private SetupUtilities;
|
|
21
|
+
private CreateSimpleAITools;
|
|
21
22
|
private CreateSimpleMetadata;
|
|
22
23
|
private CreateSimpleRunQuery;
|
|
23
24
|
private CreateSimpleRunView;
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
* @module @memberjunction/ng-react/utilities
|
|
4
4
|
*/
|
|
5
5
|
import { __decorate } from "tslib";
|
|
6
|
-
import { Metadata, RunView, RunQuery, LogError } from '@memberjunction/core';
|
|
6
|
+
import { Metadata, RunView, RunQuery, LogError, BaseEntity } from '@memberjunction/core';
|
|
7
7
|
import { MJGlobal, RegisterClass } from '@memberjunction/global';
|
|
8
|
+
import { GraphQLDataProvider } from '@memberjunction/graphql-dataprovider';
|
|
9
|
+
import { SimpleVectorService } from '@memberjunction/ai-vectors-memory';
|
|
8
10
|
/**
|
|
9
11
|
* Base class for providing runtime utilities to React components in Angular.
|
|
10
12
|
* This class can be extended and registered with MJ's ClassFactory
|
|
@@ -28,10 +30,69 @@ let RuntimeUtilities = class RuntimeUtilities {
|
|
|
28
30
|
const u = {
|
|
29
31
|
md: this.CreateSimpleMetadata(md),
|
|
30
32
|
rv: this.CreateSimpleRunView(rv),
|
|
31
|
-
rq: this.CreateSimpleRunQuery(rq)
|
|
33
|
+
rq: this.CreateSimpleRunQuery(rq),
|
|
34
|
+
ai: this.CreateSimpleAITools()
|
|
32
35
|
};
|
|
33
36
|
return u;
|
|
34
37
|
}
|
|
38
|
+
CreateSimpleAITools() {
|
|
39
|
+
// Get the GraphQL provider - it's the same as the BaseEntity provider
|
|
40
|
+
const provider = BaseEntity.Provider;
|
|
41
|
+
// Check if it's a GraphQLDataProvider
|
|
42
|
+
if (!(provider instanceof GraphQLDataProvider)) {
|
|
43
|
+
throw new Error('Current data provider is not a GraphQLDataProvider. AI tools require GraphQL provider.');
|
|
44
|
+
}
|
|
45
|
+
const graphQLProvider = provider;
|
|
46
|
+
return {
|
|
47
|
+
ExecutePrompt: async (params) => {
|
|
48
|
+
try {
|
|
49
|
+
// Use the AI client from GraphQLDataProvider to execute simple prompt
|
|
50
|
+
const result = await graphQLProvider.AI.ExecuteSimplePrompt({
|
|
51
|
+
systemPrompt: params.systemPrompt,
|
|
52
|
+
messages: params.messages,
|
|
53
|
+
preferredModels: params.preferredModels,
|
|
54
|
+
modelPower: params.modelPower
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
success: result.success,
|
|
58
|
+
result: result.result || '',
|
|
59
|
+
resultObject: result.resultObject,
|
|
60
|
+
modelName: result.modelName || ''
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
LogError(error);
|
|
65
|
+
return {
|
|
66
|
+
success: false,
|
|
67
|
+
result: 'Failed to execute prompt: ' + (error instanceof Error ? error.message : String(error)),
|
|
68
|
+
modelName: ''
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
EmbedText: async (params) => {
|
|
73
|
+
try {
|
|
74
|
+
// Use the AI client from GraphQLDataProvider to generate embeddings
|
|
75
|
+
const result = await graphQLProvider.AI.EmbedText({
|
|
76
|
+
textToEmbed: params.textToEmbed,
|
|
77
|
+
modelSize: params.modelSize
|
|
78
|
+
});
|
|
79
|
+
if (result.error) {
|
|
80
|
+
throw new Error(result.error || 'Failed to generate embeddings');
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
result: result.embeddings,
|
|
84
|
+
modelName: result.modelName,
|
|
85
|
+
vectorDimensions: result.vectorDimensions
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
LogError(error);
|
|
90
|
+
throw error; // Re-throw for embeddings as they're critical
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
VectorService: new SimpleVectorService()
|
|
94
|
+
};
|
|
95
|
+
}
|
|
35
96
|
CreateSimpleMetadata(md) {
|
|
36
97
|
return {
|
|
37
98
|
Entities: md.Entities,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-utilities.js","sourceRoot":"","sources":["../../../src/lib/utilities/runtime-utilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EACL,QAAQ,EACR,OAAO,EACP,QAAQ,EAGR,QAAQ,EACT,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGjE;;;;GAIG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC3B;;;OAGG;IACI,cAAc;QACnB,MAAM,EAAE,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;IAED;;OAEG;IACK,cAAc,CAAC,EAAY;QACjC,MAAM,EAAE,GAAG,IAAI,OAAO,EAAE,CAAC;QACzB,MAAM,EAAE,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC1B,MAAM,CAAC,GAAuB;YAC5B,EAAE,EAAE,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC;YACjC,EAAE,EAAE,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC;YAChC,EAAE,EAAE,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC;SAClC,CAAC;QACF,OAAO,CAAC,CAAC;IACX,CAAC;IAEO,oBAAoB,CAAC,EAAY;QACvC,OAAO;YACL,QAAQ,EAAE,EAAE,CAAC,QAAQ;YACrB,eAAe,EAAE,CAAC,UAAkB,EAAE,EAAE;gBAC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a,CAAC,gBAAgB,EAAE,kBAAkB,CAAC;GACvC,gBAAgB,CAwE5B;;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB;IACpC,kEAAkE;IAClE,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,IAAI,CAAC;YACH,oFAAoF;YACpF,MAAM,GAAG,GAAG,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,cAAc,CAAmB,gBAAgB,CAAC,CAAC;YAC9F,IAAI,CAAC,GAAG,EAAE,CAAC;gBACT,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;YAChE,CAAC;YAED,uDAAuD;YACvD,OAAO,GAAG,CAAC;QACb,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,0BAA0B;QAC5B,CAAC;IACH,CAAC;IAED,mCAAmC;IACnC,OAAO,IAAI,gBAAgB,EAAE,CAAC;AAChC,CAAC","sourcesContent":["/**\n * @fileoverview Runtime utilities for React components providing access to MemberJunction core functionality\n * @module @memberjunction/ng-react/utilities\n */\n\nimport { \n Metadata, \n RunView, \n RunQuery, \n RunViewParams, \n RunQueryParams,\n LogError\n} from '@memberjunction/core';\n\nimport { MJGlobal, RegisterClass } from '@memberjunction/global';\nimport { ComponentUtilities, SimpleMetadata, SimpleRunQuery, SimpleRunView } from '@memberjunction/interactive-component-types';\n\n/**\n * Base class for providing runtime utilities to React components in Angular.\n * This class can be extended and registered with MJ's ClassFactory\n * to provide custom implementations of data access methods.\n */\n@RegisterClass(RuntimeUtilities, 'RuntimeUtilities')\nexport class RuntimeUtilities {\n /**\n * Builds the complete utilities object for React components\n * This is the main method that components will use\n */\n public buildUtilities(): ComponentUtilities {\n const md = new Metadata();\n return this.SetupUtilities(md);\n }\n\n /**\n * Sets up the utilities object - copied from skip-chat implementation\n */\n private SetupUtilities(md: Metadata): ComponentUtilities {\n const rv = new RunView();\n const rq = new RunQuery();\n const u: ComponentUtilities = {\n md: this.CreateSimpleMetadata(md),\n rv: this.CreateSimpleRunView(rv),\n rq: this.CreateSimpleRunQuery(rq)\n }; \n return u;\n }\n\n private CreateSimpleMetadata(md: Metadata): SimpleMetadata {\n return {\n Entities: md.Entities,\n GetEntityObject: (entityName: string) => {\n return md.GetEntityObject(entityName)\n }\n }\n }\n\n private CreateSimpleRunQuery(rq: RunQuery): SimpleRunQuery {\n return {\n RunQuery: async (params: RunQueryParams) => {\n // Run a single query and return the results\n try {\n const result = await rq.RunQuery(params);\n return result;\n } catch (error) {\n LogError(error);\n throw error; // Re-throw to handle it in the caller\n }\n }\n }\n }\n\n private CreateSimpleRunView(rv: RunView): SimpleRunView {\n return {\n RunView: async (params: RunViewParams) => {\n // Run a single view and return the results\n try {\n const result = await rv.RunView(params);\n return result;\n } catch (error) {\n LogError(error);\n throw error; // Re-throw to handle it in the caller\n }\n },\n RunViews: async (params: RunViewParams[]) => {\n // Runs multiple views and returns the results\n try {\n const results = await rv.RunViews(params);\n return results;\n } catch (error) {\n LogError(error);\n throw error; // Re-throw to handle it in the caller\n }\n }\n }\n }\n}\n\n/**\n * Factory function to create RuntimeUtilities\n * In a Node.js environment, this will use MJ's ClassFactory for runtime substitution\n * In a browser environment, it will use the base class directly\n */\nexport function createRuntimeUtilities(): RuntimeUtilities {\n // Check if we're in a Node.js environment with MJGlobal available\n if (typeof window === 'undefined') {\n try {\n // Use ClassFactory to get the registered class, defaulting to base RuntimeUtilities\n const obj = MJGlobal.Instance.ClassFactory.CreateInstance<RuntimeUtilities>(RuntimeUtilities);\n if (!obj) {\n throw new Error('Failed to create RuntimeUtilities instance');\n }\n\n // Ensure the object is an instance of RuntimeUtilities\n return obj;\n } catch (e) {\n // Fall through to default\n }\n }\n \n // Default: just use the base class\n return new RuntimeUtilities();\n}"]}
|
|
1
|
+
{"version":3,"file":"runtime-utilities.js","sourceRoot":"","sources":["../../../src/lib/utilities/runtime-utilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EACL,QAAQ,EACR,OAAO,EACP,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,MAAuB,EAAE,EAAE;gBAC1C,8CAA8C;gBAC9C,IAAI,CAAC;oBACH,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;oBAC1C,OAAO,OAAO,CAAC;gBACjB,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,QAAQ,CAAC,KAAK,CAAC,CAAC;oBAChB,MAAM,KAAK,CAAC,CAAC,sCAAsC;gBACrD,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAA;AA1IY,gBAAgB;IAD5B,aAAa,CAAC,gBAAgB,EAAE,kBAAkB,CAAC;GACvC,gBAAgB,CA0I5B;;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB;IACpC,kEAAkE;IAClE,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,IAAI,CAAC;YACH,oFAAoF;YACpF,MAAM,GAAG,GAAG,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,cAAc,CAAmB,gBAAgB,CAAC,CAAC;YAC9F,IAAI,CAAC,GAAG,EAAE,CAAC;gBACT,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;YAChE,CAAC;YAED,uDAAuD;YACvD,OAAO,GAAG,CAAC;QACb,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,0BAA0B;QAC5B,CAAC;IACH,CAAC;IAED,mCAAmC;IACnC,OAAO,IAAI,gBAAgB,EAAE,CAAC;AAChC,CAAC","sourcesContent":["/**\n * @fileoverview Runtime utilities for React components providing access to MemberJunction core functionality\n * @module @memberjunction/ng-react/utilities\n */\n\nimport { \n Metadata, \n RunView, \n RunQuery, \n RunViewParams, \n RunQueryParams,\n LogError,\n BaseEntity,\n IEntityDataProvider\n} from '@memberjunction/core';\n\nimport { MJGlobal, RegisterClass } from '@memberjunction/global';\nimport { \n ComponentUtilities, \n SimpleAITools, \n SimpleMetadata, \n SimpleRunQuery, \n SimpleRunView,\n SimpleExecutePromptParams,\n SimpleExecutePromptResult,\n SimpleEmbedTextParams,\n SimpleEmbedTextResult\n} from '@memberjunction/interactive-component-types';\nimport { GraphQLDataProvider } from '@memberjunction/graphql-dataprovider';\nimport { SimpleVectorService } from '@memberjunction/ai-vectors-memory';\n\n/**\n * Base class for providing runtime utilities to React components in Angular.\n * This class can be extended and registered with MJ's ClassFactory\n * to provide custom implementations of data access methods.\n */\n@RegisterClass(RuntimeUtilities, 'RuntimeUtilities')\nexport class RuntimeUtilities {\n /**\n * Builds the complete utilities object for React components\n * This is the main method that components will use\n */\n public buildUtilities(): ComponentUtilities {\n const md = new Metadata();\n return this.SetupUtilities(md);\n }\n\n /**\n * Sets up the utilities object - copied from skip-chat implementation\n */\n private SetupUtilities(md: Metadata): ComponentUtilities {\n const rv = new RunView();\n const rq = new RunQuery();\n const u: ComponentUtilities = {\n md: this.CreateSimpleMetadata(md),\n rv: this.CreateSimpleRunView(rv),\n rq: this.CreateSimpleRunQuery(rq),\n ai: this.CreateSimpleAITools()\n }; \n return u;\n }\n\n private CreateSimpleAITools(): SimpleAITools {\n // Get the GraphQL provider - it's the same as the BaseEntity provider\n const provider = BaseEntity.Provider;\n \n // Check if it's a GraphQLDataProvider\n if (!(provider instanceof GraphQLDataProvider)) {\n throw new Error('Current data provider is not a GraphQLDataProvider. AI tools require GraphQL provider.');\n }\n\n const graphQLProvider = provider as GraphQLDataProvider;\n \n return {\n ExecutePrompt: async (params: SimpleExecutePromptParams): Promise<SimpleExecutePromptResult> => {\n try {\n // Use the AI client from GraphQLDataProvider to execute simple prompt\n const result = await graphQLProvider.AI.ExecuteSimplePrompt({\n systemPrompt: params.systemPrompt,\n messages: params.messages,\n preferredModels: params.preferredModels,\n modelPower: params.modelPower\n });\n \n return {\n success: result.success,\n result: result.result || '',\n resultObject: result.resultObject,\n modelName: result.modelName || ''\n };\n } catch (error) {\n LogError(error);\n return {\n success: false,\n result: 'Failed to execute prompt: ' + (error instanceof Error ? error.message : String(error)),\n modelName: ''\n };\n }\n },\n \n EmbedText: async (params: SimpleEmbedTextParams): Promise<SimpleEmbedTextResult> => {\n try {\n // Use the AI client from GraphQLDataProvider to generate embeddings\n const result = await graphQLProvider.AI.EmbedText({\n textToEmbed: params.textToEmbed,\n modelSize: params.modelSize\n });\n \n if (result.error) {\n throw new Error(result.error || 'Failed to generate embeddings');\n }\n \n return {\n result: result.embeddings,\n modelName: result.modelName,\n vectorDimensions: result.vectorDimensions\n };\n } catch (error) {\n LogError(error);\n throw error; // Re-throw for embeddings as they're critical\n }\n },\n \n VectorService: new SimpleVectorService()\n };\n }\n\n private CreateSimpleMetadata(md: Metadata): SimpleMetadata {\n return {\n Entities: md.Entities,\n GetEntityObject: (entityName: string) => {\n return md.GetEntityObject(entityName)\n }\n }\n }\n\n private CreateSimpleRunQuery(rq: RunQuery): SimpleRunQuery {\n return {\n RunQuery: async (params: RunQueryParams) => {\n // Run a single query and return the results\n try {\n const result = await rq.RunQuery(params);\n return result;\n } catch (error) {\n LogError(error);\n throw error; // Re-throw to handle it in the caller\n }\n }\n }\n }\n\n private CreateSimpleRunView(rv: RunView): SimpleRunView {\n return {\n RunView: async (params: RunViewParams) => {\n // Run a single view and return the results\n try {\n const result = await rv.RunView(params);\n return result;\n } catch (error) {\n LogError(error);\n throw error; // Re-throw to handle it in the caller\n }\n },\n RunViews: async (params: RunViewParams[]) => {\n // Runs multiple views and returns the results\n try {\n const results = await rv.RunViews(params);\n return results;\n } catch (error) {\n LogError(error);\n throw error; // Re-throw to handle it in the caller\n }\n }\n }\n }\n}\n\n/**\n * Factory function to create RuntimeUtilities\n * In a Node.js environment, this will use MJ's ClassFactory for runtime substitution\n * In a browser environment, it will use the base class directly\n */\nexport function createRuntimeUtilities(): RuntimeUtilities {\n // Check if we're in a Node.js environment with MJGlobal available\n if (typeof window === 'undefined') {\n try {\n // Use ClassFactory to get the registered class, defaulting to base RuntimeUtilities\n const obj = MJGlobal.Instance.ClassFactory.CreateInstance<RuntimeUtilities>(RuntimeUtilities);\n if (!obj) {\n throw new Error('Failed to create RuntimeUtilities instance');\n }\n\n // Ensure the object is an instance of RuntimeUtilities\n return obj;\n } catch (e) {\n // Fall through to default\n }\n }\n \n // Default: just use the base class\n return new RuntimeUtilities();\n}"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.93.0",
|
|
4
4
|
"description": "Angular components for hosting React components in MemberJunction applications",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "ngc -p tsconfig.json",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"styles"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@memberjunction/core": "2.
|
|
44
|
-
"@memberjunction/react-runtime": "2.
|
|
45
|
-
"@memberjunction/interactive-component-types": "^2.
|
|
43
|
+
"@memberjunction/core": "2.93.0",
|
|
44
|
+
"@memberjunction/react-runtime": "2.93.0",
|
|
45
|
+
"@memberjunction/interactive-component-types": "^2.93.0",
|
|
46
46
|
"@angular/common": ">=18.0.0",
|
|
47
47
|
"@angular/core": ">=18.0.0",
|
|
48
48
|
"@angular/platform-browser": ">=18.0.0",
|