@memberjunction/ng-react 2.95.0 → 2.97.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/components/mj-react-component.component.d.ts +7 -1
- package/dist/lib/components/mj-react-component.component.js +33 -10
- package/dist/lib/components/mj-react-component.component.js.map +1 -1
- package/dist/lib/config/react-debug.config.d.ts +42 -0
- package/dist/lib/config/react-debug.config.js +60 -0
- package/dist/lib/config/react-debug.config.js.map +1 -0
- package/dist/lib/services/angular-adapter.service.d.ts +6 -1
- package/dist/lib/services/angular-adapter.service.js +26 -8
- package/dist/lib/services/angular-adapter.service.js.map +1 -1
- package/dist/lib/services/react-bridge.service.d.ts +1 -0
- package/dist/lib/services/react-bridge.service.js +20 -5
- package/dist/lib/services/react-bridge.service.js.map +1 -1
- package/dist/lib/services/script-loader.service.d.ts +4 -1
- package/dist/lib/services/script-loader.service.js +3 -2
- package/dist/lib/services/script-loader.service.js.map +1 -1
- package/dist/lib/utilities/runtime-utilities.d.ts +2 -1
- package/dist/lib/utilities/runtime-utilities.js +46 -1
- package/dist/lib/utilities/runtime-utilities.js.map +1 -1
- package/dist/public-api.d.ts +1 -1
- package/dist/public-api.js +2 -2
- package/dist/public-api.js.map +1 -1
- package/package.json +4 -4
- package/dist/lib/default-styles.d.ts +0 -10
- package/dist/lib/default-styles.js +0 -106
- package/dist/lib/default-styles.js.map +0 -1
|
@@ -41,6 +41,12 @@ export declare class MJReactComponent implements AfterViewInit, OnDestroy {
|
|
|
41
41
|
private adapter;
|
|
42
42
|
private cdr;
|
|
43
43
|
component: ComponentSpec;
|
|
44
|
+
/**
|
|
45
|
+
* Controls verbose logging for component lifecycle and operations.
|
|
46
|
+
* Note: This does NOT control which React build (dev/prod) is loaded.
|
|
47
|
+
* To control React builds, use ReactDebugConfig.setDebugMode() at app startup.
|
|
48
|
+
*/
|
|
49
|
+
enableLogging: boolean;
|
|
44
50
|
private _utilities;
|
|
45
51
|
set utilities(value: any);
|
|
46
52
|
get utilities(): any;
|
|
@@ -192,5 +198,5 @@ export declare class MJReactComponent implements AfterViewInit, OnDestroy {
|
|
|
192
198
|
*/
|
|
193
199
|
static forceClearRegistries(): void;
|
|
194
200
|
static ɵfac: i0.ɵɵFactoryDeclaration<MJReactComponent, never>;
|
|
195
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<MJReactComponent, "mj-react-component", never, { "component": { "alias": "component"; "required": false; }; "utilities": { "alias": "utilities"; "required": false; }; "styles": { "alias": "styles"; "required": false; }; "savedUserSettings": { "alias": "savedUserSettings"; "required": false; }; }, { "stateChange": "stateChange"; "componentEvent": "componentEvent"; "refreshData": "refreshData"; "openEntityRecord": "openEntityRecord"; "userSettingsChanged": "userSettingsChanged"; }, never, never, false, never>;
|
|
201
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<MJReactComponent, "mj-react-component", never, { "component": { "alias": "component"; "required": false; }; "enableLogging": { "alias": "enableLogging"; "required": false; }; "utilities": { "alias": "utilities"; "required": false; }; "styles": { "alias": "styles"; "required": false; }; "savedUserSettings": { "alias": "savedUserSettings"; "required": false; }; }, { "stateChange": "stateChange"; "componentEvent": "componentEvent"; "refreshData": "refreshData"; "openEntityRecord": "openEntityRecord"; "userSettingsChanged": "userSettingsChanged"; }, never, never, false, never>;
|
|
196
202
|
}
|
|
@@ -37,8 +37,10 @@ export class MJReactComponent {
|
|
|
37
37
|
// Lazy initialization - only create default utilities when needed
|
|
38
38
|
if (!this._utilities) {
|
|
39
39
|
const runtimeUtils = createRuntimeUtilities();
|
|
40
|
-
this._utilities = runtimeUtils.buildUtilities();
|
|
41
|
-
|
|
40
|
+
this._utilities = runtimeUtils.buildUtilities(this.enableLogging);
|
|
41
|
+
if (this.enableLogging) {
|
|
42
|
+
console.log('MJReactComponent: Auto-initialized utilities using createRuntimeUtilities()');
|
|
43
|
+
}
|
|
42
44
|
}
|
|
43
45
|
return this._utilities;
|
|
44
46
|
}
|
|
@@ -49,7 +51,9 @@ export class MJReactComponent {
|
|
|
49
51
|
// Lazy initialization - only create default styles when needed
|
|
50
52
|
if (!this._styles) {
|
|
51
53
|
this._styles = SetupStyles();
|
|
52
|
-
|
|
54
|
+
if (this.enableLogging) {
|
|
55
|
+
console.log('MJReactComponent: Auto-initialized styles using SetupStyles()');
|
|
56
|
+
}
|
|
53
57
|
}
|
|
54
58
|
return this._styles;
|
|
55
59
|
}
|
|
@@ -67,6 +71,12 @@ export class MJReactComponent {
|
|
|
67
71
|
this.reactBridge = reactBridge;
|
|
68
72
|
this.adapter = adapter;
|
|
69
73
|
this.cdr = cdr;
|
|
74
|
+
/**
|
|
75
|
+
* Controls verbose logging for component lifecycle and operations.
|
|
76
|
+
* Note: This does NOT control which React build (dev/prod) is loaded.
|
|
77
|
+
* To control React builds, use ReactDebugConfig.setDebugMode() at app startup.
|
|
78
|
+
*/
|
|
79
|
+
this.enableLogging = false;
|
|
70
80
|
this._savedUserSettings = {};
|
|
71
81
|
this.stateChange = new EventEmitter();
|
|
72
82
|
this.componentEvent = new EventEmitter();
|
|
@@ -192,11 +202,15 @@ export class MJReactComponent {
|
|
|
192
202
|
async resolveComponentsWithVersion(spec, version, namespace = 'Global') {
|
|
193
203
|
const resolver = this.adapter.getResolver();
|
|
194
204
|
// Debug: Log what dependencies we're trying to resolve
|
|
195
|
-
|
|
205
|
+
if (this.enableLogging) {
|
|
206
|
+
console.log(`Resolving components for ${spec.name}. Dependencies:`, spec.dependencies);
|
|
207
|
+
}
|
|
196
208
|
// Use the runtime's resolver which now handles registry-based components
|
|
197
209
|
const resolved = await resolver.resolveComponents(spec, namespace, Metadata.Provider.CurrentUser // Pass current user context for database operations
|
|
198
210
|
);
|
|
199
|
-
|
|
211
|
+
if (this.enableLogging) {
|
|
212
|
+
console.log(`Resolved ${Object.keys(resolved).length} components for version ${version}:`, Object.keys(resolved));
|
|
213
|
+
}
|
|
200
214
|
return resolved;
|
|
201
215
|
}
|
|
202
216
|
/**
|
|
@@ -206,12 +220,16 @@ export class MJReactComponent {
|
|
|
206
220
|
// Use semantic version from spec or generate hash-based version for uniqueness
|
|
207
221
|
const version = this.component.version || this.generateComponentHash(this.component);
|
|
208
222
|
this.componentVersion = version; // Store for use in resolver
|
|
209
|
-
|
|
223
|
+
if (this.enableLogging) {
|
|
224
|
+
console.log(`Registering ${this.component.name}@${version}`);
|
|
225
|
+
}
|
|
210
226
|
// Check if already registered to avoid duplication
|
|
211
227
|
const registry = this.adapter.getRegistry();
|
|
212
228
|
const existingComponent = registry.get(this.component.name, this.component.namespace || 'Global', version);
|
|
213
229
|
if (existingComponent) {
|
|
214
|
-
|
|
230
|
+
if (this.enableLogging) {
|
|
231
|
+
console.log(`Component ${this.component.name}@${version} already registered`);
|
|
232
|
+
}
|
|
215
233
|
return;
|
|
216
234
|
}
|
|
217
235
|
// Initialize metadata engine
|
|
@@ -224,13 +242,16 @@ export class MJReactComponent {
|
|
|
224
242
|
namespace: this.component.namespace || 'Global',
|
|
225
243
|
version: version,
|
|
226
244
|
allowOverride: false, // Each version is unique
|
|
227
|
-
allLibraries: ComponentMetadataEngine.Instance.ComponentLibraries
|
|
245
|
+
allLibraries: ComponentMetadataEngine.Instance.ComponentLibraries,
|
|
246
|
+
debug: true
|
|
228
247
|
});
|
|
229
248
|
if (!result.success) {
|
|
230
249
|
const errors = result.errors.map(e => e.error).join(', ');
|
|
231
250
|
throw new Error(`Component registration failed: ${errors}`);
|
|
232
251
|
}
|
|
233
|
-
|
|
252
|
+
if (this.enableLogging) {
|
|
253
|
+
console.log(`Registered ${result.registeredComponents.length} components`);
|
|
254
|
+
}
|
|
234
255
|
}
|
|
235
256
|
/**
|
|
236
257
|
* Render the React component
|
|
@@ -571,7 +592,7 @@ export class MJReactComponent {
|
|
|
571
592
|
} if (rf & 2) {
|
|
572
593
|
let _t;
|
|
573
594
|
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.container = _t.first);
|
|
574
|
-
} }, inputs: { component: "component", utilities: "utilities", styles: "styles", savedUserSettings: "savedUserSettings" }, outputs: { stateChange: "stateChange", componentEvent: "componentEvent", refreshData: "refreshData", openEntityRecord: "openEntityRecord", userSettingsChanged: "userSettingsChanged" }, decls: 4, vars: 3, consts: [["container", ""], [1, "react-component-wrapper"], [1, "react-component-container"], [1, "loading-overlay"], [1, "loading-spinner"], [1, "fa-solid", "fa-spinner", "fa-spin"], [1, "loading-text"]], template: function MJReactComponent_Template(rf, ctx) { if (rf & 1) {
|
|
595
|
+
} }, inputs: { component: "component", enableLogging: "enableLogging", utilities: "utilities", styles: "styles", savedUserSettings: "savedUserSettings" }, outputs: { stateChange: "stateChange", componentEvent: "componentEvent", refreshData: "refreshData", openEntityRecord: "openEntityRecord", userSettingsChanged: "userSettingsChanged" }, decls: 4, vars: 3, consts: [["container", ""], [1, "react-component-wrapper"], [1, "react-component-container"], [1, "loading-overlay"], [1, "loading-spinner"], [1, "fa-solid", "fa-spinner", "fa-spin"], [1, "loading-text"]], template: function MJReactComponent_Template(rf, ctx) { if (rf & 1) {
|
|
575
596
|
i0.ɵɵelementStart(0, "div", 1);
|
|
576
597
|
i0.ɵɵelement(1, "div", 2, 0);
|
|
577
598
|
i0.ɵɵtemplate(3, MJReactComponent_Conditional_3_Template, 5, 0, "div", 3);
|
|
@@ -600,6 +621,8 @@ export class MJReactComponent {
|
|
|
600
621
|
`, changeDetection: ChangeDetectionStrategy.OnPush, 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 "] }]
|
|
601
622
|
}], () => [{ type: i1.ReactBridgeService }, { type: i2.AngularAdapterService }, { type: i0.ChangeDetectorRef }], { component: [{
|
|
602
623
|
type: Input
|
|
624
|
+
}], enableLogging: [{
|
|
625
|
+
type: Input
|
|
603
626
|
}], utilities: [{
|
|
604
627
|
type: Input
|
|
605
628
|
}], styles: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mj-react-component.component.js","sourceRoot":"","sources":["../../../src/lib/components/mj-react-component.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,SAAS,EACT,KAAK,EACL,MAAM,EACN,YAAY,EACZ,SAAS,EACT,UAAU,EAGV,uBAAuB,EACvB,iBAAiB,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,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,EACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAgB,QAAQ,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;;;;;;IAuC9D,AADF,8BAA6B,aACE;IAC3B,uBAA2C;IAC7C,iBAAM;IACN,8BAA0B;IAAA,oCAAoB;IAChD,AADgD,iBAAM,EAChD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gBAAgB;cA7D5B,SAAS;2BACE,oBAAoB,YACpB;;;;;;;;;;;;GAYT,mBA6CgB,uBAAuB,CAAC,MAAM;uHAGtC,SAAS;kBAAjB,KAAK;YAKF,SAAS;kBADZ,KAAK;YAiBF,MAAM;kBADT,KAAK;YAeF,iBAAiB;kBADpB,KAAK;YAYI,WAAW;kBAApB,MAAM;YACG,cAAc;kBAAvB,MAAM;YACG,WAAW;kBAApB,MAAM;YACG,gBAAgB;kBAAzB,MAAM;YACG,mBAAmB;kBAA5B,MAAM;YAEqD,SAAS;kBAApE,SAAS;mBAAC,WAAW,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE;;kFArD/C,gBAAgB","sourcesContent":["/**\n * @fileoverview Angular component that hosts React components with proper memory management.\n * Provides a bridge between Angular and React ecosystems in MemberJunction applications.\n * @module @memberjunction/ng-react\n */\n\nimport {\n Component,\n Input,\n Output,\n EventEmitter,\n ViewChild,\n ElementRef,\n AfterViewInit,\n OnDestroy,\n ChangeDetectionStrategy,\n ChangeDetectorRef\n} from '@angular/core';\nimport { Subject } 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 { ComponentMetadataEngine } from '@memberjunction/core-entities';\n\n/**\n * Event emitted by React components\n */\nexport interface ReactComponentEvent {\n type: string;\n payload: any;\n}\n\n/**\n * State change event emitted when component state updates\n */\nexport interface StateChangeEvent {\n path: string;\n value: any;\n}\n\n/**\n * User settings changed event emitted when component saves user preferences\n */\nexport interface UserSettingsChangedEvent {\n settings: Record<string, any>;\n componentName?: string;\n timestamp: Date;\n}\n\n/**\n * Angular component that hosts React components with proper memory management.\n * This component provides a bridge between Angular and React, allowing React components\n * to be used seamlessly within Angular applications.\n */\n@Component({\n selector: 'mj-react-component',\n template: `\n <div class=\"react-component-wrapper\">\n <div #container class=\"react-component-container\" [class.loading]=\"!isInitialized\"></div>\n @if (!isInitialized && !hasError) {\n <div class=\"loading-overlay\">\n <div class=\"loading-spinner\">\n <i class=\"fa-solid fa-spinner fa-spin\"></i>\n </div>\n <div class=\"loading-text\">Loading component...</div>\n </div>\n }\n </div>\n `,\n styles: [`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n }\n .react-component-wrapper {\n position: relative;\n width: 100%;\n height: 100%;\n }\n .react-component-container {\n width: 100%;\n height: 100%;\n transition: opacity 0.3s ease;\n }\n .react-component-container.loading {\n opacity: 0;\n }\n .loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n background-color: rgba(255, 255, 255, 0.9);\n z-index: 1;\n }\n .loading-spinner {\n font-size: 48px;\n color: #5B4FE9;\n margin-bottom: 16px;\n }\n .loading-text {\n font-family: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", Roboto, sans-serif;\n font-size: 14px;\n color: #64748B;\n margin-top: 8px;\n }\n `],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class MJReactComponent implements AfterViewInit, OnDestroy {\n @Input() component!: ComponentSpec;\n \n // Auto-initialize utilities if not provided\n private _utilities: any;\n @Input()\n set utilities(value: any) {\n this._utilities = value;\n }\n get utilities(): any {\n // Lazy initialization - only create default utilities when needed\n if (!this._utilities) {\n const runtimeUtils = createRuntimeUtilities();\n this._utilities = runtimeUtils.buildUtilities();\n console.log('MJReactComponent: Auto-initialized utilities using createRuntimeUtilities()');\n }\n return this._utilities;\n }\n \n // Auto-initialize styles if not provided\n private _styles?: Partial<ComponentStyles>;\n @Input()\n set styles(value: Partial<ComponentStyles> | undefined) {\n this._styles = value;\n }\n get styles(): Partial<ComponentStyles> {\n // Lazy initialization - only create default styles when needed\n if (!this._styles) {\n this._styles = SetupStyles();\n console.log('MJReactComponent: Auto-initialized styles using SetupStyles()');\n }\n return this._styles;\n }\n \n private _savedUserSettings: any = {};\n @Input()\n set savedUserSettings(value: any) {\n this._savedUserSettings = value || {};\n // Re-render if component is initialized\n if (this.isInitialized) {\n this.renderComponent();\n }\n }\n get savedUserSettings(): any {\n return this._savedUserSettings;\n }\n \n @Output() stateChange = new EventEmitter<StateChangeEvent>();\n @Output() componentEvent = new EventEmitter<ReactComponentEvent>();\n @Output() refreshData = new EventEmitter<void>();\n @Output() openEntityRecord = new EventEmitter<{ entityName: string; key: CompositeKey }>();\n @Output() userSettingsChanged = new EventEmitter<UserSettingsChangedEvent>();\n \n @ViewChild('container', { read: ElementRef, static: true }) container!: ElementRef<HTMLDivElement>;\n \n private reactRootId: string | null = null;\n private compiledComponent: ComponentObject | null = null;\n private destroyed$ = new Subject<void>();\n private currentCallbacks: ComponentCallbacks | null = null;\n isInitialized = false;\n private isRendering = false;\n private pendingRender = false;\n private isDestroying = false;\n private componentId: string;\n private componentVersion: string = ''; // Store the version for resolver\n hasError = false;\n\n constructor(\n private reactBridge: ReactBridgeService,\n private adapter: AngularAdapterService,\n private cdr: ChangeDetectorRef\n ) {\n // Generate unique component ID for resource tracking\n this.componentId = `mj-react-component-${Date.now()}-${Math.random()}`;\n }\n\n async ngAfterViewInit() {\n // Trigger change detection to show loading state\n this.cdr.detectChanges();\n await this.initializeComponent();\n }\n\n ngOnDestroy() {\n // Set destroying flag immediately\n this.isDestroying = true;\n \n // Cancel any pending renders\n this.pendingRender = false;\n \n this.destroyed$.next();\n this.destroyed$.complete();\n this.cleanup();\n }\n\n\n /**\n * Initialize the React component\n */\n private async initializeComponent() {\n try {\n // Ensure React is loaded\n await this.reactBridge.getReactContext();\n \n // Wait for React to be fully ready (handles first-load delay)\n await this.reactBridge.waitForReactReady();\n \n // Register component hierarchy (this compiles and registers all components)\n await this.registerComponentHierarchy();\n \n // Get the already-registered component from the registry\n const registry = this.adapter.getRegistry();\n const componentWrapper = registry.get(\n this.component.name, \n this.component.namespace || 'Global', \n this.componentVersion\n );\n \n if (!componentWrapper) {\n throw new Error(`Component ${this.component.name} was not found in registry after registration`);\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 \n // Create managed React root\n const reactContext = this.reactBridge.getCurrentContext();\n if (!reactContext) {\n throw new Error('React context not available');\n }\n \n this.reactRootId = reactRootManager.createRoot(\n this.container.nativeElement,\n (container: HTMLElement) => reactContext.ReactDOM.createRoot(container),\n this.componentId\n );\n \n // Initial render\n this.renderComponent();\n this.isInitialized = true;\n \n // Trigger change detection since we're using OnPush\n this.cdr.detectChanges();\n \n } catch (error) {\n this.hasError = true;\n LogError(`Failed to initialize React component: ${error}`);\n this.componentEvent.emit({\n type: 'error',\n payload: {\n error: error instanceof Error ? error.message : String(error),\n source: 'initialization'\n }\n });\n // Trigger change detection to show error state\n this.cdr.detectChanges();\n }\n }\n\n /**\n * Generate a hash from component code for versioning\n * Uses a simple hash function that's fast and sufficient for version differentiation\n */\n private generateComponentHash(spec: ComponentSpec): string {\n // Collect all code from the component hierarchy\n const codeStrings: string[] = [];\n \n const collectCode = (s: ComponentSpec) => {\n if (s.code) {\n codeStrings.push(s.code);\n }\n if (s.dependencies) {\n for (const dep of s.dependencies) {\n collectCode(dep);\n }\n }\n };\n \n collectCode(spec);\n \n // Generate hash from concatenated code\n const fullCode = codeStrings.join('|');\n let hash = 0;\n for (let i = 0; i < fullCode.length; i++) {\n const char = fullCode.charCodeAt(i);\n hash = ((hash << 5) - hash) + char;\n hash = hash & hash; // Convert to 32bit integer\n }\n \n // Convert to hex string and take first 8 characters for readability\n const hexHash = Math.abs(hash).toString(16).padStart(8, '0').substring(0, 8);\n return `v${hexHash}`;\n }\n\n /**\n * Resolve components using the runtime's resolver\n */\n private async resolveComponentsWithVersion(spec: ComponentSpec, version: string, namespace: string = 'Global'): Promise<ResolvedComponents> {\n const resolver = this.adapter.getResolver();\n \n // Debug: Log what dependencies we're trying to resolve\n console.log(`Resolving components for ${spec.name}. Dependencies:`, spec.dependencies);\n \n // Use the runtime's resolver which now handles registry-based components\n const resolved = await resolver.resolveComponents(\n spec, \n namespace,\n Metadata.Provider.CurrentUser // Pass current user context for database operations\n );\n \n console.log(`Resolved ${Object.keys(resolved).length} components for version ${version}:`, Object.keys(resolved));\n return resolved;\n }\n\n\n /**\n * Register all components in the hierarchy\n */\n private async registerComponentHierarchy() {\n // Use semantic version from spec or generate hash-based version for uniqueness\n const version = this.component.version || this.generateComponentHash(this.component);\n this.componentVersion = version; // Store for use in resolver\n \n console.log(`Registering ${this.component.name}@${version}`);\n \n // Check if already registered to avoid duplication\n const registry = this.adapter.getRegistry();\n const existingComponent = registry.get(this.component.name, this.component.namespace || 'Global', version);\n if (existingComponent) {\n console.log(`Component ${this.component.name}@${version} already registered`);\n return;\n }\n \n // Initialize metadata engine\n await ComponentMetadataEngine.Instance.Config(false, Metadata.Provider.CurrentUser);\n \n // Use the runtime's hierarchy registrar\n const registrar = new ComponentHierarchyRegistrar(\n this.adapter.getCompiler(),\n this.adapter.getRegistry(),\n this.adapter.getRuntimeContext()\n );\n \n // Register with proper configuration\n const result = await registrar.registerHierarchy(\n this.component,\n {\n styles: this.styles as ComponentStyles,\n namespace: this.component.namespace || 'Global',\n version: version,\n allowOverride: false, // Each version is unique\n allLibraries: ComponentMetadataEngine.Instance.ComponentLibraries\n }\n );\n \n if (!result.success) {\n const errors = result.errors.map(e => e.error).join(', ');\n throw new Error(`Component registration failed: ${errors}`);\n }\n \n console.log(`Registered ${result.registeredComponents.length} components`);\n }\n\n /**\n * Render the React component\n */\n private async renderComponent() {\n // Don't render if component is being destroyed\n if (this.isDestroying) {\n return;\n }\n \n if (!this.compiledComponent || !this.reactRootId) {\n return;\n }\n\n // Prevent concurrent renders\n if (this.isRendering) {\n this.pendingRender = true;\n return;\n }\n\n const context = this.reactBridge.getCurrentContext();\n if (!context) {\n return;\n }\n\n this.isRendering = true;\n const { React } = context;\n \n // Resolve components with the correct version using runtime's resolver\n const components = await this.resolveComponentsWithVersion(this.component, this.componentVersion);\n \n // Create callbacks once per component instance\n if (!this.currentCallbacks) {\n this.currentCallbacks = this.createCallbacks();\n }\n \n // Build props with savedUserSettings pattern\n const props = {\n utilities: this.utilities, // Now uses getter which auto-initializes if needed\n callbacks: this.currentCallbacks,\n components,\n styles: this.styles as any,\n savedUserSettings: this._savedUserSettings,\n onSaveUserSettings: this.handleSaveUserSettings.bind(this)\n };\n\n // Validate component before creating element\n if (!this.compiledComponent.component) {\n LogError(`Component is undefined for ${this.component.name} during render`);\n return;\n }\n \n // 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 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}"]}
|
|
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;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,EAC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AE,MAAM,EAAE,IAAI,EAAE;;kFA/D/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 { 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 \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 destroyed$ = new Subject<void>();\n private currentCallbacks: ComponentCallbacks | null = null;\n isInitialized = false;\n private isRendering = false;\n private pendingRender = false;\n private isDestroying = false;\n private componentId: string;\n private componentVersion: string = ''; // Store the version for resolver\n hasError = false;\n\n constructor(\n private reactBridge: ReactBridgeService,\n private adapter: AngularAdapterService,\n private cdr: ChangeDetectorRef\n ) {\n // Generate unique component ID for resource tracking\n this.componentId = `mj-react-component-${Date.now()}-${Math.random()}`;\n }\n\n async ngAfterViewInit() {\n // Trigger change detection to show loading state\n this.cdr.detectChanges();\n await this.initializeComponent();\n }\n\n ngOnDestroy() {\n // Set destroying flag immediately\n this.isDestroying = true;\n \n // Cancel any pending renders\n this.pendingRender = false;\n \n this.destroyed$.next();\n this.destroyed$.complete();\n this.cleanup();\n }\n\n\n /**\n * Initialize the React component\n */\n private async initializeComponent() {\n try {\n // Ensure React is loaded\n await this.reactBridge.getReactContext();\n \n // Wait for React to be fully ready (handles first-load delay)\n await this.reactBridge.waitForReactReady();\n \n // Register component hierarchy (this compiles and registers all components)\n await this.registerComponentHierarchy();\n \n // Get the already-registered component from the registry\n const registry = this.adapter.getRegistry();\n const componentWrapper = registry.get(\n this.component.name, \n this.component.namespace || 'Global', \n this.componentVersion\n );\n \n if (!componentWrapper) {\n throw new Error(`Component ${this.component.name} was not found in registry after registration`);\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 \n // Create managed React root\n const reactContext = this.reactBridge.getCurrentContext();\n if (!reactContext) {\n throw new Error('React context not available');\n }\n \n this.reactRootId = reactRootManager.createRoot(\n this.container.nativeElement,\n (container: HTMLElement) => reactContext.ReactDOM.createRoot(container),\n this.componentId\n );\n \n // Initial render\n this.renderComponent();\n this.isInitialized = true;\n \n // Trigger change detection since we're using OnPush\n this.cdr.detectChanges();\n \n } catch (error) {\n this.hasError = true;\n LogError(`Failed to initialize React component: ${error}`);\n this.componentEvent.emit({\n type: 'error',\n payload: {\n error: error instanceof Error ? error.message : String(error),\n source: 'initialization'\n }\n });\n // Trigger change detection to show error state\n this.cdr.detectChanges();\n }\n }\n\n /**\n * Generate a hash from component code for versioning\n * Uses a simple hash function that's fast and sufficient for version differentiation\n */\n private generateComponentHash(spec: ComponentSpec): string {\n // Collect all code from the component hierarchy\n const codeStrings: string[] = [];\n \n const collectCode = (s: ComponentSpec) => {\n if (s.code) {\n codeStrings.push(s.code);\n }\n if (s.dependencies) {\n for (const dep of s.dependencies) {\n collectCode(dep);\n }\n }\n };\n \n collectCode(spec);\n \n // Generate hash from concatenated code\n const fullCode = codeStrings.join('|');\n let hash = 0;\n for (let i = 0; i < fullCode.length; i++) {\n const char = fullCode.charCodeAt(i);\n hash = ((hash << 5) - hash) + char;\n hash = hash & hash; // Convert to 32bit integer\n }\n \n // Convert to hex string and take first 8 characters for readability\n const hexHash = Math.abs(hash).toString(16).padStart(8, '0').substring(0, 8);\n return `v${hexHash}`;\n }\n\n /**\n * Resolve components using the runtime's resolver\n */\n private async resolveComponentsWithVersion(spec: ComponentSpec, version: string, namespace: string = 'Global'): Promise<ResolvedComponents> {\n const resolver = this.adapter.getResolver();\n \n // Debug: Log what dependencies we're trying to resolve\n 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 * Register all components in the hierarchy\n */\n private async registerComponentHierarchy() {\n // Use semantic version from spec or generate hash-based version for uniqueness\n const version = this.component.version || this.generateComponentHash(this.component);\n this.componentVersion = version; // Store for use in resolver\n \n if (this.enableLogging) {\n console.log(`Registering ${this.component.name}@${version}`);\n }\n \n // Check if already registered to avoid duplication\n const registry = this.adapter.getRegistry();\n const existingComponent = registry.get(this.component.name, this.component.namespace || 'Global', version);\n if (existingComponent) {\n if (this.enableLogging) {\n console.log(`Component ${this.component.name}@${version} already registered`);\n }\n return;\n }\n \n // Initialize metadata engine\n await ComponentMetadataEngine.Instance.Config(false, Metadata.Provider.CurrentUser);\n \n // Use the runtime's hierarchy registrar\n const registrar = new ComponentHierarchyRegistrar(\n this.adapter.getCompiler(),\n this.adapter.getRegistry(),\n this.adapter.getRuntimeContext()\n );\n \n // Register with proper configuration\n const result = await registrar.registerHierarchy(\n this.component,\n {\n styles: this.styles as ComponentStyles,\n namespace: this.component.namespace || 'Global',\n version: version,\n allowOverride: false, // Each version is unique\n allLibraries: ComponentMetadataEngine.Instance.ComponentLibraries,\n debug: true\n }\n );\n \n if (!result.success) {\n const errors = result.errors.map(e => e.error).join(', ');\n throw new Error(`Component registration failed: ${errors}`);\n }\n \n if (this.enableLogging) {\n console.log(`Registered ${result.registeredComponents.length} components`);\n }\n }\n\n /**\n * Render the React component\n */\n private async renderComponent() {\n // Don't render if component is being destroyed\n if (this.isDestroying) {\n return;\n }\n \n if (!this.compiledComponent || !this.reactRootId) {\n return;\n }\n\n // Prevent concurrent renders\n if (this.isRendering) {\n this.pendingRender = true;\n return;\n }\n\n const context = this.reactBridge.getCurrentContext();\n if (!context) {\n return;\n }\n\n this.isRendering = true;\n const { React } = context;\n \n // Resolve components with the correct version using runtime's resolver\n const components = await this.resolveComponentsWithVersion(this.component, this.componentVersion);\n \n // Create callbacks once per component instance\n if (!this.currentCallbacks) {\n this.currentCallbacks = this.createCallbacks();\n }\n \n // Build props with savedUserSettings pattern\n const props = {\n utilities: this.utilities, // Now uses getter which auto-initializes if needed\n callbacks: this.currentCallbacks,\n components,\n styles: this.styles as any,\n savedUserSettings: this._savedUserSettings,\n onSaveUserSettings: this.handleSaveUserSettings.bind(this)\n };\n\n // Validate component before creating element\n if (!this.compiledComponent.component) {\n LogError(`Component is undefined for ${this.component.name} during render`);\n return;\n }\n \n // 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 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}"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Project-level React debug configuration
|
|
3
|
+
* Controls whether React development or production builds are loaded
|
|
4
|
+
* @module @memberjunction/ng-react/config
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Global configuration for React library loading.
|
|
8
|
+
* Set this to true in development environments to get detailed React error messages.
|
|
9
|
+
* Set to false in production for smaller bundle sizes and better performance.
|
|
10
|
+
*
|
|
11
|
+
* This must be configured before any React components are loaded.
|
|
12
|
+
* Typically set in your app.module.ts or main.ts file.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // In your app.module.ts or environment configuration:
|
|
16
|
+
* import { REACT_DEBUG_MODE } from '@memberjunction/ng-react';
|
|
17
|
+
*
|
|
18
|
+
* // For development:
|
|
19
|
+
* (window as any).__MJ_REACT_DEBUG_MODE__ = true;
|
|
20
|
+
*
|
|
21
|
+
* // Or use Angular environment:
|
|
22
|
+
* (window as any).__MJ_REACT_DEBUG_MODE__ = !environment.production;
|
|
23
|
+
*/
|
|
24
|
+
export declare class ReactDebugConfig {
|
|
25
|
+
/**
|
|
26
|
+
* Static property that controls React debug mode globally.
|
|
27
|
+
* Can be overridden at application startup before React loads.
|
|
28
|
+
* Defaults to true for better development experience.
|
|
29
|
+
* Should be explicitly set to false in production.
|
|
30
|
+
*/
|
|
31
|
+
static DEBUG_MODE: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Get the current debug mode setting.
|
|
34
|
+
* Checks window global first (for runtime configuration),
|
|
35
|
+
* then falls back to static property.
|
|
36
|
+
*/
|
|
37
|
+
static getDebugMode(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Set the debug mode (must be called before React loads)
|
|
40
|
+
*/
|
|
41
|
+
static setDebugMode(debug: boolean): void;
|
|
42
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Project-level React debug configuration
|
|
3
|
+
* Controls whether React development or production builds are loaded
|
|
4
|
+
* @module @memberjunction/ng-react/config
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Global configuration for React library loading.
|
|
8
|
+
* Set this to true in development environments to get detailed React error messages.
|
|
9
|
+
* Set to false in production for smaller bundle sizes and better performance.
|
|
10
|
+
*
|
|
11
|
+
* This must be configured before any React components are loaded.
|
|
12
|
+
* Typically set in your app.module.ts or main.ts file.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // In your app.module.ts or environment configuration:
|
|
16
|
+
* import { REACT_DEBUG_MODE } from '@memberjunction/ng-react';
|
|
17
|
+
*
|
|
18
|
+
* // For development:
|
|
19
|
+
* (window as any).__MJ_REACT_DEBUG_MODE__ = true;
|
|
20
|
+
*
|
|
21
|
+
* // Or use Angular environment:
|
|
22
|
+
* (window as any).__MJ_REACT_DEBUG_MODE__ = !environment.production;
|
|
23
|
+
*/
|
|
24
|
+
export class ReactDebugConfig {
|
|
25
|
+
/**
|
|
26
|
+
* Static property that controls React debug mode globally.
|
|
27
|
+
* Can be overridden at application startup before React loads.
|
|
28
|
+
* Defaults to true for better development experience.
|
|
29
|
+
* Should be explicitly set to false in production.
|
|
30
|
+
*/
|
|
31
|
+
static { this.DEBUG_MODE = true; }
|
|
32
|
+
/**
|
|
33
|
+
* Get the current debug mode setting.
|
|
34
|
+
* Checks window global first (for runtime configuration),
|
|
35
|
+
* then falls back to static property.
|
|
36
|
+
*/
|
|
37
|
+
static getDebugMode() {
|
|
38
|
+
// Check if a global override has been set
|
|
39
|
+
if (typeof window !== 'undefined' && window.__MJ_REACT_DEBUG_MODE__ !== undefined) {
|
|
40
|
+
return window.__MJ_REACT_DEBUG_MODE__;
|
|
41
|
+
}
|
|
42
|
+
// Check if we're in development mode (common Angular pattern)
|
|
43
|
+
// ngDevMode is truthy in dev mode, false in prod mode
|
|
44
|
+
if (typeof window !== 'undefined' && window.ngDevMode) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
// Fall back to static property
|
|
48
|
+
return ReactDebugConfig.DEBUG_MODE;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Set the debug mode (must be called before React loads)
|
|
52
|
+
*/
|
|
53
|
+
static setDebugMode(debug) {
|
|
54
|
+
ReactDebugConfig.DEBUG_MODE = debug;
|
|
55
|
+
if (typeof window !== 'undefined') {
|
|
56
|
+
window.__MJ_REACT_DEBUG_MODE__ = debug;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=react-debug.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-debug.config.js","sourceRoot":"","sources":["../../../src/lib/config/react-debug.config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,gBAAgB;IAC3B;;;;;OAKG;aACI,eAAU,GAAY,IAAI,CAAC;IAElC;;;;OAIG;IACH,MAAM,CAAC,YAAY;QACjB,0CAA0C;QAC1C,IAAI,OAAO,MAAM,KAAK,WAAW,IAAK,MAAc,CAAC,uBAAuB,KAAK,SAAS,EAAE,CAAC;YAC3F,OAAQ,MAAc,CAAC,uBAAuB,CAAC;QACjD,CAAC;QAED,8DAA8D;QAC9D,sDAAsD;QACtD,IAAI,OAAO,MAAM,KAAK,WAAW,IAAK,MAAc,CAAC,SAAS,EAAE,CAAC;YAC/D,OAAO,IAAI,CAAC;QACd,CAAC;QAED,+BAA+B;QAC/B,OAAO,gBAAgB,CAAC,UAAU,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,KAAc;QAChC,gBAAgB,CAAC,UAAU,GAAG,KAAK,CAAC;QACpC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;YACjC,MAAc,CAAC,uBAAuB,GAAG,KAAK,CAAC;QAClD,CAAC;IACH,CAAC","sourcesContent":["/**\n * @fileoverview Project-level React debug configuration\n * Controls whether React development or production builds are loaded\n * @module @memberjunction/ng-react/config\n */\n\n/**\n * Global configuration for React library loading.\n * Set this to true in development environments to get detailed React error messages.\n * Set to false in production for smaller bundle sizes and better performance.\n * \n * This must be configured before any React components are loaded.\n * Typically set in your app.module.ts or main.ts file.\n * \n * @example\n * // In your app.module.ts or environment configuration:\n * import { REACT_DEBUG_MODE } from '@memberjunction/ng-react';\n * \n * // For development:\n * (window as any).__MJ_REACT_DEBUG_MODE__ = true;\n * \n * // Or use Angular environment:\n * (window as any).__MJ_REACT_DEBUG_MODE__ = !environment.production;\n */\nexport class ReactDebugConfig {\n /**\n * Static property that controls React debug mode globally.\n * Can be overridden at application startup before React loads.\n * Defaults to true for better development experience.\n * Should be explicitly set to false in production.\n */\n static DEBUG_MODE: boolean = true;\n\n /**\n * Get the current debug mode setting.\n * Checks window global first (for runtime configuration),\n * then falls back to static property.\n */\n static getDebugMode(): boolean {\n // Check if a global override has been set\n if (typeof window !== 'undefined' && (window as any).__MJ_REACT_DEBUG_MODE__ !== undefined) {\n return (window as any).__MJ_REACT_DEBUG_MODE__;\n }\n \n // Check if we're in development mode (common Angular pattern)\n // ngDevMode is truthy in dev mode, false in prod mode\n if (typeof window !== 'undefined' && (window as any).ngDevMode) {\n return true;\n }\n \n // Fall back to static property\n return ReactDebugConfig.DEBUG_MODE;\n }\n\n /**\n * Set the debug mode (must be called before React loads)\n */\n static setDebugMode(debug: boolean): void {\n ReactDebugConfig.DEBUG_MODE = debug;\n if (typeof window !== 'undefined') {\n (window as any).__MJ_REACT_DEBUG_MODE__ = debug;\n }\n }\n}"]}
|
|
@@ -9,14 +9,19 @@ export declare class AngularAdapterService {
|
|
|
9
9
|
private scriptLoader;
|
|
10
10
|
private runtime?;
|
|
11
11
|
private runtimeContext?;
|
|
12
|
+
private initializationPromise;
|
|
12
13
|
constructor(scriptLoader: ScriptLoaderService);
|
|
13
14
|
/**
|
|
14
15
|
* Initialize the React runtime with Angular-specific configuration
|
|
15
16
|
* @param config Optional library configuration
|
|
16
17
|
* @param additionalLibraries Optional additional libraries to merge
|
|
18
|
+
* @param options Optional options including debug flag
|
|
17
19
|
* @returns Promise resolving when runtime is ready
|
|
18
20
|
*/
|
|
19
|
-
initialize(config?: LibraryConfiguration, additionalLibraries?: ExternalLibraryConfig[]
|
|
21
|
+
initialize(config?: LibraryConfiguration, additionalLibraries?: ExternalLibraryConfig[], options?: {
|
|
22
|
+
debug?: boolean;
|
|
23
|
+
}): Promise<void>;
|
|
24
|
+
private doInitialize;
|
|
20
25
|
/**
|
|
21
26
|
* Get the component compiler
|
|
22
27
|
* @returns Component compiler instance
|
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
* @module @memberjunction/ng-react
|
|
5
5
|
*/
|
|
6
6
|
import { Injectable } from '@angular/core';
|
|
7
|
-
import { createReactRuntime } from '@memberjunction/react-runtime';
|
|
7
|
+
import { createReactRuntime, SetupStyles } from '@memberjunction/react-runtime';
|
|
8
8
|
import { ScriptLoaderService } from './script-loader.service';
|
|
9
|
-
import { DEFAULT_STYLES } from '../default-styles';
|
|
10
9
|
import * as i0 from "@angular/core";
|
|
11
10
|
import * as i1 from "./script-loader.service";
|
|
12
11
|
/**
|
|
@@ -21,14 +20,31 @@ export class AngularAdapterService {
|
|
|
21
20
|
* Initialize the React runtime with Angular-specific configuration
|
|
22
21
|
* @param config Optional library configuration
|
|
23
22
|
* @param additionalLibraries Optional additional libraries to merge
|
|
23
|
+
* @param options Optional options including debug flag
|
|
24
24
|
* @returns Promise resolving when runtime is ready
|
|
25
25
|
*/
|
|
26
|
-
async initialize(config, additionalLibraries) {
|
|
26
|
+
async initialize(config, additionalLibraries, options) {
|
|
27
27
|
if (this.runtime) {
|
|
28
28
|
return; // Already initialized
|
|
29
29
|
}
|
|
30
|
+
if (this.initializationPromise) {
|
|
31
|
+
return this.initializationPromise; // in progress
|
|
32
|
+
}
|
|
33
|
+
// Start initialization and store the promise immediately
|
|
34
|
+
this.initializationPromise = this.doInitialize(config, additionalLibraries, options);
|
|
35
|
+
try {
|
|
36
|
+
await this.initializationPromise;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
// Clear the promise on error so it can be retried
|
|
40
|
+
this.initializationPromise = undefined;
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
async doInitialize(config, additionalLibraries, options) {
|
|
30
46
|
// Load React ecosystem with optional additional libraries
|
|
31
|
-
const ecosystem = await this.scriptLoader.loadReactEcosystem(config, additionalLibraries);
|
|
47
|
+
const ecosystem = await this.scriptLoader.loadReactEcosystem(config, additionalLibraries, options);
|
|
32
48
|
// Create runtime context
|
|
33
49
|
this.runtimeContext = {
|
|
34
50
|
React: ecosystem.React,
|
|
@@ -42,15 +58,17 @@ export class AngularAdapterService {
|
|
|
42
58
|
this.runtime = createReactRuntime(ecosystem.Babel, {
|
|
43
59
|
compiler: {
|
|
44
60
|
cache: true,
|
|
45
|
-
maxCacheSize: 100
|
|
61
|
+
maxCacheSize: 100,
|
|
62
|
+
debug: options?.debug
|
|
46
63
|
},
|
|
47
64
|
registry: {
|
|
48
65
|
maxComponents: 1000,
|
|
49
66
|
cleanupInterval: 60000,
|
|
50
67
|
useLRU: true,
|
|
51
|
-
enableNamespaces: true
|
|
68
|
+
enableNamespaces: true,
|
|
69
|
+
debug: options?.debug
|
|
52
70
|
}
|
|
53
|
-
}, this.runtimeContext);
|
|
71
|
+
}, this.runtimeContext, options?.debug);
|
|
54
72
|
}
|
|
55
73
|
/**
|
|
56
74
|
* Get the component compiler
|
|
@@ -120,7 +138,7 @@ export class AngularAdapterService {
|
|
|
120
138
|
// Apply default styles if not provided
|
|
121
139
|
const optionsWithDefaults = {
|
|
122
140
|
...options,
|
|
123
|
-
styles: options.styles ||
|
|
141
|
+
styles: options.styles || SetupStyles()
|
|
124
142
|
};
|
|
125
143
|
return this.runtime.compiler.compile(optionsWithDefaults);
|
|
126
144
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-adapter.service.js","sourceRoot":"","sources":["../../../src/lib/services/angular-adapter.service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAIL,kBAAkB,EAKnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;;;AAGnD;;;GAGG;AAEH,MAAM,OAAO,qBAAqB;IAShC,YAAoB,YAAiC;QAAjC,iBAAY,GAAZ,YAAY,CAAqB;IAAG,CAAC;IAEzD;;;;;OAKG;IACH,KAAK,CAAC,UAAU,CACd,MAA6B,EAC7B,mBAA6C;QAE7C,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO,CAAC,sBAAsB;QAChC,CAAC;QAED,0DAA0D;QAC1D,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAA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K,CAAC,iDAAiD,CAAC,CAAC;QACrE,CAAC;QAED,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE;gBACnC,OAAO,EAAE,CAAC,OAAO,CAAC;gBAClB,QAAQ,EAAE,QAAQ,IAAI,eAAe;aACtC,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,4BAA4B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;sFAxOU,qBAAqB;uEAArB,qBAAqB,WAArB,qBAAqB,mBADR,MAAM;;iFACnB,qBAAqB;cADjC,UAAU;eAAC,EAAE,UAAU,EAAE,MAAM,EAAE","sourcesContent":["/**\n * @fileoverview Angular adapter service that bridges the React runtime with Angular.\n * Provides Angular-specific functionality for the platform-agnostic React runtime.\n * @module @memberjunction/ng-react\n */\n\nimport { Injectable } from '@angular/core';\nimport { \n ComponentCompiler,\n ComponentRegistry,\n ComponentResolver,\n createReactRuntime,\n CompileOptions,\n RuntimeContext,\n ExternalLibraryConfig,\n LibraryConfiguration\n} from '@memberjunction/react-runtime';\nimport { ScriptLoaderService } from './script-loader.service';\nimport { DEFAULT_STYLES } from '../default-styles';\nimport { ComponentStyles } from '@memberjunction/interactive-component-types';\n\n/**\n * Angular-specific adapter for the React runtime.\n * Manages the integration between Angular services and the platform-agnostic React runtime.\n */\n@Injectable({ providedIn: 'root' })\nexport class AngularAdapterService {\n private runtime?: {\n compiler: ComponentCompiler;\n registry: ComponentRegistry;\n resolver: ComponentResolver;\n version: string;\n };\n private runtimeContext?: RuntimeContext;\n\n constructor(private scriptLoader: ScriptLoaderService) {}\n\n /**\n * Initialize the React runtime with Angular-specific configuration\n * @param config Optional library configuration\n * @param additionalLibraries Optional additional libraries to merge\n * @returns Promise resolving when runtime is ready\n */\n async initialize(\n config?: LibraryConfiguration,\n additionalLibraries?: ExternalLibraryConfig[]\n ): Promise<void> {\n if (this.runtime) {\n return; // Already initialized\n }\n\n // Load React ecosystem with optional additional libraries\n const ecosystem = await this.scriptLoader.loadReactEcosystem(config, additionalLibraries);\n \n // Create runtime context\n this.runtimeContext = {\n React: ecosystem.React,\n ReactDOM: ecosystem.ReactDOM,\n libraries: ecosystem.libraries,\n utilities: {\n // Add any Angular-specific utilities here\n }\n };\n\n // Create the React runtime with runtime context for registry support\n this.runtime = createReactRuntime(ecosystem.Babel, {\n compiler: {\n cache: true,\n maxCacheSize: 100\n },\n registry: {\n maxComponents: 1000,\n cleanupInterval: 60000,\n useLRU: true,\n enableNamespaces: true\n }\n }, this.runtimeContext);\n }\n\n /**\n * Get the component compiler\n * @returns Component compiler instance\n */\n getCompiler(): ComponentCompiler {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.compiler;\n }\n\n /**\n * Get the component registry\n * @returns Component registry instance\n */\n getRegistry(): ComponentRegistry {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.registry;\n }\n\n /**\n * Get the component resolver\n * @returns Component resolver instance\n */\n getResolver(): ComponentResolver {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.resolver;\n }\n\n /**\n * Get the runtime context\n * @returns Runtime context with React and libraries\n */\n getRuntimeContext(): RuntimeContext {\n if (!this.runtimeContext) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtimeContext;\n }\n\n\n /**\n * Compile a component with Angular-specific defaults\n * @param options - Compilation options\n * @returns Promise resolving to compilation result\n */\n async compileComponent(options: CompileOptions) {\n // Validate options before initialization\n if (!options) {\n throw new Error(\n 'Angular adapter error: No compilation options provided.\\n' +\n 'This usually means the component spec is null or undefined.\\n' +\n 'Please check that:\\n' +\n '1. Your component data is loaded properly\\n' +\n '2. The component spec has \"name\" and \"code\" properties\\n' +\n '3. The component input is not undefined'\n );\n }\n\n if (!options.componentName || options.componentName.trim() === '') {\n throw new Error(\n 'Angular adapter error: Component name is missing or empty.\\n' +\n `Received options: ${JSON.stringify(options, null, 2)}\\n` +\n 'Make sure your component spec includes a \"name\" property.'\n );\n }\n\n if (!options.componentCode || options.componentCode.trim() === '') {\n throw new Error(\n `Angular adapter error: Component code is missing or empty for component \"${options.componentName}\".\\n` +\n 'Make sure your component spec includes a \"code\" property with the React component source.'\n );\n }\n\n await this.initialize();\n \n // Apply default styles if not provided\n const optionsWithDefaults = {\n ...options,\n styles: options.styles || DEFAULT_STYLES\n };\n\n return this.runtime!.compiler.compile(optionsWithDefaults);\n }\n\n /**\n * Register a component in the registry\n * @param name - Component name\n * @param component - Compiled component\n * @param namespace - Component namespace\n * @param version - Component version\n * @returns Component metadata\n */\n registerComponent(\n name: string,\n component: any,\n namespace: string = 'Global',\n version: string = 'v1'\n ) {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.registry.register(name, component, namespace, version);\n }\n\n /**\n * Get a component from the registry\n * @param name - Component name\n * @param namespace - Component namespace\n * @param version - Component version\n * @returns Component if found\n */\n getComponent(name: string, namespace: string = 'Global', version?: string) {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.registry.get(name, namespace, version);\n }\n\n /**\n * Check if runtime is initialized\n * @returns true if initialized\n */\n isInitialized(): boolean {\n return !!this.runtime && !!this.runtimeContext;\n }\n\n /**\n * Get runtime version\n * @returns Runtime version string\n */\n getVersion(): string {\n return this.runtime?.version || 'unknown';\n }\n\n /**\n * Clean up resources\n */\n destroy(): void {\n if (this.runtime) {\n this.runtime.registry.destroy();\n this.runtime = undefined;\n this.runtimeContext = undefined;\n }\n }\n\n /**\n * Get Babel instance for direct use\n * @returns Babel instance\n */\n getBabel(): any {\n return this.runtimeContext?.libraries?.Babel || (window as any).Babel;\n }\n\n /**\n * Transpile JSX code directly\n * @param code - JSX code to transpile\n * @param filename - Optional filename for better error messages\n * @returns Transpiled JavaScript code\n */\n transpileJSX(code: string, filename?: string): string {\n const babel = this.getBabel();\n if (!babel) {\n throw new Error('Babel not loaded. Initialize the runtime first.');\n }\n\n try {\n const result = babel.transform(code, {\n presets: ['react'],\n filename: filename || 'component.jsx'\n });\n return result.code;\n } catch (error: any) {\n throw new Error(`Failed to transpile JSX: ${error.message}`);\n }\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"angular-adapter.service.js","sourceRoot":"","sources":["../../../src/lib/services/angular-adapter.service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAIL,kBAAkB,EAKlB,WAAW,EACZ,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;;;AAG9D;;;GAGG;AAEH,MAAM,OAAO,qBAAqB;IAUhC,YAAoB,YAAiC;QAAjC,iBAAY,GAAZ,YAAY,CAAqB;IAAG,CAAC;IAEzD;;;;;;OAMG;IACH,KAAK,CAAC,UAAU,CACd,MAA6B,EAC7B,mBAA6C,EAC7C,OAA6B;QAE7B,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO,CAAC,sBAAsB;QAChC,CAAC;QACD,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC,qBAAqB,CAAC,CAAC,cAAc;QACnD,CAAC;QAED,yDAAyD;QACzD,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAC;QAErF,IAAI,CAAC;YACD,MAAM,IAAI,CAAC,qBAAqB,CAAC;QACrC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,kDAAkD;YAClD,IAAI,CAAC,qBAAqB,GAAG,SAAS,CAAC;YACvC,MAAM,KAAK,CAAC;QAChB,CAA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AAC;IAED;;;OAGG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,cAAc,EAAE,SAAS,EAAE,KAAK,IAAK,MAAc,CAAC,KAAK,CAAC;IACxE,CAAC;IAED;;;;;OAKG;IACH,YAAY,CAAC,IAAY,EAAE,QAAiB;QAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,CAAC;QAED,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE;gBACnC,OAAO,EAAE,CAAC,OAAO,CAAC;gBAClB,QAAQ,EAAE,QAAQ,IAAI,eAAe;aACtC,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,4BAA4B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;sFAnQU,qBAAqB;uEAArB,qBAAqB,WAArB,qBAAqB,mBADR,MAAM;;iFACnB,qBAAqB;cADjC,UAAU;eAAC,EAAE,UAAU,EAAE,MAAM,EAAE","sourcesContent":["/**\n * @fileoverview Angular adapter service that bridges the React runtime with Angular.\n * Provides Angular-specific functionality for the platform-agnostic React runtime.\n * @module @memberjunction/ng-react\n */\n\nimport { Injectable } from '@angular/core';\nimport { \n ComponentCompiler,\n ComponentRegistry,\n ComponentResolver,\n createReactRuntime,\n CompileOptions,\n RuntimeContext,\n ExternalLibraryConfig,\n LibraryConfiguration,\n SetupStyles\n} from '@memberjunction/react-runtime';\nimport { ScriptLoaderService } from './script-loader.service';\nimport { ComponentStyles } from '@memberjunction/interactive-component-types';\n\n/**\n * Angular-specific adapter for the React runtime.\n * Manages the integration between Angular services and the platform-agnostic React runtime.\n */\n@Injectable({ providedIn: 'root' })\nexport class AngularAdapterService {\n private runtime?: {\n compiler: ComponentCompiler;\n registry: ComponentRegistry;\n resolver: ComponentResolver;\n version: string;\n };\n private runtimeContext?: RuntimeContext;\n private initializationPromise: Promise<void> | undefined;\n\n constructor(private scriptLoader: ScriptLoaderService) {}\n\n /**\n * Initialize the React runtime with Angular-specific configuration\n * @param config Optional library configuration\n * @param additionalLibraries Optional additional libraries to merge\n * @param options Optional options including debug flag\n * @returns Promise resolving when runtime is ready\n */\n async initialize(\n config?: LibraryConfiguration,\n additionalLibraries?: ExternalLibraryConfig[],\n options?: { debug?: boolean }\n ): Promise<void> {\n if (this.runtime) {\n return; // Already initialized\n }\n if (this.initializationPromise) {\n return this.initializationPromise; // in progress\n }\n\n // Start initialization and store the promise immediately\n this.initializationPromise = this.doInitialize(config, additionalLibraries, options);\n\n try {\n await this.initializationPromise;\n } catch (error) {\n // Clear the promise on error so it can be retried\n this.initializationPromise = undefined;\n throw error;\n }\n\n return;\n }\n\n private async doInitialize(\n config?: LibraryConfiguration,\n additionalLibraries?: ExternalLibraryConfig[],\n options?: { debug?: boolean }\n ): Promise<void> {\n // Load React ecosystem with optional additional libraries\n const ecosystem = await this.scriptLoader.loadReactEcosystem(config, additionalLibraries, options);\n \n // Create runtime context\n this.runtimeContext = {\n React: ecosystem.React,\n ReactDOM: ecosystem.ReactDOM,\n libraries: ecosystem.libraries,\n utilities: {\n // Add any Angular-specific utilities here\n }\n };\n\n // Create the React runtime with runtime context for registry support\n this.runtime = createReactRuntime(ecosystem.Babel, {\n compiler: {\n cache: true,\n maxCacheSize: 100,\n debug: options?.debug\n },\n registry: {\n maxComponents: 1000,\n cleanupInterval: 60000,\n useLRU: true,\n enableNamespaces: true,\n debug: options?.debug\n }\n }, this.runtimeContext, options?.debug);\n }\n\n /**\n * Get the component compiler\n * @returns Component compiler instance\n */\n getCompiler(): ComponentCompiler {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.compiler;\n }\n\n /**\n * Get the component registry\n * @returns Component registry instance\n */\n getRegistry(): ComponentRegistry {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.registry;\n }\n\n /**\n * Get the component resolver\n * @returns Component resolver instance\n */\n getResolver(): ComponentResolver {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.resolver;\n }\n\n /**\n * Get the runtime context\n * @returns Runtime context with React and libraries\n */\n getRuntimeContext(): RuntimeContext {\n if (!this.runtimeContext) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtimeContext;\n }\n\n\n /**\n * Compile a component with Angular-specific defaults\n * @param options - Compilation options\n * @returns Promise resolving to compilation result\n */\n async compileComponent(options: CompileOptions) {\n // Validate options before initialization\n if (!options) {\n throw new Error(\n 'Angular adapter error: No compilation options provided.\\n' +\n 'This usually means the component spec is null or undefined.\\n' +\n 'Please check that:\\n' +\n '1. Your component data is loaded properly\\n' +\n '2. The component spec has \"name\" and \"code\" properties\\n' +\n '3. The component input is not undefined'\n );\n }\n\n if (!options.componentName || options.componentName.trim() === '') {\n throw new Error(\n 'Angular adapter error: Component name is missing or empty.\\n' +\n `Received options: ${JSON.stringify(options, null, 2)}\\n` +\n 'Make sure your component spec includes a \"name\" property.'\n );\n }\n\n if (!options.componentCode || options.componentCode.trim() === '') {\n throw new Error(\n `Angular adapter error: Component code is missing or empty for component \"${options.componentName}\".\\n` +\n 'Make sure your component spec includes a \"code\" property with the React component source.'\n );\n }\n\n await this.initialize();\n \n // Apply default styles if not provided\n const optionsWithDefaults = {\n ...options,\n styles: options.styles || SetupStyles()\n };\n\n return this.runtime!.compiler.compile(optionsWithDefaults);\n }\n\n /**\n * Register a component in the registry\n * @param name - Component name\n * @param component - Compiled component\n * @param namespace - Component namespace\n * @param version - Component version\n * @returns Component metadata\n */\n registerComponent(\n name: string,\n component: any,\n namespace: string = 'Global',\n version: string = 'v1'\n ) {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.registry.register(name, component, namespace, version);\n }\n\n /**\n * Get a component from the registry\n * @param name - Component name\n * @param namespace - Component namespace\n * @param version - Component version\n * @returns Component if found\n */\n getComponent(name: string, namespace: string = 'Global', version?: string) {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.registry.get(name, namespace, version);\n }\n\n /**\n * Check if runtime is initialized\n * @returns true if initialized\n */\n isInitialized(): boolean {\n return !!this.runtime && !!this.runtimeContext;\n }\n\n /**\n * Get runtime version\n * @returns Runtime version string\n */\n getVersion(): string {\n return this.runtime?.version || 'unknown';\n }\n\n /**\n * Clean up resources\n */\n destroy(): void {\n if (this.runtime) {\n this.runtime.registry.destroy();\n this.runtime = undefined;\n this.runtimeContext = undefined;\n }\n }\n\n /**\n * Get Babel instance for direct use\n * @returns Babel instance\n */\n getBabel(): any {\n return this.runtimeContext?.libraries?.Babel || (window as any).Babel;\n }\n\n /**\n * Transpile JSX code directly\n * @param code - JSX code to transpile\n * @param filename - Optional filename for better error messages\n * @returns Transpiled JavaScript code\n */\n transpileJSX(code: string, filename?: string): string {\n const babel = this.getBabel();\n if (!babel) {\n throw new Error('Babel not loaded. Initialize the runtime first.');\n }\n\n try {\n const result = babel.transform(code, {\n presets: ['react'],\n filename: filename || 'component.jsx'\n });\n return result.code;\n } catch (error: any) {\n throw new Error(`Failed to transpile JSX: ${error.message}`);\n }\n }\n}"]}
|