@memberjunction/react-runtime 2.112.0 â 2.113.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +11 -10
- package/CHANGELOG.md +14 -1
- package/dist/compiler/component-compiler.d.ts.map +1 -1
- package/dist/compiler/component-compiler.js +56 -66
- package/dist/compiler/component-compiler.js.map +1 -1
- package/dist/component-manager/component-manager.d.ts.map +1 -1
- package/dist/component-manager/component-manager.js +42 -48
- package/dist/component-manager/component-manager.js.map +1 -1
- package/dist/component-manager/types.d.ts +1 -1
- package/dist/component-manager/types.d.ts.map +1 -1
- package/dist/component-manager/types.js.map +1 -1
- package/dist/registry/component-registry-service.d.ts +1 -1
- package/dist/registry/component-registry-service.d.ts.map +1 -1
- package/dist/registry/component-registry-service.js +34 -34
- package/dist/registry/component-registry-service.js.map +1 -1
- package/dist/registry/component-resolver.d.ts +1 -1
- package/dist/registry/component-resolver.d.ts.map +1 -1
- package/dist/registry/component-resolver.js +11 -10
- package/dist/registry/component-resolver.js.map +1 -1
- package/dist/runtime/component-hierarchy.d.ts +1 -1
- package/dist/runtime/component-hierarchy.d.ts.map +1 -1
- package/dist/runtime/component-hierarchy.js +43 -43
- package/dist/runtime/component-hierarchy.js.map +1 -1
- package/dist/runtime/prop-builder.d.ts.map +1 -1
- package/dist/runtime/prop-builder.js +24 -22
- package/dist/runtime/prop-builder.js.map +1 -1
- package/dist/runtime.umd.js +511 -494
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/library-registry.d.ts +1 -1
- package/dist/utilities/library-registry.d.ts.map +1 -1
- package/dist/utilities/library-registry.js +10 -10
- package/dist/utilities/library-registry.js.map +1 -1
- package/package.json +6 -5
- package/src/compiler/component-compiler.ts +164 -186
- package/src/component-manager/component-manager.ts +216 -162
- package/src/component-manager/types.ts +27 -27
- package/src/registry/component-registry-service.ts +218 -190
- package/src/registry/component-resolver.ts +98 -87
- package/src/runtime/component-hierarchy.ts +94 -57
- package/src/runtime/prop-builder.ts +33 -28
- package/src/types/index.ts +4 -3
- package/src/utilities/library-registry.ts +19 -14
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
|
|
2
|
-
> @memberjunction/react-runtime@2.
|
|
2
|
+
> @memberjunction/react-runtime@2.113.1 build
|
|
3
3
|
> npm run build:node && npm run build:umd
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @memberjunction/react-runtime@2.
|
|
6
|
+
> @memberjunction/react-runtime@2.113.1 build:node
|
|
7
7
|
> tsc
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @memberjunction/react-runtime@2.
|
|
10
|
+
> @memberjunction/react-runtime@2.113.1 build:umd
|
|
11
11
|
> webpack --config webpack.umd.config.js
|
|
12
12
|
|
|
13
|
-
(node:
|
|
13
|
+
(node:8088) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
|
|
14
14
|
(Use `node --trace-deprecation ...` to show where the warning was created)
|
|
15
15
|
[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.
|
|
16
|
-
asset runtime.umd.js 2.
|
|
16
|
+
asset runtime.umd.js 2.41 MiB [emitted] [minimized] [big] (name: main) 1 related asset
|
|
17
17
|
orphan modules 513 KiB [orphan] 123 modules
|
|
18
18
|
runtime modules 1010 bytes 5 modules
|
|
19
|
-
modules by path ../../ 4.
|
|
20
|
-
modules by path ../../../node_modules/ 1.
|
|
21
|
-
modules by path ../../MJGlobal/
|
|
19
|
+
modules by path ../../ 4.93 MiB
|
|
20
|
+
modules by path ../../../node_modules/ 1.62 MiB 258 modules
|
|
21
|
+
modules by path ../../MJGlobal/ 174 KiB 35 modules
|
|
22
|
+
modules by path ../../MJCore/ 627 KiB 31 modules
|
|
22
23
|
modules by path ../../MJCoreEntities/dist/ 2.38 MiB 26 modules
|
|
23
|
-
modules by path ../../GraphQLDataProvider/
|
|
24
|
+
modules by path ../../GraphQLDataProvider/ 113 KiB 22 modules
|
|
24
25
|
modules by path ../../InteractiveComponents/dist/*.js 34.5 KiB 10 modules
|
|
25
26
|
modules by path ./dist/ 454 KiB 28 modules
|
|
26
|
-
webpack 5.92.1 compiled successfully in
|
|
27
|
+
webpack 5.92.1 compiled successfully in 102525 ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @memberjunction/react-runtime
|
|
2
2
|
|
|
3
|
+
## 2.113.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [7f8390e]
|
|
8
|
+
- Updated dependencies [4436cd2]
|
|
9
|
+
- @memberjunction/core-entities@2.113.1
|
|
10
|
+
- @memberjunction/global@2.113.1
|
|
11
|
+
- @memberjunction/core@2.113.1
|
|
12
|
+
- @memberjunction/graphql-dataprovider@2.113.1
|
|
13
|
+
- @memberjunction/interactive-component-types@2.113.1
|
|
14
|
+
|
|
3
15
|
## 2.112.0
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -7,8 +19,9 @@
|
|
|
7
19
|
- Updated dependencies [c126b59]
|
|
8
20
|
- @memberjunction/global@2.112.0
|
|
9
21
|
- @memberjunction/graphql-dataprovider@2.112.0
|
|
10
|
-
- @memberjunction/
|
|
22
|
+
- @memberjunction/core@2.112.0
|
|
11
23
|
- @memberjunction/core-entities@2.112.0
|
|
24
|
+
- @memberjunction/interactive-component-types@2.112.0
|
|
12
25
|
|
|
13
26
|
## 2.110.1
|
|
14
27
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-compiler.d.ts","sourceRoot":"","sources":["../../src/compiler/component-compiler.ts"],"names":[],"mappings":"AAOA,OAAO,
|
|
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"}
|
|
@@ -7,13 +7,13 @@ const component_unwrapper_1 = require("../utilities/component-unwrapper");
|
|
|
7
7
|
const DEFAULT_COMPILER_CONFIG = {
|
|
8
8
|
babel: {
|
|
9
9
|
presets: ['react'],
|
|
10
|
-
plugins: []
|
|
10
|
+
plugins: []
|
|
11
11
|
},
|
|
12
12
|
minify: false,
|
|
13
13
|
sourceMaps: false,
|
|
14
14
|
cache: true,
|
|
15
15
|
maxCacheSize: 100,
|
|
16
|
-
debug: false
|
|
16
|
+
debug: false
|
|
17
17
|
};
|
|
18
18
|
class ComponentCompiler {
|
|
19
19
|
constructor(config) {
|
|
@@ -33,7 +33,7 @@ class ComponentCompiler {
|
|
|
33
33
|
return {
|
|
34
34
|
success: true,
|
|
35
35
|
component: cached,
|
|
36
|
-
duration: Date.now() - startTime
|
|
36
|
+
duration: Date.now() - startTime
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -46,7 +46,7 @@ class ComponentCompiler {
|
|
|
46
46
|
id: this.generateComponentId(options.componentName),
|
|
47
47
|
name: options.componentName,
|
|
48
48
|
compiledAt: new Date(),
|
|
49
|
-
warnings: []
|
|
49
|
+
warnings: []
|
|
50
50
|
};
|
|
51
51
|
if (this.config.cache) {
|
|
52
52
|
this.cacheComponent(compiledComponent, options.componentCode);
|
|
@@ -56,14 +56,14 @@ class ComponentCompiler {
|
|
|
56
56
|
component: compiledComponent,
|
|
57
57
|
duration: Date.now() - startTime,
|
|
58
58
|
size: transpiledCode.length,
|
|
59
|
-
loadedLibraries: loadedLibraries
|
|
59
|
+
loadedLibraries: loadedLibraries
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
catch (error) {
|
|
63
63
|
return {
|
|
64
64
|
success: false,
|
|
65
65
|
error: this.createCompilationError(error, options.componentName),
|
|
66
|
-
duration: Date.now() - startTime
|
|
66
|
+
duration: Date.now() - startTime
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -78,7 +78,7 @@ class ComponentCompiler {
|
|
|
78
78
|
plugins: options.babelPlugins || this.config.babel.plugins,
|
|
79
79
|
filename: `${componentName}.jsx`,
|
|
80
80
|
sourceMaps: this.config.sourceMaps,
|
|
81
|
-
minified: this.config.minify
|
|
81
|
+
minified: this.config.minify
|
|
82
82
|
});
|
|
83
83
|
return result.code;
|
|
84
84
|
}
|
|
@@ -90,14 +90,14 @@ class ComponentCompiler {
|
|
|
90
90
|
const debug = this.config.debug;
|
|
91
91
|
const libraryDeclarations = libraries && libraries.length > 0
|
|
92
92
|
? libraries
|
|
93
|
-
.filter(
|
|
94
|
-
.map(
|
|
93
|
+
.filter(lib => lib.globalVariable && !this.CORE_LIBRARIES.has(lib.globalVariable))
|
|
94
|
+
.map(lib => `const ${lib.globalVariable} = libraries['${lib.globalVariable}'];`)
|
|
95
95
|
.join('\n ')
|
|
96
96
|
: '';
|
|
97
97
|
const libraryLogChecks = libraries && libraries.length > 0
|
|
98
98
|
? libraries
|
|
99
|
-
.filter(
|
|
100
|
-
.map(
|
|
99
|
+
.filter(lib => lib.globalVariable && !this.CORE_LIBRARIES.has(lib.globalVariable))
|
|
100
|
+
.map(lib => `\nif (!${lib.globalVariable}) { console.error('[React-Runtime-JS] Library "${lib.globalVariable}" is not defined'); } else { ${debug ? `console.log('[React-Runtime-JS] Library "${lib.globalVariable}" is defined');` : ''} }`)
|
|
101
101
|
.join('\n ')
|
|
102
102
|
: '';
|
|
103
103
|
const seenDependencies = new Set();
|
|
@@ -119,36 +119,32 @@ class ComponentCompiler {
|
|
|
119
119
|
}
|
|
120
120
|
const duplicateWarnings = duplicates.length > 0
|
|
121
121
|
? duplicates
|
|
122
|
-
.map(
|
|
122
|
+
.map(name => `console.warn('[React-Runtime-JS] WARNING: Component "${name}" is registered multiple times as a dependency. Using first occurrence only.');`)
|
|
123
123
|
.join('\n ')
|
|
124
124
|
: '';
|
|
125
125
|
const componentDeclarations = uniqueDependencies.length > 0
|
|
126
126
|
? uniqueDependencies
|
|
127
|
-
.map(
|
|
128
|
-
${debug
|
|
129
|
-
? `console.log('[React-Runtime-JS] Extracting ${dep.name}:');
|
|
127
|
+
.map(dep => `const ${dep.name}Raw = componentsOuter['${dep.name}'];
|
|
128
|
+
${debug ? `console.log('[React-Runtime-JS] Extracting ${dep.name}:');
|
|
130
129
|
console.log(' - Raw value type:', typeof ${dep.name}Raw);
|
|
131
130
|
console.log(' - Raw value:', ${dep.name}Raw);
|
|
132
131
|
if (${dep.name}Raw && typeof ${dep.name}Raw === 'object') {
|
|
133
132
|
console.log(' - Has .component property:', 'component' in ${dep.name}Raw);
|
|
134
133
|
console.log(' - .component type:', typeof ${dep.name}Raw.component);
|
|
135
|
-
}`
|
|
136
|
-
: ''}
|
|
134
|
+
}` : ''}
|
|
137
135
|
const ${dep.name} = ${dep.name}Raw?.component || ${dep.name}Raw;
|
|
138
|
-
${debug
|
|
139
|
-
|
|
140
|
-
console.log(' - Final ${dep.name} is function:', typeof ${dep.name} === 'function');`
|
|
141
|
-
: ''}`)
|
|
136
|
+
${debug ? `console.log(' - Final ${dep.name} type:', typeof ${dep.name});
|
|
137
|
+
console.log(' - Final ${dep.name} is function:', typeof ${dep.name} === 'function');` : ''}`)
|
|
142
138
|
.join('\n ')
|
|
143
139
|
: '';
|
|
144
140
|
const componentLogChecks = uniqueDependencies.length > 0
|
|
145
141
|
? uniqueDependencies
|
|
146
|
-
.map(
|
|
142
|
+
.map(dep => `if (!${dep.name}) { console.error('[React-Runtime-JS] Dependency "${dep.name}" is not defined'); } else { ${debug ? `console.log('[React-Runtime-JS] Dependency "${dep.name}" is defined');` : ''} }`)
|
|
147
143
|
.join('\n ')
|
|
148
144
|
: '';
|
|
149
145
|
const wrappedCode = `
|
|
150
146
|
function createComponent(
|
|
151
|
-
React, ReactDOM,
|
|
147
|
+
React, ReactDOM,
|
|
152
148
|
useState, useEffect, useCallback, useMemo, useRef, useContext, useReducer, useLayoutEffect,
|
|
153
149
|
libraries, styles, console, components,
|
|
154
150
|
unwrapLibraryComponent, unwrapLibraryComponents, unwrapAllLibraryComponents
|
|
@@ -162,10 +158,10 @@ class ComponentCompiler {
|
|
|
162
158
|
const unwrapComponent = unwrapLibraryComponent;
|
|
163
159
|
const unwrapComponents = unwrapLibraryComponents;
|
|
164
160
|
const unwrapAllComponents = unwrapAllLibraryComponents;
|
|
165
|
-
|
|
161
|
+
|
|
166
162
|
// Code for ${componentName}
|
|
167
163
|
${componentCode}
|
|
168
|
-
|
|
164
|
+
|
|
169
165
|
// Ensure the component exists
|
|
170
166
|
if (typeof ${componentName} === 'undefined') {
|
|
171
167
|
throw new Error('Component "${componentName}" is not defined in the provided code');
|
|
@@ -173,7 +169,7 @@ class ComponentCompiler {
|
|
|
173
169
|
else {
|
|
174
170
|
${debug ? `console.log('[React-Runtime-JS] Component "${componentName}" is defined');` : ''}
|
|
175
171
|
}
|
|
176
|
-
|
|
172
|
+
|
|
177
173
|
// Store the component in a variable so we don't lose it
|
|
178
174
|
const UserComponent = ${componentName};
|
|
179
175
|
|
|
@@ -182,10 +178,9 @@ class ComponentCompiler {
|
|
|
182
178
|
const ActualComponent = (typeof UserComponent === 'object' && UserComponent !== null && 'component' in UserComponent)
|
|
183
179
|
? UserComponent.component
|
|
184
180
|
: UserComponent;
|
|
185
|
-
|
|
181
|
+
|
|
186
182
|
// Debug logging to understand what we're getting
|
|
187
|
-
${debug
|
|
188
|
-
? `
|
|
183
|
+
${debug ? `
|
|
189
184
|
console.log('[React-Runtime-JS]Component ${componentName} type:', typeof UserComponent);
|
|
190
185
|
if (typeof UserComponent === 'object' && UserComponent !== null) {
|
|
191
186
|
console.log('[React-Runtime-JS]Component ${componentName} keys:', Object.keys(UserComponent));
|
|
@@ -193,9 +188,8 @@ class ComponentCompiler {
|
|
|
193
188
|
if ('component' in UserComponent) {
|
|
194
189
|
console.log('[React-Runtime-JS]Component ${componentName}.component type:', typeof UserComponent.component);
|
|
195
190
|
}
|
|
196
|
-
}`
|
|
197
|
-
|
|
198
|
-
|
|
191
|
+
}` : ''}
|
|
192
|
+
|
|
199
193
|
// Validate that we have a function (React component)
|
|
200
194
|
if (typeof ActualComponent !== 'function') {
|
|
201
195
|
console.error('[React-Runtime-JS] Invalid component type for ${componentName}:', typeof ActualComponent);
|
|
@@ -212,8 +206,7 @@ class ComponentCompiler {
|
|
|
212
206
|
if (!utilitiesOuter) {
|
|
213
207
|
utilitiesOuter = props?.utilities;
|
|
214
208
|
}
|
|
215
|
-
${debug
|
|
216
|
-
? `
|
|
209
|
+
${debug ? `
|
|
217
210
|
console.log('[React-Runtime-JS] DestructureWrapperUserComponent for ${componentName}:');
|
|
218
211
|
console.log(' - Props:', props);
|
|
219
212
|
console.log(' - componentsOuter type:', typeof componentsOuter);
|
|
@@ -231,43 +224,42 @@ class ComponentCompiler {
|
|
|
231
224
|
}
|
|
232
225
|
console.log(' - styles:', styles);
|
|
233
226
|
console.log(' - utilities:', utilitiesOuter);
|
|
234
|
-
console.log(' - libraries:', libraries);`
|
|
235
|
-
: ''}
|
|
227
|
+
console.log(' - libraries:', libraries);` : ''}
|
|
236
228
|
${duplicateWarnings ? '// Duplicate dependency warnings\n ' + duplicateWarnings + '\n ' : ''}
|
|
237
229
|
${libraryDeclarations ? '// Destructure Libraries\n' + libraryDeclarations + '\n ' : ''}
|
|
238
230
|
${componentDeclarations ? '// Destructure Dependencies\n' + componentDeclarations + '\n ' : ''}
|
|
239
231
|
${libraryLogChecks}
|
|
240
|
-
${componentLogChecks}
|
|
232
|
+
${componentLogChecks}
|
|
241
233
|
|
|
242
234
|
const newProps = {
|
|
243
235
|
...props,
|
|
244
236
|
components: componentsOuter,
|
|
245
|
-
utilities: utilitiesOuter
|
|
237
|
+
utilities: utilitiesOuter
|
|
246
238
|
}
|
|
247
239
|
return ActualComponent(newProps);
|
|
248
240
|
};
|
|
249
|
-
|
|
241
|
+
|
|
250
242
|
// Create a fresh method registry for each factory call
|
|
251
243
|
const methodRegistry = new Map();
|
|
252
|
-
|
|
244
|
+
|
|
253
245
|
// Create a wrapper component that provides RegisterMethod in callbacks
|
|
254
246
|
const ComponentWithMethodRegistry = (props) => {
|
|
255
247
|
// Register methods on mount
|
|
256
248
|
React.useEffect(() => {
|
|
257
249
|
// Clear previous methods
|
|
258
250
|
methodRegistry.clear();
|
|
259
|
-
|
|
251
|
+
|
|
260
252
|
// Provide RegisterMethod callback if callbacks exist
|
|
261
253
|
if (props.callbacks && typeof props.callbacks.RegisterMethod === 'function') {
|
|
262
254
|
// Component can now register its methods
|
|
263
255
|
// This will be called from within the component
|
|
264
256
|
}
|
|
265
257
|
}, [props.callbacks]);
|
|
266
|
-
|
|
258
|
+
|
|
267
259
|
// Create enhanced callbacks with RegisterMethod
|
|
268
260
|
const enhancedCallbacks = React.useMemo(() => {
|
|
269
261
|
if (!props.callbacks) return {};
|
|
270
|
-
|
|
262
|
+
|
|
271
263
|
return {
|
|
272
264
|
...props.callbacks,
|
|
273
265
|
RegisterMethod: (methodName, handler) => {
|
|
@@ -277,36 +269,36 @@ class ComponentCompiler {
|
|
|
277
269
|
}
|
|
278
270
|
};
|
|
279
271
|
}, [props.callbacks]);
|
|
280
|
-
|
|
272
|
+
|
|
281
273
|
// Render the original component with enhanced callbacks
|
|
282
274
|
return React.createElement(DestructureWrapperUserComponent, {
|
|
283
275
|
...props,
|
|
284
276
|
callbacks: enhancedCallbacks
|
|
285
277
|
});
|
|
286
278
|
};
|
|
287
|
-
|
|
279
|
+
|
|
288
280
|
ComponentWithMethodRegistry.displayName = '${componentName}WithMethods';
|
|
289
|
-
|
|
281
|
+
|
|
290
282
|
// Return the component object with method access
|
|
291
283
|
return {
|
|
292
284
|
component: ComponentWithMethodRegistry,
|
|
293
|
-
|
|
294
|
-
print: function() {
|
|
285
|
+
|
|
286
|
+
print: function() {
|
|
295
287
|
const printMethod = methodRegistry.get('print');
|
|
296
288
|
if (printMethod) {
|
|
297
289
|
printMethod();
|
|
298
290
|
} else if (typeof window !== 'undefined' && window.print) {
|
|
299
|
-
window.print();
|
|
291
|
+
window.print();
|
|
300
292
|
}
|
|
301
293
|
},
|
|
302
|
-
refresh: function(data) {
|
|
294
|
+
refresh: function(data) {
|
|
303
295
|
const refreshMethod = methodRegistry.get('refresh');
|
|
304
296
|
if (refreshMethod) {
|
|
305
297
|
refreshMethod(data);
|
|
306
298
|
}
|
|
307
299
|
// Refresh functionality is handled by the host environment
|
|
308
300
|
},
|
|
309
|
-
|
|
301
|
+
|
|
310
302
|
// Standard method accessors with type safety
|
|
311
303
|
getCurrentDataState: function() {
|
|
312
304
|
const method = methodRegistry.get('getCurrentDataState');
|
|
@@ -336,7 +328,7 @@ class ComponentCompiler {
|
|
|
336
328
|
const method = methodRegistry.get('focus');
|
|
337
329
|
if (method) method(target);
|
|
338
330
|
},
|
|
339
|
-
|
|
331
|
+
|
|
340
332
|
// Generic method invoker for custom methods
|
|
341
333
|
invokeMethod: function(methodName, ...args) {
|
|
342
334
|
const method = methodRegistry.get(methodName);
|
|
@@ -346,7 +338,7 @@ class ComponentCompiler {
|
|
|
346
338
|
console.warn(\`[React-Runtime-JS] Method '\${methodName}' is not registered on component ${componentName}\`);
|
|
347
339
|
return undefined;
|
|
348
340
|
},
|
|
349
|
-
|
|
341
|
+
|
|
350
342
|
// Check if a method exists
|
|
351
343
|
hasMethod: function(methodName) {
|
|
352
344
|
return methodRegistry.has(methodName);
|
|
@@ -361,7 +353,7 @@ class ComponentCompiler {
|
|
|
361
353
|
if (this.config.debug) {
|
|
362
354
|
console.log('đ loadRequiredLibraries called with:', {
|
|
363
355
|
librariesCount: libraries?.length || 0,
|
|
364
|
-
libraries: libraries?.map(
|
|
356
|
+
libraries: libraries?.map(l => ({ name: l.name, version: l.version, globalVariable: l.globalVariable }))
|
|
365
357
|
});
|
|
366
358
|
}
|
|
367
359
|
if (!libraries || libraries.length === 0) {
|
|
@@ -380,7 +372,7 @@ class ComponentCompiler {
|
|
|
380
372
|
else {
|
|
381
373
|
console.warn('â ī¸ No componentLibraries provided for LibraryRegistry initialization');
|
|
382
374
|
}
|
|
383
|
-
const filteredLibraries = libraries.filter(
|
|
375
|
+
const filteredLibraries = libraries.filter(lib => {
|
|
384
376
|
if (!lib || typeof lib !== 'object' || !lib.name) {
|
|
385
377
|
console.warn(`â ī¸ Invalid library entry detected (missing name):`, lib);
|
|
386
378
|
return false;
|
|
@@ -400,7 +392,9 @@ class ComponentCompiler {
|
|
|
400
392
|
}
|
|
401
393
|
return true;
|
|
402
394
|
});
|
|
403
|
-
const libraryNames = filteredLibraries
|
|
395
|
+
const libraryNames = filteredLibraries
|
|
396
|
+
.map(lib => lib.name)
|
|
397
|
+
.filter(name => name && typeof name === 'string');
|
|
404
398
|
if (this.config.debug) {
|
|
405
399
|
console.log('đĻ Using dependency-aware loading for libraries:', libraryNames);
|
|
406
400
|
}
|
|
@@ -411,9 +405,7 @@ class ComponentCompiler {
|
|
|
411
405
|
return loadedLibraries;
|
|
412
406
|
}
|
|
413
407
|
try {
|
|
414
|
-
const loadedLibraryMap = await library_loader_1.LibraryLoader.loadLibrariesWithDependencies(libraryNames, componentLibraries, 'component-compiler', {
|
|
415
|
-
debug: this.config.debug,
|
|
416
|
-
});
|
|
408
|
+
const loadedLibraryMap = await library_loader_1.LibraryLoader.loadLibrariesWithDependencies(libraryNames, componentLibraries, 'component-compiler', { debug: this.config.debug });
|
|
417
409
|
for (const lib of filteredLibraries) {
|
|
418
410
|
const isApproved = library_registry_1.LibraryRegistry.isApproved(lib.name);
|
|
419
411
|
if (!isApproved) {
|
|
@@ -474,7 +466,7 @@ class ComponentCompiler {
|
|
|
474
466
|
return loadedLibraries;
|
|
475
467
|
}
|
|
476
468
|
async loadStyles(urls) {
|
|
477
|
-
const loadPromises = urls.map(
|
|
469
|
+
const loadPromises = urls.map(url => {
|
|
478
470
|
return new Promise((resolve) => {
|
|
479
471
|
const existingLink = document.querySelector(`link[href="${url}"]`);
|
|
480
472
|
if (existingLink) {
|
|
@@ -528,7 +520,7 @@ class ComponentCompiler {
|
|
|
528
520
|
else if (attempts >= maxAttempts) {
|
|
529
521
|
if (this.config.debug) {
|
|
530
522
|
console.error(` â ${globalName} not found after ${attempts * checkInterval}ms`);
|
|
531
|
-
const matchingKeys = Object.keys(window).filter(
|
|
523
|
+
const matchingKeys = Object.keys(window).filter(k => k.toLowerCase().includes(globalName.toLowerCase()));
|
|
532
524
|
console.log(` âšī¸ Matching window properties: ${matchingKeys.join(', ') || 'none'}`);
|
|
533
525
|
}
|
|
534
526
|
reject(new Error(`${globalName} not found after loading script from ${url}`));
|
|
@@ -632,9 +624,7 @@ class ComponentCompiler {
|
|
|
632
624
|
throw new Error(`Component compilation failed: Component code must define a component named "${options.componentName}".\n` +
|
|
633
625
|
'The function/component name in the code must match the componentName property.\n' +
|
|
634
626
|
`Expected to find: function ${options.componentName}(...) or const ${options.componentName} = ...\n` +
|
|
635
|
-
'Code preview: ' +
|
|
636
|
-
options.componentCode.substring(0, 200) +
|
|
637
|
-
'...');
|
|
627
|
+
'Code preview: ' + options.componentCode.substring(0, 200) + '...');
|
|
638
628
|
}
|
|
639
629
|
}
|
|
640
630
|
generateComponentId(componentName) {
|
|
@@ -648,7 +638,7 @@ class ComponentCompiler {
|
|
|
648
638
|
let hash = 0;
|
|
649
639
|
for (let i = 0; i < code.length; i++) {
|
|
650
640
|
const char = code.charCodeAt(i);
|
|
651
|
-
hash = (hash << 5) - hash + char;
|
|
641
|
+
hash = ((hash << 5) - hash) + char;
|
|
652
642
|
hash = hash & hash;
|
|
653
643
|
}
|
|
654
644
|
return `${componentName}_${hash.toString(36)}`;
|
|
@@ -668,7 +658,7 @@ class ComponentCompiler {
|
|
|
668
658
|
stack: error.stack,
|
|
669
659
|
componentName,
|
|
670
660
|
phase: 'compilation',
|
|
671
|
-
details: error
|
|
661
|
+
details: error
|
|
672
662
|
};
|
|
673
663
|
}
|
|
674
664
|
clearCache() {
|