@memberjunction/react-runtime 2.74.0 → 2.76.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 (54) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +27 -0
  3. package/README.md +96 -4
  4. package/dist/compiler/component-compiler.d.ts +0 -1
  5. package/dist/compiler/component-compiler.d.ts.map +1 -1
  6. package/dist/compiler/component-compiler.js +34 -25
  7. package/dist/index.d.ts +2 -2
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +3 -6
  10. package/dist/registry/component-resolver.d.ts +1 -6
  11. package/dist/registry/component-resolver.d.ts.map +1 -1
  12. package/dist/registry/component-resolver.js +19 -19
  13. package/dist/registry/index.d.ts +2 -1
  14. package/dist/registry/index.d.ts.map +1 -1
  15. package/dist/registry/index.js +3 -1
  16. package/dist/runtime/component-hierarchy.d.ts +1 -1
  17. package/dist/runtime/component-hierarchy.d.ts.map +1 -1
  18. package/dist/runtime/component-hierarchy.js +25 -25
  19. package/dist/runtime/index.d.ts +1 -1
  20. package/dist/runtime/index.d.ts.map +1 -1
  21. package/dist/runtime/index.js +1 -2
  22. package/dist/runtime/prop-builder.d.ts +1 -2
  23. package/dist/runtime/prop-builder.d.ts.map +1 -1
  24. package/dist/runtime/prop-builder.js +4 -76
  25. package/dist/types/index.d.ts +2 -0
  26. package/dist/types/index.d.ts.map +1 -1
  27. package/dist/types/index.js +15 -0
  28. package/dist/types/library-config.d.ts +32 -0
  29. package/dist/types/library-config.d.ts.map +1 -0
  30. package/dist/types/library-config.js +2 -0
  31. package/dist/utilities/core-libraries.d.ts +5 -0
  32. package/dist/utilities/core-libraries.d.ts.map +1 -0
  33. package/dist/utilities/core-libraries.js +52 -0
  34. package/dist/utilities/library-loader.d.ts +3 -2
  35. package/dist/utilities/library-loader.d.ts.map +1 -1
  36. package/dist/utilities/library-loader.js +65 -76
  37. package/dist/utilities/standard-libraries.d.ts +13 -24
  38. package/dist/utilities/standard-libraries.d.ts.map +1 -1
  39. package/dist/utilities/standard-libraries.js +58 -47
  40. package/package.json +4 -4
  41. package/samples/entities-1.js +493 -0
  42. package/src/compiler/component-compiler.ts +64 -35
  43. package/src/index.ts +1 -5
  44. package/src/registry/component-resolver.ts +21 -30
  45. package/src/registry/index.ts +2 -1
  46. package/src/runtime/component-hierarchy.ts +26 -26
  47. package/src/runtime/index.ts +0 -1
  48. package/src/runtime/prop-builder.ts +5 -112
  49. package/src/types/index.ts +6 -1
  50. package/src/types/library-config.ts +75 -0
  51. package/src/utilities/core-libraries.ts +61 -0
  52. package/src/utilities/library-loader.ts +113 -93
  53. package/src/utilities/standard-libraries.ts +104 -71
  54. package/tsconfig.tsbuildinfo +1 -1
@@ -2,76 +2,81 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LibraryLoader = void 0;
4
4
  const standard_libraries_1 = require("./standard-libraries");
5
+ const core_libraries_1 = require("./core-libraries");
5
6
  class LibraryLoader {
6
- static async loadAllLibraries() {
7
- return this.loadLibraries({
8
- loadCore: true,
9
- loadUI: true,
10
- loadCSS: true
7
+ static async loadAllLibraries(config, additionalLibraries) {
8
+ if (config) {
9
+ standard_libraries_1.StandardLibraryManager.setConfiguration(config);
10
+ }
11
+ if (additionalLibraries && additionalLibraries.length > 0) {
12
+ const currentConfig = standard_libraries_1.StandardLibraryManager.getConfiguration();
13
+ const mergedConfig = {
14
+ libraries: [...currentConfig.libraries, ...additionalLibraries],
15
+ metadata: {
16
+ ...currentConfig.metadata,
17
+ lastUpdated: new Date().toISOString()
18
+ }
19
+ };
20
+ standard_libraries_1.StandardLibraryManager.setConfiguration(mergedConfig);
21
+ }
22
+ return this.loadLibrariesFromConfig();
23
+ }
24
+ static async loadLibrariesFromConfig(options) {
25
+ const coreLibraries = (0, core_libraries_1.getCoreRuntimeLibraries)();
26
+ const corePromises = coreLibraries.map(lib => this.loadScript(lib.cdnUrl, lib.globalVariable));
27
+ const coreResults = await Promise.all(corePromises);
28
+ const React = coreResults.find((_, i) => coreLibraries[i].globalVariable === 'React');
29
+ const ReactDOM = coreResults.find((_, i) => coreLibraries[i].globalVariable === 'ReactDOM');
30
+ const Babel = coreResults.find((_, i) => coreLibraries[i].globalVariable === 'Babel');
31
+ const config = standard_libraries_1.StandardLibraryManager.getConfiguration();
32
+ const enabledLibraries = standard_libraries_1.StandardLibraryManager.getEnabledLibraries();
33
+ let pluginLibraries = enabledLibraries.filter(lib => !(0, core_libraries_1.isCoreRuntimeLibrary)(lib.id));
34
+ if (options) {
35
+ if (options.categories) {
36
+ pluginLibraries = pluginLibraries.filter(lib => options.categories.includes(lib.category));
37
+ }
38
+ if (options.excludeRuntimeOnly) {
39
+ pluginLibraries = pluginLibraries.filter(lib => !lib.isRuntimeOnly);
40
+ }
41
+ }
42
+ pluginLibraries.forEach(lib => {
43
+ if (lib.cdnCssUrl) {
44
+ this.loadCSS(lib.cdnCssUrl);
45
+ }
11
46
  });
47
+ const pluginPromises = pluginLibraries.map(lib => this.loadScript(lib.cdnUrl, lib.globalVariable));
48
+ const pluginResults = await Promise.all(pluginPromises);
49
+ const libraries = {};
50
+ pluginLibraries.forEach((lib, index) => {
51
+ libraries[lib.globalVariable] = pluginResults[index];
52
+ });
53
+ return {
54
+ React: React || window.React,
55
+ ReactDOM: ReactDOM || window.ReactDOM,
56
+ Babel: Babel || window.Babel,
57
+ libraries
58
+ };
12
59
  }
13
60
  static async loadLibraries(options) {
14
61
  const { loadCore = true, loadUI = true, loadCSS = true, customLibraries = [] } = options;
15
- const [React, ReactDOM, Babel] = await Promise.all([
16
- this.loadScript(standard_libraries_1.STANDARD_LIBRARY_URLS.REACT, 'React'),
17
- this.loadScript(standard_libraries_1.STANDARD_LIBRARY_URLS.REACT_DOM, 'ReactDOM'),
18
- this.loadScript(standard_libraries_1.STANDARD_LIBRARY_URLS.BABEL, 'Babel')
19
- ]);
20
- if (loadCSS) {
21
- (0, standard_libraries_1.getCSSUrls)().forEach(url => this.loadCSS(url));
22
- }
23
- const libraryPromises = [];
24
- const libraryNames = [];
62
+ const categoriesToLoad = ['runtime'];
25
63
  if (loadCore) {
26
- const coreUrls = (0, standard_libraries_1.getCoreLibraryUrls)();
27
- coreUrls.forEach(url => {
28
- const name = this.getLibraryNameFromUrl(url);
29
- libraryNames.push(name);
30
- libraryPromises.push(this.loadScript(url, name));
31
- });
64
+ categoriesToLoad.push('utility', 'charting');
32
65
  }
33
66
  if (loadUI) {
34
- const uiUrls = (0, standard_libraries_1.getUILibraryUrls)();
35
- uiUrls.forEach(url => {
36
- const name = this.getLibraryNameFromUrl(url);
37
- libraryNames.push(name);
38
- libraryPromises.push(this.loadScript(url, name));
39
- });
67
+ categoriesToLoad.push('ui');
40
68
  }
41
- customLibraries.forEach(({ url, globalName }) => {
42
- libraryNames.push(globalName);
43
- libraryPromises.push(this.loadScript(url, globalName));
44
- });
45
- const loadedLibraries = await Promise.all(libraryPromises);
46
- const libraries = {
47
- _: undefined
48
- };
49
- libraryNames.forEach((name, index) => {
50
- if (name === '_') {
51
- libraries._ = loadedLibraries[index];
52
- }
53
- else {
54
- libraries[name] = loadedLibraries[index];
55
- }
69
+ const result = await this.loadLibrariesFromConfig({
70
+ categories: categoriesToLoad
56
71
  });
57
- if (!libraries._)
58
- libraries._ = window._;
59
- if (!libraries.d3)
60
- libraries.d3 = window.d3;
61
- if (!libraries.Chart)
62
- libraries.Chart = window.Chart;
63
- if (!libraries.dayjs)
64
- libraries.dayjs = window.dayjs;
65
- if (!libraries.antd)
66
- libraries.antd = window.antd;
67
- if (!libraries.ReactBootstrap)
68
- libraries.ReactBootstrap = window.ReactBootstrap;
69
- return {
70
- React,
71
- ReactDOM,
72
- Babel,
73
- libraries
74
- };
72
+ if (customLibraries.length > 0) {
73
+ const customPromises = customLibraries.map(({ url, globalName }) => this.loadScript(url, globalName));
74
+ const customResults = await Promise.all(customPromises);
75
+ customLibraries.forEach(({ globalName }, index) => {
76
+ result.libraries[globalName] = customResults[index];
77
+ });
78
+ }
79
+ return result;
75
80
  }
76
81
  static async loadScript(url, globalName) {
77
82
  const existing = this.loadedResources.get(url);
@@ -166,22 +171,6 @@ class LibraryLoader {
166
171
  };
167
172
  script.addEventListener('load', loadHandler);
168
173
  }
169
- static getLibraryNameFromUrl(url) {
170
- if (url.includes('lodash'))
171
- return '_';
172
- if (url.includes('d3'))
173
- return 'd3';
174
- if (url.includes('Chart.js') || url.includes('chart'))
175
- return 'Chart';
176
- if (url.includes('dayjs'))
177
- return 'dayjs';
178
- if (url.includes('antd'))
179
- return 'antd';
180
- if (url.includes('react-bootstrap'))
181
- return 'ReactBootstrap';
182
- const match = url.match(/\/([^\/]+)(?:\.min)?\.js$/);
183
- return match ? match[1] : 'unknown';
184
- }
185
174
  static getLoadedResources() {
186
175
  return this.loadedResources;
187
176
  }
@@ -1,27 +1,16 @@
1
- export declare const STANDARD_LIBRARY_URLS: {
2
- REACT: string;
3
- REACT_DOM: string;
4
- BABEL: string;
5
- D3: string;
6
- CHART_JS: string;
7
- LODASH: string;
8
- DAYJS: string;
9
- ANTD: string;
10
- REACT_BOOTSTRAP: string;
11
- ANTD_CSS: string;
12
- BOOTSTRAP_CSS: string;
13
- };
14
- export interface StandardLibraries {
15
- _: any;
16
- d3?: any;
17
- Chart?: any;
18
- dayjs?: any;
19
- antd?: any;
20
- ReactBootstrap?: any;
21
- [key: string]: any;
1
+ import { LibraryConfiguration, ExternalLibraryConfig } from '../types/library-config';
2
+ export type StandardLibraries = Record<string, any>;
3
+ export declare class StandardLibraryManager {
4
+ private static configuration;
5
+ static setConfiguration(config: LibraryConfiguration): void;
6
+ static getConfiguration(): LibraryConfiguration;
7
+ static getEnabledLibraries(): ExternalLibraryConfig[];
8
+ static getLibrariesByCategory(category: ExternalLibraryConfig['category']): ExternalLibraryConfig[];
9
+ static getCoreLibraries(): ExternalLibraryConfig[];
10
+ static getComponentLibraries(): ExternalLibraryConfig[];
11
+ static getLibraryById(id: string): ExternalLibraryConfig | undefined;
12
+ static getLibraryUrls(): Record<string, string>;
13
+ static resetToDefault(): void;
22
14
  }
23
- export declare function getCoreLibraryUrls(): string[];
24
- export declare function getUILibraryUrls(): string[];
25
- export declare function getCSSUrls(): string[];
26
15
  export declare function createStandardLibraries(): StandardLibraries;
27
16
  //# sourceMappingURL=standard-libraries.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"standard-libraries.d.ts","sourceRoot":"","sources":["../../src/utilities/standard-libraries.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;CAqBjC,CAAC;AAKF,MAAM,WAAW,iBAAiB;IAChC,CAAC,EAAE,GAAG,CAAC;IACP,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,cAAc,CAAC,EAAE,GAAG,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAKD,wBAAgB,kBAAkB,IAAI,MAAM,EAAE,CAO7C;AAKD,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAK3C;AAKD,wBAAgB,UAAU,IAAI,MAAM,EAAE,CAKrC;AAMD,wBAAgB,uBAAuB,IAAI,iBAAiB,CAgB3D"}
1
+ {"version":3,"file":"standard-libraries.d.ts","sourceRoot":"","sources":["../../src/utilities/standard-libraries.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAMtF,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAkBpD,qBAAa,sBAAsB;IACjC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAgD;IAK5E,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI;IAO3D,MAAM,CAAC,gBAAgB,IAAI,oBAAoB;IAO/C,MAAM,CAAC,mBAAmB,IAAI,qBAAqB,EAAE;IAOrD,MAAM,CAAC,sBAAsB,CAAC,QAAQ,EAAE,qBAAqB,CAAC,UAAU,CAAC,GAAG,qBAAqB,EAAE;IAOnG,MAAM,CAAC,gBAAgB,IAAI,qBAAqB,EAAE;IAOlD,MAAM,CAAC,qBAAqB,IAAI,qBAAqB,EAAE;IAOvD,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS;IAOpE,MAAM,CAAC,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAkB/C,MAAM,CAAC,cAAc,IAAI,IAAI;CAG9B;AAOD,wBAAgB,uBAAuB,IAAI,iBAAiB,CAiB3D"}
@@ -1,55 +1,66 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createStandardLibraries = exports.getCSSUrls = exports.getUILibraryUrls = exports.getCoreLibraryUrls = exports.STANDARD_LIBRARY_URLS = void 0;
4
- exports.STANDARD_LIBRARY_URLS = {
5
- REACT: 'https://unpkg.com/react@18/umd/react.development.js',
6
- REACT_DOM: 'https://unpkg.com/react-dom@18/umd/react-dom.development.js',
7
- BABEL: 'https://unpkg.com/@babel/standalone/babel.min.js',
8
- D3: 'https://cdnjs.cloudflare.com/ajax/libs/d3/7.8.5/d3.min.js',
9
- CHART_JS: 'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.0/chart.umd.js',
10
- LODASH: 'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js',
11
- DAYJS: 'https://unpkg.com/dayjs@1.11.10/dayjs.min.js',
12
- ANTD: 'https://unpkg.com/antd@5.11.5/dist/antd.min.js',
13
- REACT_BOOTSTRAP: 'https://unpkg.com/react-bootstrap@2.9.1/dist/react-bootstrap.min.js',
14
- ANTD_CSS: 'https://unpkg.com/antd@5.11.5/dist/reset.css',
15
- BOOTSTRAP_CSS: 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css'
3
+ exports.createStandardLibraries = exports.StandardLibraryManager = void 0;
4
+ const DEFAULT_LIBRARY_CONFIG = {
5
+ libraries: [],
6
+ metadata: {
7
+ version: '1.0.0',
8
+ lastUpdated: new Date().toISOString(),
9
+ description: 'Empty default configuration - libraries should be configured at runtime'
10
+ }
16
11
  };
17
- function getCoreLibraryUrls() {
18
- return [
19
- exports.STANDARD_LIBRARY_URLS.LODASH,
20
- exports.STANDARD_LIBRARY_URLS.D3,
21
- exports.STANDARD_LIBRARY_URLS.CHART_JS,
22
- exports.STANDARD_LIBRARY_URLS.DAYJS
23
- ];
24
- }
25
- exports.getCoreLibraryUrls = getCoreLibraryUrls;
26
- function getUILibraryUrls() {
27
- return [
28
- exports.STANDARD_LIBRARY_URLS.ANTD,
29
- exports.STANDARD_LIBRARY_URLS.REACT_BOOTSTRAP
30
- ];
31
- }
32
- exports.getUILibraryUrls = getUILibraryUrls;
33
- function getCSSUrls() {
34
- return [
35
- exports.STANDARD_LIBRARY_URLS.ANTD_CSS,
36
- exports.STANDARD_LIBRARY_URLS.BOOTSTRAP_CSS
37
- ];
12
+ class StandardLibraryManager {
13
+ static setConfiguration(config) {
14
+ this.configuration = config;
15
+ }
16
+ static getConfiguration() {
17
+ return this.configuration;
18
+ }
19
+ static getEnabledLibraries() {
20
+ return this.configuration.libraries.filter(lib => lib.isEnabled);
21
+ }
22
+ static getLibrariesByCategory(category) {
23
+ return this.configuration.libraries.filter(lib => lib.category === category && lib.isEnabled);
24
+ }
25
+ static getCoreLibraries() {
26
+ return this.configuration.libraries.filter(lib => lib.isCore && lib.isEnabled);
27
+ }
28
+ static getComponentLibraries() {
29
+ return this.configuration.libraries.filter(lib => !lib.isRuntimeOnly && lib.isEnabled);
30
+ }
31
+ static getLibraryById(id) {
32
+ return this.configuration.libraries.find(lib => lib.id === id);
33
+ }
34
+ static getLibraryUrls() {
35
+ const urls = {};
36
+ this.configuration.libraries
37
+ .filter(lib => lib.isEnabled)
38
+ .forEach(lib => {
39
+ const key = lib.id.replace(/-/g, '_').toUpperCase();
40
+ urls[key] = lib.cdnUrl;
41
+ if (lib.cdnCssUrl) {
42
+ urls[`${key}_CSS`] = lib.cdnCssUrl;
43
+ }
44
+ });
45
+ return urls;
46
+ }
47
+ static resetToDefault() {
48
+ this.configuration = DEFAULT_LIBRARY_CONFIG;
49
+ }
38
50
  }
39
- exports.getCSSUrls = getCSSUrls;
51
+ exports.StandardLibraryManager = StandardLibraryManager;
52
+ StandardLibraryManager.configuration = DEFAULT_LIBRARY_CONFIG;
40
53
  function createStandardLibraries() {
41
54
  if (typeof window === 'undefined') {
42
- return {
43
- _: undefined
44
- };
45
- }
46
- return {
47
- _: window._,
48
- d3: window.d3,
49
- Chart: window.Chart,
50
- dayjs: window.dayjs,
51
- antd: window.antd,
52
- ReactBootstrap: window.ReactBootstrap
53
- };
55
+ return {};
56
+ }
57
+ const libs = {};
58
+ StandardLibraryManager.getComponentLibraries().forEach(lib => {
59
+ const globalValue = window[lib.globalVariable];
60
+ if (globalValue !== undefined) {
61
+ libs[lib.globalVariable] = globalValue;
62
+ }
63
+ });
64
+ return libs;
54
65
  }
55
66
  exports.createStandardLibraries = createStandardLibraries;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/react-runtime",
3
- "version": "2.74.0",
3
+ "version": "2.76.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.74.0",
29
- "@memberjunction/global": "2.74.0",
30
- "@memberjunction/interactive-component-types": "2.74.0",
28
+ "@memberjunction/core": "2.76.0",
29
+ "@memberjunction/global": "2.76.0",
30
+ "@memberjunction/interactive-component-types": "2.76.0",
31
31
  "@babel/standalone": "^7.23.5",
32
32
  "rxjs": "^7.8.1"
33
33
  },