@memberjunction/react-runtime 2.111.1 â 2.112.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.
- package/.turbo/turbo-build.log +10 -11
- package/CHANGELOG.md +6 -6
- package/dist/compiler/component-compiler.d.ts.map +1 -1
- package/dist/compiler/component-compiler.js +66 -56
- 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 +48 -42
- 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 +10 -11
- 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 +22 -24
- package/dist/runtime/prop-builder.js.map +1 -1
- package/dist/runtime.umd.js +494 -511
- 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 +5 -6
- package/src/compiler/component-compiler.ts +186 -164
- package/src/component-manager/component-manager.ts +162 -216
- package/src/component-manager/types.ts +27 -27
- package/src/registry/component-registry-service.ts +190 -218
- package/src/registry/component-resolver.ts +87 -98
- package/src/runtime/component-hierarchy.ts +57 -94
- package/src/runtime/prop-builder.ts +28 -33
- package/src/types/index.ts +3 -4
- package/src/utilities/library-registry.ts +14 -19
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
|
|
2
|
-
> @memberjunction/react-runtime@2.
|
|
2
|
+
> @memberjunction/react-runtime@2.112.0 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.112.0 build:node
|
|
7
7
|
> tsc
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @memberjunction/react-runtime@2.
|
|
10
|
+
> @memberjunction/react-runtime@2.112.0 build:umd
|
|
11
11
|
> webpack --config webpack.umd.config.js
|
|
12
12
|
|
|
13
|
-
(node:
|
|
13
|
+
(node:7965) [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
16
|
asset runtime.umd.js 2.39 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/
|
|
22
|
-
modules by path ../../
|
|
23
|
-
modules by path ../../
|
|
24
|
-
modules by path ../../GraphQLDataProvider/ 113 KiB 22 modules
|
|
19
|
+
modules by path ../../ 4.91 MiB
|
|
20
|
+
modules by path ../../../node_modules/ 1.63 MiB 261 modules
|
|
21
|
+
modules by path ../../MJGlobal/ 784 KiB 63 modules
|
|
22
|
+
modules by path ../../MJCoreEntities/dist/ 2.38 MiB 26 modules
|
|
23
|
+
modules by path ../../GraphQLDataProvider/ 108 KiB 22 modules
|
|
25
24
|
modules by path ../../InteractiveComponents/dist/*.js 34.5 KiB 10 modules
|
|
26
25
|
modules by path ./dist/ 454 KiB 28 modules
|
|
27
|
-
webpack 5.92.1 compiled successfully in
|
|
26
|
+
webpack 5.92.1 compiled successfully in 99684 ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# @memberjunction/react-runtime
|
|
2
2
|
|
|
3
|
-
## 2.
|
|
3
|
+
## 2.112.0
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
- @memberjunction/
|
|
9
|
-
- @memberjunction/
|
|
10
|
-
- @memberjunction/
|
|
11
|
-
- @memberjunction/
|
|
7
|
+
- Updated dependencies [c126b59]
|
|
8
|
+
- @memberjunction/global@2.112.0
|
|
9
|
+
- @memberjunction/graphql-dataprovider@2.112.0
|
|
10
|
+
- @memberjunction/interactive-component-types@2.112.0
|
|
11
|
+
- @memberjunction/core-entities@2.112.0
|
|
12
12
|
|
|
13
13
|
## 2.110.1
|
|
14
14
|
|
|
@@ -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,EAAE,cAAc,EAAqB,iBAAiB,EAAE,cAAc,EAAkC,MAAM,UAAU,CAAC;AA0BhI,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;IAiElE,OAAO,CAAC,kBAAkB;IA+B1B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAkC;IAEjE,OAAO,CAAC,iBAAiB;YA+TX,qBAAqB;YA4JrB,UAAU;IA+BxB,OAAO,CAAC,UAAU;IA0ElB,OAAO,CAAC,sBAAsB;IA6I9B,OAAO,CAAC,sBAAsB;IAmE9B,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,cAAc;IAgBtB,OAAO,CAAC,cAAc;IAkBtB,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(lib => lib.globalVariable && !this.CORE_LIBRARIES.has(lib.globalVariable))
|
|
94
|
-
.map(lib => `const ${lib.globalVariable} = libraries['${lib.globalVariable}'];`)
|
|
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(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');` : ''} }`)
|
|
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,32 +119,36 @@ class ComponentCompiler {
|
|
|
119
119
|
}
|
|
120
120
|
const duplicateWarnings = duplicates.length > 0
|
|
121
121
|
? duplicates
|
|
122
|
-
.map(name => `console.warn('[React-Runtime-JS] WARNING: Component "${name}" is registered multiple times as a dependency. Using first occurrence only.');`)
|
|
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(dep => `const ${dep.name}Raw = componentsOuter['${dep.name}'];
|
|
128
|
-
${debug
|
|
127
|
+
.map((dep) => `const ${dep.name}Raw = componentsOuter['${dep.name}'];
|
|
128
|
+
${debug
|
|
129
|
+
? `console.log('[React-Runtime-JS] Extracting ${dep.name}:');
|
|
129
130
|
console.log(' - Raw value type:', typeof ${dep.name}Raw);
|
|
130
131
|
console.log(' - Raw value:', ${dep.name}Raw);
|
|
131
132
|
if (${dep.name}Raw && typeof ${dep.name}Raw === 'object') {
|
|
132
133
|
console.log(' - Has .component property:', 'component' in ${dep.name}Raw);
|
|
133
134
|
console.log(' - .component type:', typeof ${dep.name}Raw.component);
|
|
134
|
-
}`
|
|
135
|
+
}`
|
|
136
|
+
: ''}
|
|
135
137
|
const ${dep.name} = ${dep.name}Raw?.component || ${dep.name}Raw;
|
|
136
|
-
${debug
|
|
137
|
-
|
|
138
|
+
${debug
|
|
139
|
+
? `console.log(' - Final ${dep.name} type:', typeof ${dep.name});
|
|
140
|
+
console.log(' - Final ${dep.name} is function:', typeof ${dep.name} === 'function');`
|
|
141
|
+
: ''}`)
|
|
138
142
|
.join('\n ')
|
|
139
143
|
: '';
|
|
140
144
|
const componentLogChecks = uniqueDependencies.length > 0
|
|
141
145
|
? uniqueDependencies
|
|
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');` : ''} }`)
|
|
146
|
+
.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');` : ''} }`)
|
|
143
147
|
.join('\n ')
|
|
144
148
|
: '';
|
|
145
149
|
const wrappedCode = `
|
|
146
150
|
function createComponent(
|
|
147
|
-
React, ReactDOM,
|
|
151
|
+
React, ReactDOM,
|
|
148
152
|
useState, useEffect, useCallback, useMemo, useRef, useContext, useReducer, useLayoutEffect,
|
|
149
153
|
libraries, styles, console, components,
|
|
150
154
|
unwrapLibraryComponent, unwrapLibraryComponents, unwrapAllLibraryComponents
|
|
@@ -158,10 +162,10 @@ class ComponentCompiler {
|
|
|
158
162
|
const unwrapComponent = unwrapLibraryComponent;
|
|
159
163
|
const unwrapComponents = unwrapLibraryComponents;
|
|
160
164
|
const unwrapAllComponents = unwrapAllLibraryComponents;
|
|
161
|
-
|
|
165
|
+
|
|
162
166
|
// Code for ${componentName}
|
|
163
167
|
${componentCode}
|
|
164
|
-
|
|
168
|
+
|
|
165
169
|
// Ensure the component exists
|
|
166
170
|
if (typeof ${componentName} === 'undefined') {
|
|
167
171
|
throw new Error('Component "${componentName}" is not defined in the provided code');
|
|
@@ -169,7 +173,7 @@ class ComponentCompiler {
|
|
|
169
173
|
else {
|
|
170
174
|
${debug ? `console.log('[React-Runtime-JS] Component "${componentName}" is defined');` : ''}
|
|
171
175
|
}
|
|
172
|
-
|
|
176
|
+
|
|
173
177
|
// Store the component in a variable so we don't lose it
|
|
174
178
|
const UserComponent = ${componentName};
|
|
175
179
|
|
|
@@ -178,9 +182,10 @@ class ComponentCompiler {
|
|
|
178
182
|
const ActualComponent = (typeof UserComponent === 'object' && UserComponent !== null && 'component' in UserComponent)
|
|
179
183
|
? UserComponent.component
|
|
180
184
|
: UserComponent;
|
|
181
|
-
|
|
185
|
+
|
|
182
186
|
// Debug logging to understand what we're getting
|
|
183
|
-
${debug
|
|
187
|
+
${debug
|
|
188
|
+
? `
|
|
184
189
|
console.log('[React-Runtime-JS]Component ${componentName} type:', typeof UserComponent);
|
|
185
190
|
if (typeof UserComponent === 'object' && UserComponent !== null) {
|
|
186
191
|
console.log('[React-Runtime-JS]Component ${componentName} keys:', Object.keys(UserComponent));
|
|
@@ -188,8 +193,9 @@ class ComponentCompiler {
|
|
|
188
193
|
if ('component' in UserComponent) {
|
|
189
194
|
console.log('[React-Runtime-JS]Component ${componentName}.component type:', typeof UserComponent.component);
|
|
190
195
|
}
|
|
191
|
-
}`
|
|
192
|
-
|
|
196
|
+
}`
|
|
197
|
+
: ''}
|
|
198
|
+
|
|
193
199
|
// Validate that we have a function (React component)
|
|
194
200
|
if (typeof ActualComponent !== 'function') {
|
|
195
201
|
console.error('[React-Runtime-JS] Invalid component type for ${componentName}:', typeof ActualComponent);
|
|
@@ -206,7 +212,8 @@ class ComponentCompiler {
|
|
|
206
212
|
if (!utilitiesOuter) {
|
|
207
213
|
utilitiesOuter = props?.utilities;
|
|
208
214
|
}
|
|
209
|
-
${debug
|
|
215
|
+
${debug
|
|
216
|
+
? `
|
|
210
217
|
console.log('[React-Runtime-JS] DestructureWrapperUserComponent for ${componentName}:');
|
|
211
218
|
console.log(' - Props:', props);
|
|
212
219
|
console.log(' - componentsOuter type:', typeof componentsOuter);
|
|
@@ -224,42 +231,43 @@ class ComponentCompiler {
|
|
|
224
231
|
}
|
|
225
232
|
console.log(' - styles:', styles);
|
|
226
233
|
console.log(' - utilities:', utilitiesOuter);
|
|
227
|
-
console.log(' - libraries:', libraries);`
|
|
234
|
+
console.log(' - libraries:', libraries);`
|
|
235
|
+
: ''}
|
|
228
236
|
${duplicateWarnings ? '// Duplicate dependency warnings\n ' + duplicateWarnings + '\n ' : ''}
|
|
229
237
|
${libraryDeclarations ? '// Destructure Libraries\n' + libraryDeclarations + '\n ' : ''}
|
|
230
238
|
${componentDeclarations ? '// Destructure Dependencies\n' + componentDeclarations + '\n ' : ''}
|
|
231
239
|
${libraryLogChecks}
|
|
232
|
-
${componentLogChecks}
|
|
240
|
+
${componentLogChecks}
|
|
233
241
|
|
|
234
242
|
const newProps = {
|
|
235
243
|
...props,
|
|
236
244
|
components: componentsOuter,
|
|
237
|
-
utilities: utilitiesOuter
|
|
245
|
+
utilities: utilitiesOuter
|
|
238
246
|
}
|
|
239
247
|
return ActualComponent(newProps);
|
|
240
248
|
};
|
|
241
|
-
|
|
249
|
+
|
|
242
250
|
// Create a fresh method registry for each factory call
|
|
243
251
|
const methodRegistry = new Map();
|
|
244
|
-
|
|
252
|
+
|
|
245
253
|
// Create a wrapper component that provides RegisterMethod in callbacks
|
|
246
254
|
const ComponentWithMethodRegistry = (props) => {
|
|
247
255
|
// Register methods on mount
|
|
248
256
|
React.useEffect(() => {
|
|
249
257
|
// Clear previous methods
|
|
250
258
|
methodRegistry.clear();
|
|
251
|
-
|
|
259
|
+
|
|
252
260
|
// Provide RegisterMethod callback if callbacks exist
|
|
253
261
|
if (props.callbacks && typeof props.callbacks.RegisterMethod === 'function') {
|
|
254
262
|
// Component can now register its methods
|
|
255
263
|
// This will be called from within the component
|
|
256
264
|
}
|
|
257
265
|
}, [props.callbacks]);
|
|
258
|
-
|
|
266
|
+
|
|
259
267
|
// Create enhanced callbacks with RegisterMethod
|
|
260
268
|
const enhancedCallbacks = React.useMemo(() => {
|
|
261
269
|
if (!props.callbacks) return {};
|
|
262
|
-
|
|
270
|
+
|
|
263
271
|
return {
|
|
264
272
|
...props.callbacks,
|
|
265
273
|
RegisterMethod: (methodName, handler) => {
|
|
@@ -269,36 +277,36 @@ class ComponentCompiler {
|
|
|
269
277
|
}
|
|
270
278
|
};
|
|
271
279
|
}, [props.callbacks]);
|
|
272
|
-
|
|
280
|
+
|
|
273
281
|
// Render the original component with enhanced callbacks
|
|
274
282
|
return React.createElement(DestructureWrapperUserComponent, {
|
|
275
283
|
...props,
|
|
276
284
|
callbacks: enhancedCallbacks
|
|
277
285
|
});
|
|
278
286
|
};
|
|
279
|
-
|
|
287
|
+
|
|
280
288
|
ComponentWithMethodRegistry.displayName = '${componentName}WithMethods';
|
|
281
|
-
|
|
289
|
+
|
|
282
290
|
// Return the component object with method access
|
|
283
291
|
return {
|
|
284
292
|
component: ComponentWithMethodRegistry,
|
|
285
|
-
|
|
286
|
-
print: function() {
|
|
293
|
+
|
|
294
|
+
print: function() {
|
|
287
295
|
const printMethod = methodRegistry.get('print');
|
|
288
296
|
if (printMethod) {
|
|
289
297
|
printMethod();
|
|
290
298
|
} else if (typeof window !== 'undefined' && window.print) {
|
|
291
|
-
window.print();
|
|
299
|
+
window.print();
|
|
292
300
|
}
|
|
293
301
|
},
|
|
294
|
-
refresh: function(data) {
|
|
302
|
+
refresh: function(data) {
|
|
295
303
|
const refreshMethod = methodRegistry.get('refresh');
|
|
296
304
|
if (refreshMethod) {
|
|
297
305
|
refreshMethod(data);
|
|
298
306
|
}
|
|
299
307
|
// Refresh functionality is handled by the host environment
|
|
300
308
|
},
|
|
301
|
-
|
|
309
|
+
|
|
302
310
|
// Standard method accessors with type safety
|
|
303
311
|
getCurrentDataState: function() {
|
|
304
312
|
const method = methodRegistry.get('getCurrentDataState');
|
|
@@ -328,7 +336,7 @@ class ComponentCompiler {
|
|
|
328
336
|
const method = methodRegistry.get('focus');
|
|
329
337
|
if (method) method(target);
|
|
330
338
|
},
|
|
331
|
-
|
|
339
|
+
|
|
332
340
|
// Generic method invoker for custom methods
|
|
333
341
|
invokeMethod: function(methodName, ...args) {
|
|
334
342
|
const method = methodRegistry.get(methodName);
|
|
@@ -338,7 +346,7 @@ class ComponentCompiler {
|
|
|
338
346
|
console.warn(\`[React-Runtime-JS] Method '\${methodName}' is not registered on component ${componentName}\`);
|
|
339
347
|
return undefined;
|
|
340
348
|
},
|
|
341
|
-
|
|
349
|
+
|
|
342
350
|
// Check if a method exists
|
|
343
351
|
hasMethod: function(methodName) {
|
|
344
352
|
return methodRegistry.has(methodName);
|
|
@@ -353,7 +361,7 @@ class ComponentCompiler {
|
|
|
353
361
|
if (this.config.debug) {
|
|
354
362
|
console.log('đ loadRequiredLibraries called with:', {
|
|
355
363
|
librariesCount: libraries?.length || 0,
|
|
356
|
-
libraries: libraries?.map(l => ({ name: l.name, version: l.version, globalVariable: l.globalVariable }))
|
|
364
|
+
libraries: libraries?.map((l) => ({ name: l.name, version: l.version, globalVariable: l.globalVariable })),
|
|
357
365
|
});
|
|
358
366
|
}
|
|
359
367
|
if (!libraries || libraries.length === 0) {
|
|
@@ -372,7 +380,7 @@ class ComponentCompiler {
|
|
|
372
380
|
else {
|
|
373
381
|
console.warn('â ī¸ No componentLibraries provided for LibraryRegistry initialization');
|
|
374
382
|
}
|
|
375
|
-
const filteredLibraries = libraries.filter(lib => {
|
|
383
|
+
const filteredLibraries = libraries.filter((lib) => {
|
|
376
384
|
if (!lib || typeof lib !== 'object' || !lib.name) {
|
|
377
385
|
console.warn(`â ī¸ Invalid library entry detected (missing name):`, lib);
|
|
378
386
|
return false;
|
|
@@ -392,9 +400,7 @@ class ComponentCompiler {
|
|
|
392
400
|
}
|
|
393
401
|
return true;
|
|
394
402
|
});
|
|
395
|
-
const libraryNames = filteredLibraries
|
|
396
|
-
.map(lib => lib.name)
|
|
397
|
-
.filter(name => name && typeof name === 'string');
|
|
403
|
+
const libraryNames = filteredLibraries.map((lib) => lib.name).filter((name) => name && typeof name === 'string');
|
|
398
404
|
if (this.config.debug) {
|
|
399
405
|
console.log('đĻ Using dependency-aware loading for libraries:', libraryNames);
|
|
400
406
|
}
|
|
@@ -405,7 +411,9 @@ class ComponentCompiler {
|
|
|
405
411
|
return loadedLibraries;
|
|
406
412
|
}
|
|
407
413
|
try {
|
|
408
|
-
const loadedLibraryMap = await library_loader_1.LibraryLoader.loadLibrariesWithDependencies(libraryNames, componentLibraries, 'component-compiler', {
|
|
414
|
+
const loadedLibraryMap = await library_loader_1.LibraryLoader.loadLibrariesWithDependencies(libraryNames, componentLibraries, 'component-compiler', {
|
|
415
|
+
debug: this.config.debug,
|
|
416
|
+
});
|
|
409
417
|
for (const lib of filteredLibraries) {
|
|
410
418
|
const isApproved = library_registry_1.LibraryRegistry.isApproved(lib.name);
|
|
411
419
|
if (!isApproved) {
|
|
@@ -466,7 +474,7 @@ class ComponentCompiler {
|
|
|
466
474
|
return loadedLibraries;
|
|
467
475
|
}
|
|
468
476
|
async loadStyles(urls) {
|
|
469
|
-
const loadPromises = urls.map(url => {
|
|
477
|
+
const loadPromises = urls.map((url) => {
|
|
470
478
|
return new Promise((resolve) => {
|
|
471
479
|
const existingLink = document.querySelector(`link[href="${url}"]`);
|
|
472
480
|
if (existingLink) {
|
|
@@ -520,7 +528,7 @@ class ComponentCompiler {
|
|
|
520
528
|
else if (attempts >= maxAttempts) {
|
|
521
529
|
if (this.config.debug) {
|
|
522
530
|
console.error(` â ${globalName} not found after ${attempts * checkInterval}ms`);
|
|
523
|
-
const matchingKeys = Object.keys(window).filter(k => k.toLowerCase().includes(globalName.toLowerCase()));
|
|
531
|
+
const matchingKeys = Object.keys(window).filter((k) => k.toLowerCase().includes(globalName.toLowerCase()));
|
|
524
532
|
console.log(` âšī¸ Matching window properties: ${matchingKeys.join(', ') || 'none'}`);
|
|
525
533
|
}
|
|
526
534
|
reject(new Error(`${globalName} not found after loading script from ${url}`));
|
|
@@ -624,7 +632,9 @@ class ComponentCompiler {
|
|
|
624
632
|
throw new Error(`Component compilation failed: Component code must define a component named "${options.componentName}".\n` +
|
|
625
633
|
'The function/component name in the code must match the componentName property.\n' +
|
|
626
634
|
`Expected to find: function ${options.componentName}(...) or const ${options.componentName} = ...\n` +
|
|
627
|
-
'Code preview: ' +
|
|
635
|
+
'Code preview: ' +
|
|
636
|
+
options.componentCode.substring(0, 200) +
|
|
637
|
+
'...');
|
|
628
638
|
}
|
|
629
639
|
}
|
|
630
640
|
generateComponentId(componentName) {
|
|
@@ -638,7 +648,7 @@ class ComponentCompiler {
|
|
|
638
648
|
let hash = 0;
|
|
639
649
|
for (let i = 0; i < code.length; i++) {
|
|
640
650
|
const char = code.charCodeAt(i);
|
|
641
|
-
hash = (
|
|
651
|
+
hash = (hash << 5) - hash + char;
|
|
642
652
|
hash = hash & hash;
|
|
643
653
|
}
|
|
644
654
|
return `${componentName}_${hash.toString(36)}`;
|
|
@@ -658,7 +668,7 @@ class ComponentCompiler {
|
|
|
658
668
|
stack: error.stack,
|
|
659
669
|
componentName,
|
|
660
670
|
phase: 'compilation',
|
|
661
|
-
details: error
|
|
671
|
+
details: error,
|
|
662
672
|
};
|
|
663
673
|
}
|
|
664
674
|
clearCache() {
|