@memberjunction/ng-react 2.70.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.
@@ -0,0 +1,101 @@
1
+ /**
2
+ * @fileoverview Service for loading external scripts and CSS in Angular applications.
3
+ * Manages the lifecycle of dynamically loaded resources with proper cleanup.
4
+ * @module @memberjunction/ng-react
5
+ */
6
+ import { OnDestroy } from '@angular/core';
7
+ import * as i0 from "@angular/core";
8
+ /**
9
+ * Service for loading external scripts and CSS with proper cleanup.
10
+ * Provides methods to dynamically load React and related libraries from CDN.
11
+ */
12
+ export declare class ScriptLoaderService implements OnDestroy {
13
+ private loadedResources;
14
+ private readonly cleanupOnDestroy;
15
+ ngOnDestroy(): void;
16
+ /**
17
+ * Load a script from URL with automatic cleanup tracking
18
+ * @param url - Script URL to load
19
+ * @param globalName - Expected global variable name
20
+ * @param autoCleanup - Whether to cleanup on service destroy
21
+ * @returns Promise resolving to the global object
22
+ */
23
+ loadScript(url: string, globalName: string, autoCleanup?: boolean): Promise<any>;
24
+ /**
25
+ * Load a script with additional validation function
26
+ * @param url - Script URL to load
27
+ * @param globalName - Expected global variable name
28
+ * @param validator - Function to validate the loaded object
29
+ * @param autoCleanup - Whether to cleanup on service destroy
30
+ * @returns Promise resolving to the validated global object
31
+ */
32
+ loadScriptWithValidation(url: string, globalName: string, validator: (obj: any) => boolean, autoCleanup?: boolean): Promise<any>;
33
+ /**
34
+ * Load CSS from URL
35
+ * @param url - CSS URL to load
36
+ */
37
+ loadCSS(url: string): void;
38
+ /**
39
+ * Load common React libraries and UI frameworks
40
+ * @returns Promise resolving to React ecosystem objects
41
+ */
42
+ loadReactEcosystem(): Promise<{
43
+ React: any;
44
+ ReactDOM: any;
45
+ Babel: any;
46
+ libraries: any;
47
+ }>;
48
+ /**
49
+ * Remove a specific loaded resource
50
+ * @param url - URL of resource to remove
51
+ */
52
+ removeResource(url: string): void;
53
+ /**
54
+ * Clean up all resources marked for auto-cleanup
55
+ */
56
+ private cleanup;
57
+ /**
58
+ * Create a promise that resolves when script loads
59
+ * @param url - Script URL
60
+ * @param globalName - Expected global variable
61
+ * @returns Promise resolving to global object
62
+ */
63
+ private createScriptPromise;
64
+ /**
65
+ * Create a promise that resolves when script loads and passes validation
66
+ * @param url - Script URL
67
+ * @param globalName - Expected global variable
68
+ * @param validator - Validation function
69
+ * @returns Promise resolving to validated global object
70
+ */
71
+ private createScriptPromiseWithValidation;
72
+ /**
73
+ * Wait for global object to be available and valid
74
+ * @param globalName - Global variable name
75
+ * @param validator - Validation function
76
+ * @param resolve - Promise resolve function
77
+ * @param reject - Promise reject function
78
+ * @param attempts - Current attempt number
79
+ * @param maxAttempts - Maximum attempts before failing
80
+ */
81
+ private waitForValidation;
82
+ /**
83
+ * Wait for existing script to load
84
+ * @param script - Script element
85
+ * @param globalName - Expected global variable
86
+ * @param resolve - Promise resolve function
87
+ * @param reject - Promise reject function
88
+ */
89
+ private waitForScriptLoad;
90
+ /**
91
+ * Wait for existing script to load with validation
92
+ * @param script - Script element
93
+ * @param globalName - Expected global variable
94
+ * @param validator - Validation function
95
+ * @param resolve - Promise resolve function
96
+ * @param reject - Promise reject function
97
+ */
98
+ private waitForScriptLoadWithValidation;
99
+ static ɵfac: i0.ɵɵFactoryDeclaration<ScriptLoaderService, never>;
100
+ static ɵprov: i0.ɵɵInjectableDeclaration<ScriptLoaderService>;
101
+ }
@@ -0,0 +1,333 @@
1
+ /**
2
+ * @fileoverview Service for loading external scripts and CSS in Angular applications.
3
+ * Manages the lifecycle of dynamically loaded resources with proper cleanup.
4
+ * @module @memberjunction/ng-react
5
+ */
6
+ import { Injectable } from '@angular/core';
7
+ import { CDN_URLS } from '../cdn-urls';
8
+ import * as i0 from "@angular/core";
9
+ /**
10
+ * Service for loading external scripts and CSS with proper cleanup.
11
+ * Provides methods to dynamically load React and related libraries from CDN.
12
+ */
13
+ export class ScriptLoaderService {
14
+ constructor() {
15
+ this.loadedResources = new Map();
16
+ this.cleanupOnDestroy = new Set();
17
+ }
18
+ ngOnDestroy() {
19
+ this.cleanup();
20
+ }
21
+ /**
22
+ * Load a script from URL with automatic cleanup tracking
23
+ * @param url - Script URL to load
24
+ * @param globalName - Expected global variable name
25
+ * @param autoCleanup - Whether to cleanup on service destroy
26
+ * @returns Promise resolving to the global object
27
+ */
28
+ async loadScript(url, globalName, autoCleanup = false) {
29
+ const existing = this.loadedResources.get(url);
30
+ if (existing) {
31
+ return existing.promise;
32
+ }
33
+ const promise = this.createScriptPromise(url, globalName);
34
+ const element = document.querySelector(`script[src="${url}"]`);
35
+ if (element) {
36
+ this.loadedResources.set(url, { element, promise });
37
+ if (autoCleanup) {
38
+ this.cleanupOnDestroy.add(url);
39
+ }
40
+ }
41
+ return promise;
42
+ }
43
+ /**
44
+ * Load a script with additional validation function
45
+ * @param url - Script URL to load
46
+ * @param globalName - Expected global variable name
47
+ * @param validator - Function to validate the loaded object
48
+ * @param autoCleanup - Whether to cleanup on service destroy
49
+ * @returns Promise resolving to the validated global object
50
+ */
51
+ async loadScriptWithValidation(url, globalName, validator, autoCleanup = false) {
52
+ const existing = this.loadedResources.get(url);
53
+ if (existing) {
54
+ const obj = await existing.promise;
55
+ // Re-validate even for cached resources
56
+ if (!validator(obj)) {
57
+ throw new Error(`${globalName} loaded but failed validation`);
58
+ }
59
+ return obj;
60
+ }
61
+ const promise = this.createScriptPromiseWithValidation(url, globalName, validator);
62
+ const element = document.querySelector(`script[src="${url}"]`);
63
+ if (element) {
64
+ this.loadedResources.set(url, { element, promise });
65
+ if (autoCleanup) {
66
+ this.cleanupOnDestroy.add(url);
67
+ }
68
+ }
69
+ return promise;
70
+ }
71
+ /**
72
+ * Load CSS from URL
73
+ * @param url - CSS URL to load
74
+ */
75
+ loadCSS(url) {
76
+ if (this.loadedResources.has(url)) {
77
+ return;
78
+ }
79
+ const existingLink = document.querySelector(`link[href="${url}"]`);
80
+ if (existingLink) {
81
+ return;
82
+ }
83
+ const link = document.createElement('link');
84
+ link.rel = 'stylesheet';
85
+ link.href = url;
86
+ document.head.appendChild(link);
87
+ this.loadedResources.set(url, {
88
+ element: link,
89
+ promise: Promise.resolve()
90
+ });
91
+ }
92
+ /**
93
+ * Load common React libraries and UI frameworks
94
+ * @returns Promise resolving to React ecosystem objects
95
+ */
96
+ async loadReactEcosystem() {
97
+ // Load React and ReactDOM with enhanced validation
98
+ const [React, ReactDOM, Babel] = await Promise.all([
99
+ this.loadScriptWithValidation(CDN_URLS.REACT, 'React', (obj) => {
100
+ return obj && typeof obj.createElement === 'function' && typeof obj.Component === 'function';
101
+ }),
102
+ this.loadScriptWithValidation(CDN_URLS.REACT_DOM, 'ReactDOM', (obj) => {
103
+ // Just check that ReactDOM exists - createRoot might not be immediately available
104
+ return obj != null && typeof obj === 'object';
105
+ }),
106
+ this.loadScript(CDN_URLS.BABEL_STANDALONE, 'Babel')
107
+ ]);
108
+ // Note: We don't validate createRoot here because it might not be immediately available
109
+ // The ReactBridgeService will handle the delayed validation
110
+ // Load CSS files (non-blocking)
111
+ this.loadCSS(CDN_URLS.ANTD_CSS);
112
+ this.loadCSS(CDN_URLS.BOOTSTRAP_CSS);
113
+ // Load UI libraries
114
+ const [antd, ReactBootstrap, d3, Chart, _, dayjs] = await Promise.all([
115
+ this.loadScript(CDN_URLS.ANTD_JS, 'antd'),
116
+ this.loadScript(CDN_URLS.REACT_BOOTSTRAP_JS, 'ReactBootstrap'),
117
+ this.loadScript(CDN_URLS.D3_JS, 'd3'),
118
+ this.loadScript(CDN_URLS.CHART_JS, 'Chart'),
119
+ this.loadScript(CDN_URLS.LODASH_JS, '_'),
120
+ this.loadScript(CDN_URLS.DAYJS, 'dayjs')
121
+ ]);
122
+ return {
123
+ React,
124
+ ReactDOM,
125
+ Babel,
126
+ libraries: { antd, ReactBootstrap, d3, Chart, _, dayjs }
127
+ };
128
+ }
129
+ /**
130
+ * Remove a specific loaded resource
131
+ * @param url - URL of resource to remove
132
+ */
133
+ removeResource(url) {
134
+ const resource = this.loadedResources.get(url);
135
+ if (resource?.element && resource.element.parentNode) {
136
+ resource.element.parentNode.removeChild(resource.element);
137
+ }
138
+ this.loadedResources.delete(url);
139
+ this.cleanupOnDestroy.delete(url);
140
+ }
141
+ /**
142
+ * Clean up all resources marked for auto-cleanup
143
+ */
144
+ cleanup() {
145
+ for (const url of this.cleanupOnDestroy) {
146
+ this.removeResource(url);
147
+ }
148
+ this.cleanupOnDestroy.clear();
149
+ }
150
+ /**
151
+ * Create a promise that resolves when script loads
152
+ * @param url - Script URL
153
+ * @param globalName - Expected global variable
154
+ * @returns Promise resolving to global object
155
+ */
156
+ createScriptPromise(url, globalName) {
157
+ return new Promise((resolve, reject) => {
158
+ // Check if already loaded
159
+ if (window[globalName]) {
160
+ resolve(window[globalName]);
161
+ return;
162
+ }
163
+ // Check if script tag exists
164
+ const existingScript = document.querySelector(`script[src="${url}"]`);
165
+ if (existingScript) {
166
+ this.waitForScriptLoad(existingScript, globalName, resolve, reject);
167
+ return;
168
+ }
169
+ // Create new script
170
+ const script = document.createElement('script');
171
+ script.src = url;
172
+ script.async = true;
173
+ script.onload = () => {
174
+ const global = window[globalName];
175
+ if (global) {
176
+ resolve(global);
177
+ }
178
+ else {
179
+ reject(new Error(`${globalName} not found after script load`));
180
+ }
181
+ };
182
+ script.onerror = () => {
183
+ reject(new Error(`Failed to load script: ${url}`));
184
+ };
185
+ document.head.appendChild(script);
186
+ this.loadedResources.set(url, { element: script, promise: Promise.resolve() });
187
+ });
188
+ }
189
+ /**
190
+ * Create a promise that resolves when script loads and passes validation
191
+ * @param url - Script URL
192
+ * @param globalName - Expected global variable
193
+ * @param validator - Validation function
194
+ * @returns Promise resolving to validated global object
195
+ */
196
+ createScriptPromiseWithValidation(url, globalName, validator) {
197
+ return new Promise((resolve, reject) => {
198
+ // Check if already loaded and valid
199
+ const existingGlobal = window[globalName];
200
+ if (existingGlobal && validator(existingGlobal)) {
201
+ resolve(existingGlobal);
202
+ return;
203
+ }
204
+ // Check if script tag exists
205
+ const existingScript = document.querySelector(`script[src="${url}"]`);
206
+ if (existingScript) {
207
+ this.waitForScriptLoadWithValidation(existingScript, globalName, validator, resolve, reject);
208
+ return;
209
+ }
210
+ // Create new script
211
+ const script = document.createElement('script');
212
+ script.src = url;
213
+ script.async = true;
214
+ script.onload = () => {
215
+ this.waitForValidation(globalName, validator, resolve, reject);
216
+ };
217
+ script.onerror = () => {
218
+ reject(new Error(`Failed to load script: ${url}`));
219
+ };
220
+ document.head.appendChild(script);
221
+ this.loadedResources.set(url, { element: script, promise: Promise.resolve() });
222
+ });
223
+ }
224
+ /**
225
+ * Wait for global object to be available and valid
226
+ * @param globalName - Global variable name
227
+ * @param validator - Validation function
228
+ * @param resolve - Promise resolve function
229
+ * @param reject - Promise reject function
230
+ * @param attempts - Current attempt number
231
+ * @param maxAttempts - Maximum attempts before failing
232
+ */
233
+ waitForValidation(globalName, validator, resolve, reject, attempts = 0, maxAttempts = 50 // 5 seconds total with 100ms intervals
234
+ ) {
235
+ const global = window[globalName];
236
+ if (global && validator(global)) {
237
+ resolve(global);
238
+ return;
239
+ }
240
+ if (attempts >= maxAttempts) {
241
+ if (global) {
242
+ reject(new Error(`${globalName} loaded but validation failed after ${maxAttempts} attempts`));
243
+ }
244
+ else {
245
+ reject(new Error(`${globalName} not found after ${maxAttempts} attempts`));
246
+ }
247
+ return;
248
+ }
249
+ // Retry with exponential backoff for first few attempts, then fixed interval
250
+ const delay = attempts < 5 ? Math.min(100 * Math.pow(1.5, attempts), 500) : 100;
251
+ setTimeout(() => {
252
+ this.waitForValidation(globalName, validator, resolve, reject, attempts + 1, maxAttempts);
253
+ }, delay);
254
+ }
255
+ /**
256
+ * Wait for existing script to load
257
+ * @param script - Script element
258
+ * @param globalName - Expected global variable
259
+ * @param resolve - Promise resolve function
260
+ * @param reject - Promise reject function
261
+ */
262
+ waitForScriptLoad(script, globalName, resolve, reject) {
263
+ const checkGlobal = () => {
264
+ if (window[globalName]) {
265
+ resolve(window[globalName]);
266
+ return;
267
+ }
268
+ // Give it a moment for the global to be defined
269
+ setTimeout(() => {
270
+ if (window[globalName]) {
271
+ resolve(window[globalName]);
272
+ }
273
+ else {
274
+ reject(new Error(`${globalName} not found after script load`));
275
+ }
276
+ }, 100);
277
+ };
278
+ if ('readyState' in script) {
279
+ // IE support
280
+ script.onreadystatechange = () => {
281
+ if (script.readyState === 'loaded' || script.readyState === 'complete') {
282
+ script.onreadystatechange = null;
283
+ checkGlobal();
284
+ }
285
+ };
286
+ }
287
+ else {
288
+ // Modern browsers
289
+ const loadHandler = () => {
290
+ script.removeEventListener('load', loadHandler);
291
+ checkGlobal();
292
+ };
293
+ script.addEventListener('load', loadHandler);
294
+ }
295
+ }
296
+ /**
297
+ * Wait for existing script to load with validation
298
+ * @param script - Script element
299
+ * @param globalName - Expected global variable
300
+ * @param validator - Validation function
301
+ * @param resolve - Promise resolve function
302
+ * @param reject - Promise reject function
303
+ */
304
+ waitForScriptLoadWithValidation(script, globalName, validator, resolve, reject) {
305
+ const checkGlobal = () => {
306
+ this.waitForValidation(globalName, validator, resolve, reject);
307
+ };
308
+ if ('readyState' in script) {
309
+ // IE support
310
+ script.onreadystatechange = () => {
311
+ if (script.readyState === 'loaded' || script.readyState === 'complete') {
312
+ script.onreadystatechange = null;
313
+ checkGlobal();
314
+ }
315
+ };
316
+ }
317
+ else {
318
+ // Modern browsers
319
+ const loadHandler = () => {
320
+ script.removeEventListener('load', loadHandler);
321
+ checkGlobal();
322
+ };
323
+ script.addEventListener('load', loadHandler);
324
+ }
325
+ }
326
+ static { this.ɵfac = function ScriptLoaderService_Factory(t) { return new (t || ScriptLoaderService)(); }; }
327
+ static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ScriptLoaderService, factory: ScriptLoaderService.ɵfac, providedIn: 'root' }); }
328
+ }
329
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ScriptLoaderService, [{
330
+ type: Injectable,
331
+ args: [{ providedIn: 'root' }]
332
+ }], null, null); })();
333
+ //# sourceMappingURL=script-loader.service.js.map
@@ -0,0 +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,EAAE,QAAQ,EAAE,MAAM,aAAa,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,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,UAAU,CAAC,GAAW,EAAE,UAAkB,EAAE,WAAW,GAAG,KAAK;QACnE,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/C,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,QAAQ,CAAC,OAAO,CAAC;QAC1B,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAC1D,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,eAAe,GAAG,IAAI,CAAsB,CAAC;QAEpF,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;YACpD,IAAI,WAAW,EAAE,CAAC;gBAChB,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,wBAAwB,CAC5B,GAAW,EACX,UAAkB,EACl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CAAC;QACjE,CAAC,CAAC;QAEF,IAAI,YAAY,IAAI,MAAM,EAAE,CAAC;YAC3B,aAAa;YACZ,MAAc,CAAC,kBAAkB,GAAG,GAAG,EAAE;gBACxC,IAAK,MAAc,CAAC,UAAU,KAAK,QAAQ,IAAK,MAAc,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;oBACxF,MAAc,CAAC,kBAAkB,GAAG,IAAI,CAAC;oBAC1C,WAAW,EAAE,CAAC;gBAChB,CAAC;YACH,CAAC,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,kBAAkB;YAClB,MAAM,WAAW,GAAG,GAAG,EAAE;gBACvB,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;gBAChD,WAAW,EAAE,CAAC;YAChB,CAAC,CAAC;YACF,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;oFA9XU,mBAAmB;uEAAnB,mBAAmB,WAAnB,mBAAmB,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 { CDN_URLS } from '../cdn-urls';\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 // Load React and ReactDOM with enhanced validation\n const [React, ReactDOM, Babel] = await Promise.all([\n this.loadScriptWithValidation(CDN_URLS.REACT, 'React', (obj) => {\n return obj && typeof obj.createElement === 'function' && typeof obj.Component === 'function';\n }),\n this.loadScriptWithValidation(CDN_URLS.REACT_DOM, 'ReactDOM', (obj) => {\n // Just check that ReactDOM exists - createRoot might not be immediately available\n return obj != null && typeof obj === 'object';\n }),\n this.loadScript(CDN_URLS.BABEL_STANDALONE, 'Babel')\n ]);\n\n // Note: We don't validate createRoot here because it might not be immediately available\n // The ReactBridgeService will handle the delayed validation\n\n // Load CSS files (non-blocking)\n this.loadCSS(CDN_URLS.ANTD_CSS);\n this.loadCSS(CDN_URLS.BOOTSTRAP_CSS);\n\n // Load UI libraries\n const [antd, ReactBootstrap, d3, Chart, _, dayjs] = await Promise.all([\n this.loadScript(CDN_URLS.ANTD_JS, 'antd'),\n this.loadScript(CDN_URLS.REACT_BOOTSTRAP_JS, 'ReactBootstrap'),\n this.loadScript(CDN_URLS.D3_JS, 'd3'),\n this.loadScript(CDN_URLS.CHART_JS, 'Chart'),\n this.loadScript(CDN_URLS.LODASH_JS, '_'),\n this.loadScript(CDN_URLS.DAYJS, 'dayjs')\n ]);\n\n return {\n React,\n ReactDOM,\n Babel,\n libraries: { antd, ReactBootstrap, d3, Chart, _, dayjs }\n };\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}"]}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @fileoverview Public API Surface of @memberjunction/ng-react
3
+ * This file exports all public APIs from the Angular React integration library.
4
+ * @module @memberjunction/ng-react
5
+ */
6
+ export * from './lib/module';
7
+ export * from './lib/components/mj-react-component.component';
8
+ export * from './lib/services/script-loader.service';
9
+ export * from './lib/services/react-bridge.service';
10
+ export * from './lib/services/angular-adapter.service';
11
+ export * from './lib/cdn-urls';
12
+ export * from './lib/default-styles';
13
+ export { ComponentProps, ComponentCallbacks, ComponentStyles, ComponentError, CompileOptions, CompilationResult } from '@memberjunction/react-runtime';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @fileoverview Public API Surface of @memberjunction/ng-react
3
+ * This file exports all public APIs from the Angular React integration library.
4
+ * @module @memberjunction/ng-react
5
+ */
6
+ // Module
7
+ export * from './lib/module';
8
+ // Components
9
+ export * from './lib/components/mj-react-component.component';
10
+ // Services
11
+ export * from './lib/services/script-loader.service';
12
+ export * from './lib/services/react-bridge.service';
13
+ export * from './lib/services/angular-adapter.service';
14
+ // Constants
15
+ export * from './lib/cdn-urls';
16
+ export * from './lib/default-styles';
17
+ //# sourceMappingURL=public-api.js.map
@@ -0,0 +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,cAAc,gBAAgB,CAAC;AAC/B,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/cdn-urls';\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 ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@memberjunction/ng-react",
3
+ "version": "2.70.0",
4
+ "description": "Angular components for hosting React components in MemberJunction applications",
5
+ "scripts": {
6
+ "build": "ngc -p tsconfig.json",
7
+ "watch": "ngc -p tsconfig.json --watch",
8
+ "test": "echo \"Tests not yet implemented\"",
9
+ "patchVersion": "npm version patch"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/MemberJunction/MJ.git"
14
+ },
15
+ "keywords": [
16
+ "memberjunction",
17
+ "angular",
18
+ "react",
19
+ "component",
20
+ "bridge"
21
+ ],
22
+ "author": "",
23
+ "license": "ISC",
24
+ "bugs": {
25
+ "url": "https://github.com/MemberJunction/MJ/issues"
26
+ },
27
+ "homepage": "https://github.com/MemberJunction/MJ#readme",
28
+ "main": "./dist/public-api.js",
29
+ "module": "./dist/public-api.js",
30
+ "typings": "./dist/public-api.d.ts",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/public-api.d.ts",
34
+ "default": "./dist/public-api.js"
35
+ },
36
+ "./styles": "./dist/styles/main.scss"
37
+ },
38
+ "files": [
39
+ "dist",
40
+ "styles"
41
+ ],
42
+ "dependencies": {
43
+ "@memberjunction/core": "2.70.0",
44
+ "@memberjunction/react-runtime": "2.70.0",
45
+ "@memberjunction/skip-types": "2.70.0",
46
+ "@angular/common": ">=18.0.0",
47
+ "@angular/core": ">=18.0.0",
48
+ "@angular/platform-browser": ">=18.0.0",
49
+ "@babel/standalone": "^7.23.5",
50
+ "react": "^18.2.0",
51
+ "react-dom": "^18.2.0",
52
+ "rxjs": "^7.8.0",
53
+ "@types/react": "^18.2.0",
54
+ "@types/react-dom": "^18.2.0"
55
+ },
56
+ "devDependencies": {
57
+ "@angular/compiler": "18.0.2",
58
+ "@angular/compiler-cli": "18.0.2",
59
+ "typescript": "5.3.3"
60
+ }
61
+ }