@memberjunction/react-runtime 2.78.0 → 2.79.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.78.0 build
2
+ > @memberjunction/react-runtime@2.79.0 build
3
3
  > tsc
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @memberjunction/react-runtime
2
2
 
3
+ ## 2.79.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [907e73f]
8
+ - @memberjunction/global@2.79.0
9
+ - @memberjunction/core@2.79.0
10
+ - @memberjunction/interactive-component-types@2.79.0
11
+
3
12
  ## 2.78.0
4
13
 
5
14
  ### Patch Changes
@@ -2,6 +2,7 @@ import { CompileOptions, CompilationResult, CompilerConfig } from '../types';
2
2
  export declare class ComponentCompiler {
3
3
  private config;
4
4
  private compilationCache;
5
+ private cacheAccessOrder;
5
6
  private babelInstance;
6
7
  constructor(config?: Partial<CompilerConfig>);
7
8
  setBabelInstance(babel: any): void;
@@ -12,6 +13,7 @@ export declare class ComponentCompiler {
12
13
  private validateCompileOptions;
13
14
  private generateComponentId;
14
15
  private getCachedComponent;
16
+ private createCacheKey;
15
17
  private cacheComponent;
16
18
  private createCompilationError;
17
19
  clearCache(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"component-compiler.d.ts","sourceRoot":"","sources":["../../src/compiler/component-compiler.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,cAAc,EAEd,iBAAiB,EACjB,cAAc,EAGf,MAAM,UAAU,CAAC;AAoBlB,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,gBAAgB,CAAiC;IACzD,OAAO,CAAC,aAAa,CAAM;gBAMf,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAS5C,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI;IAS5B,O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CAAC,cAAc,CAAC,GAAG,IAAI;CAGpD"}
@@ -23,7 +23,7 @@ class ComponentCompiler {
23
23
  const startTime = Date.now();
24
24
  try {
25
25
  if (this.config.cache) {
26
- const cached = this.getCachedComponent(options.componentName);
26
+ const cached = this.getCachedComponent(options.componentName, options.componentCode);
27
27
  if (cached) {
28
28
  return {
29
29
  success: true,
@@ -43,7 +43,7 @@ class ComponentCompiler {
43
43
  warnings: []
44
44
  };
45
45
  if (this.config.cache) {
46
- this.cacheComponent(compiledComponent);
46
+ this.cacheComponent(compiledComponent, options.componentCode);
47
47
  }
48
48
  return {
49
49
  success: true,
@@ -114,7 +114,8 @@ class ComponentCompiler {
114
114
  return (context, styles = {}) => {
115
115
  const { React, ReactDOM, libraries = {} } = context;
116
116
  const createComponentFn = factoryCreator(React, ReactDOM, React.useState, React.useEffect, React.useCallback, React.useMemo, React.useRef, React.useContext, React.useReducer, React.useLayoutEffect, libraries, styles, console);
117
- return createComponentFn(React, ReactDOM, React.useState, React.useEffect, React.useCallback, React.useMemo, React.useRef, React.useContext, React.useReducer, React.useLayoutEffect, libraries, styles, console);
117
+ const Component = createComponentFn(React, ReactDOM, React.useState, React.useEffect, React.useCallback, React.useMemo, React.useRef, React.useContext, React.useReducer, React.useLayoutEffect, libraries, styles, console);
118
+ return Component;
118
119
  };
119
120
  }
120
121
  catch (error) {
@@ -160,20 +161,26 @@ class ComponentCompiler {
160
161
  generateComponentId(componentName) {
161
162
  return `${componentName}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
162
163
  }
163
- getCachedComponent(componentName) {
164
- for (const [key, component] of this.compilationCache) {
165
- if (component.name === componentName) {
166
- return component;
167
- }
168
- }
169
- return undefined;
164
+ getCachedComponent(componentName, code) {
165
+ const cacheKey = this.createCacheKey(componentName, code);
166
+ return this.compilationCache.get(cacheKey);
167
+ }
168
+ createCacheKey(componentName, code) {
169
+ let hash = 0;
170
+ for (let i = 0; i < code.length; i++) {
171
+ const char = code.charCodeAt(i);
172
+ hash = ((hash << 5) - hash) + char;
173
+ hash = hash & hash;
174
+ }
175
+ return `${componentName}_${hash.toString(36)}`;
170
176
  }
171
- cacheComponent(component) {
177
+ cacheComponent(component, code) {
172
178
  if (this.compilationCache.size >= this.config.maxCacheSize) {
173
179
  const firstKey = this.compilationCache.keys().next().value;
174
180
  this.compilationCache.delete(firstKey);
175
181
  }
176
- this.compilationCache.set(component.id, component);
182
+ const cacheKey = this.createCacheKey(component.name, code);
183
+ this.compilationCache.set(cacheKey, component);
177
184
  }
178
185
  createCompilationError(error, componentName) {
179
186
  return {
package/dist/index.d.ts CHANGED
@@ -7,7 +7,6 @@ export { DEFAULT_PRESETS, DEFAULT_PLUGINS, PRODUCTION_CONFIG, DEVELOPMENT_CONFIG
7
7
  export { ComponentRegistry } from './registry';
8
8
  export { ComponentResolver, ComponentSpec, ResolvedComponents } from './registry';
9
9
  export { createErrorBoundary, withErrorBoundary, formatComponentError, createErrorLogger } from './runtime';
10
- export { wrapComponent, memoizeComponent, lazyComponent, injectProps, conditionalComponent, withErrorHandler, portalComponent, WrapperOptions } from './runtime';
11
10
  export { buildComponentProps, normalizeCallbacks, normalizeStyles, validateComponentProps, mergeProps, createPropsTransformer, wrapCallbacksWithLogging, extractPropPaths, PropBuilderOptions } from './runtime';
12
11
  export { ComponentHierarchyRegistrar, registerComponentHierarchy, validateComponentSpec, flattenComponentHierarchy, countComponentsInHierarchy, HierarchyRegistrationResult, ComponentRegistrationError, HierarchyRegistrationOptions } from './runtime';
13
12
  export { ReactRootManager, reactRootManager, ManagedReactRoot } from './runtime';
@@ -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;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, 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.DEFAULT_CONFIGS = exports.VERSION = exports.CacheManager = exports.resourceManager = exports.ResourceManager = exports.ComponentErrorAnalyzer = exports.LibraryLoader = exports.createStandardLibraries = exports.StandardLibraryManager = exports.createDefaultComponentStyles = exports.SetupStyles = exports.createRuntimeUtilities = exports.RuntimeUtilities = exports.reactRootManager = exports.ReactRootManager = 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.ComponentSpec = 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
- exports.createReactRuntime = void 0;
17
+ exports.createReactRuntime = exports.DEFAULT_CONFIGS = exports.VERSION = exports.CacheManager = exports.resourceManager = exports.ResourceManager = exports.ComponentErrorAnalyzer = exports.LibraryLoader = exports.createStandardLibraries = exports.StandardLibraryManager = exports.createDefaultComponentStyles = exports.SetupStyles = exports.createRuntimeUtilities = exports.RuntimeUtilities = exports.reactRootManager = exports.ReactRootManager = 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.createErrorLogger = exports.formatComponentError = exports.withErrorBoundary = exports.createErrorBoundary = exports.ComponentSpec = 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;
19
18
  const compiler_1 = require("./compiler");
20
19
  const registry_1 = require("./registry");
21
20
  const registry_2 = require("./registry");
@@ -41,31 +40,23 @@ Object.defineProperty(exports, "withErrorBoundary", { enumerable: true, get: fun
41
40
  Object.defineProperty(exports, "formatComponentError", { enumerable: true, get: function () { return runtime_1.formatComponentError; } });
42
41
  Object.defineProperty(exports, "createErrorLogger", { enumerable: true, get: function () { return runtime_1.createErrorLogger; } });
43
42
  var runtime_2 = require("./runtime");
44
- Object.defineProperty(exports, "wrapComponent", { enumerable: true, get: function () { return runtime_2.wrapComponent; } });
45
- Object.defineProperty(exports, "memoizeComponent", { enumerable: true, get: function () { return runtime_2.memoizeComponent; } });
46
- Object.defineProperty(exports, "lazyComponent", { enumerable: true, get: function () { return runtime_2.lazyComponent; } });
47
- Object.defineProperty(exports, "injectProps", { enumerable: true, get: function () { return runtime_2.injectProps; } });
48
- Object.defineProperty(exports, "conditionalComponent", { enumerable: true, get: function () { return runtime_2.conditionalComponent; } });
49
- Object.defineProperty(exports, "withErrorHandler", { enumerable: true, get: function () { return runtime_2.withErrorHandler; } });
50
- Object.defineProperty(exports, "portalComponent", { enumerable: true, get: function () { return runtime_2.portalComponent; } });
43
+ Object.defineProperty(exports, "buildComponentProps", { enumerable: true, get: function () { return runtime_2.buildComponentProps; } });
44
+ Object.defineProperty(exports, "normalizeCallbacks", { enumerable: true, get: function () { return runtime_2.normalizeCallbacks; } });
45
+ Object.defineProperty(exports, "normalizeStyles", { enumerable: true, get: function () { return runtime_2.normalizeStyles; } });
46
+ Object.defineProperty(exports, "validateComponentProps", { enumerable: true, get: function () { return runtime_2.validateComponentProps; } });
47
+ Object.defineProperty(exports, "mergeProps", { enumerable: true, get: function () { return runtime_2.mergeProps; } });
48
+ Object.defineProperty(exports, "createPropsTransformer", { enumerable: true, get: function () { return runtime_2.createPropsTransformer; } });
49
+ Object.defineProperty(exports, "wrapCallbacksWithLogging", { enumerable: true, get: function () { return runtime_2.wrapCallbacksWithLogging; } });
50
+ Object.defineProperty(exports, "extractPropPaths", { enumerable: true, get: function () { return runtime_2.extractPropPaths; } });
51
51
  var runtime_3 = require("./runtime");
52
- Object.defineProperty(exports, "buildComponentProps", { enumerable: true, get: function () { return runtime_3.buildComponentProps; } });
53
- Object.defineProperty(exports, "normalizeCallbacks", { enumerable: true, get: function () { return runtime_3.normalizeCallbacks; } });
54
- Object.defineProperty(exports, "normalizeStyles", { enumerable: true, get: function () { return runtime_3.normalizeStyles; } });
55
- Object.defineProperty(exports, "validateComponentProps", { enumerable: true, get: function () { return runtime_3.validateComponentProps; } });
56
- Object.defineProperty(exports, "mergeProps", { enumerable: true, get: function () { return runtime_3.mergeProps; } });
57
- Object.defineProperty(exports, "createPropsTransformer", { enumerable: true, get: function () { return runtime_3.createPropsTransformer; } });
58
- Object.defineProperty(exports, "wrapCallbacksWithLogging", { enumerable: true, get: function () { return runtime_3.wrapCallbacksWithLogging; } });
59
- Object.defineProperty(exports, "extractPropPaths", { enumerable: true, get: function () { return runtime_3.extractPropPaths; } });
52
+ Object.defineProperty(exports, "ComponentHierarchyRegistrar", { enumerable: true, get: function () { return runtime_3.ComponentHierarchyRegistrar; } });
53
+ Object.defineProperty(exports, "registerComponentHierarchy", { enumerable: true, get: function () { return runtime_3.registerComponentHierarchy; } });
54
+ Object.defineProperty(exports, "validateComponentSpec", { enumerable: true, get: function () { return runtime_3.validateComponentSpec; } });
55
+ Object.defineProperty(exports, "flattenComponentHierarchy", { enumerable: true, get: function () { return runtime_3.flattenComponentHierarchy; } });
56
+ Object.defineProperty(exports, "countComponentsInHierarchy", { enumerable: true, get: function () { return runtime_3.countComponentsInHierarchy; } });
60
57
  var runtime_4 = require("./runtime");
61
- Object.defineProperty(exports, "ComponentHierarchyRegistrar", { enumerable: true, get: function () { return runtime_4.ComponentHierarchyRegistrar; } });
62
- Object.defineProperty(exports, "registerComponentHierarchy", { enumerable: true, get: function () { return runtime_4.registerComponentHierarchy; } });
63
- Object.defineProperty(exports, "validateComponentSpec", { enumerable: true, get: function () { return runtime_4.validateComponentSpec; } });
64
- Object.defineProperty(exports, "flattenComponentHierarchy", { enumerable: true, get: function () { return runtime_4.flattenComponentHierarchy; } });
65
- Object.defineProperty(exports, "countComponentsInHierarchy", { enumerable: true, get: function () { return runtime_4.countComponentsInHierarchy; } });
66
- var runtime_5 = require("./runtime");
67
- Object.defineProperty(exports, "ReactRootManager", { enumerable: true, get: function () { return runtime_5.ReactRootManager; } });
68
- Object.defineProperty(exports, "reactRootManager", { enumerable: true, get: function () { return runtime_5.reactRootManager; } });
58
+ Object.defineProperty(exports, "ReactRootManager", { enumerable: true, get: function () { return runtime_4.ReactRootManager; } });
59
+ Object.defineProperty(exports, "reactRootManager", { enumerable: true, get: function () { return runtime_4.reactRootManager; } });
69
60
  var runtime_utilities_1 = require("./utilities/runtime-utilities");
70
61
  Object.defineProperty(exports, "RuntimeUtilities", { enumerable: true, get: function () { return runtime_utilities_1.RuntimeUtilities; } });
71
62
  Object.defineProperty(exports, "createRuntimeUtilities", { enumerable: true, get: function () { return runtime_utilities_1.createRuntimeUtilities; } });
@@ -1,5 +1,4 @@
1
1
  export { createErrorBoundary, withErrorBoundary, formatComponentError, createErrorLogger } from './error-boundary';
2
- export { wrapComponent, memoizeComponent, lazyComponent, injectProps, conditionalComponent, withErrorHandler, portalComponent, WrapperOptions } from './component-wrapper';
3
2
  export { buildComponentProps, normalizeCallbacks, normalizeStyles, validateComponentProps, mergeProps, createPropsTransformer, wrapCallbacksWithLogging, extractPropPaths, PropBuilderOptions } from './prop-builder';
4
3
  export { ComponentHierarchyRegistrar, registerComponentHierarchy, validateComponentSpec, flattenComponentHierarchy, countComponentsInHierarchy, HierarchyRegistrationResult, ComponentRegistrationError, HierarchyRegistrationOptions } from './component-hierarchy';
5
4
  export { ReactRootManager, reactRootManager, ManagedReactRoot } from './react-root-manager';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,UAAU,EACV,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC7B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,UAAU,EACV,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC7B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,sBAAsB,CAAC"}
@@ -1,19 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.reactRootManager = exports.ReactRootManager = 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 = void 0;
3
+ exports.reactRootManager = exports.ReactRootManager = 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.createErrorLogger = exports.formatComponentError = exports.withErrorBoundary = exports.createErrorBoundary = void 0;
4
4
  var error_boundary_1 = require("./error-boundary");
5
5
  Object.defineProperty(exports, "createErrorBoundary", { enumerable: true, get: function () { return error_boundary_1.createErrorBoundary; } });
6
6
  Object.defineProperty(exports, "withErrorBoundary", { enumerable: true, get: function () { return error_boundary_1.withErrorBoundary; } });
7
7
  Object.defineProperty(exports, "formatComponentError", { enumerable: true, get: function () { return error_boundary_1.formatComponentError; } });
8
8
  Object.defineProperty(exports, "createErrorLogger", { enumerable: true, get: function () { return error_boundary_1.createErrorLogger; } });
9
- var component_wrapper_1 = require("./component-wrapper");
10
- Object.defineProperty(exports, "wrapComponent", { enumerable: true, get: function () { return component_wrapper_1.wrapComponent; } });
11
- Object.defineProperty(exports, "memoizeComponent", { enumerable: true, get: function () { return component_wrapper_1.memoizeComponent; } });
12
- Object.defineProperty(exports, "lazyComponent", { enumerable: true, get: function () { return component_wrapper_1.lazyComponent; } });
13
- Object.defineProperty(exports, "injectProps", { enumerable: true, get: function () { return component_wrapper_1.injectProps; } });
14
- Object.defineProperty(exports, "conditionalComponent", { enumerable: true, get: function () { return component_wrapper_1.conditionalComponent; } });
15
- Object.defineProperty(exports, "withErrorHandler", { enumerable: true, get: function () { return component_wrapper_1.withErrorHandler; } });
16
- Object.defineProperty(exports, "portalComponent", { enumerable: true, get: function () { return component_wrapper_1.portalComponent; } });
17
9
  var prop_builder_1 = require("./prop-builder");
18
10
  Object.defineProperty(exports, "buildComponentProps", { enumerable: true, get: function () { return prop_builder_1.buildComponentProps; } });
19
11
  Object.defineProperty(exports, "normalizeCallbacks", { enumerable: true, get: function () { return prop_builder_1.normalizeCallbacks; } });
@@ -1 +1 @@
1
- {"version":3,"file":"react-root-manager.d.ts","sourceRoot":"","sources":["../../src/runtime/react-root-manager.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,GAAG,CAAC;IACV,SAAS,EAAE,WAAW,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,IAAI,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAMD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAAuC;IACpD,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,YA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gCT,MAAM,CACJ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,GAAG,EACZ,UAAU,CAAC,EAAE,MAAM,IAAI,GACtB,IAAI;IAkDP,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAgD5D,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB/D,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAOpC,QAAQ,IAAI;QACV,UAAU,EAAE,MAAM,CAAC;QACnB,cAAc,EAAE,MAAM,CAAC;QACvB,eAAe,EAAE,MAAM,CAAC;KACzB;IAWK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAI/B;AAGD,eAAO,MAAM,gBAAgB,kBAAyB,CAAC"}
@@ -72,8 +72,7 @@ class ReactRootManager {
72
72
  this.renderingRoots.delete(rootId);
73
73
  if (managedRoot.container) {
74
74
  delete managedRoot.container._reactRootContainer;
75
- const newContainer = managedRoot.container.cloneNode(false);
76
- managedRoot.container.parentNode?.replaceChild(newContainer, managedRoot.container);
75
+ managedRoot.container.innerHTML = '';
77
76
  }
78
77
  resolve();
79
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/react-runtime",
3
- "version": "2.78.0",
3
+ "version": "2.79.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.78.0",
29
- "@memberjunction/global": "2.78.0",
30
- "@memberjunction/interactive-component-types": "2.78.0",
28
+ "@memberjunction/core": "2.79.0",
29
+ "@memberjunction/global": "2.79.0",
30
+ "@memberjunction/interactive-component-types": "2.79.0",
31
31
  "@babel/standalone": "^7.23.5",
32
32
  "rxjs": "^7.8.1"
33
33
  },
@@ -34,6 +34,7 @@ const DEFAULT_COMPILER_CONFIG: CompilerConfig = {
34
34
  export class ComponentCompiler {
35
35
  private config: CompilerConfig;
36
36
  private compilationCache: Map<string, CompiledComponent>;
37
+ private cacheAccessOrder: string[]; // Track access order for LRU
37
38
  private babelInstance: any;
38
39
 
39
40
  /**
@@ -64,7 +65,7 @@ export class ComponentCompiler {
64
65
  try {
65
66
  // Check cache first if enabled
66
67
  if (this.config.cache) {
67
- const cached = this.getCachedComponent(options.componentName);
68
+ const cached = this.getCachedComponent(options.componentName, options.componentCode);
68
69
  if (cached) {
69
70
  return {
70
71
  success: true,
@@ -101,7 +102,7 @@ export class ComponentCompiler {
101
102
 
102
103
  // Cache if enabled
103
104
  if (this.config.cache) {
104
- this.cacheComponent(compiledComponent);
105
+ this.cacheComponent(compiledComponent, options.componentCode);
105
106
  }
106
107
 
107
108
  return {
@@ -227,7 +228,7 @@ export class ComponentCompiler {
227
228
  );
228
229
 
229
230
  // Call createComponent to get the actual component
230
- return createComponentFn(
231
+ const Component = createComponentFn(
231
232
  React,
232
233
  ReactDOM,
233
234
  React.useState,
@@ -242,6 +243,9 @@ export class ComponentCompiler {
242
243
  styles,
243
244
  console
244
245
  );
246
+
247
+ // Return the component directly
248
+ return Component;
245
249
  };
246
250
  } catch (error: any) {
247
251
  throw new Error(`Failed to create component factory: ${error.message}`);
@@ -326,24 +330,38 @@ export class ComponentCompiler {
326
330
  /**
327
331
  * Gets a cached component if available
328
332
  * @param componentName - Name of the component
333
+ * @param code - Component source code
329
334
  * @returns Cached component or undefined
330
335
  */
331
- private getCachedComponent(componentName: string): CompiledComponent | undefined {
332
- // Simple cache lookup by name
333
- // In production, might want to include code hash for cache key
334
- for (const [key, component] of this.compilationCache) {
335
- if (component.name === componentName) {
336
- return component;
337
- }
336
+ private getCachedComponent(componentName: string, code: string): CompiledComponent | undefined {
337
+ // Create cache key based on name AND content hash
338
+ const cacheKey = this.createCacheKey(componentName, code);
339
+ return this.compilationCache.get(cacheKey);
340
+ }
341
+
342
+ /**
343
+ * Creates a cache key based on component name and code content
344
+ * @param componentName - Name of the component
345
+ * @param code - Component source code
346
+ * @returns Cache key
347
+ */
348
+ private createCacheKey(componentName: string, code: string): string {
349
+ // Simple hash function for code content
350
+ let hash = 0;
351
+ for (let i = 0; i < code.length; i++) {
352
+ const char = code.charCodeAt(i);
353
+ hash = ((hash << 5) - hash) + char;
354
+ hash = hash & hash; // Convert to 32-bit integer
338
355
  }
339
- return undefined;
356
+ return `${componentName}_${hash.toString(36)}`;
340
357
  }
341
358
 
342
359
  /**
343
360
  * Caches a compiled component
344
361
  * @param component - Component to cache
362
+ * @param code - Original source code
345
363
  */
346
- private cacheComponent(component: CompiledComponent): void {
364
+ private cacheComponent(component: CompiledComponent, code: string): void {
347
365
  // Enforce cache size limit
348
366
  if (this.compilationCache.size >= this.config.maxCacheSize) {
349
367
  // Remove oldest entry (first in map)
@@ -351,7 +369,8 @@ export class ComponentCompiler {
351
369
  this.compilationCache.delete(firstKey);
352
370
  }
353
371
 
354
- this.compilationCache.set(component.id, component);
372
+ const cacheKey = this.createCacheKey(component.name, code);
373
+ this.compilationCache.set(cacheKey, component);
355
374
  }
356
375
 
357
376
  /**
package/src/index.ts CHANGED
@@ -40,16 +40,6 @@ export {
40
40
  createErrorLogger
41
41
  } from './runtime';
42
42
 
43
- export {
44
- wrapComponent,
45
- memoizeComponent,
46
- lazyComponent,
47
- injectProps,
48
- conditionalComponent,
49
- withErrorHandler,
50
- portalComponent,
51
- WrapperOptions
52
- } from './runtime';
53
43
 
54
44
  export {
55
45
  buildComponentProps,
@@ -10,16 +10,6 @@ export {
10
10
  createErrorLogger
11
11
  } from './error-boundary';
12
12
 
13
- export {
14
- wrapComponent,
15
- memoizeComponent,
16
- lazyComponent,
17
- injectProps,
18
- conditionalComponent,
19
- withErrorHandler,
20
- portalComponent,
21
- WrapperOptions
22
- } from './component-wrapper';
23
13
 
24
14
  export {
25
15
  buildComponentProps,
@@ -138,9 +138,8 @@ export class ReactRootManager {
138
138
  if (managedRoot.container) {
139
139
  // Clear React's internal references
140
140
  delete (managedRoot.container as any)._reactRootContainer;
141
- // Clear all event listeners
142
- const newContainer = managedRoot.container.cloneNode(false) as HTMLElement;
143
- managedRoot.container.parentNode?.replaceChild(newContainer, managedRoot.container);
141
+ // Clear the container content without replacing the node
142
+ managedRoot.container.innerHTML = '';
144
143
  }
145
144
 
146
145
  resolve();