@memberjunction/ng-react 2.74.0 → 2.76.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/README.md +81 -36
- package/dist/lib/components/mj-react-component.component.d.ts +20 -3
- package/dist/lib/components/mj-react-component.component.js +54 -42
- package/dist/lib/components/mj-react-component.component.js.map +1 -1
- package/dist/lib/services/angular-adapter.service.d.ts +4 -2
- package/dist/lib/services/angular-adapter.service.js +23 -3
- package/dist/lib/services/angular-adapter.service.js.map +1 -1
- package/dist/lib/services/script-loader.service.d.ts +4 -1
- package/dist/lib/services/script-loader.service.js +4 -2
- package/dist/lib/services/script-loader.service.js.map +1 -1
- package/dist/public-api.d.ts +0 -1
- package/dist/public-api.js +0 -2
- package/dist/public-api.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ The `@memberjunction/ng-react` package enables Angular applications to render Re
|
|
|
10
10
|
|
|
11
11
|
- **Dynamic React Component Rendering**: Compile and render React components from source code
|
|
12
12
|
- **Automatic Dependency Loading**: Loads React, ReactDOM, and Babel from CDN
|
|
13
|
+
- **Dynamic Library Management**: Configure external libraries per organization or use case
|
|
13
14
|
- **Component Registry**: Manages compiled components with namespace support
|
|
14
15
|
- **Error Boundaries**: Comprehensive error handling for React components
|
|
15
16
|
- **Two-Way Data Binding**: Seamless data flow between Angular and React
|
|
@@ -57,7 +58,7 @@ export class YourModule { }
|
|
|
57
58
|
|
|
58
59
|
```typescript
|
|
59
60
|
import { Component } from '@angular/core';
|
|
60
|
-
import {
|
|
61
|
+
import { ComponentSpec } from '@memberjunction/interactive-component-types';
|
|
61
62
|
|
|
62
63
|
@Component({
|
|
63
64
|
selector: 'app-example',
|
|
@@ -69,9 +70,9 @@ import { SkipComponentRootSpec } from '@memberjunction/skip-types';
|
|
|
69
70
|
`
|
|
70
71
|
})
|
|
71
72
|
export class ExampleComponent {
|
|
72
|
-
reactComponent:
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
reactComponent: ComponentSpec = {
|
|
74
|
+
name: 'MyReactComponent',
|
|
75
|
+
code: `
|
|
75
76
|
function MyReactComponent({ data, callbacks }) {
|
|
76
77
|
return (
|
|
77
78
|
<div>
|
|
@@ -113,20 +114,66 @@ interface ComponentProps {
|
|
|
113
114
|
|
|
114
115
|
## Advanced Features
|
|
115
116
|
|
|
117
|
+
### Dynamic Library Configuration
|
|
118
|
+
|
|
119
|
+
Configure which external libraries are available to React components:
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import { ScriptLoaderService, LibraryConfiguration } from '@memberjunction/ng-react';
|
|
123
|
+
|
|
124
|
+
// Define organization-specific library configuration
|
|
125
|
+
const orgLibraryConfig: LibraryConfiguration = {
|
|
126
|
+
libraries: [
|
|
127
|
+
{
|
|
128
|
+
id: 'lodash',
|
|
129
|
+
name: 'lodash',
|
|
130
|
+
displayName: 'Lodash',
|
|
131
|
+
category: 'utility',
|
|
132
|
+
globalVariable: '_',
|
|
133
|
+
version: '4.17.21',
|
|
134
|
+
cdnUrl: 'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js',
|
|
135
|
+
isEnabled: true,
|
|
136
|
+
isCore: false
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
id: 'chart-js',
|
|
140
|
+
name: 'Chart',
|
|
141
|
+
displayName: 'Chart.js',
|
|
142
|
+
category: 'charting',
|
|
143
|
+
globalVariable: 'Chart',
|
|
144
|
+
version: '4.4.0',
|
|
145
|
+
cdnUrl: 'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.0/chart.umd.js',
|
|
146
|
+
isEnabled: true,
|
|
147
|
+
isCore: false
|
|
148
|
+
}
|
|
149
|
+
// Add more libraries as needed
|
|
150
|
+
],
|
|
151
|
+
metadata: {
|
|
152
|
+
version: '1.0.0',
|
|
153
|
+
lastUpdated: '2024-01-01'
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// Load libraries before rendering components
|
|
158
|
+
async ngOnInit() {
|
|
159
|
+
await this.scriptLoader.loadReactEcosystem(orgLibraryConfig);
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
116
163
|
### Component Hierarchies
|
|
117
164
|
|
|
118
165
|
```typescript
|
|
119
|
-
const componentSpec:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
166
|
+
const componentSpec: ComponentSpec = {
|
|
167
|
+
name: 'ParentComponent',
|
|
168
|
+
code: '...',
|
|
169
|
+
dependencies: [
|
|
123
170
|
{
|
|
124
|
-
|
|
125
|
-
|
|
171
|
+
name: 'ChildComponent1',
|
|
172
|
+
code: '...'
|
|
126
173
|
},
|
|
127
174
|
{
|
|
128
|
-
|
|
129
|
-
|
|
175
|
+
name: 'ChildComponent2',
|
|
176
|
+
code: '...'
|
|
130
177
|
}
|
|
131
178
|
]
|
|
132
179
|
};
|
|
@@ -145,38 +192,36 @@ const styles: SkipComponentStyles = {
|
|
|
145
192
|
}
|
|
146
193
|
};
|
|
147
194
|
```
|
|
148
|
-
|
|
149
|
-
### State Management
|
|
150
|
-
|
|
151
|
-
```typescript
|
|
152
|
-
// In your Angular component
|
|
153
|
-
onStateChange(event: StateChangeEvent) {
|
|
154
|
-
console.log(`State ${event.path} changed to:`, event.value);
|
|
155
|
-
// Update your Angular component state
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// In your React component
|
|
159
|
-
function MyComponent({ userState, callbacks }) {
|
|
160
|
-
const updateState = () => {
|
|
161
|
-
callbacks.UpdateUserState({
|
|
162
|
-
counter: userState.counter + 1
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
return <button onClick={updateState}>Count: {userState.counter}</button>;
|
|
167
|
-
}
|
|
168
|
-
```
|
|
195
|
+
|
|
169
196
|
|
|
170
197
|
## Services
|
|
171
198
|
|
|
172
199
|
### ScriptLoaderService
|
|
173
200
|
|
|
174
|
-
Manages loading of external scripts and CSS:
|
|
201
|
+
Manages loading of external scripts and CSS with support for dynamic library configurations:
|
|
175
202
|
|
|
176
203
|
```typescript
|
|
177
204
|
constructor(private scriptLoader: ScriptLoaderService) {}
|
|
178
205
|
|
|
179
|
-
|
|
206
|
+
// Load with default configuration
|
|
207
|
+
async loadDefaultLibraries() {
|
|
208
|
+
await this.scriptLoader.loadReactEcosystem();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Load with custom configuration
|
|
212
|
+
async loadCustomLibraries() {
|
|
213
|
+
const customConfig = {
|
|
214
|
+
libraries: [
|
|
215
|
+
// Define your custom library set
|
|
216
|
+
],
|
|
217
|
+
metadata: { version: '1.0.0' }
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
await this.scriptLoader.loadReactEcosystem(customConfig);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Load individual library
|
|
224
|
+
async loadSingleLibrary() {
|
|
180
225
|
const lib = await this.scriptLoader.loadScript(
|
|
181
226
|
'https://cdn.example.com/lib.js',
|
|
182
227
|
'MyLibrary'
|
|
@@ -245,7 +290,7 @@ This package requires:
|
|
|
245
290
|
- Angular 18+
|
|
246
291
|
- React 18+
|
|
247
292
|
- @memberjunction/react-runtime
|
|
248
|
-
- @memberjunction/
|
|
293
|
+
- @memberjunction/interactive-component-types
|
|
249
294
|
- @memberjunction/core
|
|
250
295
|
|
|
251
296
|
## License
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @module @memberjunction/ng-react
|
|
5
5
|
*/
|
|
6
6
|
import { EventEmitter, ElementRef, AfterViewInit, OnDestroy, ChangeDetectorRef } from '@angular/core';
|
|
7
|
-
import {
|
|
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
10
|
import { CompositeKey } from '@memberjunction/core';
|
|
@@ -23,6 +23,14 @@ export interface StateChangeEvent {
|
|
|
23
23
|
path: string;
|
|
24
24
|
value: any;
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* User settings changed event emitted when component saves user preferences
|
|
28
|
+
*/
|
|
29
|
+
export interface UserSettingsChangedEvent {
|
|
30
|
+
settings: Record<string, any>;
|
|
31
|
+
componentName?: string;
|
|
32
|
+
timestamp: Date;
|
|
33
|
+
}
|
|
26
34
|
/**
|
|
27
35
|
* Angular component that hosts React components with proper memory management.
|
|
28
36
|
* This component provides a bridge between Angular and React, allowing React components
|
|
@@ -32,7 +40,7 @@ export declare class MJReactComponent implements AfterViewInit, OnDestroy {
|
|
|
32
40
|
private reactBridge;
|
|
33
41
|
private adapter;
|
|
34
42
|
private cdr;
|
|
35
|
-
component:
|
|
43
|
+
component: ComponentSpec;
|
|
36
44
|
private _data;
|
|
37
45
|
set data(value: any);
|
|
38
46
|
get data(): any;
|
|
@@ -41,6 +49,9 @@ export declare class MJReactComponent implements AfterViewInit, OnDestroy {
|
|
|
41
49
|
get state(): any;
|
|
42
50
|
utilities: any;
|
|
43
51
|
styles?: Partial<ComponentStyles>;
|
|
52
|
+
private _savedUserSettings;
|
|
53
|
+
set savedUserSettings(value: any);
|
|
54
|
+
get savedUserSettings(): any;
|
|
44
55
|
stateChange: EventEmitter<StateChangeEvent>;
|
|
45
56
|
componentEvent: EventEmitter<ReactComponentEvent>;
|
|
46
57
|
refreshData: EventEmitter<void>;
|
|
@@ -48,6 +59,7 @@ export declare class MJReactComponent implements AfterViewInit, OnDestroy {
|
|
|
48
59
|
entityName: string;
|
|
49
60
|
key: CompositeKey;
|
|
50
61
|
}>;
|
|
62
|
+
userSettingsChanged: EventEmitter<UserSettingsChangedEvent>;
|
|
51
63
|
container: ElementRef<HTMLDivElement>;
|
|
52
64
|
private reactRoot;
|
|
53
65
|
private compiledComponent;
|
|
@@ -83,6 +95,11 @@ export declare class MJReactComponent implements AfterViewInit, OnDestroy {
|
|
|
83
95
|
* Handle React component errors
|
|
84
96
|
*/
|
|
85
97
|
private handleReactError;
|
|
98
|
+
/**
|
|
99
|
+
* Handle onSaveUserSettings from components
|
|
100
|
+
* This implements the SavedUserSettings pattern
|
|
101
|
+
*/
|
|
102
|
+
private handleSaveUserSettings;
|
|
86
103
|
/**
|
|
87
104
|
* Clean up resources
|
|
88
105
|
*/
|
|
@@ -103,5 +120,5 @@ export declare class MJReactComponent implements AfterViewInit, OnDestroy {
|
|
|
103
120
|
*/
|
|
104
121
|
private isEqual;
|
|
105
122
|
static ɵfac: i0.ɵɵFactoryDeclaration<MJReactComponent, never>;
|
|
106
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<MJReactComponent, "mj-react-component", never, { "component": { "alias": "component"; "required": false; }; "data": { "alias": "data"; "required": false; }; "state": { "alias": "state"; "required": false; }; "utilities": { "alias": "utilities"; "required": false; }; "styles": { "alias": "styles"; "required": false; }; }, { "stateChange": "stateChange"; "componentEvent": "componentEvent"; "refreshData": "refreshData"; "openEntityRecord": "openEntityRecord"; }, never, never, false, never>;
|
|
123
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<MJReactComponent, "mj-react-component", never, { "component": { "alias": "component"; "required": false; }; "data": { "alias": "data"; "required": false; }; "state": { "alias": "state"; "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>;
|
|
107
124
|
}
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { Component, Input, Output, EventEmitter, ViewChild, ElementRef, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
|
|
7
7
|
import { Subject } from 'rxjs';
|
|
8
|
+
import { ComponentSpec } from '@memberjunction/interactive-component-types';
|
|
8
9
|
import { ReactBridgeService } from '../services/react-bridge.service';
|
|
9
10
|
import { AngularAdapterService } from '../services/angular-adapter.service';
|
|
10
|
-
import {
|
|
11
|
+
import { createErrorBoundary, ComponentHierarchyRegistrar } from '@memberjunction/react-runtime';
|
|
11
12
|
import { LogError, CompositeKey } from '@memberjunction/core';
|
|
12
13
|
import * as i0 from "@angular/core";
|
|
13
14
|
import * as i1 from "../services/react-bridge.service";
|
|
@@ -50,6 +51,16 @@ export class MJReactComponent {
|
|
|
50
51
|
get state() {
|
|
51
52
|
return this._state;
|
|
52
53
|
}
|
|
54
|
+
set savedUserSettings(value) {
|
|
55
|
+
this._savedUserSettings = value || {};
|
|
56
|
+
// Re-render if component is initialized
|
|
57
|
+
if (this.isInitialized) {
|
|
58
|
+
this.renderComponent();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
get savedUserSettings() {
|
|
62
|
+
return this._savedUserSettings;
|
|
63
|
+
}
|
|
53
64
|
constructor(reactBridge, adapter, cdr) {
|
|
54
65
|
this.reactBridge = reactBridge;
|
|
55
66
|
this.adapter = adapter;
|
|
@@ -57,10 +68,12 @@ export class MJReactComponent {
|
|
|
57
68
|
this._data = {};
|
|
58
69
|
this._state = {};
|
|
59
70
|
this.utilities = {};
|
|
71
|
+
this._savedUserSettings = {};
|
|
60
72
|
this.stateChange = new EventEmitter();
|
|
61
73
|
this.componentEvent = new EventEmitter();
|
|
62
74
|
this.refreshData = new EventEmitter();
|
|
63
75
|
this.openEntityRecord = new EventEmitter();
|
|
76
|
+
this.userSettingsChanged = new EventEmitter();
|
|
64
77
|
this.reactRoot = null;
|
|
65
78
|
this.compiledComponent = null;
|
|
66
79
|
this.destroyed$ = new Subject();
|
|
@@ -100,8 +113,8 @@ export class MJReactComponent {
|
|
|
100
113
|
await this.registerComponentHierarchy();
|
|
101
114
|
// Compile main component
|
|
102
115
|
const result = await this.adapter.compileComponent({
|
|
103
|
-
componentName: this.component.
|
|
104
|
-
componentCode: this.component.
|
|
116
|
+
componentName: this.component.name,
|
|
117
|
+
componentCode: this.component.code,
|
|
105
118
|
styles: this.styles
|
|
106
119
|
});
|
|
107
120
|
if (!result.success) {
|
|
@@ -179,10 +192,16 @@ export class MJReactComponent {
|
|
|
179
192
|
if (!this.currentCallbacks) {
|
|
180
193
|
this.currentCallbacks = this.createCallbacks();
|
|
181
194
|
}
|
|
182
|
-
// Build props
|
|
183
|
-
const props =
|
|
184
|
-
|
|
185
|
-
|
|
195
|
+
// Build props with savedUserSettings pattern
|
|
196
|
+
const props = {
|
|
197
|
+
...this._data, // Spread data properties directly
|
|
198
|
+
utilities: this.utilities || {},
|
|
199
|
+
callbacks: this.currentCallbacks,
|
|
200
|
+
components,
|
|
201
|
+
styles: this.styles,
|
|
202
|
+
savedUserSettings: this._savedUserSettings,
|
|
203
|
+
onSaveUserSettings: this.handleSaveUserSettings.bind(this)
|
|
204
|
+
};
|
|
186
205
|
// Create error boundary
|
|
187
206
|
const ErrorBoundary = createErrorBoundary(React, {
|
|
188
207
|
onError: this.handleReactError.bind(this),
|
|
@@ -238,9 +257,6 @@ export class MJReactComponent {
|
|
|
238
257
|
*/
|
|
239
258
|
createCallbacks() {
|
|
240
259
|
return {
|
|
241
|
-
RefreshData: () => {
|
|
242
|
-
this.refreshData.emit();
|
|
243
|
-
},
|
|
244
260
|
OpenEntityRecord: (entityName, key) => {
|
|
245
261
|
let keyToUse = null;
|
|
246
262
|
if (key instanceof Array) {
|
|
@@ -261,35 +277,6 @@ export class MJReactComponent {
|
|
|
261
277
|
if (keyToUse) {
|
|
262
278
|
this.openEntityRecord.emit({ entityName, key: keyToUse });
|
|
263
279
|
}
|
|
264
|
-
},
|
|
265
|
-
UpdateUserState: (userState) => {
|
|
266
|
-
// Prevent updates during rendering or destruction
|
|
267
|
-
if (this.isRendering || this.isDestroying) {
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
// Deep comparison to detect actual changes
|
|
271
|
-
const hasChanges = Object.keys(userState).some(key => {
|
|
272
|
-
const currentValue = this.currentState[key];
|
|
273
|
-
const newValue = userState[key];
|
|
274
|
-
return !this.isEqual(currentValue, newValue);
|
|
275
|
-
});
|
|
276
|
-
if (!hasChanges) {
|
|
277
|
-
// No actual changes, skip update to prevent infinite loop
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
this.currentState = {
|
|
281
|
-
...this.currentState,
|
|
282
|
-
...userState
|
|
283
|
-
};
|
|
284
|
-
// Emit change for each key in the state update
|
|
285
|
-
Object.keys(userState).forEach(path => {
|
|
286
|
-
this.stateChange.emit({ path, value: userState[path] });
|
|
287
|
-
});
|
|
288
|
-
// Schedule re-render
|
|
289
|
-
this.renderComponent();
|
|
290
|
-
},
|
|
291
|
-
NotifyEvent: (event, data) => {
|
|
292
|
-
this.componentEvent.emit({ type: event, payload: data });
|
|
293
280
|
}
|
|
294
281
|
};
|
|
295
282
|
}
|
|
@@ -307,6 +294,28 @@ export class MJReactComponent {
|
|
|
307
294
|
}
|
|
308
295
|
});
|
|
309
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* Handle onSaveUserSettings from components
|
|
299
|
+
* This implements the SavedUserSettings pattern
|
|
300
|
+
*/
|
|
301
|
+
handleSaveUserSettings(newSettings) {
|
|
302
|
+
// Check if there are actual changes
|
|
303
|
+
const hasChanges = !this.isEqual(this._savedUserSettings, newSettings);
|
|
304
|
+
if (!hasChanges) {
|
|
305
|
+
// No actual changes, skip update to prevent infinite loop
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
// Update saved settings
|
|
309
|
+
this._savedUserSettings = { ...newSettings };
|
|
310
|
+
// Emit user settings changed event
|
|
311
|
+
this.userSettingsChanged.emit({
|
|
312
|
+
settings: this._savedUserSettings,
|
|
313
|
+
componentName: this.component?.name,
|
|
314
|
+
timestamp: new Date()
|
|
315
|
+
});
|
|
316
|
+
// Schedule re-render
|
|
317
|
+
this.renderComponent();
|
|
318
|
+
}
|
|
310
319
|
/**
|
|
311
320
|
* Clean up resources
|
|
312
321
|
*/
|
|
@@ -318,7 +327,6 @@ export class MJReactComponent {
|
|
|
318
327
|
}
|
|
319
328
|
// Clean up prop builder subscriptions
|
|
320
329
|
if (this.currentCallbacks) {
|
|
321
|
-
cleanupPropBuilder(this.currentCallbacks);
|
|
322
330
|
this.currentCallbacks = null;
|
|
323
331
|
}
|
|
324
332
|
// Unmount React root only if not currently rendering
|
|
@@ -386,7 +394,7 @@ export class MJReactComponent {
|
|
|
386
394
|
} if (rf & 2) {
|
|
387
395
|
let _t;
|
|
388
396
|
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.container = _t.first);
|
|
389
|
-
} }, inputs: { component: "component", data: "data", state: "state", utilities: "utilities", styles: "styles" }, outputs: { stateChange: "stateChange", componentEvent: "componentEvent", refreshData: "refreshData", openEntityRecord: "openEntityRecord" }, 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) {
|
|
397
|
+
} }, inputs: { component: "component", data: "data", state: "state", 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) {
|
|
390
398
|
i0.ɵɵelementStart(0, "div", 1);
|
|
391
399
|
i0.ɵɵelement(1, "div", 2, 0);
|
|
392
400
|
i0.ɵɵtemplate(3, MJReactComponent_Conditional_3_Template, 5, 0, "div", 3);
|
|
@@ -423,6 +431,8 @@ export class MJReactComponent {
|
|
|
423
431
|
type: Input
|
|
424
432
|
}], styles: [{
|
|
425
433
|
type: Input
|
|
434
|
+
}], savedUserSettings: [{
|
|
435
|
+
type: Input
|
|
426
436
|
}], stateChange: [{
|
|
427
437
|
type: Output
|
|
428
438
|
}], componentEvent: [{
|
|
@@ -431,9 +441,11 @@ export class MJReactComponent {
|
|
|
431
441
|
type: Output
|
|
432
442
|
}], openEntityRecord: [{
|
|
433
443
|
type: Output
|
|
444
|
+
}], userSettingsChanged: [{
|
|
445
|
+
type: Output
|
|
434
446
|
}], container: [{
|
|
435
447
|
type: ViewChild,
|
|
436
448
|
args: ['container', { read: ElementRef, static: true }]
|
|
437
449
|
}] }); })();
|
|
438
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MJReactComponent, { className: "MJReactComponent", filePath: "lib/components/mj-react-component.component.ts", lineNumber:
|
|
450
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MJReactComponent, { className: "MJReactComponent", filePath: "lib/components/mj-react-component.component.ts", lineNumber: 122 }); })();
|
|
439
451
|
//# sourceMappingURL=mj-react-component.component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mj-react-component.component.js","sourceRoot":"","sources":["../../../src/lib/components/mj-react-component.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,SAAS,EACT,KAAK,EACL,MAAM,EACN,YAAY,EACZ,SAAS,EACT,UAAU,EAGV,uBAAuB,EACvB,iBAAiB,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAa,MAAM,MAAM,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAElB,mBAAmB,EACnB,2BAA2B,EAE5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,QAAQ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,SAAS;kBAApE,SAAS;mBAAC,WAAW,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE;;kFA1C/C,gBAAgB","sourcesContent":["/**\n * @fileoverview Angular component that hosts React components with proper memory management.\n * Provides a bridge between Angular and React ecosystems in MemberJunction applications.\n * @module @memberjunction/ng-react\n */\n\nimport {\n Component,\n Input,\n Output,\n EventEmitter,\n ViewChild,\n ElementRef,\n AfterViewInit,\n OnDestroy,\n ChangeDetectionStrategy,\n ChangeDetectorRef\n} from '@angular/core';\nimport { Subject, takeUntil } from 'rxjs';\nimport { ComponentRootSpec, ComponentCallbacks, ComponentStyles } from '@memberjunction/interactive-component-types';\nimport { ReactBridgeService } from '../services/react-bridge.service';\nimport { AngularAdapterService } from '../services/angular-adapter.service';\nimport { \n buildComponentProps,\n cleanupPropBuilder,\n ComponentError,\n createErrorBoundary,\n ComponentHierarchyRegistrar,\n HierarchyRegistrationResult\n} from '@memberjunction/react-runtime';\nimport { LogError, CompositeKey, KeyValuePair } from '@memberjunction/core';\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 * 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!: ComponentRootSpec;\n \n private _data: any = {};\n @Input() \n set data(value: any) {\n const oldData = this._data;\n this._data = value;\n \n // Only re-render if data actually changed and component is initialized\n if (this.isInitialized && !this.isEqual(oldData, value)) {\n this.renderComponent();\n }\n }\n get data(): any {\n return this._data;\n }\n \n private _state: any = {};\n @Input() \n set state(value: any) {\n const oldState = this._state;\n this._state = value;\n \n // Only update state and re-render if it actually changed\n if (this.isInitialized && !this.isEqual(oldState, value)) {\n this.currentState = { ...value };\n this.renderComponent();\n }\n }\n get state(): any {\n return this._state;\n }\n \n @Input() utilities: any = {};\n @Input() styles?: Partial<ComponentStyles>;\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 \n @ViewChild('container', { read: ElementRef, static: true }) container!: ElementRef<HTMLDivElement>;\n \n private reactRoot: any = null;\n private compiledComponent: any = null;\n private destroyed$ = new Subject<void>();\n private currentCallbacks: ComponentCallbacks | null = null;\n private currentState: any = {};\n isInitialized = false;\n private isRendering = false;\n private pendingRender = false;\n private isDestroying = false;\n private renderTimeout: any = null;\n hasError = false;\n\n constructor(\n private reactBridge: ReactBridgeService,\n private adapter: AngularAdapterService,\n private cdr: ChangeDetectorRef\n ) {}\n\n async ngAfterViewInit() {\n // Trigger change detection to show loading state\n this.cdr.detectChanges();\n await this.initializeComponent();\n }\n\n ngOnDestroy() {\n // Set destroying flag immediately\n this.isDestroying = true;\n \n // Cancel any pending renders\n this.pendingRender = false;\n \n this.destroyed$.next();\n this.destroyed$.complete();\n this.cleanup();\n }\n\n\n /**\n * Initialize the React component\n */\n private async initializeComponent() {\n try {\n // Ensure React is loaded\n await this.reactBridge.getReactContext();\n \n // Wait for React to be fully ready (handles first-load delay)\n await this.reactBridge.waitForReactReady();\n \n // Register component hierarchy\n await this.registerComponentHierarchy();\n \n // Compile main component\n const result = await this.adapter.compileComponent({\n componentName: this.component.componentName,\n componentCode: this.component.componentCode,\n styles: this.styles\n });\n\n if (!result.success) {\n throw new Error(result.error?.message || 'Component compilation failed');\n }\n\n // Get runtime context and execute component factory\n const context = this.adapter.getRuntimeContext();\n this.compiledComponent = result.component!.component(context, this.styles);\n this.currentState = { ...this._state };\n \n // Create React root\n this.reactRoot = this.reactBridge.createRoot(this.container.nativeElement);\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 * Register all components in the hierarchy\n */\n private async registerComponentHierarchy() {\n // Create the hierarchy registrar with adapter's compiler and registry\n const registrar = new ComponentHierarchyRegistrar(\n this.adapter.getCompiler(),\n this.adapter.getRegistry(),\n this.adapter.getRuntimeContext()\n );\n \n // Register the entire hierarchy\n const result: HierarchyRegistrationResult = await registrar.registerHierarchy(\n this.component,\n {\n styles: this.styles as any, // Skip components use SkipComponentStyles which is a superset\n namespace: 'Global',\n version: 'v1'\n }\n );\n \n // Check for errors\n if (!result.success) {\n const errorMessages = result.errors.map(e => \n `${e.componentName}: ${e.error}`\n );\n throw new Error(`Component registration failed: ${errorMessages.join(', ')}`);\n }\n }\n\n /**\n * Render the React component\n */\n private renderComponent() {\n // Don't render if component is being destroyed\n if (this.isDestroying) {\n return;\n }\n \n if (!this.compiledComponent || !this.reactRoot) {\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 // Get components from resolver\n const components = this.adapter.getResolver().resolveComponents(this.component);\n \n // Create callbacks once per component instance\n if (!this.currentCallbacks) {\n this.currentCallbacks = this.createCallbacks();\n }\n \n // Build props - pass styles as-is for Skip components\n const props = buildComponentProps(\n this._data || {},\n this.currentState,\n this.utilities || {},\n this.currentCallbacks,\n components,\n this.styles as any, // Skip components expect the full SkipComponentStyles structure\n { debounceUpdateUserState: 3000 } // 3 second debounce by default\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 // Clear any existing render timeout\n if (this.renderTimeout) {\n clearTimeout(this.renderTimeout);\n }\n \n // Render with timeout protection\n this.renderTimeout = setTimeout(() => {\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 }, 5000);\n\n try {\n this.reactRoot.render(element);\n clearTimeout(this.renderTimeout);\n this.renderTimeout = null;\n \n // Reset rendering flag after a microtask to allow React to complete\n Promise.resolve().then(() => {\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 } catch (error) {\n clearTimeout(this.renderTimeout);\n this.renderTimeout = null;\n this.isRendering = false;\n this.handleReactError(error);\n }\n }\n\n /**\n * Create callbacks for the React component\n */\n private createCallbacks(): ComponentCallbacks {\n return {\n RefreshData: () => {\n this.refreshData.emit();\n },\n OpenEntityRecord: (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 this.openEntityRecord.emit({ entityName, key: keyToUse });\n } \n },\n UpdateUserState: (userState: any) => {\n // Prevent updates during rendering or destruction\n if (this.isRendering || this.isDestroying) {\n return;\n }\n \n // Deep comparison to detect actual changes\n const hasChanges = Object.keys(userState).some(key => {\n const currentValue = this.currentState[key];\n const newValue = userState[key];\n return !this.isEqual(currentValue, newValue);\n });\n \n if (!hasChanges) {\n // No actual changes, skip update to prevent infinite loop\n return;\n }\n \n this.currentState = {\n ...this.currentState,\n ...userState\n };\n \n // Emit change for each key in the state update\n Object.keys(userState).forEach(path => {\n this.stateChange.emit({ path, value: userState[path] });\n });\n \n // Schedule re-render\n this.renderComponent();\n },\n NotifyEvent: (event: string, data: any) => {\n this.componentEvent.emit({ type: event, payload: data });\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 * Clean up resources\n */\n private cleanup() {\n // Clear any pending render timeout\n if (this.renderTimeout) {\n clearTimeout(this.renderTimeout);\n this.renderTimeout = null;\n }\n \n // Clean up prop builder subscriptions\n if (this.currentCallbacks) {\n cleanupPropBuilder(this.currentCallbacks);\n this.currentCallbacks = null;\n }\n \n // Unmount React root only if not currently rendering\n if (this.reactRoot) {\n // If still rendering, wait for completion before unmounting\n if (this.isRendering) {\n // Force stop rendering\n this.isRendering = false;\n this.pendingRender = false;\n }\n \n this.reactBridge.unmountRoot(this.reactRoot);\n this.reactRoot = null;\n }\n\n // Clear references\n this.compiledComponent = null;\n this.currentState = {};\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 * @param newData - Optional new data to merge\n */\n refresh(newData?: any) {\n if (newData) {\n // Use the setter to trigger change detection\n this.data = { ...this._data, ...newData };\n } else {\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 */\n updateState(path: string, value: any) {\n this.currentState = {\n ...this.currentState,\n [path]: value\n };\n this.stateChange.emit({ path, value });\n this.renderComponent();\n }\n\n /**\n * Deep equality check that handles null/undefined properly\n */\n private isEqual(a: any, b: any): boolean {\n // Handle null/undefined cases\n if (a === b) return true;\n if (a == null || b == null) return false;\n \n // For objects/arrays, use JSON comparison\n if (typeof a === 'object' && typeof b === 'object') {\n return JSON.stringify(a) === JSON.stringify(b);\n }\n \n return a === b;\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,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;YACG,mBAAmB;kBAA5B,MAAM;YAEqD,SAAS;kBAApE,SAAS;mBAAC,WAAW,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE;;kFAxD/C,gBAAgB","sourcesContent":["/**\n * @fileoverview Angular component that hosts React components with proper memory management.\n * Provides a bridge between Angular and React ecosystems in MemberJunction applications.\n * @module @memberjunction/ng-react\n */\n\nimport {\n Component,\n Input,\n Output,\n EventEmitter,\n ViewChild,\n ElementRef,\n AfterViewInit,\n OnDestroy,\n ChangeDetectionStrategy,\n ChangeDetectorRef\n} from '@angular/core';\nimport { Subject, takeUntil } from 'rxjs';\nimport { ComponentSpec, ComponentCallbacks, ComponentStyles } from '@memberjunction/interactive-component-types';\nimport { ReactBridgeService } from '../services/react-bridge.service';\nimport { AngularAdapterService } from '../services/angular-adapter.service';\nimport { \n buildComponentProps,\n createErrorBoundary,\n ComponentHierarchyRegistrar,\n HierarchyRegistrationResult\n} from '@memberjunction/react-runtime';\nimport { LogError, CompositeKey, KeyValuePair } from '@memberjunction/core';\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 private _data: any = {};\n @Input() \n set data(value: any) {\n const oldData = this._data;\n this._data = value;\n \n // Only re-render if data actually changed and component is initialized\n if (this.isInitialized && !this.isEqual(oldData, value)) {\n this.renderComponent();\n }\n }\n get data(): any {\n return this._data;\n }\n \n private _state: any = {};\n @Input() \n set state(value: any) {\n const oldState = this._state;\n this._state = value;\n \n // Only update state and re-render if it actually changed\n if (this.isInitialized && !this.isEqual(oldState, value)) {\n this.currentState = { ...value };\n this.renderComponent();\n }\n }\n get state(): any {\n return this._state;\n }\n \n @Input() utilities: any = {};\n @Input() styles?: Partial<ComponentStyles>;\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 reactRoot: any = null;\n private compiledComponent: any = null;\n private destroyed$ = new Subject<void>();\n private currentCallbacks: ComponentCallbacks | null = null;\n private currentState: any = {};\n isInitialized = false;\n private isRendering = false;\n private pendingRender = false;\n private isDestroying = false;\n private renderTimeout: any = null;\n hasError = false;\n\n constructor(\n private reactBridge: ReactBridgeService,\n private adapter: AngularAdapterService,\n private cdr: ChangeDetectorRef\n ) {}\n\n async ngAfterViewInit() {\n // Trigger change detection to show loading state\n this.cdr.detectChanges();\n await this.initializeComponent();\n }\n\n ngOnDestroy() {\n // Set destroying flag immediately\n this.isDestroying = true;\n \n // Cancel any pending renders\n this.pendingRender = false;\n \n this.destroyed$.next();\n this.destroyed$.complete();\n this.cleanup();\n }\n\n\n /**\n * Initialize the React component\n */\n private async initializeComponent() {\n try {\n // Ensure React is loaded\n await this.reactBridge.getReactContext();\n \n // Wait for React to be fully ready (handles first-load delay)\n await this.reactBridge.waitForReactReady();\n \n // Register component hierarchy\n await this.registerComponentHierarchy();\n \n // Compile main component\n const result = await this.adapter.compileComponent({\n componentName: this.component.name,\n componentCode: this.component.code,\n styles: this.styles\n });\n\n if (!result.success) {\n throw new Error(result.error?.message || 'Component compilation failed');\n }\n\n // Get runtime context and execute component factory\n const context = this.adapter.getRuntimeContext();\n this.compiledComponent = result.component!.component(context, this.styles);\n this.currentState = { ...this._state };\n \n // Create React root\n this.reactRoot = this.reactBridge.createRoot(this.container.nativeElement);\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 * Register all components in the hierarchy\n */\n private async registerComponentHierarchy() {\n // Create the hierarchy registrar with adapter's compiler and registry\n const registrar = new ComponentHierarchyRegistrar(\n this.adapter.getCompiler(),\n this.adapter.getRegistry(),\n this.adapter.getRuntimeContext()\n );\n \n // Register the entire hierarchy\n const result: HierarchyRegistrationResult = await registrar.registerHierarchy(\n this.component,\n {\n styles: this.styles as any, // Skip components use SkipComponentStyles which is a superset\n namespace: 'Global',\n version: 'v1'\n }\n );\n \n // Check for errors\n if (!result.success) {\n const errorMessages = result.errors.map(e => \n `${e.componentName}: ${e.error}`\n );\n throw new Error(`Component registration failed: ${errorMessages.join(', ')}`);\n }\n }\n\n /**\n * Render the React component\n */\n private renderComponent() {\n // Don't render if component is being destroyed\n if (this.isDestroying) {\n return;\n }\n \n if (!this.compiledComponent || !this.reactRoot) {\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 // Get components from resolver\n const components = this.adapter.getResolver().resolveComponents(this.component);\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 ...this._data, // Spread data properties directly\n utilities: this.utilities || {},\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 // 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 // Clear any existing render timeout\n if (this.renderTimeout) {\n clearTimeout(this.renderTimeout);\n }\n \n // Render with timeout protection\n this.renderTimeout = setTimeout(() => {\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 }, 5000);\n\n try {\n this.reactRoot.render(element);\n clearTimeout(this.renderTimeout);\n this.renderTimeout = null;\n \n // Reset rendering flag after a microtask to allow React to complete\n Promise.resolve().then(() => {\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 } catch (error) {\n clearTimeout(this.renderTimeout);\n this.renderTimeout = null;\n this.isRendering = false;\n this.handleReactError(error);\n }\n }\n\n /**\n * Create callbacks for the React component\n */\n private createCallbacks(): ComponentCallbacks {\n return {\n OpenEntityRecord: (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 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 // Check if there are actual changes\n const hasChanges = !this.isEqual(this._savedUserSettings, newSettings);\n \n if (!hasChanges) {\n // No actual changes, skip update to prevent infinite loop\n return;\n }\n \n // Update saved settings\n this._savedUserSettings = { ...newSettings };\n \n // Emit user settings changed event\n this.userSettingsChanged.emit({\n settings: this._savedUserSettings,\n componentName: this.component?.name,\n timestamp: new Date()\n });\n \n // Schedule re-render\n this.renderComponent();\n }\n\n /**\n * Clean up resources\n */\n private cleanup() {\n // Clear any pending render timeout\n if (this.renderTimeout) {\n clearTimeout(this.renderTimeout);\n this.renderTimeout = null;\n }\n \n // Clean up prop builder subscriptions\n if (this.currentCallbacks) {\n this.currentCallbacks = null;\n }\n \n // Unmount React root only if not currently rendering\n if (this.reactRoot) {\n // If still rendering, wait for completion before unmounting\n if (this.isRendering) {\n // Force stop rendering\n this.isRendering = false;\n this.pendingRender = false;\n }\n \n this.reactBridge.unmountRoot(this.reactRoot);\n this.reactRoot = null;\n }\n\n // Clear references\n this.compiledComponent = null;\n this.currentState = {};\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 * @param newData - Optional new data to merge\n */\n refresh(newData?: any) {\n if (newData) {\n // Use the setter to trigger change detection\n this.data = { ...this._data, ...newData };\n } else {\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 */\n updateState(path: string, value: any) {\n this.currentState = {\n ...this.currentState,\n [path]: value\n };\n this.stateChange.emit({ path, value });\n this.renderComponent();\n }\n\n /**\n * Deep equality check that handles null/undefined properly\n */\n private isEqual(a: any, b: any): boolean {\n // Handle null/undefined cases\n if (a === b) return true;\n if (a == null || b == null) return false;\n \n // For objects/arrays, use JSON comparison\n if (typeof a === 'object' && typeof b === 'object') {\n return JSON.stringify(a) === JSON.stringify(b);\n }\n \n return a === b;\n }\n}"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentCompiler, ComponentRegistry, ComponentResolver, CompileOptions, RuntimeContext } from '@memberjunction/react-runtime';
|
|
1
|
+
import { ComponentCompiler, ComponentRegistry, ComponentResolver, CompileOptions, RuntimeContext, ExternalLibraryConfig, LibraryConfiguration } from '@memberjunction/react-runtime';
|
|
2
2
|
import { ScriptLoaderService } from './script-loader.service';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
4
|
/**
|
|
@@ -12,9 +12,11 @@ export declare class AngularAdapterService {
|
|
|
12
12
|
constructor(scriptLoader: ScriptLoaderService);
|
|
13
13
|
/**
|
|
14
14
|
* Initialize the React runtime with Angular-specific configuration
|
|
15
|
+
* @param config Optional library configuration
|
|
16
|
+
* @param additionalLibraries Optional additional libraries to merge
|
|
15
17
|
* @returns Promise resolving when runtime is ready
|
|
16
18
|
*/
|
|
17
|
-
initialize(): Promise<void>;
|
|
19
|
+
initialize(config?: LibraryConfiguration, additionalLibraries?: ExternalLibraryConfig[]): Promise<void>;
|
|
18
20
|
/**
|
|
19
21
|
* Get the component compiler
|
|
20
22
|
* @returns Component compiler instance
|
|
@@ -19,14 +19,16 @@ export class AngularAdapterService {
|
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Initialize the React runtime with Angular-specific configuration
|
|
22
|
+
* @param config Optional library configuration
|
|
23
|
+
* @param additionalLibraries Optional additional libraries to merge
|
|
22
24
|
* @returns Promise resolving when runtime is ready
|
|
23
25
|
*/
|
|
24
|
-
async initialize() {
|
|
26
|
+
async initialize(config, additionalLibraries) {
|
|
25
27
|
if (this.runtime) {
|
|
26
28
|
return; // Already initialized
|
|
27
29
|
}
|
|
28
|
-
// Load React ecosystem
|
|
29
|
-
const ecosystem = await this.scriptLoader.loadReactEcosystem();
|
|
30
|
+
// Load React ecosystem with optional additional libraries
|
|
31
|
+
const ecosystem = await this.scriptLoader.loadReactEcosystem(config, additionalLibraries);
|
|
30
32
|
// Create runtime context
|
|
31
33
|
this.runtimeContext = {
|
|
32
34
|
React: ecosystem.React,
|
|
@@ -111,6 +113,24 @@ export class AngularAdapterService {
|
|
|
111
113
|
* @returns Promise resolving to compilation result
|
|
112
114
|
*/
|
|
113
115
|
async compileComponent(options) {
|
|
116
|
+
// Validate options before initialization
|
|
117
|
+
if (!options) {
|
|
118
|
+
throw new Error('Angular adapter error: No compilation options provided.\n' +
|
|
119
|
+
'This usually means the component spec is null or undefined.\n' +
|
|
120
|
+
'Please check that:\n' +
|
|
121
|
+
'1. Your component data is loaded properly\n' +
|
|
122
|
+
'2. The component spec has "name" and "code" properties\n' +
|
|
123
|
+
'3. The component input is not undefined');
|
|
124
|
+
}
|
|
125
|
+
if (!options.componentName || options.componentName.trim() === '') {
|
|
126
|
+
throw new Error('Angular adapter error: Component name is missing or empty.\n' +
|
|
127
|
+
`Received options: ${JSON.stringify(options, null, 2)}\n` +
|
|
128
|
+
'Make sure your component spec includes a "name" property.');
|
|
129
|
+
}
|
|
130
|
+
if (!options.componentCode || options.componentCode.trim() === '') {
|
|
131
|
+
throw new Error(`Angular adapter error: Component code is missing or empty for component "${options.componentName}".\n` +
|
|
132
|
+
'Make sure your component spec includes a "code" property with the React component source.');
|
|
133
|
+
}
|
|
114
134
|
await this.initialize();
|
|
115
135
|
// Apply default styles if not provided
|
|
116
136
|
const optionsWithDefaults = {
|
|
@@ -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,EAInB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;;;AAEnD;;;GAGG;AAEH,MAAM,OAAO,qBAAqB;IAShC,YAAoB,YAAiC;QAAjC,iBAAY,GAAZ,YAAY,CAAqB;IAAG,CAAC;IAEzD;;;OAGG;IACH,KAAK,CAAC,UAA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,KAAK,CAAC,4BAA4B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;sFAvNU,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 ComponentStyles\n} from '@memberjunction/react-runtime';\nimport { ScriptLoaderService } from './script-loader.service';\nimport { DEFAULT_STYLES } from '../default-styles';\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 * @returns Promise resolving when runtime is ready\n */\n async initialize(): Promise<void> {\n if (this.runtime) {\n return; // Already initialized\n }\n\n // Load React ecosystem\n const ecosystem = await this.scriptLoader.loadReactEcosystem();\n \n // Create runtime context\n this.runtimeContext = {\n React: ecosystem.React,\n ReactDOM: ecosystem.ReactDOM,\n libraries: ecosystem.libraries,\n utilities: {\n // Add any Angular-specific utilities here\n }\n };\n\n // Create the React runtime\n this.runtime = createReactRuntime(ecosystem.Babel, {\n compiler: {\n cache: true,\n maxCacheSize: 100\n },\n registry: {\n maxComponents: 1000,\n cleanupInterval: 60000,\n useLRU: true,\n enableNamespaces: true\n }\n });\n }\n\n /**\n * Get the component compiler\n * @returns Component compiler instance\n */\n getCompiler(): ComponentCompiler {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.compiler;\n }\n\n /**\n * Get the component registry\n * @returns Component registry instance\n */\n getRegistry(): ComponentRegistry {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.registry;\n }\n\n /**\n * Get the component resolver\n * @returns Component resolver instance\n */\n getResolver(): ComponentResolver {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.resolver;\n }\n\n /**\n * Get the runtime context\n * @returns Runtime context with React and libraries\n */\n getRuntimeContext(): RuntimeContext {\n if (!this.runtimeContext) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtimeContext;\n }\n\n /**\n * Convert SkipComponentStyles to ComponentStyles\n * @param skipStyles - Skip component styles\n * @returns Component styles for React runtime\n */\n private convertStyles(skipStyles?: any): ComponentStyles | undefined {\n if (!skipStyles) return undefined;\n \n // Extract CSS-compatible properties\n return {\n className: skipStyles.className,\n style: skipStyles.style,\n globalCss: skipStyles.globalCss\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 & { styles?: any }) {\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,EAMnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;;;AAEnD;;;GAGG;AAEH,MAAM,OAAO,qBAAqB;IAShC,YAAoB,YAAiC;QAAjC,iBAAY,GAAZ,YAAY,CAAqB;IAAG,CAAC;IAEzD;;;;;OAKG;IACH,KAAK,CAAC,UAAU,CACd,MAA6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CAAC;YAChC,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;YACzB,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;QAClC,CAAC;IACH,CAAC;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;sFAvPU,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 ComponentStyles,\n ExternalLibraryConfig,\n LibraryConfiguration\n} from '@memberjunction/react-runtime';\nimport { ScriptLoaderService } from './script-loader.service';\nimport { DEFAULT_STYLES } from '../default-styles';\n\n/**\n * Angular-specific adapter for the React runtime.\n * Manages the integration between Angular services and the platform-agnostic React runtime.\n */\n@Injectable({ providedIn: 'root' })\nexport class AngularAdapterService {\n private runtime?: {\n compiler: ComponentCompiler;\n registry: ComponentRegistry;\n resolver: ComponentResolver;\n version: string;\n };\n private runtimeContext?: RuntimeContext;\n\n constructor(private scriptLoader: ScriptLoaderService) {}\n\n /**\n * Initialize the React runtime with Angular-specific configuration\n * @param config Optional library configuration\n * @param additionalLibraries Optional additional libraries to merge\n * @returns Promise resolving when runtime is ready\n */\n async initialize(\n config?: LibraryConfiguration,\n additionalLibraries?: ExternalLibraryConfig[]\n ): Promise<void> {\n if (this.runtime) {\n return; // Already initialized\n }\n\n // Load React ecosystem with optional additional libraries\n const ecosystem = await this.scriptLoader.loadReactEcosystem(config, additionalLibraries);\n \n // Create runtime context\n this.runtimeContext = {\n React: ecosystem.React,\n ReactDOM: ecosystem.ReactDOM,\n libraries: ecosystem.libraries,\n utilities: {\n // Add any Angular-specific utilities here\n }\n };\n\n // Create the React runtime\n this.runtime = createReactRuntime(ecosystem.Babel, {\n compiler: {\n cache: true,\n maxCacheSize: 100\n },\n registry: {\n maxComponents: 1000,\n cleanupInterval: 60000,\n useLRU: true,\n enableNamespaces: true\n }\n });\n }\n\n /**\n * Get the component compiler\n * @returns Component compiler instance\n */\n getCompiler(): ComponentCompiler {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.compiler;\n }\n\n /**\n * Get the component registry\n * @returns Component registry instance\n */\n getRegistry(): ComponentRegistry {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.registry;\n }\n\n /**\n * Get the component resolver\n * @returns Component resolver instance\n */\n getResolver(): ComponentResolver {\n if (!this.runtime) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtime.resolver;\n }\n\n /**\n * Get the runtime context\n * @returns Runtime context with React and libraries\n */\n getRuntimeContext(): RuntimeContext {\n if (!this.runtimeContext) {\n throw new Error('React runtime not initialized. Call initialize() first.');\n }\n return this.runtimeContext;\n }\n\n /**\n * Convert SkipComponentStyles to ComponentStyles\n * @param skipStyles - Skip component styles\n * @returns Component styles for React runtime\n */\n private convertStyles(skipStyles?: any): ComponentStyles | undefined {\n if (!skipStyles) return undefined;\n \n // Extract CSS-compatible properties\n return {\n className: skipStyles.className,\n style: skipStyles.style,\n globalCss: skipStyles.globalCss\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 & { styles?: any }) {\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}"]}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* @module @memberjunction/ng-react
|
|
5
5
|
*/
|
|
6
6
|
import { OnDestroy } from '@angular/core';
|
|
7
|
+
import { LibraryConfiguration, ExternalLibraryConfig } from '@memberjunction/react-runtime';
|
|
7
8
|
import * as i0 from "@angular/core";
|
|
8
9
|
/**
|
|
9
10
|
* Service for loading external scripts and CSS with proper cleanup.
|
|
@@ -37,9 +38,11 @@ export declare class ScriptLoaderService implements OnDestroy {
|
|
|
37
38
|
loadCSS(url: string): void;
|
|
38
39
|
/**
|
|
39
40
|
* Load common React libraries and UI frameworks
|
|
41
|
+
* @param config Optional library configuration
|
|
42
|
+
* @param additionalLibraries Optional additional libraries to merge
|
|
40
43
|
* @returns Promise resolving to React ecosystem objects
|
|
41
44
|
*/
|
|
42
|
-
loadReactEcosystem(): Promise<{
|
|
45
|
+
loadReactEcosystem(config?: LibraryConfiguration, additionalLibraries?: ExternalLibraryConfig[]): Promise<{
|
|
43
46
|
React: any;
|
|
44
47
|
ReactDOM: any;
|
|
45
48
|
Babel: any;
|
|
@@ -91,11 +91,13 @@ export class ScriptLoaderService {
|
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
93
|
* Load common React libraries and UI frameworks
|
|
94
|
+
* @param config Optional library configuration
|
|
95
|
+
* @param additionalLibraries Optional additional libraries to merge
|
|
94
96
|
* @returns Promise resolving to React ecosystem objects
|
|
95
97
|
*/
|
|
96
|
-
async loadReactEcosystem() {
|
|
98
|
+
async loadReactEcosystem(config, additionalLibraries) {
|
|
97
99
|
// Use the new LibraryLoader from react-runtime for consistency
|
|
98
|
-
const result = await LibraryLoader.loadAllLibraries();
|
|
100
|
+
const result = await LibraryLoader.loadAllLibraries(config, additionalLibraries);
|
|
99
101
|
// The LibraryLoader handles all the loading, but we need to ensure
|
|
100
102
|
// ReactDOM.createRoot is available for Angular's specific needs
|
|
101
103
|
// The ReactBridgeService will handle the delayed validation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script-loader.service.js","sourceRoot":"","sources":["../../../src/lib/services/script-loader.service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AACtD,OAAO,EAKL,aAAa,EACd,MAAM,+BAA+B,CAAC;;AAUvC;;;GAGG;AAEH,MAAM,OAAO,mBAAmB;IADhC;QAEU,oBAAe,GAAG,IAAI,GAAG,EAAwB,CAAC;QACzC,qBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;KA6XvD;IA3XC,WAAW;QACT,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,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AmB;cAD/B,UAAU;eAAC,EAAE,UAAU,EAAE,MAAM,EAAE","sourcesContent":["/**\n * @fileoverview Service for loading external scripts and CSS in Angular applications.\n * Manages the lifecycle of dynamically loaded resources with proper cleanup.\n * @module @memberjunction/ng-react\n */\n\nimport { Injectable, OnDestroy } from '@angular/core';\nimport { \n STANDARD_LIBRARY_URLS,\n getCoreLibraryUrls,\n getUILibraryUrls,\n getCSSUrls,\n LibraryLoader\n} from '@memberjunction/react-runtime';\n\n/**\n * Represents a loaded script or CSS resource\n */\ninterface LoadedScript {\n element: HTMLScriptElement | HTMLLinkElement;\n promise: Promise<any>;\n}\n\n/**\n * Service for loading external scripts and CSS with proper cleanup.\n * Provides methods to dynamically load React and related libraries from CDN.\n */\n@Injectable({ providedIn: 'root' })\nexport class ScriptLoaderService implements OnDestroy {\n private loadedResources = new Map<string, LoadedScript>();\n private readonly cleanupOnDestroy = new Set<string>();\n\n ngOnDestroy(): void {\n this.cleanup();\n }\n\n /**\n * Load a script from URL with automatic cleanup tracking\n * @param url - Script URL to load\n * @param globalName - Expected global variable name\n * @param autoCleanup - Whether to cleanup on service destroy\n * @returns Promise resolving to the global object\n */\n async loadScript(url: string, globalName: string, autoCleanup = false): Promise<any> {\n const existing = this.loadedResources.get(url);\n if (existing) {\n return existing.promise;\n }\n\n const promise = this.createScriptPromise(url, globalName);\n const element = document.querySelector(`script[src=\"${url}\"]`) as HTMLScriptElement;\n \n if (element) {\n this.loadedResources.set(url, { element, promise });\n if (autoCleanup) {\n this.cleanupOnDestroy.add(url);\n }\n }\n\n return promise;\n }\n\n /**\n * Load a script with additional validation function\n * @param url - Script URL to load\n * @param globalName - Expected global variable name\n * @param validator - Function to validate the loaded object\n * @param autoCleanup - Whether to cleanup on service destroy\n * @returns Promise resolving to the validated global object\n */\n async loadScriptWithValidation(\n url: string, \n globalName: string, \n validator: (obj: any) => boolean,\n autoCleanup = false\n ): Promise<any> {\n const existing = this.loadedResources.get(url);\n if (existing) {\n const obj = await existing.promise;\n // Re-validate even for cached resources\n if (!validator(obj)) {\n throw new Error(`${globalName} loaded but failed validation`);\n }\n return obj;\n }\n\n const promise = this.createScriptPromiseWithValidation(url, globalName, validator);\n const element = document.querySelector(`script[src=\"${url}\"]`) as HTMLScriptElement;\n \n if (element) {\n this.loadedResources.set(url, { element, promise });\n if (autoCleanup) {\n this.cleanupOnDestroy.add(url);\n }\n }\n\n return promise;\n }\n\n /**\n * Load CSS from URL\n * @param url - CSS URL to load\n */\n loadCSS(url: string): void {\n if (this.loadedResources.has(url)) {\n return;\n }\n\n const existingLink = document.querySelector(`link[href=\"${url}\"]`);\n if (existingLink) {\n return;\n }\n\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = url;\n document.head.appendChild(link);\n\n this.loadedResources.set(url, {\n element: link,\n promise: Promise.resolve()\n });\n }\n\n /**\n * Load common React libraries and UI frameworks\n * @returns Promise resolving to React ecosystem objects\n */\n async loadReactEcosystem(): Promise<{\n React: any;\n ReactDOM: any;\n Babel: any;\n libraries: any;\n }> {\n // Use the new LibraryLoader from react-runtime for consistency\n const result = await LibraryLoader.loadAllLibraries();\n \n // The LibraryLoader handles all the loading, but we need to ensure\n // ReactDOM.createRoot is available for Angular's specific needs\n // The ReactBridgeService will handle the delayed validation\n \n // Track loaded resources for cleanup\n LibraryLoader.getLoadedResources().forEach((resource, url) => {\n this.loadedResources.set(url, resource);\n });\n \n return result;\n }\n\n /**\n * Get library name from URL for global variable mapping\n * @param url - Library URL\n * @returns Global variable name\n */\n private getLibraryNameFromUrl(url: string): string {\n // Map known URLs to their global variable names\n if (url.includes('lodash')) return '_';\n if (url.includes('d3')) return 'd3';\n if (url.includes('Chart.js') || url.includes('chart')) return 'Chart';\n if (url.includes('dayjs')) return 'dayjs';\n if (url.includes('antd')) return 'antd';\n if (url.includes('react-bootstrap')) return 'ReactBootstrap';\n if (url.includes('react-dom')) return 'ReactDOM';\n if (url.includes('react')) return 'React';\n if (url.includes('babel')) return 'Babel';\n \n // Default: extract library name from filename\n const match = url.match(/\\/([^/]+?)(?:\\.min)?\\.js$/i);\n return match ? match[1] : 'UnknownLibrary';\n }\n\n /**\n * Remove a specific loaded resource\n * @param url - URL of resource to remove\n */\n removeResource(url: string): void {\n const resource = this.loadedResources.get(url);\n if (resource?.element && resource.element.parentNode) {\n resource.element.parentNode.removeChild(resource.element);\n }\n this.loadedResources.delete(url);\n this.cleanupOnDestroy.delete(url);\n }\n\n /**\n * Clean up all resources marked for auto-cleanup\n */\n private cleanup(): void {\n for (const url of this.cleanupOnDestroy) {\n this.removeResource(url);\n }\n this.cleanupOnDestroy.clear();\n }\n\n /**\n * Create a promise that resolves when script loads\n * @param url - Script URL\n * @param globalName - Expected global variable\n * @returns Promise resolving to global object\n */\n private createScriptPromise(url: string, globalName: string): Promise<any> {\n return new Promise((resolve, reject) => {\n // Check if already loaded\n if ((window as any)[globalName]) {\n resolve((window as any)[globalName]);\n return;\n }\n\n // Check if script tag exists\n const existingScript = document.querySelector(`script[src=\"${url}\"]`);\n if (existingScript) {\n this.waitForScriptLoad(existingScript as HTMLScriptElement, globalName, resolve, reject);\n return;\n }\n\n // Create new script\n const script = document.createElement('script');\n script.src = url;\n script.async = true;\n\n script.onload = () => {\n const global = (window as any)[globalName];\n if (global) {\n resolve(global);\n } else {\n reject(new Error(`${globalName} not found after script load`));\n }\n };\n\n script.onerror = () => {\n reject(new Error(`Failed to load script: ${url}`));\n };\n\n document.head.appendChild(script);\n this.loadedResources.set(url, { element: script, promise: Promise.resolve() });\n });\n }\n\n /**\n * Create a promise that resolves when script loads and passes validation\n * @param url - Script URL\n * @param globalName - Expected global variable\n * @param validator - Validation function\n * @returns Promise resolving to validated global object\n */\n private createScriptPromiseWithValidation(\n url: string, \n globalName: string, \n validator: (obj: any) => boolean\n ): Promise<any> {\n return new Promise((resolve, reject) => {\n // Check if already loaded and valid\n const existingGlobal = (window as any)[globalName];\n if (existingGlobal && validator(existingGlobal)) {\n resolve(existingGlobal);\n return;\n }\n\n // Check if script tag exists\n const existingScript = document.querySelector(`script[src=\"${url}\"]`);\n if (existingScript) {\n this.waitForScriptLoadWithValidation(\n existingScript as HTMLScriptElement, \n globalName, \n validator,\n resolve, \n reject\n );\n return;\n }\n\n // Create new script\n const script = document.createElement('script');\n script.src = url;\n script.async = true;\n\n script.onload = () => {\n this.waitForValidation(globalName, validator, resolve, reject);\n };\n\n script.onerror = () => {\n reject(new Error(`Failed to load script: ${url}`));\n };\n\n document.head.appendChild(script);\n this.loadedResources.set(url, { element: script, promise: Promise.resolve() });\n });\n }\n\n /**\n * Wait for global object to be available and valid\n * @param globalName - Global variable name\n * @param validator - Validation function\n * @param resolve - Promise resolve function\n * @param reject - Promise reject function\n * @param attempts - Current attempt number\n * @param maxAttempts - Maximum attempts before failing\n */\n private waitForValidation(\n globalName: string,\n validator: (obj: any) => boolean,\n resolve: (value: any) => void,\n reject: (reason: any) => void,\n attempts = 0,\n maxAttempts = 50 // 5 seconds total with 100ms intervals\n ): void {\n const global = (window as any)[globalName];\n \n if (global && validator(global)) {\n resolve(global);\n return;\n }\n\n if (attempts >= maxAttempts) {\n if (global) {\n reject(new Error(`${globalName} loaded but validation failed after ${maxAttempts} attempts`));\n } else {\n reject(new Error(`${globalName} not found after ${maxAttempts} attempts`));\n }\n return;\n }\n\n // Retry with exponential backoff for first few attempts, then fixed interval\n const delay = attempts < 5 ? Math.min(100 * Math.pow(1.5, attempts), 500) : 100;\n setTimeout(() => {\n this.waitForValidation(globalName, validator, resolve, reject, attempts + 1, maxAttempts);\n }, delay);\n }\n\n /**\n * Wait for existing script to load\n * @param script - Script element\n * @param globalName - Expected global variable\n * @param resolve - Promise resolve function\n * @param reject - Promise reject function\n */\n private waitForScriptLoad(\n script: HTMLScriptElement,\n globalName: string,\n resolve: (value: any) => void,\n reject: (reason: any) => void\n ): void {\n const checkGlobal = () => {\n if ((window as any)[globalName]) {\n resolve((window as any)[globalName]);\n return;\n }\n // Give it a moment for the global to be defined\n setTimeout(() => {\n if ((window as any)[globalName]) {\n resolve((window as any)[globalName]);\n } else {\n reject(new Error(`${globalName} not found after script load`));\n }\n }, 100);\n };\n\n if ('readyState' in script) {\n // IE support\n (script as any).onreadystatechange = () => {\n if ((script as any).readyState === 'loaded' || (script as any).readyState === 'complete') {\n (script as any).onreadystatechange = null;\n checkGlobal();\n }\n };\n } else {\n // Modern browsers\n const loadHandler = () => {\n script.removeEventListener('load', loadHandler);\n checkGlobal();\n };\n script.addEventListener('load', loadHandler);\n }\n }\n\n /**\n * Wait for existing script to load with validation\n * @param script - Script element\n * @param globalName - Expected global variable\n * @param validator - Validation function\n * @param resolve - Promise resolve function\n * @param reject - Promise reject function\n */\n private waitForScriptLoadWithValidation(\n script: HTMLScriptElement,\n globalName: string,\n validator: (obj: any) => boolean,\n resolve: (value: any) => void,\n reject: (reason: any) => void\n ): void {\n const checkGlobal = () => {\n this.waitForValidation(globalName, validator, resolve, reject);\n };\n\n if ('readyState' in script) {\n // IE support\n (script as any).onreadystatechange = () => {\n if ((script as any).readyState === 'loaded' || (script as any).readyState === 'complete') {\n (script as any).onreadystatechange = null;\n checkGlobal();\n }\n };\n } else {\n // Modern browsers\n const loadHandler = () => {\n script.removeEventListener('load', loadHandler);\n checkGlobal();\n };\n script.addEventListener('load', loadHandler);\n }\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"script-loader.service.js","sourceRoot":"","sources":["../../../src/lib/services/script-loader.service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AACtD,OAAO,EACL,aAAa,EAGd,MAAM,+BAA+B,CAAC;;AAUvC;;;GAGG;AAEH,MAAM,OAAO,mBAAmB;IADhC;QAEU,oBAAe,GAAG,IAAI,GAAG,EAAwB,CAAC;QACzC,qBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;KAkYvD;IAhYC,WAAW;QACT,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED;;;;;;OAMG;IACH,K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AmB,mBADN,MAAM;;iFACnB,mBAAmB;cAD/B,UAAU;eAAC,EAAE,UAAU,EAAE,MAAM,EAAE","sourcesContent":["/**\n * @fileoverview Service for loading external scripts and CSS in Angular applications.\n * Manages the lifecycle of dynamically loaded resources with proper cleanup.\n * @module @memberjunction/ng-react\n */\n\nimport { Injectable, OnDestroy } from '@angular/core';\nimport { \n LibraryLoader,\n LibraryConfiguration,\n ExternalLibraryConfig\n} from '@memberjunction/react-runtime';\n\n/**\n * Represents a loaded script or CSS resource\n */\ninterface LoadedScript {\n element: HTMLScriptElement | HTMLLinkElement;\n promise: Promise<any>;\n}\n\n/**\n * Service for loading external scripts and CSS with proper cleanup.\n * Provides methods to dynamically load React and related libraries from CDN.\n */\n@Injectable({ providedIn: 'root' })\nexport class ScriptLoaderService implements OnDestroy {\n private loadedResources = new Map<string, LoadedScript>();\n private readonly cleanupOnDestroy = new Set<string>();\n\n ngOnDestroy(): void {\n this.cleanup();\n }\n\n /**\n * Load a script from URL with automatic cleanup tracking\n * @param url - Script URL to load\n * @param globalName - Expected global variable name\n * @param autoCleanup - Whether to cleanup on service destroy\n * @returns Promise resolving to the global object\n */\n async loadScript(url: string, globalName: string, autoCleanup = false): Promise<any> {\n const existing = this.loadedResources.get(url);\n if (existing) {\n return existing.promise;\n }\n\n const promise = this.createScriptPromise(url, globalName);\n const element = document.querySelector(`script[src=\"${url}\"]`) as HTMLScriptElement;\n \n if (element) {\n this.loadedResources.set(url, { element, promise });\n if (autoCleanup) {\n this.cleanupOnDestroy.add(url);\n }\n }\n\n return promise;\n }\n\n /**\n * Load a script with additional validation function\n * @param url - Script URL to load\n * @param globalName - Expected global variable name\n * @param validator - Function to validate the loaded object\n * @param autoCleanup - Whether to cleanup on service destroy\n * @returns Promise resolving to the validated global object\n */\n async loadScriptWithValidation(\n url: string, \n globalName: string, \n validator: (obj: any) => boolean,\n autoCleanup = false\n ): Promise<any> {\n const existing = this.loadedResources.get(url);\n if (existing) {\n const obj = await existing.promise;\n // Re-validate even for cached resources\n if (!validator(obj)) {\n throw new Error(`${globalName} loaded but failed validation`);\n }\n return obj;\n }\n\n const promise = this.createScriptPromiseWithValidation(url, globalName, validator);\n const element = document.querySelector(`script[src=\"${url}\"]`) as HTMLScriptElement;\n \n if (element) {\n this.loadedResources.set(url, { element, promise });\n if (autoCleanup) {\n this.cleanupOnDestroy.add(url);\n }\n }\n\n return promise;\n }\n\n /**\n * Load CSS from URL\n * @param url - CSS URL to load\n */\n loadCSS(url: string): void {\n if (this.loadedResources.has(url)) {\n return;\n }\n\n const existingLink = document.querySelector(`link[href=\"${url}\"]`);\n if (existingLink) {\n return;\n }\n\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = url;\n document.head.appendChild(link);\n\n this.loadedResources.set(url, {\n element: link,\n promise: Promise.resolve()\n });\n }\n\n /**\n * Load common React libraries and UI frameworks\n * @param config Optional library configuration\n * @param additionalLibraries Optional additional libraries to merge\n * @returns Promise resolving to React ecosystem objects\n */\n async loadReactEcosystem(\n config?: LibraryConfiguration,\n additionalLibraries?: ExternalLibraryConfig[]\n ): Promise<{\n React: any;\n ReactDOM: any;\n Babel: any;\n libraries: any;\n }> {\n // Use the new LibraryLoader from react-runtime for consistency\n const result = await LibraryLoader.loadAllLibraries(config, additionalLibraries);\n \n // The LibraryLoader handles all the loading, but we need to ensure\n // ReactDOM.createRoot is available for Angular's specific needs\n // The ReactBridgeService will handle the delayed validation\n \n // Track loaded resources for cleanup\n LibraryLoader.getLoadedResources().forEach((resource, url) => {\n this.loadedResources.set(url, resource);\n });\n \n return result;\n }\n\n /**\n * Get library name from URL for global variable mapping\n * @param url - Library URL\n * @returns Global variable name\n */\n private getLibraryNameFromUrl(url: string): string {\n // Map known URLs to their global variable names\n if (url.includes('lodash')) return '_';\n if (url.includes('d3')) return 'd3';\n if (url.includes('Chart.js') || url.includes('chart')) return 'Chart';\n if (url.includes('dayjs')) return 'dayjs';\n if (url.includes('antd')) return 'antd';\n if (url.includes('react-bootstrap')) return 'ReactBootstrap';\n if (url.includes('react-dom')) return 'ReactDOM';\n if (url.includes('react')) return 'React';\n if (url.includes('babel')) return 'Babel';\n \n // Default: extract library name from filename\n const match = url.match(/\\/([^/]+?)(?:\\.min)?\\.js$/i);\n return match ? match[1] : 'UnknownLibrary';\n }\n\n /**\n * Remove a specific loaded resource\n * @param url - URL of resource to remove\n */\n removeResource(url: string): void {\n const resource = this.loadedResources.get(url);\n if (resource?.element && resource.element.parentNode) {\n resource.element.parentNode.removeChild(resource.element);\n }\n this.loadedResources.delete(url);\n this.cleanupOnDestroy.delete(url);\n }\n\n /**\n * Clean up all resources marked for auto-cleanup\n */\n private cleanup(): void {\n for (const url of this.cleanupOnDestroy) {\n this.removeResource(url);\n }\n this.cleanupOnDestroy.clear();\n }\n\n /**\n * Create a promise that resolves when script loads\n * @param url - Script URL\n * @param globalName - Expected global variable\n * @returns Promise resolving to global object\n */\n private createScriptPromise(url: string, globalName: string): Promise<any> {\n return new Promise((resolve, reject) => {\n // Check if already loaded\n if ((window as any)[globalName]) {\n resolve((window as any)[globalName]);\n return;\n }\n\n // Check if script tag exists\n const existingScript = document.querySelector(`script[src=\"${url}\"]`);\n if (existingScript) {\n this.waitForScriptLoad(existingScript as HTMLScriptElement, globalName, resolve, reject);\n return;\n }\n\n // Create new script\n const script = document.createElement('script');\n script.src = url;\n script.async = true;\n\n script.onload = () => {\n const global = (window as any)[globalName];\n if (global) {\n resolve(global);\n } else {\n reject(new Error(`${globalName} not found after script load`));\n }\n };\n\n script.onerror = () => {\n reject(new Error(`Failed to load script: ${url}`));\n };\n\n document.head.appendChild(script);\n this.loadedResources.set(url, { element: script, promise: Promise.resolve() });\n });\n }\n\n /**\n * Create a promise that resolves when script loads and passes validation\n * @param url - Script URL\n * @param globalName - Expected global variable\n * @param validator - Validation function\n * @returns Promise resolving to validated global object\n */\n private createScriptPromiseWithValidation(\n url: string, \n globalName: string, \n validator: (obj: any) => boolean\n ): Promise<any> {\n return new Promise((resolve, reject) => {\n // Check if already loaded and valid\n const existingGlobal = (window as any)[globalName];\n if (existingGlobal && validator(existingGlobal)) {\n resolve(existingGlobal);\n return;\n }\n\n // Check if script tag exists\n const existingScript = document.querySelector(`script[src=\"${url}\"]`);\n if (existingScript) {\n this.waitForScriptLoadWithValidation(\n existingScript as HTMLScriptElement, \n globalName, \n validator,\n resolve, \n reject\n );\n return;\n }\n\n // Create new script\n const script = document.createElement('script');\n script.src = url;\n script.async = true;\n\n script.onload = () => {\n this.waitForValidation(globalName, validator, resolve, reject);\n };\n\n script.onerror = () => {\n reject(new Error(`Failed to load script: ${url}`));\n };\n\n document.head.appendChild(script);\n this.loadedResources.set(url, { element: script, promise: Promise.resolve() });\n });\n }\n\n /**\n * Wait for global object to be available and valid\n * @param globalName - Global variable name\n * @param validator - Validation function\n * @param resolve - Promise resolve function\n * @param reject - Promise reject function\n * @param attempts - Current attempt number\n * @param maxAttempts - Maximum attempts before failing\n */\n private waitForValidation(\n globalName: string,\n validator: (obj: any) => boolean,\n resolve: (value: any) => void,\n reject: (reason: any) => void,\n attempts = 0,\n maxAttempts = 50 // 5 seconds total with 100ms intervals\n ): void {\n const global = (window as any)[globalName];\n \n if (global && validator(global)) {\n resolve(global);\n return;\n }\n\n if (attempts >= maxAttempts) {\n if (global) {\n reject(new Error(`${globalName} loaded but validation failed after ${maxAttempts} attempts`));\n } else {\n reject(new Error(`${globalName} not found after ${maxAttempts} attempts`));\n }\n return;\n }\n\n // Retry with exponential backoff for first few attempts, then fixed interval\n const delay = attempts < 5 ? Math.min(100 * Math.pow(1.5, attempts), 500) : 100;\n setTimeout(() => {\n this.waitForValidation(globalName, validator, resolve, reject, attempts + 1, maxAttempts);\n }, delay);\n }\n\n /**\n * Wait for existing script to load\n * @param script - Script element\n * @param globalName - Expected global variable\n * @param resolve - Promise resolve function\n * @param reject - Promise reject function\n */\n private waitForScriptLoad(\n script: HTMLScriptElement,\n globalName: string,\n resolve: (value: any) => void,\n reject: (reason: any) => void\n ): void {\n const checkGlobal = () => {\n if ((window as any)[globalName]) {\n resolve((window as any)[globalName]);\n return;\n }\n // Give it a moment for the global to be defined\n setTimeout(() => {\n if ((window as any)[globalName]) {\n resolve((window as any)[globalName]);\n } else {\n reject(new Error(`${globalName} not found after script load`));\n }\n }, 100);\n };\n\n if ('readyState' in script) {\n // IE support\n (script as any).onreadystatechange = () => {\n if ((script as any).readyState === 'loaded' || (script as any).readyState === 'complete') {\n (script as any).onreadystatechange = null;\n checkGlobal();\n }\n };\n } else {\n // Modern browsers\n const loadHandler = () => {\n script.removeEventListener('load', loadHandler);\n checkGlobal();\n };\n script.addEventListener('load', loadHandler);\n }\n }\n\n /**\n * Wait for existing script to load with validation\n * @param script - Script element\n * @param globalName - Expected global variable\n * @param validator - Validation function\n * @param resolve - Promise resolve function\n * @param reject - Promise reject function\n */\n private waitForScriptLoadWithValidation(\n script: HTMLScriptElement,\n globalName: string,\n validator: (obj: any) => boolean,\n resolve: (value: any) => void,\n reject: (reason: any) => void\n ): void {\n const checkGlobal = () => {\n this.waitForValidation(globalName, validator, resolve, reject);\n };\n\n if ('readyState' in script) {\n // IE support\n (script as any).onreadystatechange = () => {\n if ((script as any).readyState === 'loaded' || (script as any).readyState === 'complete') {\n (script as any).onreadystatechange = null;\n checkGlobal();\n }\n };\n } else {\n // Modern browsers\n const loadHandler = () => {\n script.removeEventListener('load', loadHandler);\n checkGlobal();\n };\n script.addEventListener('load', loadHandler);\n }\n }\n}"]}
|
package/dist/public-api.d.ts
CHANGED
|
@@ -8,6 +8,5 @@ export * from './lib/components/mj-react-component.component';
|
|
|
8
8
|
export * from './lib/services/script-loader.service';
|
|
9
9
|
export * from './lib/services/react-bridge.service';
|
|
10
10
|
export * from './lib/services/angular-adapter.service';
|
|
11
|
-
export { STANDARD_LIBRARY_URLS, getCoreLibraryUrls, getUILibraryUrls, getCSSUrls } from '@memberjunction/react-runtime';
|
|
12
11
|
export * from './lib/default-styles';
|
|
13
12
|
export { ComponentProps, ComponentCallbacks, ComponentStyles, ComponentError, CompileOptions, CompilationResult } from '@memberjunction/react-runtime';
|
package/dist/public-api.js
CHANGED
|
@@ -12,7 +12,5 @@ export * from './lib/services/script-loader.service';
|
|
|
12
12
|
export * from './lib/services/react-bridge.service';
|
|
13
13
|
export * from './lib/services/angular-adapter.service';
|
|
14
14
|
// Constants
|
|
15
|
-
// CDN URLs are now provided by @memberjunction/react-runtime
|
|
16
|
-
export { STANDARD_LIBRARY_URLS, getCoreLibraryUrls, getUILibraryUrls, getCSSUrls } from '@memberjunction/react-runtime';
|
|
17
15
|
export * from './lib/default-styles';
|
|
18
16
|
//# sourceMappingURL=public-api.js.map
|
package/dist/public-api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public-api.js","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,SAAS;AACT,cAAc,cAAc,CAAC;AAE7B,aAAa;AACb,cAAc,+CAA+C,CAAC;AAE9D,WAAW;AACX,cAAc,sCAAsC,CAAC;AACrD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AAEvD,YAAY;AACZ,
|
|
1
|
+
{"version":3,"file":"public-api.js","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,SAAS;AACT,cAAc,cAAc,CAAC;AAE7B,aAAa;AACb,cAAc,+CAA+C,CAAC;AAE9D,WAAW;AACX,cAAc,sCAAsC,CAAC;AACrD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AAEvD,YAAY;AACZ,cAAc,sBAAsB,CAAC","sourcesContent":["/**\n * @fileoverview Public API Surface of @memberjunction/ng-react\n * This file exports all public APIs from the Angular React integration library.\n * @module @memberjunction/ng-react\n */\n\n// Module\nexport * from './lib/module';\n\n// Components\nexport * from './lib/components/mj-react-component.component';\n\n// Services\nexport * from './lib/services/script-loader.service';\nexport * from './lib/services/react-bridge.service';\nexport * from './lib/services/angular-adapter.service';\n\n// Constants\nexport * from './lib/default-styles';\n\n// Re-export useful types from react-runtime for convenience\nexport { \n ComponentProps,\n ComponentCallbacks,\n ComponentStyles,\n ComponentError,\n CompileOptions,\n CompilationResult\n} from '@memberjunction/react-runtime';"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.76.0",
|
|
4
4
|
"description": "Angular components for hosting React components in MemberJunction applications",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "ngc -p tsconfig.json",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"styles"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@memberjunction/core": "2.
|
|
44
|
-
"@memberjunction/react-runtime": "2.
|
|
45
|
-
"@memberjunction/interactive-component-types": "^2.
|
|
43
|
+
"@memberjunction/core": "2.76.0",
|
|
44
|
+
"@memberjunction/react-runtime": "2.76.0",
|
|
45
|
+
"@memberjunction/interactive-component-types": "^2.76.0",
|
|
46
46
|
"@angular/common": ">=18.0.0",
|
|
47
47
|
"@angular/core": ">=18.0.0",
|
|
48
48
|
"@angular/platform-browser": ">=18.0.0",
|