@memberjunction/ng-react 2.112.0 → 2.113.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.
@@ -7,7 +7,7 @@ import { EventEmitter, ElementRef, AfterViewInit, OnDestroy, ChangeDetectorRef }
7
7
  import { ComponentSpec, ComponentStyles } from '@memberjunction/interactive-component-types';
8
8
  import { ReactBridgeService } from '../services/react-bridge.service';
9
9
  import { AngularAdapterService } from '../services/angular-adapter.service';
10
- import { CompositeKey } from '@memberjunction/global';
10
+ import { CompositeKey } from '@memberjunction/core';
11
11
  import { MJNotificationService } from '@memberjunction/ng-notifications';
12
12
  import * as i0 from "@angular/core";
13
13
  /**
@@ -3,14 +3,14 @@
3
3
  * Provides a bridge between Angular and React ecosystems in MemberJunction applications.
4
4
  * @module @memberjunction/ng-react
5
5
  */
6
- import { Component, Input, Output, EventEmitter, ViewChild, ElementRef, ChangeDetectionStrategy, ChangeDetectorRef, } from '@angular/core';
6
+ import { Component, Input, Output, EventEmitter, ViewChild, ElementRef, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
7
7
  import { Subject } from 'rxjs';
8
8
  import { ComponentSpec } from '@memberjunction/interactive-component-types';
9
9
  import { ReactBridgeService } from '../services/react-bridge.service';
10
10
  import { AngularAdapterService } from '../services/angular-adapter.service';
11
- import { createErrorBoundary, ComponentHierarchyRegistrar, resourceManager, reactRootManager, SetupStyles, ComponentRegistryService, } from '@memberjunction/react-runtime';
11
+ import { createErrorBoundary, ComponentHierarchyRegistrar, resourceManager, reactRootManager, SetupStyles, ComponentRegistryService } from '@memberjunction/react-runtime';
12
12
  import { createRuntimeUtilities } from '../utilities/runtime-utilities';
13
- import { LogError, CompositeKey, Metadata, RunView } from '@memberjunction/global';
13
+ import { LogError, CompositeKey, Metadata, RunView } from '@memberjunction/core';
14
14
  import { MJNotificationService } from '@memberjunction/ng-notifications';
15
15
  import { ComponentMetadataEngine } from '@memberjunction/core-entities';
16
16
  import * as i0 from "@angular/core";
@@ -126,7 +126,7 @@ export class MJReactComponent {
126
126
  componentId: this.componentId,
127
127
  componentName: this.component?.name,
128
128
  timestamp: new Date().toISOString(),
129
- registrySize: registrySize,
129
+ registrySize: registrySize
130
130
  });
131
131
  // Trigger change detection to show loading state
132
132
  this.cdr.detectChanges();
@@ -151,7 +151,7 @@ export class MJReactComponent {
151
151
  registry: this.component?.registry,
152
152
  hasCode: !!this.component?.code,
153
153
  browserRefreshed: performance.navigation.type === 1,
154
- performanceType: performance.navigation.type,
154
+ performanceType: performance.navigation.type
155
155
  });
156
156
  // Ensure React is loaded
157
157
  await this.reactBridge.getReactContext();
@@ -175,7 +175,7 @@ export class MJReactComponent {
175
175
  console.log(`🔍 [initializeComponent] Looking for component in registry:`, {
176
176
  name: this.component.name,
177
177
  namespace: this.component.namespace || 'Global',
178
- version: this.componentVersion,
178
+ version: this.componentVersion
179
179
  });
180
180
  // Let's also check what's actually in the registry
181
181
  // Note: ComponentRegistry doesn't have a list() method, so we'll skip this for now
@@ -183,7 +183,7 @@ export class MJReactComponent {
183
183
  console.log(`🔍 [initializeComponent] Registry.get result:`, {
184
184
  found: !!componentWrapper,
185
185
  type: componentWrapper ? typeof componentWrapper : 'undefined',
186
- hasComponent: componentWrapper ? !!componentWrapper.component : false,
186
+ hasComponent: componentWrapper ? !!componentWrapper.component : false
187
187
  });
188
188
  if (!componentWrapper) {
189
189
  const source = this.component.registry ? `external registry ${this.component.registry}` : 'local registry';
@@ -191,7 +191,7 @@ export class MJReactComponent {
191
191
  searchedName: this.component.name,
192
192
  searchedNamespace: this.component.namespace || 'Global',
193
193
  searchedVersion: this.componentVersion,
194
- source: source,
194
+ source: source
195
195
  });
196
196
  throw new Error(`Component ${this.component.name} was not found in registry after registration from ${source}`);
197
197
  }
@@ -228,8 +228,8 @@ export class MJReactComponent {
228
228
  type: 'error',
229
229
  payload: {
230
230
  error: error instanceof Error ? error.message : String(error),
231
- source: 'initialization',
232
- },
231
+ source: 'initialization'
232
+ }
233
233
  });
234
234
  // Trigger change detection to show error state
235
235
  this.cdr.detectChanges();
@@ -258,7 +258,7 @@ export class MJReactComponent {
258
258
  let hash = 0;
259
259
  for (let i = 0; i < fullCode.length; i++) {
260
260
  const char = fullCode.charCodeAt(i);
261
- hash = (hash << 5) - hash + char;
261
+ hash = ((hash << 5) - hash) + char;
262
262
  hash = hash & hash; // Convert to 32bit integer
263
263
  }
264
264
  // Convert to hex string and take first 8 characters for readability
@@ -294,10 +294,10 @@ export class MJReactComponent {
294
294
  contextUser: Metadata.Provider.CurrentUser,
295
295
  defaultNamespace: 'Global',
296
296
  defaultVersion: this.component.version || this.generateComponentHash(this.component),
297
- returnType: 'both',
297
+ returnType: 'both'
298
298
  });
299
299
  if (!result.success) {
300
- const errorMessages = result.errors.map((e) => `${e.componentName}: ${e.message}`).join(', ');
300
+ const errorMessages = result.errors.map(e => `${e.componentName}: ${e.message}`).join(', ');
301
301
  console.error(`❌ [ComponentManager] Failed to load hierarchy:`, errorMessages);
302
302
  throw new Error(`Component loading failed: ${errorMessages}`);
303
303
  }
@@ -311,7 +311,7 @@ export class MJReactComponent {
311
311
  rootComponent: result.resolvedSpec?.name,
312
312
  loadedCount: result.loadedComponents.length,
313
313
  dependencies: Object.keys(this.loadedDependencies),
314
- stats: result.stats,
314
+ stats: result.stats
315
315
  });
316
316
  // Component is ready to render
317
317
  return true;
@@ -334,7 +334,7 @@ export class MJReactComponent {
334
334
  registry: this.component.registry,
335
335
  namespace: this.component.namespace,
336
336
  hasCode: !!this.component.code,
337
- codeLength: this.component.code?.length || 0,
337
+ codeLength: this.component.code?.length || 0
338
338
  });
339
339
  // Check if already registered to avoid duplication
340
340
  const registry = this.adapter.getRegistry();
@@ -344,12 +344,12 @@ export class MJReactComponent {
344
344
  namespace: checkNamespace,
345
345
  version: version,
346
346
  registrySize: registry.size(),
347
- registryId: registry.registryId || 'unknown',
347
+ registryId: registry.registryId || 'unknown'
348
348
  });
349
349
  // Log registry state for debugging
350
350
  console.log(`📦 [registerComponentHierarchy] Registry state:`, {
351
351
  totalSize: registry.size(),
352
- registryInstance: registry.registryId || 'unknown',
352
+ registryInstance: registry.registryId || 'unknown'
353
353
  });
354
354
  const existingComponent = registry.get(this.component.name, checkNamespace, version);
355
355
  if (existingComponent) {
@@ -357,7 +357,7 @@ export class MJReactComponent {
357
357
  existingType: typeof existingComponent,
358
358
  hasComponent: !!existingComponent.component,
359
359
  registrationTime: existingComponent.registeredAt || 'unknown',
360
- runtimeContextLibraries: Object.keys(this.adapter.getRuntimeContext().libraries || {}),
360
+ runtimeContextLibraries: Object.keys(this.adapter.getRuntimeContext().libraries || {})
361
361
  });
362
362
  // For registry components, we need to check the resolved spec's libraries, not the input spec
363
363
  // The input spec from Angular doesn't have library information for registry components
@@ -369,12 +369,12 @@ export class MJReactComponent {
369
369
  // For local components, check using the input spec
370
370
  const requiredLibraries = this.component.libraries || [];
371
371
  const runtimeLibraries = this.adapter.getRuntimeContext().libraries || {};
372
- const missingLibraries = requiredLibraries.filter((lib) => !runtimeLibraries[lib.globalVariable]);
372
+ const missingLibraries = requiredLibraries.filter(lib => !runtimeLibraries[lib.globalVariable]);
373
373
  if (missingLibraries.length > 0) {
374
374
  console.warn(`⚠️ [registerComponentHierarchy] Component registered but libraries missing:`, {
375
- required: requiredLibraries.map((l) => l.globalVariable),
375
+ required: requiredLibraries.map(l => l.globalVariable),
376
376
  loaded: Object.keys(runtimeLibraries),
377
- missing: missingLibraries.map((l) => l.globalVariable),
377
+ missing: missingLibraries.map(l => l.globalVariable)
378
378
  });
379
379
  // Don't return early - continue to load libraries
380
380
  }
@@ -397,7 +397,7 @@ export class MJReactComponent {
397
397
  version: version,
398
398
  libraryCount: ComponentMetadataEngine.Instance.ComponentLibraries?.length || 0,
399
399
  hasCode: !!this.component.code,
400
- codeLength: this.component.code?.length || 0,
400
+ codeLength: this.component.code?.length || 0
401
401
  });
402
402
  // Register with proper configuration
403
403
  // Pass the partial spec - the React runtime will handle fetching from registries
@@ -409,10 +409,10 @@ export class MJReactComponent {
409
409
  allowOverride: false, // Each version is unique
410
410
  allLibraries: ComponentMetadataEngine.Instance.ComponentLibraries,
411
411
  debug: true,
412
- contextUser: Metadata.Provider.CurrentUser,
412
+ contextUser: Metadata.Provider.CurrentUser
413
413
  });
414
414
  if (!result.success) {
415
- const errors = result.errors.map((e) => e.error).join(', ');
415
+ const errors = result.errors.map(e => e.error).join(', ');
416
416
  console.error(`❌ [registerComponentHierarchy] Registration failed:`, errors);
417
417
  throw new Error(`Component registration failed: ${errors}`);
418
418
  }
@@ -423,7 +423,7 @@ export class MJReactComponent {
423
423
  name: result.resolvedSpec.name,
424
424
  hasCode: !!result.resolvedSpec.code,
425
425
  libraryCount: result.resolvedSpec.libraries?.length || 0,
426
- dependencyCount: result.resolvedSpec.dependencies?.length || 0,
426
+ dependencyCount: result.resolvedSpec.dependencies?.length || 0
427
427
  });
428
428
  }
429
429
  console.log(`✅ [registerComponentHierarchy] Successfully registered ${result.registeredComponents.length} components:`, result.registeredComponents);
@@ -434,7 +434,7 @@ export class MJReactComponent {
434
434
  name: this.component.name,
435
435
  namespace: this.component.namespace || 'Global',
436
436
  version: version,
437
- componentType: verifyComponent ? typeof verifyComponent : 'not found',
437
+ componentType: verifyComponent ? typeof verifyComponent : 'not found'
438
438
  });
439
439
  }
440
440
  /**
@@ -450,7 +450,7 @@ export class MJReactComponent {
450
450
  // Recursive function to process spec and all dependencies
451
451
  // Takes the original spec at the same level to find registry info
452
452
  const processSpec = (currentSpec, originalSpec) => {
453
- // If this component has code but shows location as 'embedded',
453
+ // If this component has code but shows location as 'embedded',
454
454
  // check the original spec to see where it came from
455
455
  if (currentSpec.code && currentSpec.location === 'embedded' && currentSpec.name) {
456
456
  // Try to find this component in the original spec at the same level
@@ -469,7 +469,7 @@ export class MJReactComponent {
469
469
  }
470
470
  // Also check in original's dependencies for a match
471
471
  if (originalSpec.dependencies) {
472
- const originalDep = originalSpec.dependencies.find((d) => d.name === currentSpec.name);
472
+ const originalDep = originalSpec.dependencies.find(d => d.name === currentSpec.name);
473
473
  if (originalDep && (originalDep.location === 'registry' || originalDep.registry)) {
474
474
  currentSpec.location = 'registry';
475
475
  if (originalDep.registry) {
@@ -485,7 +485,7 @@ export class MJReactComponent {
485
485
  if (currentSpec.dependencies && Array.isArray(currentSpec.dependencies)) {
486
486
  currentSpec.dependencies.forEach((dep, index) => {
487
487
  // Find the corresponding original dependency by name or use the one at same index
488
- let originalDep = originalSpec.dependencies?.find((d) => d.name === dep.name);
488
+ let originalDep = originalSpec.dependencies?.find(d => d.name === dep.name);
489
489
  if (!originalDep && originalSpec.dependencies && index < originalSpec.dependencies.length) {
490
490
  originalDep = originalSpec.dependencies[index];
491
491
  }
@@ -546,7 +546,7 @@ export class MJReactComponent {
546
546
  styles: this.styles,
547
547
  libraries, // Pass the loaded libraries to components
548
548
  savedUserSettings: this._savedUserSettings,
549
- onSaveUserSettings: this.handleSaveUserSettings.bind(this),
549
+ onSaveUserSettings: this.handleSaveUserSettings.bind(this)
550
550
  };
551
551
  // Validate component before creating element
552
552
  if (!this.compiledComponent.component) {
@@ -562,7 +562,7 @@ export class MJReactComponent {
562
562
  const ErrorBoundary = createErrorBoundary(React, {
563
563
  onError: this.handleReactError.bind(this),
564
564
  logErrors: true,
565
- recovery: 'retry',
565
+ recovery: 'retry'
566
566
  });
567
567
  // Create element with error boundary
568
568
  const element = React.createElement(ErrorBoundary, null, React.createElement(this.compiledComponent.component, props));
@@ -574,8 +574,8 @@ export class MJReactComponent {
574
574
  type: 'error',
575
575
  payload: {
576
576
  error: 'Component render timeout - possible infinite loop detected',
577
- source: 'render',
578
- },
577
+ source: 'render'
578
+ }
579
579
  });
580
580
  }
581
581
  }, 5000, { purpose: 'render-timeout-protection' });
@@ -636,7 +636,7 @@ export class MJReactComponent {
636
636
  let shouldRunView = false;
637
637
  // now check each key in the keyToUse to see if it is a pkey
638
638
  for (const singleKey of keyToUse.KeyValuePairs) {
639
- const field = e.Fields.find((f) => f.Name.trim().toLowerCase() === singleKey.FieldName.trim().toLowerCase());
639
+ const field = e.Fields.find(f => f.Name.trim().toLowerCase() === singleKey.FieldName.trim().toLowerCase());
640
640
  if (!field) {
641
641
  // if we get here this is a problem, the component has given us a non-matching field, this shouldn't ever happen
642
642
  // but if it doesn't log warning to console and exit
@@ -656,15 +656,15 @@ export class MJReactComponent {
656
656
  const rv = new RunView();
657
657
  const result = await rv.RunView({
658
658
  EntityName: entityName,
659
- ExtraFilter: keyToUse.ToWhereClause(),
659
+ ExtraFilter: keyToUse.ToWhereClause()
660
660
  });
661
661
  if (result && result.Success && result.Results.length > 0) {
662
662
  // we have a match, use the first row and update our keyToUse
663
663
  const kvPairs = [];
664
- e.PrimaryKeys.forEach((pk) => {
664
+ e.PrimaryKeys.forEach(pk => {
665
665
  kvPairs.push({
666
666
  FieldName: pk.Name,
667
- Value: result.Results[0][pk.Name],
667
+ Value: result.Results[0][pk.Name]
668
668
  });
669
669
  });
670
670
  keyToUse = CompositeKey.FromKeyValuePairs(kvPairs);
@@ -672,7 +672,7 @@ export class MJReactComponent {
672
672
  }
673
673
  this.openEntityRecord.emit({ entityName, key: keyToUse });
674
674
  }
675
- },
675
+ }
676
676
  };
677
677
  }
678
678
  /**
@@ -685,8 +685,8 @@ export class MJReactComponent {
685
685
  payload: {
686
686
  error: error?.toString() || 'Unknown error',
687
687
  errorInfo,
688
- source: 'react',
689
- },
688
+ source: 'react'
689
+ }
690
690
  });
691
691
  }
692
692
  /**
@@ -699,7 +699,7 @@ export class MJReactComponent {
699
699
  this.userSettingsChanged.emit({
700
700
  settings: newSettings,
701
701
  componentName: this.component?.name,
702
- timestamp: new Date(),
702
+ timestamp: new Date()
703
703
  });
704
704
  // DO NOT re-render the component!
705
705
  // The component already has the correct state - it's the one that told us about the change.
@@ -908,5 +908,5 @@ export class MJReactComponent {
908
908
  type: ViewChild,
909
909
  args: ['container', { read: ElementRef, static: true }]
910
910
  }] }); })();
911
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MJReactComponent, { className: "MJReactComponent", filePath: "lib/components/mj-react-component.component.ts", lineNumber: 130 }); })();
911
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MJReactComponent, { className: "MJReactComponent", filePath: "lib/components/mj-react-component.component.ts", lineNumber: 128 }); })();
912
912
  //# 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,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAwD,MAAM,6CAA6C,CAAC;AAClI,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,eAAe,EACf,gBAAgB,EAEhB,WAAW,EACX,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAgB,QAAQ,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjG,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;;;;;;;IAuC9D,AADF,8BAA6B,aACE;IAC3B,uBAA2C;IAC7C,iBAAM;IACN,8BAA0B;IAAA,oCAAoB;IAChD,AADgD,iBAAM,EAChD;;AAhBd;;;;GAIG;AAgEH,MAA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AoC,GAAG,IAAI,CAAC;QAC9D,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,oDAAoD,CAAC,CAAC;IACpE,CAAC;iFAh8BU,gBAAgB;oEAAhB,gBAAgB;mCAgEK,UAAU;;;;;YA5HxC,8BAAqC;YACnC,4BAAyF;YACzF,yEAAmC;YAQrC,iBAAM;;YAT8C,cAAgC;YAAhC,6CAAgC;YAClF,eAOC;YAPD,8DAOC;;;iFAmDM,gBAAgB;cA/D5B,SAAS;2BACE,oBAAoB,YACpB;;;;;;;;;;;;GAYT,mBA+CgB,uBAAuB,CAAC,MAAM;2JAGtC,SAAS;kBAAjB,KAAK;YAMG,aAAa;kBAArB,KAAK;YACG,mBAAmB;kBAA3B,KAAK;YAKF,SAAS;kBADZ,KAAK;YAmBF,MAAM;kBADT,KAAK;YAiBF,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;;kFAhE/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 } from 'rxjs';\nimport { ComponentSpec, ComponentCallbacks, ComponentStyles, ComponentObject } from '@memberjunction/interactive-component-types';\nimport { ReactBridgeService } from '../services/react-bridge.service';\nimport { AngularAdapterService } from '../services/angular-adapter.service';\nimport {\n createErrorBoundary,\n ComponentHierarchyRegistrar,\n resourceManager,\n reactRootManager,\n ResolvedComponents,\n SetupStyles,\n ComponentRegistryService,\n} from '@memberjunction/react-runtime';\nimport { createRuntimeUtilities } from '../utilities/runtime-utilities';\nimport { LogError, CompositeKey, KeyValuePair, Metadata, RunView } from '@memberjunction/global';\nimport { MJNotificationService } from '@memberjunction/ng-notifications';\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 `\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 ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class MJReactComponent implements AfterViewInit, OnDestroy {\n @Input() component!: ComponentSpec;\n /**\n * Controls verbose logging for component lifecycle and operations.\n * Note: This does NOT control which React build (dev/prod) is loaded.\n * To control React builds, use ReactDebugConfig.setDebugMode() at app startup.\n */\n @Input() enableLogging: boolean = false;\n @Input() useComponentManager: boolean = true; // NEW: Use unified ComponentManager by default\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(this.enableLogging);\n if (this.enableLogging) {\n console.log('MJReactComponent: Auto-initialized utilities using createRuntimeUtilities()');\n }\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 if (this.enableLogging) {\n console.log('MJReactComponent: Auto-initialized styles using SetupStyles()');\n }\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: ComponentObject | null = null;\n private loadedDependencies: Record<string, ComponentObject> = {};\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 /**\n * Public property containing the fully resolved component specification.\n * This includes all external code fetched from registries, allowing consumers\n * to inspect the complete resolved specification including dependencies.\n * Only populated after successful component initialization.\n */\n public resolvedComponentSpec: ComponentSpec | null = null;\n\n constructor(\n private reactBridge: ReactBridgeService,\n private adapter: AngularAdapterService,\n private cdr: ChangeDetectorRef,\n private notificationService: MJNotificationService\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 // Try to get registry size safely\n let registrySize = 'N/A';\n try {\n if (this.adapter.isInitialized()) {\n registrySize = this.adapter.getRegistry().size().toString();\n } else {\n registrySize = 'Not initialized yet';\n }\n } catch (e) {\n registrySize = 'Not available';\n }\n\n console.log(`🎬 [ngAfterViewInit] Starting component initialization:`, {\n componentId: this.componentId,\n componentName: this.component?.name,\n timestamp: new Date().toISOString(),\n registrySize: registrySize,\n });\n\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 * Initialize the React component\n */\n private async initializeComponent() {\n try {\n console.log(`🔄 [initializeComponent] Starting initialization for ${this.component?.name}:`, {\n location: this.component?.location,\n registry: this.component?.registry,\n hasCode: !!this.component?.code,\n browserRefreshed: performance.navigation.type === 1,\n performanceType: performance.navigation.type,\n });\n\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 // NEW: Use ComponentManager if enabled (default: true)\n if (this.useComponentManager) {\n console.log(`🎯 [initializeComponent] Using NEW ComponentManager approach`);\n await this.loadComponentWithManager();\n\n // Component is already compiled and stored in this.compiledComponent\n // No need to fetch from registry - it's already set\n } else {\n console.log(`📦 [initializeComponent] Using legacy approach (will be deprecated)`);\n // Register component hierarchy (this compiles and registers all components including from registries)\n await this.registerComponentHierarchy();\n\n // The resolved spec should now be available from the registration result\n // No need to fetch again\n\n // Get the already-registered component from the registry\n const registry = this.adapter.getRegistry();\n\n console.log(`🔍 [initializeComponent] Looking for component in registry:`, {\n name: this.component.name,\n namespace: this.component.namespace || 'Global',\n version: this.componentVersion,\n });\n\n // Let's also check what's actually in the registry\n // Note: ComponentRegistry doesn't have a list() method, so we'll skip this for now\n\n const componentWrapper = registry.get(this.component.name, this.component.namespace || 'Global', this.componentVersion);\n\n console.log(`🔍 [initializeComponent] Registry.get result:`, {\n found: !!componentWrapper,\n type: componentWrapper ? typeof componentWrapper : 'undefined',\n hasComponent: componentWrapper ? !!componentWrapper.component : false,\n });\n\n if (!componentWrapper) {\n const source = this.component.registry ? `external registry ${this.component.registry}` : 'local registry';\n console.error(`❌ [initializeComponent] Component not found! Details:`, {\n searchedName: this.component.name,\n searchedNamespace: this.component.namespace || 'Global',\n searchedVersion: this.componentVersion,\n source: source,\n });\n throw new Error(`Component ${this.component.name} was not found in registry after registration from ${source}`);\n }\n\n // The registry now stores ComponentObjects directly\n // Validate it has the expected 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 // Now that we use a regular HOC wrapper, components should always be functions\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 } // End of else block for legacy approach\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 } 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(\n spec: ComponentSpec,\n version: string,\n namespace: string = 'Global'\n ): Promise<ResolvedComponents> {\n const resolver = this.adapter.getResolver();\n\n // Debug: Log what dependencies we're trying to resolve\n if (this.enableLogging) {\n console.log(`Resolving components for ${spec.name}. Dependencies:`, spec.dependencies);\n }\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 if (this.enableLogging) {\n console.log(`Resolved ${Object.keys(resolved).length} components for version ${version}:`, Object.keys(resolved));\n }\n return resolved;\n }\n\n /**\n * NEW: Load component using unified ComponentManager - MUCH SIMPLER!\n */\n private async loadComponentWithManager() {\n try {\n const manager = this.adapter.getComponentManager();\n\n console.log(`🚀 [ComponentManager] Loading component hierarchy: ${this.component.name}`);\n\n // Load the entire hierarchy with one simple call\n const result = await manager.loadHierarchy(this.component, {\n contextUser: Metadata.Provider.CurrentUser,\n defaultNamespace: 'Global',\n defaultVersion: this.component.version || this.generateComponentHash(this.component),\n returnType: 'both',\n });\n\n if (!result.success) {\n const errorMessages = result.errors.map((e) => `${e.componentName}: ${e.message}`).join(', ');\n console.error(`❌ [ComponentManager] Failed to load hierarchy:`, errorMessages);\n throw new Error(`Component loading failed: ${errorMessages}`);\n }\n\n // Store the results (handle undefined values)\n this.resolvedComponentSpec = this.enrichSpecWithRegistryInfo(result.resolvedSpec || null);\n this.compiledComponent = result.rootComponent || null;\n this.componentVersion = result.resolvedSpec?.version || this.component.version || 'latest';\n\n // IMPORTANT: Store the loaded dependencies for use in renderComponent\n this.loadedDependencies = result.components || {};\n\n console.log(`✅ [ComponentManager] Successfully loaded hierarchy:`, {\n rootComponent: result.resolvedSpec?.name,\n loadedCount: result.loadedComponents.length,\n dependencies: Object.keys(this.loadedDependencies),\n stats: result.stats,\n });\n\n // Component is ready to render\n return true;\n } catch (error) {\n console.error(`❌ [ComponentManager] Error loading component:`, error);\n throw error;\n }\n }\n\n /**\n * Register all components in the hierarchy\n * @deprecated Use loadComponentWithManager() instead\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(`🔍 [registerComponentHierarchy] Starting registration for ${this.component.name}@${version}`, {\n location: this.component.location,\n registry: this.component.registry,\n namespace: this.component.namespace,\n hasCode: !!this.component.code,\n codeLength: this.component.code?.length || 0,\n });\n\n // Check if already registered to avoid duplication\n const registry = this.adapter.getRegistry();\n const checkNamespace = this.component.namespace || 'Global';\n\n console.log(`🔍 [registerComponentHierarchy] Checking registry for existing component:`, {\n name: this.component.name,\n namespace: checkNamespace,\n version: version,\n registrySize: registry.size(),\n registryId: registry.registryId || 'unknown',\n });\n\n // Log registry state for debugging\n console.log(`📦 [registerComponentHierarchy] Registry state:`, {\n totalSize: registry.size(),\n registryInstance: registry.registryId || 'unknown',\n });\n\n const existingComponent = registry.get(this.component.name, checkNamespace, version);\n\n if (existingComponent) {\n console.log(`⚠️ [registerComponentHierarchy] Component ${this.component.name}@${version} already registered!`, {\n existingType: typeof existingComponent,\n hasComponent: !!(existingComponent as any).component,\n registrationTime: (existingComponent as any).registeredAt || 'unknown',\n runtimeContextLibraries: Object.keys(this.adapter.getRuntimeContext().libraries || {}),\n });\n\n // For registry components, we need to check the resolved spec's libraries, not the input spec\n // The input spec from Angular doesn't have library information for registry components\n if (this.component.location === 'registry' && this.component.registry) {\n console.log(`📋 [registerComponentHierarchy] Component is from registry, need to fetch full spec to check libraries`);\n // Continue to fetch the full spec below - don't return early\n } else {\n // For local components, check using the input spec\n const requiredLibraries = this.component.libraries || [];\n const runtimeLibraries = this.adapter.getRuntimeContext().libraries || {};\n const missingLibraries = requiredLibraries.filter((lib) => !runtimeLibraries[lib.globalVariable]);\n\n if (missingLibraries.length > 0) {\n console.warn(`⚠️ [registerComponentHierarchy] Component registered but libraries missing:`, {\n required: requiredLibraries.map((l) => l.globalVariable),\n loaded: Object.keys(runtimeLibraries),\n missing: missingLibraries.map((l) => l.globalVariable),\n });\n // Don't return early - continue to load libraries\n } else {\n console.log(\n `✅ [registerComponentHierarchy] Component ${this.component.name}@${version} already registered with all libraries, skipping`\n );\n return;\n }\n }\n } else {\n console.log(`🆕 [registerComponentHierarchy] Component not found in registry, proceeding with registration`);\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 console.log(`📦 [registerComponentHierarchy] Calling registrar.registerHierarchy for ${this.component.name}`, {\n hasStyles: !!this.styles,\n namespace: this.component.namespace || 'Global',\n version: version,\n libraryCount: ComponentMetadataEngine.Instance.ComponentLibraries?.length || 0,\n hasCode: !!this.component.code,\n codeLength: this.component.code?.length || 0,\n });\n\n // Register with proper configuration\n // Pass the partial spec - the React runtime will handle fetching from registries\n const result = await registrar.registerHierarchy(\n this.component, // Pass the original spec, not fetched\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 debug: true,\n contextUser: Metadata.Provider.CurrentUser,\n }\n );\n\n if (!result.success) {\n const errors = result.errors.map((e) => e.error).join(', ');\n console.error(`❌ [registerComponentHierarchy] Registration failed:`, errors);\n throw new Error(`Component registration failed: ${errors}`);\n }\n\n // Store the resolved spec from the registration result\n if (result.resolvedSpec) {\n this.resolvedComponentSpec = this.enrichSpecWithRegistryInfo(result.resolvedSpec || null);\n console.log(`📋 [registerComponentHierarchy] Received resolved spec from runtime:`, {\n name: result.resolvedSpec.name,\n hasCode: !!result.resolvedSpec.code,\n libraryCount: result.resolvedSpec.libraries?.length || 0,\n dependencyCount: result.resolvedSpec.dependencies?.length || 0,\n });\n }\n\n console.log(\n `✅ [registerComponentHierarchy] Successfully registered ${result.registeredComponents.length} components:`,\n result.registeredComponents\n );\n\n // Verify the component is actually in the registry\n const verifyComponent = registry.get(this.component.name, this.component.namespace || 'Global', version);\n console.log(`🔍 [registerComponentHierarchy] Verification - component in registry after registration:`, {\n found: !!verifyComponent,\n name: this.component.name,\n namespace: this.component.namespace || 'Global',\n version: version,\n componentType: verifyComponent ? typeof verifyComponent : 'not found',\n });\n }\n\n /**\n * Post-process resolved spec to ensure all components show their true registry source.\n * This enriches the spec for UI display purposes to show where components actually came from.\n * Applied to all resolved specs so any consumer of this wrapper benefits.\n */\n private enrichSpecWithRegistryInfo(spec: ComponentSpec | null): ComponentSpec | null {\n if (!spec || !this.component) return spec;\n\n // Create a deep copy to avoid mutating the original\n const enrichedSpec = JSON.parse(JSON.stringify(spec));\n\n // Recursive function to process spec and all dependencies\n // Takes the original spec at the same level to find registry info\n const processSpec = (currentSpec: ComponentSpec, originalSpec: ComponentSpec) => {\n // If this component has code but shows location as 'embedded',\n // check the original spec to see where it came from\n if (currentSpec.code && currentSpec.location === 'embedded' && currentSpec.name) {\n // Try to find this component in the original spec at the same level\n // First check if the original spec itself matches by name\n if (originalSpec.name === currentSpec.name) {\n // Use the original's registry info if it had any\n if (originalSpec.location === 'registry' || originalSpec.registry) {\n currentSpec.location = 'registry';\n if (originalSpec.registry) {\n currentSpec.registry = originalSpec.registry;\n }\n if (originalSpec.namespace) {\n currentSpec.namespace = originalSpec.namespace;\n }\n }\n }\n\n // Also check in original's dependencies for a match\n if (originalSpec.dependencies) {\n const originalDep = originalSpec.dependencies.find((d) => d.name === currentSpec.name);\n if (originalDep && (originalDep.location === 'registry' || originalDep.registry)) {\n currentSpec.location = 'registry';\n if (originalDep.registry) {\n currentSpec.registry = originalDep.registry;\n }\n if (originalDep.namespace) {\n currentSpec.namespace = originalDep.namespace;\n }\n }\n }\n }\n\n // Process all dependencies recursively\n if (currentSpec.dependencies && Array.isArray(currentSpec.dependencies)) {\n currentSpec.dependencies.forEach((dep, index) => {\n // Find the corresponding original dependency by name or use the one at same index\n let originalDep = originalSpec.dependencies?.find((d) => d.name === dep.name);\n if (!originalDep && originalSpec.dependencies && index < originalSpec.dependencies.length) {\n originalDep = originalSpec.dependencies[index];\n }\n if (originalDep) {\n processSpec(dep, originalDep);\n }\n });\n }\n };\n\n processSpec(enrichedSpec, this.component);\n return enrichedSpec;\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 // SKIP this if using ComponentManager - components are already loaded!\n let components = {};\n if (!this.useComponentManager) {\n components = await this.resolveComponentsWithVersion(this.component, this.componentVersion);\n } else {\n // Use the dependencies that were already loaded and unwrapped by ComponentManager\n components = this.loadedDependencies;\n console.log(`🎯 [renderComponent] Using dependencies from ComponentManager:`, Object.keys(components));\n }\n\n // Create callbacks once per component instance\n if (!this.currentCallbacks) {\n this.currentCallbacks = this.createCallbacks();\n }\n\n // Get libraries from runtime context\n const runtimeContext = this.adapter.getRuntimeContext();\n const libraries = runtimeContext.libraries || {};\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 libraries, // Pass the loaded libraries to components\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 // Components should be functions after HOC wrapping\n if (typeof this.compiledComponent.component !== 'function') {\n LogError(`Component is not a function for ${this.component.name}: ${typeof this.compiledComponent.component}`);\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(ErrorBoundary, null, React.createElement(this.compiledComponent.component, props));\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(this.reactRootId, element, () => {\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 * Create callbacks for the React component\n */\n private createCallbacks(): ComponentCallbacks {\n return {\n RegisterMethod: (_methodName: string, _handler: any) => {\n // The component compiler wrapper will handle this internally\n // This is just a placeholder to satisfy the interface\n // The actual registration happens in the wrapper component\n },\n CreateSimpleNotification: (message: string, style: 'none' | 'success' | 'error' | 'warning' | 'info', hideAfter?: number) => {\n // Use the MJ notification service to display the notification\n const notificationStyle = style as 'none' | 'success' | 'error' | 'warning' | 'info' | undefined;\n this.notificationService.CreateSimpleNotification(message, style, hideAfter);\n },\n OpenEntityRecord: async (entityName: string, key: CompositeKey) => {\n let keyToUse: CompositeKey | null = null;\n if (key instanceof Array) {\n keyToUse = CompositeKey.FromKeyValuePairs(key);\n } else if (typeof key === 'object' && !!key.GetValueByFieldName) {\n keyToUse = key as CompositeKey;\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 } 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 FieldName: pk.Name,\n Value: result.Results[0][pk.Name],\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 // Check if the component has registered a refresh method\n if (this.compiledComponent?.refresh) {\n this.compiledComponent.refresh();\n } else {\n // Fallback: trigger a re-render if needed\n this.renderComponent();\n }\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 // =================================================================\n // Standard Component Methods - Strongly Typed\n // =================================================================\n\n /**\n * Gets the current data state of the component\n * Used by AI agents to understand what data is currently displayed\n * @returns The current data state, or undefined if not implemented\n */\n getCurrentDataState(): any {\n return this.compiledComponent?.getCurrentDataState?.();\n }\n\n /**\n * Gets the history of data state changes in the component\n * @returns Array of timestamped state snapshots, or empty array if not implemented\n */\n getDataStateHistory(): Array<{ timestamp: Date; state: any }> {\n return this.compiledComponent?.getDataStateHistory?.() || [];\n }\n\n /**\n * Validates the current state of the component\n * @returns true if valid, false or validation errors otherwise\n */\n validate(): boolean | { valid: boolean; errors?: string[] } {\n return this.compiledComponent?.validate?.() || true;\n }\n\n /**\n * Checks if the component has unsaved changes\n * @returns true if dirty, false otherwise\n */\n isDirty(): boolean {\n return this.compiledComponent?.isDirty?.() || false;\n }\n\n /**\n * Resets the component to its initial state\n */\n reset(): void {\n this.compiledComponent?.reset?.();\n }\n\n /**\n * Scrolls to a specific element or position within the component\n * @param target - Element selector, element reference, or scroll options\n */\n scrollTo(target: string | HTMLElement | { top?: number; left?: number }): void {\n this.compiledComponent?.scrollTo?.(target);\n }\n\n /**\n * Sets focus to a specific element within the component\n * @param target - Element selector or element reference\n */\n focus(target?: string | HTMLElement): void {\n this.compiledComponent?.focus?.(target);\n }\n\n /**\n * Invokes a custom method on the component\n * @param methodName - Name of the method to invoke\n * @param args - Arguments to pass to the method\n * @returns The result of the method call, or undefined if method doesn't exist\n */\n invokeMethod(methodName: string, ...args: any[]): any {\n return this.compiledComponent?.invokeMethod?.(methodName, ...args);\n }\n\n /**\n * Checks if a method is available on the component\n * @param methodName - Name of the method to check\n * @returns true if the method exists\n */\n hasMethod(methodName: string): boolean {\n return this.compiledComponent?.hasMethod?.(methodName) || false;\n }\n\n /**\n * Print the component content\n * Uses component's print method if available, otherwise uses window.print()\n */\n print(): void {\n if (this.compiledComponent?.print) {\n this.compiledComponent.print();\n } else if (typeof window !== 'undefined' && window.print) {\n window.print();\n }\n }\n\n /**\n * Force clear component registries\n * Used by Component Studio for fresh loads\n * This is a static method that can be called without a component instance\n */\n public static forceClearRegistries(): void {\n // Clear React runtime's component registry service\n ComponentRegistryService.reset();\n\n // Clear any cached hierarchy registrar\n if (typeof window !== 'undefined' && (window as any).__MJ_COMPONENT_HIERARCHY_REGISTRAR__) {\n (window as any).__MJ_COMPONENT_HIERARCHY_REGISTRAR__ = null;\n }\n\n console.log('🧹 All component registries cleared for fresh load');\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,iBAAiB,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAwD,MAAM,6CAA6C,CAAC;A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AM;YAEqD,SAAS;kBAApE,SAAS;mBAAC,WAAW,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE;;kFAhE/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 } from 'rxjs';\nimport { ComponentSpec, ComponentCallbacks, ComponentStyles, ComponentObject } from '@memberjunction/interactive-component-types';\nimport { ReactBridgeService } from '../services/react-bridge.service';\nimport { AngularAdapterService } from '../services/angular-adapter.service';\nimport { \n createErrorBoundary,\n ComponentHierarchyRegistrar,\n resourceManager,\n reactRootManager,\n ResolvedComponents,\n SetupStyles,\n ComponentRegistryService\n} from '@memberjunction/react-runtime';\nimport { createRuntimeUtilities } from '../utilities/runtime-utilities';\nimport { LogError, CompositeKey, KeyValuePair, Metadata, RunView } from '@memberjunction/core';\nimport { MJNotificationService } from '@memberjunction/ng-notifications';\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 * Controls verbose logging for component lifecycle and operations.\n * Note: This does NOT control which React build (dev/prod) is loaded.\n * To control React builds, use ReactDebugConfig.setDebugMode() at app startup.\n */\n @Input() enableLogging: boolean = false;\n @Input() useComponentManager: boolean = true; // NEW: Use unified ComponentManager by default\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(this.enableLogging);\n if (this.enableLogging) {\n console.log('MJReactComponent: Auto-initialized utilities using createRuntimeUtilities()');\n }\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 if (this.enableLogging) {\n console.log('MJReactComponent: Auto-initialized styles using SetupStyles()');\n }\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: ComponentObject | null = null;\n private loadedDependencies: Record<string, ComponentObject> = {};\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 /**\n * Public property containing the fully resolved component specification.\n * This includes all external code fetched from registries, allowing consumers\n * to inspect the complete resolved specification including dependencies.\n * Only populated after successful component initialization.\n */\n public resolvedComponentSpec: ComponentSpec | null = null;\n\n constructor(\n private reactBridge: ReactBridgeService,\n private adapter: AngularAdapterService,\n private cdr: ChangeDetectorRef,\n private notificationService: MJNotificationService\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 // Try to get registry size safely\n let registrySize = 'N/A';\n try {\n if (this.adapter.isInitialized()) {\n registrySize = this.adapter.getRegistry().size().toString();\n } else {\n registrySize = 'Not initialized yet';\n }\n } catch (e) {\n registrySize = 'Not available';\n }\n \n console.log(`🎬 [ngAfterViewInit] Starting component initialization:`, {\n componentId: this.componentId,\n componentName: this.component?.name,\n timestamp: new Date().toISOString(),\n registrySize: registrySize\n });\n \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 console.log(`🔄 [initializeComponent] Starting initialization for ${this.component?.name}:`, {\n location: this.component?.location,\n registry: this.component?.registry,\n hasCode: !!this.component?.code,\n browserRefreshed: performance.navigation.type === 1,\n performanceType: performance.navigation.type\n });\n \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 // NEW: Use ComponentManager if enabled (default: true)\n if (this.useComponentManager) {\n console.log(`🎯 [initializeComponent] Using NEW ComponentManager approach`);\n await this.loadComponentWithManager();\n \n // Component is already compiled and stored in this.compiledComponent\n // No need to fetch from registry - it's already set\n } else {\n console.log(`📦 [initializeComponent] Using legacy approach (will be deprecated)`);\n // Register component hierarchy (this compiles and registers all components including from registries)\n await this.registerComponentHierarchy();\n \n // The resolved spec should now be available from the registration result\n // No need to fetch again\n \n // Get the already-registered component from the registry\n const registry = this.adapter.getRegistry();\n \n console.log(`🔍 [initializeComponent] Looking for component in registry:`, {\n name: this.component.name,\n namespace: this.component.namespace || 'Global',\n version: this.componentVersion\n });\n \n // Let's also check what's actually in the registry\n // Note: ComponentRegistry doesn't have a list() method, so we'll skip this for now\n \n const componentWrapper = registry.get(\n this.component.name, \n this.component.namespace || 'Global', \n this.componentVersion\n );\n \n console.log(`🔍 [initializeComponent] Registry.get result:`, {\n found: !!componentWrapper,\n type: componentWrapper ? typeof componentWrapper : 'undefined',\n hasComponent: componentWrapper ? !!componentWrapper.component : false\n });\n \n if (!componentWrapper) {\n const source = this.component.registry ? `external registry ${this.component.registry}` : 'local registry';\n console.error(`❌ [initializeComponent] Component not found! Details:`, {\n searchedName: this.component.name,\n searchedNamespace: this.component.namespace || 'Global',\n searchedVersion: this.componentVersion,\n source: source\n });\n throw new Error(`Component ${this.component.name} was not found in registry after registration from ${source}`);\n }\n \n // The registry now stores ComponentObjects directly\n // Validate it has the expected 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 // Now that we use a regular HOC wrapper, components should always be functions\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 } // End of else block for legacy approach\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 /**\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 if (this.enableLogging) {\n console.log(`Resolving components for ${spec.name}. Dependencies:`, spec.dependencies);\n }\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 if (this.enableLogging) {\n console.log(`Resolved ${Object.keys(resolved).length} components for version ${version}:`, Object.keys(resolved));\n }\n return resolved;\n }\n\n\n /**\n * NEW: Load component using unified ComponentManager - MUCH SIMPLER!\n */\n private async loadComponentWithManager() {\n try {\n const manager = this.adapter.getComponentManager();\n \n console.log(`🚀 [ComponentManager] Loading component hierarchy: ${this.component.name}`);\n \n // Load the entire hierarchy with one simple call\n const result = await manager.loadHierarchy(this.component, {\n contextUser: Metadata.Provider.CurrentUser,\n defaultNamespace: 'Global',\n defaultVersion: this.component.version || this.generateComponentHash(this.component),\n returnType: 'both'\n });\n \n if (!result.success) {\n const errorMessages = result.errors.map(e => `${e.componentName}: ${e.message}`).join(', ');\n console.error(`❌ [ComponentManager] Failed to load hierarchy:`, errorMessages);\n throw new Error(`Component loading failed: ${errorMessages}`);\n }\n \n // Store the results (handle undefined values)\n this.resolvedComponentSpec = this.enrichSpecWithRegistryInfo(result.resolvedSpec || null);\n this.compiledComponent = result.rootComponent || null;\n this.componentVersion = result.resolvedSpec?.version || this.component.version || 'latest';\n \n // IMPORTANT: Store the loaded dependencies for use in renderComponent\n this.loadedDependencies = result.components || {};\n \n console.log(`✅ [ComponentManager] Successfully loaded hierarchy:`, {\n rootComponent: result.resolvedSpec?.name,\n loadedCount: result.loadedComponents.length,\n dependencies: Object.keys(this.loadedDependencies),\n stats: result.stats\n });\n \n // Component is ready to render\n return true;\n \n } catch (error) {\n console.error(`❌ [ComponentManager] Error loading component:`, error);\n throw error;\n }\n }\n\n /**\n * Register all components in the hierarchy\n * @deprecated Use loadComponentWithManager() instead\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(`🔍 [registerComponentHierarchy] Starting registration for ${this.component.name}@${version}`, {\n location: this.component.location,\n registry: this.component.registry,\n namespace: this.component.namespace,\n hasCode: !!this.component.code,\n codeLength: this.component.code?.length || 0\n });\n \n // Check if already registered to avoid duplication\n const registry = this.adapter.getRegistry();\n const checkNamespace = this.component.namespace || 'Global';\n \n console.log(`🔍 [registerComponentHierarchy] Checking registry for existing component:`, {\n name: this.component.name,\n namespace: checkNamespace,\n version: version,\n registrySize: registry.size(),\n registryId: registry.registryId || 'unknown'\n });\n \n // Log registry state for debugging\n console.log(`📦 [registerComponentHierarchy] Registry state:`, {\n totalSize: registry.size(),\n registryInstance: registry.registryId || 'unknown'\n });\n \n const existingComponent = registry.get(this.component.name, checkNamespace, version);\n \n if (existingComponent) {\n console.log(`⚠️ [registerComponentHierarchy] Component ${this.component.name}@${version} already registered!`, {\n existingType: typeof existingComponent,\n hasComponent: !!(existingComponent as any).component,\n registrationTime: (existingComponent as any).registeredAt || 'unknown',\n runtimeContextLibraries: Object.keys(this.adapter.getRuntimeContext().libraries || {})\n });\n \n // For registry components, we need to check the resolved spec's libraries, not the input spec\n // The input spec from Angular doesn't have library information for registry components\n if (this.component.location === 'registry' && this.component.registry) {\n console.log(`📋 [registerComponentHierarchy] Component is from registry, need to fetch full spec to check libraries`);\n // Continue to fetch the full spec below - don't return early\n } else {\n // For local components, check using the input spec\n const requiredLibraries = this.component.libraries || [];\n const runtimeLibraries = this.adapter.getRuntimeContext().libraries || {};\n const missingLibraries = requiredLibraries.filter(lib => !runtimeLibraries[lib.globalVariable]);\n \n if (missingLibraries.length > 0) {\n console.warn(`⚠️ [registerComponentHierarchy] Component registered but libraries missing:`, {\n required: requiredLibraries.map(l => l.globalVariable),\n loaded: Object.keys(runtimeLibraries),\n missing: missingLibraries.map(l => l.globalVariable)\n });\n // Don't return early - continue to load libraries\n } else {\n console.log(`✅ [registerComponentHierarchy] Component ${this.component.name}@${version} already registered with all libraries, skipping`);\n return;\n }\n }\n } else {\n console.log(`🆕 [registerComponentHierarchy] Component not found in registry, proceeding with registration`);\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 console.log(`📦 [registerComponentHierarchy] Calling registrar.registerHierarchy for ${this.component.name}`, {\n hasStyles: !!this.styles,\n namespace: this.component.namespace || 'Global',\n version: version,\n libraryCount: ComponentMetadataEngine.Instance.ComponentLibraries?.length || 0,\n hasCode: !!this.component.code,\n codeLength: this.component.code?.length || 0\n });\n \n // Register with proper configuration\n // Pass the partial spec - the React runtime will handle fetching from registries\n const result = await registrar.registerHierarchy(\n this.component, // Pass the original spec, not fetched\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 debug: true,\n contextUser: Metadata.Provider.CurrentUser\n }\n );\n \n if (!result.success) {\n const errors = result.errors.map(e => e.error).join(', ');\n console.error(`❌ [registerComponentHierarchy] Registration failed:`, errors);\n throw new Error(`Component registration failed: ${errors}`);\n }\n \n // Store the resolved spec from the registration result\n if (result.resolvedSpec) {\n this.resolvedComponentSpec = this.enrichSpecWithRegistryInfo(result.resolvedSpec || null);\n console.log(`📋 [registerComponentHierarchy] Received resolved spec from runtime:`, {\n name: result.resolvedSpec.name,\n hasCode: !!result.resolvedSpec.code,\n libraryCount: result.resolvedSpec.libraries?.length || 0,\n dependencyCount: result.resolvedSpec.dependencies?.length || 0\n });\n }\n \n console.log(`✅ [registerComponentHierarchy] Successfully registered ${result.registeredComponents.length} components:`, result.registeredComponents);\n \n // Verify the component is actually in the registry\n const verifyComponent = registry.get(this.component.name, this.component.namespace || 'Global', version);\n console.log(`🔍 [registerComponentHierarchy] Verification - component in registry after registration:`, {\n found: !!verifyComponent,\n name: this.component.name,\n namespace: this.component.namespace || 'Global',\n version: version,\n componentType: verifyComponent ? typeof verifyComponent : 'not found'\n });\n }\n\n /**\n * Post-process resolved spec to ensure all components show their true registry source.\n * This enriches the spec for UI display purposes to show where components actually came from.\n * Applied to all resolved specs so any consumer of this wrapper benefits.\n */\n private enrichSpecWithRegistryInfo(spec: ComponentSpec | null): ComponentSpec | null {\n if (!spec || !this.component) return spec;\n \n // Create a deep copy to avoid mutating the original\n const enrichedSpec = JSON.parse(JSON.stringify(spec));\n \n // Recursive function to process spec and all dependencies\n // Takes the original spec at the same level to find registry info\n const processSpec = (currentSpec: ComponentSpec, originalSpec: ComponentSpec) => {\n // If this component has code but shows location as 'embedded', \n // check the original spec to see where it came from\n if (currentSpec.code && currentSpec.location === 'embedded' && currentSpec.name) {\n // Try to find this component in the original spec at the same level\n // First check if the original spec itself matches by name\n if (originalSpec.name === currentSpec.name) {\n // Use the original's registry info if it had any\n if (originalSpec.location === 'registry' || originalSpec.registry) {\n currentSpec.location = 'registry';\n if (originalSpec.registry) {\n currentSpec.registry = originalSpec.registry;\n }\n if (originalSpec.namespace) {\n currentSpec.namespace = originalSpec.namespace;\n }\n }\n }\n \n // Also check in original's dependencies for a match\n if (originalSpec.dependencies) {\n const originalDep = originalSpec.dependencies.find(d => d.name === currentSpec.name);\n if (originalDep && (originalDep.location === 'registry' || originalDep.registry)) {\n currentSpec.location = 'registry';\n if (originalDep.registry) {\n currentSpec.registry = originalDep.registry;\n }\n if (originalDep.namespace) {\n currentSpec.namespace = originalDep.namespace;\n }\n }\n }\n }\n \n // Process all dependencies recursively\n if (currentSpec.dependencies && Array.isArray(currentSpec.dependencies)) {\n currentSpec.dependencies.forEach((dep, index) => {\n // Find the corresponding original dependency by name or use the one at same index\n let originalDep = originalSpec.dependencies?.find(d => d.name === dep.name);\n if (!originalDep && originalSpec.dependencies && index < originalSpec.dependencies.length) {\n originalDep = originalSpec.dependencies[index];\n }\n if (originalDep) {\n processSpec(dep, originalDep);\n }\n });\n }\n };\n \n processSpec(enrichedSpec, this.component);\n return enrichedSpec;\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 // SKIP this if using ComponentManager - components are already loaded!\n let components = {};\n if (!this.useComponentManager) {\n components = await this.resolveComponentsWithVersion(this.component, this.componentVersion);\n } else {\n // Use the dependencies that were already loaded and unwrapped by ComponentManager\n components = this.loadedDependencies;\n console.log(`🎯 [renderComponent] Using dependencies from ComponentManager:`, Object.keys(components));\n }\n \n // Create callbacks once per component instance\n if (!this.currentCallbacks) {\n this.currentCallbacks = this.createCallbacks();\n }\n \n // Get libraries from runtime context\n const runtimeContext = this.adapter.getRuntimeContext();\n const libraries = runtimeContext.libraries || {};\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 libraries, // Pass the loaded libraries to components\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 // Components should be functions after HOC wrapping\n if (typeof this.compiledComponent.component !== 'function') {\n LogError(`Component is not a function for ${this.component.name}: ${typeof this.compiledComponent.component}`);\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 RegisterMethod: (_methodName: string, _handler: any) => {\n // The component compiler wrapper will handle this internally\n // This is just a placeholder to satisfy the interface\n // The actual registration happens in the wrapper component\n },\n CreateSimpleNotification: (message: string, style: \"none\" | \"success\" | \"error\" | \"warning\" | \"info\", hideAfter?: number) => {\n // Use the MJ notification service to display the notification\n const notificationStyle = style as \"none\" | \"success\" | \"error\" | \"warning\" | \"info\" | undefined;\n this.notificationService.CreateSimpleNotification(\n message, \n style, \n hideAfter\n );\n },\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 // Check if the component has registered a refresh method\n if (this.compiledComponent?.refresh) {\n this.compiledComponent.refresh();\n } else {\n // Fallback: trigger a re-render if needed\n this.renderComponent();\n }\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 // =================================================================\n // Standard Component Methods - Strongly Typed\n // =================================================================\n \n /**\n * Gets the current data state of the component\n * Used by AI agents to understand what data is currently displayed\n * @returns The current data state, or undefined if not implemented\n */\n getCurrentDataState(): any {\n return this.compiledComponent?.getCurrentDataState?.();\n }\n \n /**\n * Gets the history of data state changes in the component\n * @returns Array of timestamped state snapshots, or empty array if not implemented\n */\n getDataStateHistory(): Array<{ timestamp: Date; state: any }> {\n return this.compiledComponent?.getDataStateHistory?.() || [];\n }\n \n /**\n * Validates the current state of the component\n * @returns true if valid, false or validation errors otherwise\n */\n validate(): boolean | { valid: boolean; errors?: string[] } {\n return this.compiledComponent?.validate?.() || true;\n }\n \n /**\n * Checks if the component has unsaved changes\n * @returns true if dirty, false otherwise\n */\n isDirty(): boolean {\n return this.compiledComponent?.isDirty?.() || false;\n }\n \n /**\n * Resets the component to its initial state\n */\n reset(): void {\n this.compiledComponent?.reset?.();\n }\n \n /**\n * Scrolls to a specific element or position within the component\n * @param target - Element selector, element reference, or scroll options\n */\n scrollTo(target: string | HTMLElement | { top?: number; left?: number }): void {\n this.compiledComponent?.scrollTo?.(target);\n }\n \n /**\n * Sets focus to a specific element within the component\n * @param target - Element selector or element reference\n */\n focus(target?: string | HTMLElement): void {\n this.compiledComponent?.focus?.(target);\n }\n \n /**\n * Invokes a custom method on the component\n * @param methodName - Name of the method to invoke\n * @param args - Arguments to pass to the method\n * @returns The result of the method call, or undefined if method doesn't exist\n */\n invokeMethod(methodName: string, ...args: any[]): any {\n return this.compiledComponent?.invokeMethod?.(methodName, ...args);\n }\n \n /**\n * Checks if a method is available on the component\n * @param methodName - Name of the method to check\n * @returns true if the method exists\n */\n hasMethod(methodName: string): boolean {\n return this.compiledComponent?.hasMethod?.(methodName) || false;\n }\n \n /**\n * Print the component content\n * Uses component's print method if available, otherwise uses window.print()\n */\n print(): void {\n if (this.compiledComponent?.print) {\n this.compiledComponent.print();\n } else if (typeof window !== 'undefined' && window.print) {\n window.print();\n }\n }\n\n /**\n * Force clear component registries\n * Used by Component Studio for fresh loads\n * This is a static method that can be called without a component instance\n */\n public static forceClearRegistries(): void {\n // Clear React runtime's component registry service\n ComponentRegistryService.reset();\n \n // Clear any cached hierarchy registrar\n if (typeof window !== 'undefined' && (window as any).__MJ_COMPONENT_HIERARCHY_REGISTRAR__) {\n (window as any).__MJ_COMPONENT_HIERARCHY_REGISTRAR__ = null;\n }\n \n console.log('🧹 All component registries cleared for fresh load');\n }\n\n}"]}
@@ -3,7 +3,7 @@
3
3
  * @module @memberjunction/ng-react/utilities
4
4
  */
5
5
  import { __decorate } from "tslib";
6
- import { Metadata, RunView, RunQuery, LogError, BaseEntity, } from '@memberjunction/global';
6
+ import { Metadata, RunView, RunQuery, LogError, BaseEntity } from '@memberjunction/core';
7
7
  import { MJGlobal, RegisterClass } from '@memberjunction/global';
8
8
  import { GraphQLDataProvider } from '@memberjunction/graphql-dataprovider';
9
9
  import { SimpleVectorService } from '@memberjunction/ai-vectors-memory';
@@ -35,7 +35,7 @@ let RuntimeUtilities = class RuntimeUtilities {
35
35
  md: this.CreateSimpleMetadata(md),
36
36
  rv: this.CreateSimpleRunView(rv),
37
37
  rq: this.CreateSimpleRunQuery(rq),
38
- ai: this.CreateSimpleAITools(),
38
+ ai: this.CreateSimpleAITools()
39
39
  };
40
40
  return u;
41
41
  }
@@ -55,7 +55,7 @@ let RuntimeUtilities = class RuntimeUtilities {
55
55
  systemPrompt: params.systemPrompt,
56
56
  messages: params.messages,
57
57
  preferredModels: params.preferredModels,
58
- modelPower: params.modelPower,
58
+ modelPower: params.modelPower
59
59
  });
60
60
  console.log(`🤖 ExecutePrompt succeeded!`);
61
61
  if (this.debug) {
@@ -66,7 +66,7 @@ let RuntimeUtilities = class RuntimeUtilities {
66
66
  success: result.success,
67
67
  result: result.result || '',
68
68
  resultObject: result.resultObject,
69
- modelName: result.modelName || '',
69
+ modelName: result.modelName || ''
70
70
  };
71
71
  }
72
72
  catch (error) {
@@ -74,7 +74,7 @@ let RuntimeUtilities = class RuntimeUtilities {
74
74
  return {
75
75
  success: false,
76
76
  result: 'Failed to execute prompt: ' + (error instanceof Error ? error.message : String(error)),
77
- modelName: '',
77
+ modelName: ''
78
78
  };
79
79
  }
80
80
  },
@@ -83,7 +83,7 @@ let RuntimeUtilities = class RuntimeUtilities {
83
83
  // Use the AI client from GraphQLDataProvider to generate embeddings
84
84
  const result = await graphQLProvider.AI.EmbedText({
85
85
  textToEmbed: params.textToEmbed,
86
- modelSize: params.modelSize,
86
+ modelSize: params.modelSize
87
87
  });
88
88
  if (result.error) {
89
89
  throw new Error(result.error || 'Failed to generate embeddings');
@@ -97,7 +97,7 @@ let RuntimeUtilities = class RuntimeUtilities {
97
97
  return {
98
98
  result: result.embeddings,
99
99
  modelName: result.modelName,
100
- vectorDimensions: result.vectorDimensions,
100
+ vectorDimensions: result.vectorDimensions
101
101
  };
102
102
  }
103
103
  catch (error) {
@@ -105,7 +105,7 @@ let RuntimeUtilities = class RuntimeUtilities {
105
105
  throw error; // Re-throw for embeddings as they're critical
106
106
  }
107
107
  },
108
- VectorService: new SimpleVectorService(),
108
+ VectorService: new SimpleVectorService()
109
109
  };
110
110
  }
111
111
  CreateSimpleMetadata(md) {
@@ -113,7 +113,7 @@ let RuntimeUtilities = class RuntimeUtilities {
113
113
  Entities: md.Entities,
114
114
  GetEntityObject: (entityName) => {
115
115
  return md.GetEntityObject(entityName);
116
- },
116
+ }
117
117
  };
118
118
  }
119
119
  CreateSimpleRunQuery(rq) {
@@ -139,7 +139,7 @@ let RuntimeUtilities = class RuntimeUtilities {
139
139
  LogError(error);
140
140
  throw error; // Re-throw to handle it in the caller
141
141
  }
142
- },
142
+ }
143
143
  };
144
144
  }
145
145
  CreateSimpleRunView(rv) {
@@ -170,7 +170,7 @@ let RuntimeUtilities = class RuntimeUtilities {
170
170
  // Runs multiple views and returns the results
171
171
  try {
172
172
  const results = await rv.RunViews(params);
173
- const entityNames = params.map((p) => p.EntityName).join(', ');
173
+ const entityNames = params.map(p => p.EntityName).join(', ');
174
174
  const totalRows = results.reduce((sum, r) => sum + (r.TotalRowCount || 0), 0);
175
175
  console.log(`✅ RunViews succeeded for [${entityNames}]: ${totalRows} total rows returned`);
176
176
  if (this.debug) {
@@ -184,7 +184,7 @@ let RuntimeUtilities = class RuntimeUtilities {
184
184
  LogError(error);
185
185
  throw error; // Re-throw to handle it in the caller
186
186
  }
187
- },
187
+ }
188
188
  };
189
189
  }
190
190
  };
@@ -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,EACR,UAAU,GAEX,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAYjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE;;;;GAIG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAAtB;QACG,UAAK,GAAY,KAAK,CAAC;IAoLjC,CAAC;IAlLC;;;OAGG;IACI,cAAc,CAAC,QAAiB,KAAK;QAC1C,IAAI,CAAC,KAAK,GAAG,KAAK,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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;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/global';\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 private debug: boolean = false;\n\n /**\n * Builds the complete utilities object for React components\n * This is the main method that components will use\n */\n public buildUtilities(debug: boolean = false): ComponentUtilities {\n this.debug = debug;\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 console.log(`🤖 ExecutePrompt succeeded!`);\n if (this.debug) {\n console.log(' > params', params);\n console.log(' > result:', result);\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 const numEmbeddings: number = Array.isArray(params.textToEmbed) ? result.embeddings?.length : 1;\n console.log(`🤖 EmbedText succeeded! ${numEmbeddings} embeddings returned`);\n if (this.debug) {\n console.log(' > params', params);\n console.log(' > result:', result);\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 if (result.Success) {\n console.log(`✅ RunQuery \"${params.QueryName}\" succeeded: ${result.RowCount} rows returned`);\n if (this.debug) {\n console.log(' > params', params);\n console.log(' > result:', result);\n }\n } else {\n console.error(`❌ RunQuery failed: ${result.ErrorMessage}`);\n }\n return result;\n } catch (error) {\n console.error(`❌ RunQuery threw exception:`, 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 if (result.Success) {\n console.log(`✅ RunView succeeded for ${params.EntityName}: ${result.TotalRowCount} rows returned`);\n if (this.debug) {\n console.log(' > params', params);\n console.log(' > result:', result);\n }\n } else {\n console.error(`❌ RunView failed for ${params.EntityName}: ${result.ErrorMessage}`);\n }\n return result;\n } catch (error) {\n console.error(`❌ RunView threw exception:`, 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 const entityNames = params.map((p) => p.EntityName).join(', ');\n const totalRows = results.reduce((sum, r) => sum + (r.TotalRowCount || 0), 0);\n console.log(`✅ RunViews succeeded for [${entityNames}]: ${totalRows} total rows returned`);\n if (this.debug) {\n console.log(' > params', params);\n console.log(' > results:', results);\n }\n return results;\n } catch (error) {\n console.error(`❌ RunViews threw exception:`, 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}\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,QAAQ,EAGR,QAAQ,EACR,UAAU,EAEX,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAYjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE;;;;GAIG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAAtB;QACG,UAAK,GAAY,KAAK,CAAC;IAoLjC,CAAC;IAlLC;;;OAGG;IACI,cAAc,CAAC,QAAiB,KAAK;QAC1C,IAAI,CAAC,KAAK,GAAG,KAAK,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;YACjC,EAAE,EAAE,IAAI,CAAC,mBAAmB,EAAE;SAC/B,CAAC;QACF,OAAO,C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AAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBAC9E,OAAO,CAAC,GAAG,CAAC,6BAA6B,WAAW,MAAM,SAAS,sBAAsB,CAAC,CAAC;oBAC3F,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;wBACf,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;wBACrC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;oBAC1C,CAAC;oBACD,OAAO,OAAO,CAAC;gBACjB,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;oBACpD,QAAQ,CAAC,KAAK,CAAC,CAAC;oBAChB,MAAM,KAAK,CAAC,CAAC,sCAAsC;gBACrD,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAA;AArLY,gBAAgB;IAD5B,aAAa,CAAC,gBAAgB,EAAE,kBAAkB,CAAC;GACvC,gBAAgB,CAqL5B;;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 private debug: boolean = false;\n \n /**\n * Builds the complete utilities object for React components\n * This is the main method that components will use\n */\n public buildUtilities(debug: boolean = false): ComponentUtilities {\n this.debug = debug;\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 console.log(`🤖 ExecutePrompt succeeded!`);\n if (this.debug) {\n console.log(' > params', params);\n console.log(' > result:', result);\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 const numEmbeddings: number = Array.isArray(params.textToEmbed) ? result.embeddings?.length : 1;\n console.log(`🤖 EmbedText succeeded! ${numEmbeddings} embeddings returned`);\n if (this.debug) {\n console.log(' > params', params);\n console.log(' > result:', result);\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 if (result.Success) {\n console.log(`✅ RunQuery \"${params.QueryName}\" succeeded: ${result.RowCount} rows returned`);\n if (this.debug) {\n console.log(' > params', params);\n console.log(' > result:', result);\n }\n } else {\n console.error(`❌ RunQuery failed: ${result.ErrorMessage}`);\n }\n return result;\n } catch (error) {\n console.error(`❌ RunQuery threw exception:`, 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 if (result.Success) {\n console.log(`✅ RunView succeeded for ${params.EntityName}: ${result.TotalRowCount} rows returned`);\n if (this.debug) {\n console.log(' > params', params);\n console.log(' > result:', result);\n }\n } else {\n console.error(`❌ RunView failed for ${params.EntityName}: ${result.ErrorMessage}`);\n }\n return result;\n } catch (error) {\n console.error(`❌ RunView threw exception:`, 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 const entityNames = params.map(p => p.EntityName).join(', ');\n const totalRows = results.reduce((sum, r) => sum + (r.TotalRowCount || 0), 0);\n console.log(`✅ RunViews succeeded for [${entityNames}]: ${totalRows} total rows returned`);\n if (this.debug) {\n console.log(' > params', params);\n console.log(' > results:', results);\n }\n return results;\n } catch (error) {\n console.error(`❌ RunViews threw exception:`, 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.112.0",
3
+ "version": "2.113.0",
4
4
  "description": "Angular components for hosting React components in MemberJunction applications",
5
5
  "scripts": {
6
6
  "build": "ngc -p tsconfig.json",
@@ -40,10 +40,10 @@
40
40
  "styles"
41
41
  ],
42
42
  "dependencies": {
43
- "@memberjunction/global": "2.112.0",
44
- "@memberjunction/react-runtime": "2.112.0",
45
- "@memberjunction/interactive-component-types": "2.112.0",
46
- "@memberjunction/ng-notifications": "2.112.0",
43
+ "@memberjunction/core": "2.113.0",
44
+ "@memberjunction/react-runtime": "2.113.0",
45
+ "@memberjunction/interactive-component-types": "2.113.0",
46
+ "@memberjunction/ng-notifications": "2.113.0",
47
47
  "@angular/common": ">=18.0.0",
48
48
  "@angular/core": ">=18.0.0",
49
49
  "@angular/platform-browser": ">=18.0.0",