@memberjunction/react-runtime 2.98.0 → 2.100.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.
Files changed (71) hide show
  1. package/.turbo/turbo-build.log +15 -20
  2. package/CHANGELOG.md +26 -0
  3. package/README.md +171 -1
  4. package/dist/compiler/component-compiler.d.ts.map +1 -1
  5. package/dist/compiler/component-compiler.js +59 -8
  6. package/dist/compiler/component-compiler.js.map +1 -1
  7. package/dist/component-manager/component-manager.d.ts +39 -0
  8. package/dist/component-manager/component-manager.d.ts.map +1 -0
  9. package/dist/component-manager/component-manager.js +474 -0
  10. package/dist/component-manager/component-manager.js.map +1 -0
  11. package/dist/component-manager/index.d.ts +3 -0
  12. package/dist/component-manager/index.d.ts.map +1 -0
  13. package/dist/component-manager/index.js +6 -0
  14. package/dist/component-manager/index.js.map +1 -0
  15. package/dist/component-manager/types.d.ts +62 -0
  16. package/dist/component-manager/types.d.ts.map +1 -0
  17. package/dist/component-manager/types.js +3 -0
  18. package/dist/component-manager/types.js.map +1 -0
  19. package/dist/index.d.ts +7 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +18 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/registry/component-registry-service.d.ts +16 -1
  24. package/dist/registry/component-registry-service.d.ts.map +1 -1
  25. package/dist/registry/component-registry-service.js +212 -10
  26. package/dist/registry/component-registry-service.js.map +1 -1
  27. package/dist/registry/component-registry.d.ts +1 -1
  28. package/dist/registry/component-registry.d.ts.map +1 -1
  29. package/dist/registry/component-registry.js.map +1 -1
  30. package/dist/registry/component-resolver.d.ts.map +1 -1
  31. package/dist/registry/component-resolver.js +122 -52
  32. package/dist/registry/component-resolver.js.map +1 -1
  33. package/dist/registry/index.d.ts +1 -1
  34. package/dist/registry/index.d.ts.map +1 -1
  35. package/dist/registry/index.js.map +1 -1
  36. package/dist/runtime/component-hierarchy.d.ts +4 -0
  37. package/dist/runtime/component-hierarchy.d.ts.map +1 -1
  38. package/dist/runtime/component-hierarchy.js +127 -12
  39. package/dist/runtime/component-hierarchy.js.map +1 -1
  40. package/dist/runtime.umd.js +535 -1
  41. package/dist/types/index.d.ts +1 -0
  42. package/dist/types/index.d.ts.map +1 -1
  43. package/dist/types/index.js.map +1 -1
  44. package/dist/utilities/component-unwrapper.d.ts +7 -0
  45. package/dist/utilities/component-unwrapper.d.ts.map +1 -0
  46. package/dist/utilities/component-unwrapper.js +369 -0
  47. package/dist/utilities/component-unwrapper.js.map +1 -0
  48. package/dist/utilities/index.d.ts +1 -0
  49. package/dist/utilities/index.d.ts.map +1 -1
  50. package/dist/utilities/index.js +1 -0
  51. package/dist/utilities/index.js.map +1 -1
  52. package/dist/utilities/library-loader.d.ts +3 -0
  53. package/dist/utilities/library-loader.d.ts.map +1 -1
  54. package/dist/utilities/library-loader.js +101 -17
  55. package/dist/utilities/library-loader.js.map +1 -1
  56. package/examples/component-registry-integration.ts +191 -0
  57. package/package.json +6 -5
  58. package/src/compiler/component-compiler.ts +101 -23
  59. package/src/component-manager/component-manager.ts +736 -0
  60. package/src/component-manager/index.ts +13 -0
  61. package/src/component-manager/types.ts +204 -0
  62. package/src/index.ts +37 -1
  63. package/src/registry/component-registry-service.ts +315 -18
  64. package/src/registry/component-registry.ts +1 -1
  65. package/src/registry/component-resolver.ts +159 -67
  66. package/src/registry/index.ts +1 -1
  67. package/src/runtime/component-hierarchy.ts +124 -13
  68. package/src/types/index.ts +2 -0
  69. package/src/utilities/component-unwrapper.ts +481 -0
  70. package/src/utilities/index.ts +2 -1
  71. package/src/utilities/library-loader.ts +155 -22
@@ -1,30 +1,25 @@
1
1
 
2
- > @memberjunction/react-runtime@2.98.0 build
2
+ > @memberjunction/react-runtime@2.100.0 build
3
3
  > npm run build:node && npm run build:umd
4
4
 
5
5
 
6
- > @memberjunction/react-runtime@2.98.0 build:node
6
+ > @memberjunction/react-runtime@2.100.0 build:node
7
7
  > tsc
8
8
 
9
9
 
10
- > @memberjunction/react-runtime@2.98.0 build:umd
10
+ > @memberjunction/react-runtime@2.100.0 build:umd
11
11
  > webpack --config webpack.umd.config.js
12
12
 
13
13
  [BABEL] Note: The code generator has deoptimised the styling of /home/runner/work/MJ/MJ/packages/MJCoreEntities/dist/generated/entity_subclasses.js as it exceeds the max of 500KB.
14
- asset runtime.umd.js 1.93 MiB [emitted] [minimized] [big] (name: main) 1 related asset
15
- runtime modules 344 bytes 2 modules
16
- modules by path ../../../node_modules/ 1.01 MiB 237 modules
17
- modules by path ../../MJGlobal/ 174 KiB
18
- modules by path ../../MJGlobal/node_modules/uuid/dist/commonjs-browser/*.js 35 KiB 21 modules
19
- modules by path ../../MJGlobal/dist/ 139 KiB 14 modules
20
- modules by path ../../MJCore/ 644 KiB 31 modules
21
- modules by path ./dist/ 361 KiB 25 modules
22
- modules by path ../../MJCoreEntities/dist/ 2.05 MiB
23
- modules by path ../../MJCoreEntities/dist/custom/*.js 245 KiB 15 modules
24
- modules by path ../../MJCoreEntities/dist/custom/ResourcePermissions/*.js 46.9 KiB 3 modules
25
- + 3 modules
26
- modules by path ../../InteractiveComponents/dist/*.js 36.8 KiB
27
- ../../InteractiveComponents/dist/index.js 1.21 KiB [built] [code generated]
28
- ../../InteractiveComponents/dist/data-requirements.js 79 bytes [built] [code generated]
29
- + 8 modules
30
- webpack 5.92.1 compiled successfully in 114094 ms
14
+ asset runtime.umd.js 2.27 MiB [emitted] [minimized] [big] (name: main) 1 related asset
15
+ orphan modules 513 KiB [orphan] 123 modules
16
+ runtime modules 1010 bytes 5 modules
17
+ modules by path ../../ 4.61 MiB
18
+ modules by path ../../../node_modules/ 1.62 MiB 258 modules
19
+ modules by path ../../MJGlobal/ 174 KiB 35 modules
20
+ modules by path ../../MJCore/ 644 KiB 31 modules
21
+ modules by path ../../GraphQLDataProvider/ 111 KiB 22 modules
22
+ modules by path ../../MJCoreEntities/dist/ 2.05 MiB 21 modules
23
+ modules by path ../../InteractiveComponents/dist/*.js 36.8 KiB 10 modules
24
+ modules by path ./dist/ 469 KiB 28 modules
25
+ webpack 5.92.1 compiled successfully in 136339 ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @memberjunction/react-runtime
2
2
 
3
+ ## 2.100.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 6dfe03c: tweaks
8
+ - Updated dependencies [5f76e3a]
9
+ - Updated dependencies [b3132ec]
10
+ - Updated dependencies [ffc2c1a]
11
+ - @memberjunction/core@2.100.0
12
+ - @memberjunction/graphql-dataprovider@2.100.0
13
+ - @memberjunction/core-entities@2.100.0
14
+ - @memberjunction/interactive-component-types@2.100.0
15
+ - @memberjunction/global@2.100.0
16
+
17
+ ## 2.99.0
18
+
19
+ ### Patch Changes
20
+
21
+ - 5af2d74: updates to react runtime
22
+ - Updated dependencies [eb7677d]
23
+ - Updated dependencies [8bbb0a9]
24
+ - @memberjunction/core-entities@2.99.0
25
+ - @memberjunction/core@2.99.0
26
+ - @memberjunction/interactive-component-types@2.99.0
27
+ - @memberjunction/global@2.99.0
28
+
3
29
  ## 2.98.0
4
30
 
5
31
  ### Minor Changes
package/README.md CHANGED
@@ -33,9 +33,104 @@ import * as Babel from '@babel/standalone';
33
33
 
34
34
  // Create runtime with Babel instance
35
35
  const runtime = createReactRuntime(Babel);
36
+
37
+ // The runtime now includes the unified ComponentManager
38
+ const { compiler, registry, resolver, manager } = runtime;
39
+ ```
40
+
41
+ ## NEW: Unified ComponentManager (Recommended)
42
+
43
+ The ComponentManager is a new unified API that simplifies component loading by handling fetching, compilation, registration, and caching in a single, efficient operation. It eliminates duplicate work and provides better performance.
44
+
45
+ ### Why Use ComponentManager?
46
+
47
+ - **Single API**: One method handles everything - no need to coordinate multiple components
48
+ - **Efficient**: Automatically prevents duplicate fetching and compilation
49
+ - **Smart Caching**: Multi-level caching with automatic invalidation
50
+ - **Registry Tracking**: Built-in usage tracking for licensing compliance
51
+ - **Better Error Handling**: Comprehensive error reporting with phases
52
+
53
+ ### Loading a Component Hierarchy
54
+
55
+ ```typescript
56
+ import { ComponentSpec } from '@memberjunction/interactive-component-types';
57
+
58
+ const componentSpec: ComponentSpec = {
59
+ name: 'Dashboard',
60
+ location: 'registry',
61
+ registry: 'SkipAI',
62
+ namespace: 'analytics',
63
+ version: '1.0.0',
64
+ dependencies: [
65
+ { name: 'Chart', location: 'registry', registry: 'SkipAI' },
66
+ { name: 'Grid', location: 'embedded', code: '...' }
67
+ ]
68
+ };
69
+
70
+ // Load the entire hierarchy with one call
71
+ const result = await runtime.manager.loadHierarchy(componentSpec, {
72
+ contextUser: currentUser,
73
+ defaultNamespace: 'Global',
74
+ defaultVersion: 'latest',
75
+ returnType: 'both'
76
+ });
77
+
78
+ if (result.success) {
79
+ // Everything is loaded and ready
80
+ const rootComponent = result.rootComponent;
81
+ const resolvedSpec = result.resolvedSpec;
82
+
83
+ console.log(`Loaded ${result.loadedComponents.length} components`);
84
+ console.log(`Stats:`, result.stats);
85
+ }
86
+ ```
87
+
88
+ ### Loading a Single Component
89
+
90
+ ```typescript
91
+ // For simple single component loading
92
+ const result = await runtime.manager.loadComponent(componentSpec, {
93
+ contextUser: currentUser,
94
+ forceRefresh: false, // Use cache if available
95
+ trackUsage: true // Track usage for licensing
96
+ });
97
+
98
+ if (result.success) {
99
+ const component = result.component;
100
+ const wasFromCache = result.fromCache;
101
+ }
102
+ ```
103
+
104
+ ### Configuration Options
105
+
106
+ ```typescript
107
+ const runtime = createReactRuntime(Babel, {
108
+ manager: {
109
+ debug: true, // Enable debug logging
110
+ maxCacheSize: 100, // Max cached specs
111
+ cacheTTL: 3600000, // 1 hour cache TTL
112
+ enableUsageTracking: true, // Track registry usage
113
+ dependencyBatchSize: 5, // Parallel dependency loading
114
+ fetchTimeout: 30000 // 30 second timeout
115
+ }
116
+ });
36
117
  ```
37
118
 
38
- ### Compiling a Component
119
+ ### Cache Management
120
+
121
+ ```typescript
122
+ // Clear all caches
123
+ runtime.manager.clearCache();
124
+
125
+ // Get cache statistics
126
+ const stats = runtime.manager.getCacheStats();
127
+ console.log(`Cached specs: ${stats.fetchCacheSize}`);
128
+ console.log(`Usage notifications: ${stats.notificationsCount}`);
129
+ ```
130
+
131
+ ## Legacy Approach (Still Supported)
132
+
133
+ ### Compiling a Component (Old Way)
39
134
 
40
135
  ```typescript
41
136
  const componentCode = `
@@ -421,6 +516,81 @@ const removed = runtime.registry.cleanup();
421
516
  console.log(`Removed ${removed} unused components`);
422
517
  ```
423
518
 
519
+ ### External Registry Components
520
+
521
+ The React Runtime supports loading components from external registries through the `ComponentRegistryService`:
522
+
523
+ ```typescript
524
+ // Component specs can reference external registries
525
+ const componentSpec = {
526
+ name: 'DataGrid',
527
+ location: 'registry',
528
+ registry: 'MJ', // Registry name (globally unique)
529
+ namespace: 'core/ui',
530
+ version: 'latest',
531
+ // ... other spec fields
532
+ };
533
+
534
+ // The runtime will:
535
+ // 1. Look up the registry by name in ComponentRegistries
536
+ // 2. Fetch the component via GraphQL/MJServer
537
+ // 3. Calculate SHA-256 hash of the spec for cache validation
538
+ // 4. Compile and cache the component
539
+ ```
540
+
541
+ #### GraphQL Client Configuration
542
+
543
+ The `ComponentRegistryService` requires a GraphQL client for fetching from external registries. It supports two configuration approaches:
544
+
545
+ 1. **Automatic Fallback** (Recommended): If no client is explicitly provided, the service automatically creates a `GraphQLComponentRegistryClient` using `Metadata.Provider`
546
+ ```typescript
547
+ // No explicit client needed - will create one from Metadata.Provider
548
+ const registryService = ComponentRegistryService.getInstance(compiler, context);
549
+ // The service will automatically:
550
+ // 1. Check if a client was provided
551
+ // 2. If not, dynamically import @memberjunction/graphql-dataprovider
552
+ // 3. Create a GraphQLComponentRegistryClient with Metadata.Provider
553
+ // 4. Cache and reuse this client for subsequent calls
554
+ ```
555
+
556
+ 2. **Explicit Client**: Provide a custom GraphQL client that implements `IComponentRegistryClient`
557
+ ```typescript
558
+ // Custom client implementation
559
+ const customClient: IComponentRegistryClient = {
560
+ GetRegistryComponent: async (params) => { /* ... */ }
561
+ };
562
+
563
+ // Pass during creation
564
+ const registryService = ComponentRegistryService.getInstance(
565
+ compiler, context, debug, customClient
566
+ );
567
+
568
+ // Or set later
569
+ registryService.setGraphQLClient(customClient);
570
+ ```
571
+
572
+ The automatic fallback ensures external registry fetching works out-of-the-box in MemberJunction environments where `Metadata.Provider` is configured. The dynamic import approach allows the React runtime to function even when `@memberjunction/graphql-dataprovider` is not available.
573
+
574
+ #### Component Caching with SHA-256 Validation
575
+
576
+ The runtime uses SHA-256 hashing to ensure cached components are up-to-date:
577
+
578
+ ```typescript
579
+ // When fetching external components:
580
+ // 1. Fetch spec from registry
581
+ // 2. Calculate SHA-256 hash using Web Crypto API
582
+ // 3. Compare with cached component's hash
583
+ // 4. Recompile only if spec has changed
584
+
585
+ // Note: Requires secure context (HTTPS or localhost)
586
+ // Web Crypto API is used for consistent hashing across environments
587
+ ```
588
+
589
+ #### Registry Types
590
+
591
+ - **Local Registry** (`registry` field undefined): Components stored in local database
592
+ - **External Registry** (`registry` field defined): Components fetched from remote registries via MJServer
593
+
424
594
  ## Configuration
425
595
 
426
596
  ### Compiler Configuration
@@ -1 +1 @@
1
- {"version":3,"file":"component-compiler.d.ts","sourceRoot":"","sources":["../../src/compiler/component-compiler.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,cAAc,EAEd,iBAAiB,EACjB,cAAc,EAGf,MAAM,UAAU,CAAC;AAyBlB,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,gBAAgB,CAAiC;IACzD,OAAO,CAAC,gBAAgB,CAAW;IACnC,OAAO,CAAC,aAAa,CAAM;gBAMf,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAS5C,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI;IAS5B,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAyElE,OAAO,CAAC,kBAAkB;IAmC1B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAkC;IAEjE,OAAO,CAAC,iBAAiB;YAqRX,qBAAqB;YAqJrB,UAAU;IA+BxB,OAAO,CAAC,UAAU;IAyElB,OAAO,CAAC,sBAAsB;IA0E9B,OAAO,CAAC,sBAAsB;IAiE9B,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,cAAc;IAgBtB,OAAO,CAAC,cAAc;IAmBtB,OAAO,CAAC,sBAAsB;IAa9B,UAAU,IAAI,IAAI;IAQlB,YAAY,IAAI,MAAM;IAQtB,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI;CAGpD"}
1
+ {"version":3,"file":"component-compiler.d.ts","sourceRoot":"","sources":["../../src/compiler/component-compiler.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,cAAc,EAEd,iBAAiB,EACjB,cAAc,EAGf,MAAM,UAAU,CAAC;AA0BlB,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,gBAAgB,CAAiC;IACzD,OAAO,CAAC,gBAAgB,CAAW;IACnC,OAAO,CAAC,aAAa,CAAM;gBAMf,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAS5C,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI;IAS5B,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA2ElE,OAAO,CAAC,kBAAkB;IAmC1B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAkC;IAEjE,OAAO,CAAC,iBAAiB;YA2RX,qBAAqB;YAiKrB,UAAU;IA+BxB,OAAO,CAAC,UAAU;IA0ElB,OAAO,CAAC,sBAAsB;IAkI9B,OAAO,CAAC,sBAAsB;IAiE9B,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,cAAc;IAgBtB,OAAO,CAAC,cAAc;IAmBtB,OAAO,CAAC,sBAAsB;IAa9B,UAAU,IAAI,IAAI;IAQlB,YAAY,IAAI,MAAM;IAQtB,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI;CAGpD"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ComponentCompiler = void 0;
4
4
  const library_registry_1 = require("../utilities/library-registry");
5
5
  const library_loader_1 = require("../utilities/library-loader");
6
+ const component_unwrapper_1 = require("../utilities/component-unwrapper");
6
7
  const DEFAULT_COMPILER_CONFIG = {
7
8
  babel: {
8
9
  presets: ['react'],
@@ -39,7 +40,7 @@ class ComponentCompiler {
39
40
  this.validateCompileOptions(options);
40
41
  const loadedLibraries = await this.loadRequiredLibraries(options.libraries, options.allLibraries);
41
42
  const transpiledCode = this.transpileComponent(options.componentCode, options.componentName, options);
42
- const componentFactory = this.createComponentFactory(transpiledCode, options.componentName, loadedLibraries);
43
+ const componentFactory = this.createComponentFactory(transpiledCode, options.componentName, loadedLibraries, options);
43
44
  const compiledComponent = {
44
45
  factory: componentFactory,
45
46
  id: this.generateComponentId(options.componentName),
@@ -54,7 +55,8 @@ class ComponentCompiler {
54
55
  success: true,
55
56
  component: compiledComponent,
56
57
  duration: Date.now() - startTime,
57
- size: transpiledCode.length
58
+ size: transpiledCode.length,
59
+ loadedLibraries: loadedLibraries
58
60
  };
59
61
  }
60
62
  catch (error) {
@@ -144,13 +146,19 @@ class ComponentCompiler {
144
146
  function createComponent(
145
147
  React, ReactDOM,
146
148
  useState, useEffect, useCallback, useMemo, useRef, useContext, useReducer, useLayoutEffect,
147
- libraries, styles, console, components
149
+ libraries, styles, console, components,
150
+ unwrapLibraryComponent, unwrapLibraryComponents, unwrapAllLibraryComponents
148
151
  ) {
149
152
  if (!React)
150
153
  console.log('[React-Runtime-JS] React is not defined');
151
154
  if (!ReactDOM)
152
155
  console.log('[React-Runtime-JS] ReactDOM is not defined');
153
156
 
157
+ // Make unwrap functions available with legacy names for backward compatibility
158
+ const unwrapComponent = unwrapLibraryComponent;
159
+ const unwrapComponents = unwrapLibraryComponents;
160
+ const unwrapAllComponents = unwrapAllLibraryComponents;
161
+
154
162
  // Code for ${componentName}
155
163
  ${componentCode}
156
164
 
@@ -369,6 +377,14 @@ class ComponentCompiler {
369
377
  console.warn(`⚠️ Invalid library entry detected (missing name):`, lib);
370
378
  return false;
371
379
  }
380
+ if (lib.name === 'unknown' || lib.name === 'null' || lib.name === 'undefined') {
381
+ console.warn(`⚠️ Filtering out invalid library with name '${lib.name}':`, lib);
382
+ return false;
383
+ }
384
+ if (!lib.globalVariable || lib.globalVariable === 'undefined' || lib.globalVariable === 'null') {
385
+ console.warn(`⚠️ Filtering out library '${lib.name}' with invalid globalVariable:`, lib.globalVariable);
386
+ return false;
387
+ }
372
388
  const libNameLower = lib.name.toLowerCase();
373
389
  if (libNameLower === 'react' || libNameLower === 'reactdom') {
374
390
  console.warn(`⚠️ Library '${lib.name}' is automatically loaded by the React runtime and should not be requested separately`);
@@ -522,17 +538,52 @@ class ComponentCompiler {
522
538
  document.head.appendChild(script);
523
539
  });
524
540
  }
525
- createComponentFactory(transpiledCode, componentName, loadedLibraries) {
541
+ createComponentFactory(transpiledCode, componentName, loadedLibraries, options) {
526
542
  try {
527
- const factoryCreator = new Function('React', 'ReactDOM', 'useState', 'useEffect', 'useCallback', 'useMemo', 'useRef', 'useContext', 'useReducer', 'useLayoutEffect', 'libraries', 'styles', 'console', 'components', `${transpiledCode}; return createComponent;`);
543
+ const factoryCreator = new Function('React', 'ReactDOM', 'useState', 'useEffect', 'useCallback', 'useMemo', 'useRef', 'useContext', 'useReducer', 'useLayoutEffect', 'libraries', 'styles', 'console', 'components', 'unwrapLibraryComponent', 'unwrapLibraryComponents', 'unwrapAllLibraryComponents', `${transpiledCode}; return createComponent;`);
528
544
  return (context, styles = {}, components = {}) => {
529
545
  const { React, ReactDOM, libraries = {} } = context;
546
+ if (!React) {
547
+ console.error('🔴 CRITICAL: React is NULL in createComponentFactory!');
548
+ console.error('Context provided:', context);
549
+ console.error('Context keys:', Object.keys(context));
550
+ throw new Error('React is null in runtime context when creating component factory');
551
+ }
552
+ if (!React.useState || !React.useEffect) {
553
+ console.error('🔴 CRITICAL: React hooks are missing!');
554
+ console.error('React object keys:', React ? Object.keys(React) : 'React is null');
555
+ console.error('useState:', typeof React?.useState);
556
+ console.error('useEffect:', typeof React?.useEffect);
557
+ }
530
558
  const mergedLibraries = { ...libraries };
559
+ const specLibraryNames = new Set((options.libraries || []).map((lib) => lib.globalVariable).filter(Boolean));
531
560
  loadedLibraries.forEach((value, key) => {
532
- mergedLibraries[key] = value;
561
+ if (specLibraryNames.has(key)) {
562
+ mergedLibraries[key] = value;
563
+ }
564
+ else if (this.config.debug) {
565
+ console.log(`⚠️ Filtering out dependency-only library: ${key}`);
566
+ }
533
567
  });
534
- const createComponentFn = factoryCreator(React, ReactDOM, React.useState, React.useEffect, React.useCallback, React.useMemo, React.useRef, React.useContext, React.useReducer, React.useLayoutEffect, mergedLibraries, styles, console, components);
535
- const Component = createComponentFn(React, ReactDOM, React.useState, React.useEffect, React.useCallback, React.useMemo, React.useRef, React.useContext, React.useReducer, React.useLayoutEffect, mergedLibraries, styles, console, components);
568
+ const boundUnwrapLibraryComponent = (lib, name) => (0, component_unwrapper_1.unwrapLibraryComponent)(lib, name, this.config.debug);
569
+ const boundUnwrapLibraryComponents = (lib, ...names) => (0, component_unwrapper_1.unwrapLibraryComponents)(lib, ...names, this.config.debug);
570
+ const boundUnwrapAllLibraryComponents = (lib) => (0, component_unwrapper_1.unwrapAllLibraryComponents)(lib, this.config.debug);
571
+ let createComponentFn;
572
+ try {
573
+ createComponentFn = factoryCreator(React, ReactDOM, React.useState, React.useEffect, React.useCallback, React.useMemo, React.useRef, React.useContext, React.useReducer, React.useLayoutEffect, mergedLibraries, styles, console, components, boundUnwrapLibraryComponent, boundUnwrapLibraryComponents, boundUnwrapAllLibraryComponents);
574
+ }
575
+ catch (error) {
576
+ console.error('🔴 CRITICAL: Error calling factoryCreator with React hooks!');
577
+ console.error('Error:', error?.message || error);
578
+ console.error('React is:', React);
579
+ console.error('React type:', typeof React);
580
+ if (React) {
581
+ console.error('React.useState:', typeof React.useState);
582
+ console.error('React.useEffect:', typeof React.useEffect);
583
+ }
584
+ throw new Error(`Failed to create component factory: ${error?.message || error}`);
585
+ }
586
+ const Component = createComponentFn(React, ReactDOM, React.useState, React.useEffect, React.useCallback, React.useMemo, React.useRef, React.useContext, React.useReducer, React.useLayoutEffect, mergedLibraries, styles, console, components, boundUnwrapLibraryComponent, boundUnwrapLibraryComponents, boundUnwrapAllLibraryComponents);
536
587
  return Component;
537
588
  };
538
589
  }