@memberjunction/react-runtime 2.71.0 → 2.72.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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @memberjunction/react-runtime@2.71.0 build
2
+ > @memberjunction/react-runtime@2.72.0 build
3
3
  > tsc
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @memberjunction/react-runtime
2
2
 
3
+ ## 2.72.0
4
+
5
+ ### Patch Changes
6
+
7
+ - @memberjunction/interactive-component-types@2.72.0
8
+ - @memberjunction/core@2.72.0
9
+ - @memberjunction/global@2.72.0
10
+
3
11
  ## 2.71.0
4
12
 
5
13
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -13,6 +13,8 @@ export { ComponentHierarchyRegistrar, registerComponentHierarchy, validateCompon
13
13
  export { RuntimeUtilities, createRuntimeUtilities } from './utilities/runtime-utilities';
14
14
  export { SetupStyles, createDefaultComponentStyles } from './utilities/component-styles';
15
15
  export { STANDARD_LIBRARY_URLS, StandardLibraries, getCoreLibraryUrls, getUILibraryUrls, getCSSUrls, createStandardLibraries } from './utilities/standard-libraries';
16
+ export { LibraryLoader, LibraryLoadOptions, LibraryLoadResult } from './utilities/library-loader';
17
+ export { ComponentErrorAnalyzer, FailedComponentInfo } from './utilities/component-error-analyzer';
16
18
  export declare const VERSION = "2.69.1";
17
19
  export declare const DEFAULT_CONFIGS: {
18
20
  compiler: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG/C,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA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CAAC;AAGnB,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,WAAW,EACX,4BAA4B,EAC7B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,uBAAuB,EACxB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,sCAAsC,CAAC;AAG9C,eAAO,MAAM,OAAO,WAAW,CAAC;AAGhC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;CAiB3B,CAAC;AAQF,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,GAAG,EAClB,MAAM,CAAC,EAAE;IACP,QAAQ,CAAC,EAAE,OAAO,CAAC,OAAO,SAAS,EAAE,cAAc,CAAC,CAAC;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC,OAAO,SAAS,EAAE,cAAc,CAAC,CAAC;CACtD;;;;;EAcF"}
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.createReactRuntime = exports.DEFAULT_CONFIGS = exports.VERSION = exports.createStandardLibraries = exports.getCSSUrls = exports.getUILibraryUrls = exports.getCoreLibraryUrls = exports.STANDARD_LIBRARY_URLS = exports.createDefaultComponentStyles = exports.SetupStyles = exports.createRuntimeUtilities = exports.RuntimeUtilities = exports.countComponentsInHierarchy = exports.flattenComponentHierarchy = exports.validateComponentSpec = exports.registerComponentHierarchy = exports.ComponentHierarchyRegistrar = exports.extractPropPaths = exports.wrapCallbacksWithLogging = exports.createPropsTransformer = exports.mergeProps = exports.validateComponentProps = exports.normalizeStyles = exports.normalizeCallbacks = exports.buildComponentProps = exports.portalComponent = exports.withErrorHandler = exports.conditionalComponent = exports.injectProps = exports.lazyComponent = exports.memoizeComponent = exports.wrapComponent = exports.createErrorLogger = exports.formatComponentError = exports.withErrorBoundary = exports.createErrorBoundary = exports.ComponentResolver = exports.ComponentRegistry = exports.getJSXConfig = exports.validateBabelPresets = exports.getBabelConfig = exports.DEVELOPMENT_CONFIG = exports.PRODUCTION_CONFIG = exports.DEFAULT_PLUGINS = exports.DEFAULT_PRESETS = exports.ComponentCompiler = void 0;
17
+ exports.createReactRuntime = exports.DEFAULT_CONFIGS = exports.VERSION = exports.ComponentErrorAnalyzer = exports.LibraryLoader = exports.createStandardLibraries = exports.getCSSUrls = exports.getUILibraryUrls = exports.getCoreLibraryUrls = exports.STANDARD_LIBRARY_URLS = exports.createDefaultComponentStyles = exports.SetupStyles = exports.createRuntimeUtilities = exports.RuntimeUtilities = exports.countComponentsInHierarchy = exports.flattenComponentHierarchy = exports.validateComponentSpec = exports.registerComponentHierarchy = exports.ComponentHierarchyRegistrar = exports.extractPropPaths = exports.wrapCallbacksWithLogging = exports.createPropsTransformer = exports.mergeProps = exports.validateComponentProps = exports.normalizeStyles = exports.normalizeCallbacks = exports.buildComponentProps = exports.portalComponent = exports.withErrorHandler = exports.conditionalComponent = exports.injectProps = exports.lazyComponent = exports.memoizeComponent = exports.wrapComponent = exports.createErrorLogger = exports.formatComponentError = exports.withErrorBoundary = exports.createErrorBoundary = exports.ComponentResolver = exports.ComponentRegistry = exports.getJSXConfig = exports.validateBabelPresets = exports.getBabelConfig = exports.DEVELOPMENT_CONFIG = exports.PRODUCTION_CONFIG = exports.DEFAULT_PLUGINS = exports.DEFAULT_PRESETS = exports.ComponentCompiler = void 0;
18
18
  const compiler_1 = require("./compiler");
19
19
  const registry_1 = require("./registry");
20
20
  const registry_2 = require("./registry");
@@ -73,6 +73,10 @@ Object.defineProperty(exports, "getCoreLibraryUrls", { enumerable: true, get: fu
73
73
  Object.defineProperty(exports, "getUILibraryUrls", { enumerable: true, get: function () { return standard_libraries_1.getUILibraryUrls; } });
74
74
  Object.defineProperty(exports, "getCSSUrls", { enumerable: true, get: function () { return standard_libraries_1.getCSSUrls; } });
75
75
  Object.defineProperty(exports, "createStandardLibraries", { enumerable: true, get: function () { return standard_libraries_1.createStandardLibraries; } });
76
+ var library_loader_1 = require("./utilities/library-loader");
77
+ Object.defineProperty(exports, "LibraryLoader", { enumerable: true, get: function () { return library_loader_1.LibraryLoader; } });
78
+ var component_error_analyzer_1 = require("./utilities/component-error-analyzer");
79
+ Object.defineProperty(exports, "ComponentErrorAnalyzer", { enumerable: true, get: function () { return component_error_analyzer_1.ComponentErrorAnalyzer; } });
76
80
  exports.VERSION = '2.69.1';
77
81
  exports.DEFAULT_CONFIGS = {
78
82
  compiler: {
@@ -0,0 +1,20 @@
1
+ export interface FailedComponentInfo {
2
+ componentName: string;
3
+ errorType: string;
4
+ errorMessage: string;
5
+ lineNumber?: number;
6
+ context?: string;
7
+ }
8
+ export declare class ComponentErrorAnalyzer {
9
+ private static readonly ERROR_PATTERNS;
10
+ static identifyFailedComponents(errors: string[]): string[];
11
+ static analyzeComponentErrors(errors: string[]): FailedComponentInfo[];
12
+ private static extractComponentsFromError;
13
+ private static analyzeError;
14
+ private static extractComponentsFromStackTrace;
15
+ private static isLikelyComponentName;
16
+ private static extractLineNumber;
17
+ private static extractContext;
18
+ static formatAnalysisResults(failures: FailedComponentInfo[]): string;
19
+ }
20
+ //# sourceMappingURL=component-error-analyzer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-error-analyzer.d.ts","sourceRoot":"","sources":["../../src/utilities/component-error-analyzer.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,mBAAmB;IAElC,aAAa,EAAE,MAAM,CAAC;IAEtB,SAAS,EAAE,MAAM,CAAC;IAElB,YAAY,EAAE,MAAM,CAAC;IAErB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAKD,qBAAa,sBAAsB;IAIjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CA6DpC;IAOF,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;IAgB3D,MAAM,CAAC,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,mBAAmB,EAAE;IAuBtE,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAuBzC,OAAO,CAAC,MAAM,CAAC,YAAY;IAsC3B,OAAO,CAAC,MAAM,CAAC,+BAA+B;IA2B9C,OAAO,CAAC,MAAM,CAAC,qBAAqB;IA6BpC,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAqBhC,OAAO,CAAC,MAAM,CAAC,cAAc;IAmB7B,MAAM,CAAC,qBAAqB,CAAC,QAAQ,EAAE,mBAAmB,EAAE,GAAG,MAAM;CAqBtE"}
@@ -0,0 +1,204 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ComponentErrorAnalyzer = void 0;
4
+ class ComponentErrorAnalyzer {
5
+ static identifyFailedComponents(errors) {
6
+ const failedComponents = new Set();
7
+ for (const error of errors) {
8
+ const components = this.extractComponentsFromError(error);
9
+ components.forEach(comp => failedComponents.add(comp));
10
+ }
11
+ return Array.from(failedComponents);
12
+ }
13
+ static analyzeComponentErrors(errors) {
14
+ const failures = [];
15
+ for (const error of errors) {
16
+ const failureInfo = this.analyzeError(error);
17
+ failures.push(...failureInfo);
18
+ }
19
+ const uniqueFailures = new Map();
20
+ failures.forEach(failure => {
21
+ const key = `${failure.componentName}-${failure.errorType}`;
22
+ if (!uniqueFailures.has(key)) {
23
+ uniqueFailures.set(key, failure);
24
+ }
25
+ });
26
+ return Array.from(uniqueFailures.values());
27
+ }
28
+ static extractComponentsFromError(error) {
29
+ const components = [];
30
+ for (const errorPattern of this.ERROR_PATTERNS) {
31
+ const match = error.match(errorPattern.pattern);
32
+ if (match) {
33
+ const componentName = errorPattern.extractComponent(match);
34
+ if (componentName && this.isLikelyComponentName(componentName)) {
35
+ components.push(componentName);
36
+ }
37
+ }
38
+ }
39
+ const stackComponents = this.extractComponentsFromStackTrace(error);
40
+ components.push(...stackComponents);
41
+ return components;
42
+ }
43
+ static analyzeError(error) {
44
+ const failures = [];
45
+ for (const errorPattern of this.ERROR_PATTERNS) {
46
+ const match = error.match(errorPattern.pattern);
47
+ if (match) {
48
+ const componentName = errorPattern.extractComponent(match);
49
+ if (componentName && this.isLikelyComponentName(componentName)) {
50
+ failures.push({
51
+ componentName,
52
+ errorType: errorPattern.errorType,
53
+ errorMessage: error,
54
+ lineNumber: this.extractLineNumber(error),
55
+ context: this.extractContext(error)
56
+ });
57
+ }
58
+ }
59
+ }
60
+ if (failures.length === 0) {
61
+ const stackComponents = this.extractComponentsFromStackTrace(error);
62
+ stackComponents.forEach(componentName => {
63
+ failures.push({
64
+ componentName,
65
+ errorType: 'unknown',
66
+ errorMessage: error,
67
+ lineNumber: this.extractLineNumber(error)
68
+ });
69
+ });
70
+ }
71
+ return failures;
72
+ }
73
+ static extractComponentsFromStackTrace(error) {
74
+ const components = [];
75
+ const stackPatterns = [
76
+ /at (\w+Component\w*)/g,
77
+ /at (\w+)\s*\(/g,
78
+ /in (\w+)\s*\(at/g,
79
+ /in (\w+)\s*\(created by/g
80
+ ];
81
+ for (const pattern of stackPatterns) {
82
+ let match;
83
+ while ((match = pattern.exec(error)) !== null) {
84
+ const name = match[1];
85
+ if (this.isLikelyComponentName(name)) {
86
+ components.push(name);
87
+ }
88
+ }
89
+ }
90
+ return [...new Set(components)];
91
+ }
92
+ static isLikelyComponentName(name) {
93
+ const jsBuiltins = new Set([
94
+ 'Object', 'Array', 'String', 'Number', 'Boolean', 'Function',
95
+ 'Promise', 'Error', 'TypeError', 'ReferenceError', 'SyntaxError',
96
+ 'undefined', 'null', 'console', 'window', 'document'
97
+ ]);
98
+ const nonComponents = new Set([
99
+ 'render', 'setState', 'forceUpdate', 'props', 'state', 'context',
100
+ 'componentDidMount', 'componentWillUnmount', 'useEffect', 'useState'
101
+ ]);
102
+ return (name.length > 0 &&
103
+ /^[A-Z]/.test(name) &&
104
+ !jsBuiltins.has(name) &&
105
+ !nonComponents.has(name) &&
106
+ !/^use[A-Z]/.test(name));
107
+ }
108
+ static extractLineNumber(error) {
109
+ const patterns = [
110
+ /:(\d+):\d+/,
111
+ /line (\d+)/i,
112
+ /Line (\d+)/
113
+ ];
114
+ for (const pattern of patterns) {
115
+ const match = error.match(pattern);
116
+ if (match) {
117
+ return parseInt(match[1], 10);
118
+ }
119
+ }
120
+ return undefined;
121
+ }
122
+ static extractContext(error) {
123
+ const fileMatch = error.match(/\(at ([^)]+)\)/);
124
+ if (fileMatch) {
125
+ return fileMatch[1];
126
+ }
127
+ const createdByMatch = error.match(/created by (\w+)/);
128
+ if (createdByMatch) {
129
+ return `Created by ${createdByMatch[1]}`;
130
+ }
131
+ return undefined;
132
+ }
133
+ static formatAnalysisResults(failures) {
134
+ if (failures.length === 0) {
135
+ return 'No component failures detected';
136
+ }
137
+ let result = `Detected ${failures.length} component failure(s):\n`;
138
+ failures.forEach((failure, index) => {
139
+ result += `\n${index + 1}. Component: ${failure.componentName}\n`;
140
+ result += ` Error Type: ${failure.errorType}\n`;
141
+ if (failure.lineNumber) {
142
+ result += ` Line: ${failure.lineNumber}\n`;
143
+ }
144
+ if (failure.context) {
145
+ result += ` Context: ${failure.context}\n`;
146
+ }
147
+ result += ` Message: ${failure.errorMessage.substring(0, 200)}${failure.errorMessage.length > 200 ? '...' : ''}\n`;
148
+ });
149
+ return result;
150
+ }
151
+ }
152
+ exports.ComponentErrorAnalyzer = ComponentErrorAnalyzer;
153
+ ComponentErrorAnalyzer.ERROR_PATTERNS = [
154
+ {
155
+ pattern: /ReferenceError: (\w+) is not defined/,
156
+ errorType: 'not_defined',
157
+ extractComponent: (match) => match[1]
158
+ },
159
+ {
160
+ pattern: /Cannot read propert(?:y|ies) '(\w+)' of undefined/,
161
+ errorType: 'property_error',
162
+ extractComponent: (match) => match[1]
163
+ },
164
+ {
165
+ pattern: /(\w+)\(\.\.\.\): Nothing was returned from render/,
166
+ errorType: 'render_error',
167
+ extractComponent: (match) => match[1]
168
+ },
169
+ {
170
+ pattern: /at (\w+Component\w*)/,
171
+ errorType: 'stack_trace',
172
+ extractComponent: (match) => match[1]
173
+ },
174
+ {
175
+ pattern: /Error: Unable to find node on an unmounted component/,
176
+ errorType: 'unmounted_component',
177
+ extractComponent: () => null
178
+ },
179
+ {
180
+ pattern: /Invalid hook call.*component (\w+)/,
181
+ errorType: 'invalid_hook',
182
+ extractComponent: (match) => match[1]
183
+ },
184
+ {
185
+ pattern: /TypeError:.*in (\w+) \(at/,
186
+ errorType: 'type_error',
187
+ extractComponent: (match) => match[1]
188
+ },
189
+ {
190
+ pattern: /Module not found: Error: Can't resolve '\.\/(\w+)'/,
191
+ errorType: 'missing_import',
192
+ extractComponent: (match) => match[1]
193
+ },
194
+ {
195
+ pattern: /(\w+) is not a function/,
196
+ errorType: 'not_a_function',
197
+ extractComponent: (match) => match[1]
198
+ },
199
+ {
200
+ pattern: /Minified React error.*Visit.*for the full message.*component[: ](\w+)/s,
201
+ errorType: 'react_error',
202
+ extractComponent: (match) => match[1]
203
+ }
204
+ ];
@@ -1,4 +1,6 @@
1
1
  export * from './runtime-utilities';
2
2
  export * from './component-styles';
3
3
  export * from './standard-libraries';
4
+ export * from './library-loader';
5
+ export * from './component-error-analyzer';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAKA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAKA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC"}
@@ -17,3 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./runtime-utilities"), exports);
18
18
  __exportStar(require("./component-styles"), exports);
19
19
  __exportStar(require("./standard-libraries"), exports);
20
+ __exportStar(require("./library-loader"), exports);
21
+ __exportStar(require("./component-error-analyzer"), exports);
@@ -0,0 +1,33 @@
1
+ import { StandardLibraries } from './standard-libraries';
2
+ interface LoadedResource {
3
+ element: HTMLScriptElement | HTMLLinkElement;
4
+ promise: Promise<any>;
5
+ }
6
+ export interface LibraryLoadOptions {
7
+ loadCore?: boolean;
8
+ loadUI?: boolean;
9
+ loadCSS?: boolean;
10
+ customLibraries?: {
11
+ url: string;
12
+ globalName: string;
13
+ }[];
14
+ }
15
+ export interface LibraryLoadResult {
16
+ React: any;
17
+ ReactDOM: any;
18
+ Babel: any;
19
+ libraries: StandardLibraries;
20
+ }
21
+ export declare class LibraryLoader {
22
+ private static loadedResources;
23
+ static loadAllLibraries(): Promise<LibraryLoadResult>;
24
+ static loadLibraries(options: LibraryLoadOptions): Promise<LibraryLoadResult>;
25
+ private static loadScript;
26
+ private static loadCSS;
27
+ private static waitForScriptLoad;
28
+ private static getLibraryNameFromUrl;
29
+ static getLoadedResources(): Map<string, LoadedResource>;
30
+ static clearCache(): void;
31
+ }
32
+ export {};
33
+ //# sourceMappingURL=library-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"library-loader.d.ts","sourceRoot":"","sources":["../../src/utilities/library-loader.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,iBAAiB,EAIlB,MAAM,sBAAsB,CAAC;AAK9B,UAAU,cAAc;IACtB,OAAO,EAAE,iBAAiB,GAAG,eAAe,CAAC;IAC7C,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;CACvB;AAKD,MAAM,WAAW,kBAAkB;IAEjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,eAAe,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACzD;AAKD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,GAAG,CAAC;IACX,QAAQ,EAAE,GAAG,CAAC;IACd,KAAK,EAAE,GAAG,CAAC;IACX,SAAS,EAAE,iBAAiB,CAAC;CAC9B;AAKD,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,eAAe,CAAqC;WAMtD,gBAAgB,IAAI,OAAO,CAAC,iBAAiB,CAAC;WAW9C,aAAa,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;mBAqF9D,UAAU;IA+D/B,OAAO,CAAC,MAAM,CAAC,OAAO;IAwBtB,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAwChC,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAiBpC,MAAM,CAAC,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC;IAOxD,MAAM,CAAC,UAAU,IAAI,IAAI;CAG1B"}
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LibraryLoader = void 0;
4
+ const standard_libraries_1 = require("./standard-libraries");
5
+ class LibraryLoader {
6
+ static async loadAllLibraries() {
7
+ return this.loadLibraries({
8
+ loadCore: true,
9
+ loadUI: true,
10
+ loadCSS: true
11
+ });
12
+ }
13
+ static async loadLibraries(options) {
14
+ const { loadCore = true, loadUI = true, loadCSS = true, customLibraries = [] } = options;
15
+ const [React, ReactDOM, Babel] = await Promise.all([
16
+ this.loadScript(standard_libraries_1.STANDARD_LIBRARY_URLS.REACT, 'React'),
17
+ this.loadScript(standard_libraries_1.STANDARD_LIBRARY_URLS.REACT_DOM, 'ReactDOM'),
18
+ this.loadScript(standard_libraries_1.STANDARD_LIBRARY_URLS.BABEL, 'Babel')
19
+ ]);
20
+ if (loadCSS) {
21
+ (0, standard_libraries_1.getCSSUrls)().forEach(url => this.loadCSS(url));
22
+ }
23
+ const libraryPromises = [];
24
+ const libraryNames = [];
25
+ if (loadCore) {
26
+ const coreUrls = (0, standard_libraries_1.getCoreLibraryUrls)();
27
+ coreUrls.forEach(url => {
28
+ const name = this.getLibraryNameFromUrl(url);
29
+ libraryNames.push(name);
30
+ libraryPromises.push(this.loadScript(url, name));
31
+ });
32
+ }
33
+ if (loadUI) {
34
+ const uiUrls = (0, standard_libraries_1.getUILibraryUrls)();
35
+ uiUrls.forEach(url => {
36
+ const name = this.getLibraryNameFromUrl(url);
37
+ libraryNames.push(name);
38
+ libraryPromises.push(this.loadScript(url, name));
39
+ });
40
+ }
41
+ customLibraries.forEach(({ url, globalName }) => {
42
+ libraryNames.push(globalName);
43
+ libraryPromises.push(this.loadScript(url, globalName));
44
+ });
45
+ const loadedLibraries = await Promise.all(libraryPromises);
46
+ const libraries = {
47
+ _: undefined
48
+ };
49
+ libraryNames.forEach((name, index) => {
50
+ if (name === '_') {
51
+ libraries._ = loadedLibraries[index];
52
+ }
53
+ else {
54
+ libraries[name] = loadedLibraries[index];
55
+ }
56
+ });
57
+ if (!libraries._)
58
+ libraries._ = window._;
59
+ if (!libraries.d3)
60
+ libraries.d3 = window.d3;
61
+ if (!libraries.Chart)
62
+ libraries.Chart = window.Chart;
63
+ if (!libraries.dayjs)
64
+ libraries.dayjs = window.dayjs;
65
+ if (!libraries.antd)
66
+ libraries.antd = window.antd;
67
+ if (!libraries.ReactBootstrap)
68
+ libraries.ReactBootstrap = window.ReactBootstrap;
69
+ return {
70
+ React,
71
+ ReactDOM,
72
+ Babel,
73
+ libraries
74
+ };
75
+ }
76
+ static async loadScript(url, globalName) {
77
+ const existing = this.loadedResources.get(url);
78
+ if (existing) {
79
+ return existing.promise;
80
+ }
81
+ const promise = new Promise((resolve, reject) => {
82
+ const existingGlobal = window[globalName];
83
+ if (existingGlobal) {
84
+ resolve(existingGlobal);
85
+ return;
86
+ }
87
+ const existingScript = document.querySelector(`script[src="${url}"]`);
88
+ if (existingScript) {
89
+ this.waitForScriptLoad(existingScript, globalName, resolve, reject);
90
+ return;
91
+ }
92
+ const script = document.createElement('script');
93
+ script.src = url;
94
+ script.async = true;
95
+ script.crossOrigin = 'anonymous';
96
+ script.onload = () => {
97
+ const global = window[globalName];
98
+ if (global) {
99
+ resolve(global);
100
+ }
101
+ else {
102
+ setTimeout(() => {
103
+ const delayedGlobal = window[globalName];
104
+ if (delayedGlobal) {
105
+ resolve(delayedGlobal);
106
+ }
107
+ else {
108
+ reject(new Error(`${globalName} not found after script load`));
109
+ }
110
+ }, 100);
111
+ }
112
+ };
113
+ script.onerror = () => {
114
+ reject(new Error(`Failed to load script: ${url}`));
115
+ };
116
+ document.head.appendChild(script);
117
+ });
118
+ this.loadedResources.set(url, {
119
+ element: document.querySelector(`script[src="${url}"]`),
120
+ promise
121
+ });
122
+ return promise;
123
+ }
124
+ static loadCSS(url) {
125
+ if (this.loadedResources.has(url)) {
126
+ return;
127
+ }
128
+ const existingLink = document.querySelector(`link[href="${url}"]`);
129
+ if (existingLink) {
130
+ return;
131
+ }
132
+ const link = document.createElement('link');
133
+ link.rel = 'stylesheet';
134
+ link.href = url;
135
+ document.head.appendChild(link);
136
+ this.loadedResources.set(url, {
137
+ element: link,
138
+ promise: Promise.resolve()
139
+ });
140
+ }
141
+ static waitForScriptLoad(script, globalName, resolve, reject) {
142
+ const checkGlobal = () => {
143
+ const global = window[globalName];
144
+ if (global) {
145
+ resolve(global);
146
+ }
147
+ else {
148
+ setTimeout(() => {
149
+ const delayedGlobal = window[globalName];
150
+ if (delayedGlobal) {
151
+ resolve(delayedGlobal);
152
+ }
153
+ else {
154
+ reject(new Error(`${globalName} not found after script load`));
155
+ }
156
+ }, 100);
157
+ }
158
+ };
159
+ if (script.complete || script.readyState === 'complete') {
160
+ checkGlobal();
161
+ return;
162
+ }
163
+ const loadHandler = () => {
164
+ script.removeEventListener('load', loadHandler);
165
+ checkGlobal();
166
+ };
167
+ script.addEventListener('load', loadHandler);
168
+ }
169
+ static getLibraryNameFromUrl(url) {
170
+ if (url.includes('lodash'))
171
+ return '_';
172
+ if (url.includes('d3'))
173
+ return 'd3';
174
+ if (url.includes('Chart.js') || url.includes('chart'))
175
+ return 'Chart';
176
+ if (url.includes('dayjs'))
177
+ return 'dayjs';
178
+ if (url.includes('antd'))
179
+ return 'antd';
180
+ if (url.includes('react-bootstrap'))
181
+ return 'ReactBootstrap';
182
+ const match = url.match(/\/([^\/]+)(?:\.min)?\.js$/);
183
+ return match ? match[1] : 'unknown';
184
+ }
185
+ static getLoadedResources() {
186
+ return this.loadedResources;
187
+ }
188
+ static clearCache() {
189
+ this.loadedResources.clear();
190
+ }
191
+ }
192
+ exports.LibraryLoader = LibraryLoader;
193
+ LibraryLoader.loadedResources = new Map();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/react-runtime",
3
- "version": "2.71.0",
3
+ "version": "2.72.0",
4
4
  "description": "Platform-agnostic React component runtime for MemberJunction. Provides core compilation, registry, and execution capabilities for React components in any JavaScript environment.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -25,9 +25,9 @@
25
25
  },
26
26
  "homepage": "https://github.com/MemberJunction/MJ#readme",
27
27
  "dependencies": {
28
- "@memberjunction/core": "2.71.0",
29
- "@memberjunction/global": "2.71.0",
30
- "@memberjunction/interactive-component-types": "2.71.0",
28
+ "@memberjunction/core": "2.72.0",
29
+ "@memberjunction/global": "2.72.0",
30
+ "@memberjunction/interactive-component-types": "2.72.0",
31
31
  "@babel/standalone": "^7.23.5"
32
32
  },
33
33
  "devDependencies": {
package/src/index.ts CHANGED
@@ -94,6 +94,17 @@ export {
94
94
  createStandardLibraries
95
95
  } from './utilities/standard-libraries';
96
96
 
97
+ export {
98
+ LibraryLoader,
99
+ LibraryLoadOptions,
100
+ LibraryLoadResult
101
+ } from './utilities/library-loader';
102
+
103
+ export {
104
+ ComponentErrorAnalyzer,
105
+ FailedComponentInfo
106
+ } from './utilities/component-error-analyzer';
107
+
97
108
  // Version information
98
109
  export const VERSION = '2.69.1';
99
110