@memberjunction/react-runtime 2.93.0 → 2.95.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 (64) hide show
  1. package/.turbo/turbo-build.log +6 -6
  2. package/CHANGELOG.md +28 -0
  3. package/README.md +180 -2
  4. package/dist/compiler/component-compiler.d.ts +1 -0
  5. package/dist/compiler/component-compiler.d.ts.map +1 -1
  6. package/dist/compiler/component-compiler.js +253 -61
  7. package/dist/compiler/component-compiler.js.map +1 -1
  8. package/dist/index.d.ts +3 -2
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +15 -5
  11. package/dist/index.js.map +1 -1
  12. package/dist/registry/component-registry-service.d.ts +6 -3
  13. package/dist/registry/component-registry-service.d.ts.map +1 -1
  14. package/dist/registry/component-registry-service.js +38 -11
  15. package/dist/registry/component-registry-service.js.map +1 -1
  16. package/dist/registry/component-registry.d.ts +6 -3
  17. package/dist/registry/component-registry.d.ts.map +1 -1
  18. package/dist/registry/component-registry.js +17 -0
  19. package/dist/registry/component-registry.js.map +1 -1
  20. package/dist/registry/component-resolver.d.ts +2 -1
  21. package/dist/registry/component-resolver.d.ts.map +1 -1
  22. package/dist/registry/component-resolver.js +101 -14
  23. package/dist/registry/component-resolver.js.map +1 -1
  24. package/dist/runtime/component-hierarchy.d.ts.map +1 -1
  25. package/dist/runtime/component-hierarchy.js +75 -13
  26. package/dist/runtime/component-hierarchy.js.map +1 -1
  27. package/dist/runtime/prop-builder.d.ts +2 -2
  28. package/dist/runtime/prop-builder.d.ts.map +1 -1
  29. package/dist/runtime/prop-builder.js +32 -14
  30. package/dist/runtime/prop-builder.js.map +1 -1
  31. package/dist/runtime.umd.js +1 -1
  32. package/dist/types/dependency-types.d.ts +62 -0
  33. package/dist/types/dependency-types.d.ts.map +1 -0
  34. package/dist/types/dependency-types.js +3 -0
  35. package/dist/types/dependency-types.js.map +1 -0
  36. package/dist/types/index.d.ts +8 -10
  37. package/dist/types/index.d.ts.map +1 -1
  38. package/dist/types/index.js +1 -0
  39. package/dist/types/index.js.map +1 -1
  40. package/dist/utilities/index.d.ts +1 -0
  41. package/dist/utilities/index.d.ts.map +1 -1
  42. package/dist/utilities/index.js +1 -0
  43. package/dist/utilities/index.js.map +1 -1
  44. package/dist/utilities/library-dependency-resolver.d.ts +19 -0
  45. package/dist/utilities/library-dependency-resolver.d.ts.map +1 -0
  46. package/dist/utilities/library-dependency-resolver.js +419 -0
  47. package/dist/utilities/library-dependency-resolver.js.map +1 -0
  48. package/dist/utilities/library-loader.d.ts +9 -0
  49. package/dist/utilities/library-loader.d.ts.map +1 -1
  50. package/dist/utilities/library-loader.js +164 -0
  51. package/dist/utilities/library-loader.js.map +1 -1
  52. package/package.json +5 -5
  53. package/src/compiler/component-compiler.ts +280 -82
  54. package/src/index.ts +20 -5
  55. package/src/registry/component-registry-service.ts +53 -14
  56. package/src/registry/component-registry.ts +36 -7
  57. package/src/registry/component-resolver.ts +130 -16
  58. package/src/runtime/component-hierarchy.ts +101 -27
  59. package/src/runtime/prop-builder.ts +38 -18
  60. package/src/types/dependency-types.ts +110 -0
  61. package/src/types/index.ts +17 -21
  62. package/src/utilities/index.ts +1 -0
  63. package/src/utilities/library-dependency-resolver.ts +613 -0
  64. package/src/utilities/library-loader.ts +274 -0
@@ -1,24 +1,24 @@
1
1
 
2
- > @memberjunction/react-runtime@2.93.0 build
2
+ > @memberjunction/react-runtime@2.95.0 build
3
3
  > npm run build:node && npm run build:umd
4
4
 
5
5
 
6
- > @memberjunction/react-runtime@2.93.0 build:node
6
+ > @memberjunction/react-runtime@2.95.0 build:node
7
7
  > tsc
8
8
 
9
9
 
10
- > @memberjunction/react-runtime@2.93.0 build:umd
10
+ > @memberjunction/react-runtime@2.95.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.88 MiB [emitted] [minimized] [big] (name: main) 1 related asset
14
+ asset runtime.umd.js 1.92 MiB [emitted] [minimized] [big] (name: main) 1 related asset
15
15
  runtime modules 344 bytes 2 modules
16
16
  modules by path ../../../node_modules/ 1.01 MiB 237 modules
17
17
  modules by path ../../MJGlobal/ 174 KiB
18
18
  modules by path ../../MJGlobal/node_modules/uuid/dist/commonjs-browser/*.js 35 KiB 21 modules
19
19
  modules by path ../../MJGlobal/dist/ 139 KiB 14 modules
20
20
  modules by path ../../MJCore/ 643 KiB 31 modules
21
- modules by path ./dist/ 283 KiB 23 modules
21
+ modules by path ./dist/ 352 KiB 25 modules
22
22
  modules by path ../../MJCoreEntities/dist/ 2.04 MiB
23
23
  modules by path ../../MJCoreEntities/dist/custom/*.js 241 KiB 15 modules
24
24
  modules by path ../../MJCoreEntities/dist/custom/ResourcePermissions/*.js 46.9 KiB 3 modules
@@ -27,4 +27,4 @@ modules by path ../../InteractiveComponents/dist/*.js 36.8 KiB
27
27
  ../../InteractiveComponents/dist/index.js 1.21 KiB [built] [code generated]
28
28
  ../../InteractiveComponents/dist/data-requirements.js 79 bytes [built] [code generated]
29
29
  + 8 modules
30
- webpack 5.92.1 compiled successfully in 108887 ms
30
+ webpack 5.92.1 compiled successfully in 110738 ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @memberjunction/react-runtime
2
2
 
3
+ ## 2.95.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 3cd7db6: fix rendering issue
8
+ - Updated dependencies [a54c014]
9
+ - Updated dependencies [85985bd]
10
+ - @memberjunction/core@2.95.0
11
+ - @memberjunction/interactive-component-types@2.95.0
12
+ - @memberjunction/core-entities@2.95.0
13
+ - @memberjunction/global@2.95.0
14
+
15
+ ## 2.94.0
16
+
17
+ ### Minor Changes
18
+
19
+ - 455654e: migration (unrelated) to bump to minor
20
+ - 7c27b04: migration
21
+ - 98afc80: migrations
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies [eed16e0]
26
+ - @memberjunction/interactive-component-types@2.94.0
27
+ - @memberjunction/core-entities@2.94.0
28
+ - @memberjunction/core@2.94.0
29
+ - @memberjunction/global@2.94.0
30
+
3
31
  ## 2.93.0
4
32
 
5
33
  ### Patch Changes
package/README.md CHANGED
@@ -165,20 +165,198 @@ const context = {
165
165
  const MyComponent = runtime.registry.get('MyComponent', 'MyNamespace');
166
166
 
167
167
  // Execute the component factory
168
- const { component } = MyComponent(context);
168
+ const componentObject = MyComponent(context);
169
+
170
+ // The componentObject contains the React component and method accessors
171
+ const { component, print, refresh, getCurrentDataState, isDirty } = componentObject;
169
172
 
170
173
  // Render with props
171
174
  const props = {
172
175
  data: { name: 'World' },
173
176
  userState: {},
174
177
  callbacks: {
175
- RefreshData: () => console.log('Refresh clicked!')
178
+ OpenEntityRecord: (entityName, key) => console.log('Open entity:', entityName),
179
+ RegisterMethod: (methodName, handler) => {
180
+ // Component will register its methods here
181
+ }
176
182
  }
177
183
  };
178
184
 
179
185
  React.createElement(component, props);
180
186
  ```
181
187
 
188
+ ## Component Methods System
189
+
190
+ ### Overview
191
+
192
+ Components can expose methods that allow containers to interact with them beyond just passing props. This enables scenarios like:
193
+ - AI agents introspecting component state
194
+ - Containers checking if components have unsaved changes
195
+ - Programmatic validation and reset operations
196
+ - Custom business logic exposed by components
197
+
198
+ ### How Components Register Methods
199
+
200
+ Components register their methods during initialization using the `RegisterMethod` callback:
201
+
202
+ ```typescript
203
+ function MyComponent({ callbacks, data, userState }) {
204
+ const [currentData, setCurrentData] = React.useState(data);
205
+ const [isDirty, setIsDirty] = React.useState(false);
206
+
207
+ // Register methods on mount
208
+ React.useEffect(() => {
209
+ if (callbacks?.RegisterMethod) {
210
+ // Register standard methods
211
+ callbacks.RegisterMethod('getCurrentDataState', () => {
212
+ return currentData;
213
+ });
214
+
215
+ callbacks.RegisterMethod('isDirty', () => {
216
+ return isDirty;
217
+ });
218
+
219
+ callbacks.RegisterMethod('reset', () => {
220
+ setCurrentData(data);
221
+ setIsDirty(false);
222
+ });
223
+
224
+ callbacks.RegisterMethod('validate', () => {
225
+ // Custom validation logic
226
+ if (!currentData.name) {
227
+ return { valid: false, errors: ['Name is required'] };
228
+ }
229
+ return true;
230
+ });
231
+
232
+ // Register custom methods
233
+ callbacks.RegisterMethod('exportToCSV', () => {
234
+ // Custom export logic
235
+ return convertToCSV(currentData);
236
+ });
237
+ }
238
+ }, [callbacks, currentData, isDirty]);
239
+
240
+ return (
241
+ <div>
242
+ {/* Component UI */}
243
+ </div>
244
+ );
245
+ }
246
+ ```
247
+
248
+ ### Standard Methods
249
+
250
+ The ComponentObject interface defines standard methods that components can optionally implement:
251
+
252
+ - **`getCurrentDataState()`**: Returns the current data being displayed
253
+ - **`getDataStateHistory()`**: Returns an array of timestamped state changes
254
+ - **`validate()`**: Validates the component state
255
+ - **`isDirty()`**: Checks if there are unsaved changes
256
+ - **`reset()`**: Resets the component to initial state
257
+ - **`scrollTo(target)`**: Scrolls to a specific element
258
+ - **`focus(target)`**: Sets focus to an element
259
+ - **`print()`**: Prints the component content
260
+ - **`refresh()`**: Refreshes the component data
261
+
262
+ ### Using Component Methods
263
+
264
+ After compilation, the ComponentObject provides typed access to standard methods:
265
+
266
+ ```typescript
267
+ // Compile the component
268
+ const result = await compiler.compile({
269
+ componentName: 'MyComponent',
270
+ componentCode: componentCode
271
+ });
272
+
273
+ // Get the component object
274
+ const componentObject = result.component.component(context);
275
+
276
+ // Call standard methods directly (type-safe)
277
+ const currentData = componentObject.getCurrentDataState();
278
+ const isDirty = componentObject.isDirty();
279
+ const validationResult = componentObject.validate();
280
+
281
+ if (isDirty) {
282
+ componentObject.reset();
283
+ }
284
+
285
+ // Call custom methods via invokeMethod
286
+ if (componentObject.hasMethod('exportToCSV')) {
287
+ const csvData = componentObject.invokeMethod('exportToCSV');
288
+ }
289
+ ```
290
+
291
+ ### Method Availability
292
+
293
+ All methods are optional. The runtime provides sensible defaults when methods aren't registered:
294
+
295
+ - `getCurrentDataState()` returns `undefined`
296
+ - `getDataStateHistory()` returns `[]`
297
+ - `isDirty()` returns `false`
298
+ - `validate()` returns `true`
299
+ - Other methods perform no operation if not implemented
300
+
301
+ ### Integration with Angular
302
+
303
+ The Angular wrapper (`@memberjunction/ng-react`) provides strongly-typed access to all standard methods:
304
+
305
+ ```typescript
306
+ export class MyDashboard {
307
+ @ViewChild(MJReactComponent) reactComponent!: MJReactComponent;
308
+
309
+ checkComponentState() {
310
+ // Standard methods have full TypeScript support
311
+ if (this.reactComponent.isDirty()) {
312
+ const data = this.reactComponent.getCurrentDataState();
313
+ console.log('Component has unsaved changes:', data);
314
+ }
315
+
316
+ // Validate before saving
317
+ const validation = this.reactComponent.validate();
318
+ if (validation === true || validation.valid) {
319
+ // Save data...
320
+ }
321
+
322
+ // Custom methods
323
+ if (this.reactComponent.hasMethod('generateReport')) {
324
+ const report = this.reactComponent.invokeMethod('generateReport', options);
325
+ }
326
+ }
327
+ }
328
+ ```
329
+
330
+ ### Method Declaration in Component Spec
331
+
332
+ Components can declare their supported methods in the ComponentSpec for discovery:
333
+
334
+ ```typescript
335
+ const componentSpec = {
336
+ name: 'MyComponent',
337
+ code: '...',
338
+ methods: [
339
+ {
340
+ name: 'getCurrentDataState',
341
+ category: 'standard',
342
+ description: 'Returns current component data',
343
+ returnType: 'DataState | undefined'
344
+ },
345
+ {
346
+ name: 'exportToExcel',
347
+ category: 'custom',
348
+ description: 'Exports data to Excel format',
349
+ parameters: [{
350
+ name: 'options',
351
+ type: '{includeHeaders?: boolean, sheetName?: string}',
352
+ required: false
353
+ }],
354
+ returnType: 'Promise<Blob>'
355
+ }
356
+ ]
357
+ };
358
+ ```
359
+
182
360
  ## Advanced Features
183
361
 
184
362
  ### Component Hierarchies
@@ -8,6 +8,7 @@ export declare class ComponentCompiler {
8
8
  setBabelInstance(babel: any): void;
9
9
  compile(options: CompileOptions): Promise<CompilationResult>;
10
10
  private transpileComponent;
11
+ private readonly CORE_LIBRARIES;
11
12
  private wrapComponentCode;
12
13
  private loadRequiredLibraries;
13
14
  private loadStyles;
@@ -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;AAsBlB,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;IAkC1B,OAAO,CAAC,iBAAiB;YAmDX,qBAAqB;YAwGrB,UAAU;IA+BxB,OAAO,CAAC,UAAU;IAmElB,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;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;YA0NX,qBAAqB;YA2HrB,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"}