@memberjunction/react-runtime 2.73.0 → 2.75.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 (37) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +23 -0
  3. package/README.md +96 -4
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +3 -5
  7. package/dist/registry/component-resolver.d.ts +1 -6
  8. package/dist/registry/component-resolver.d.ts.map +1 -1
  9. package/dist/registry/component-resolver.js +19 -19
  10. package/dist/registry/index.d.ts +2 -1
  11. package/dist/registry/index.d.ts.map +1 -1
  12. package/dist/registry/index.js +3 -1
  13. package/dist/runtime/component-hierarchy.d.ts +1 -1
  14. package/dist/runtime/component-hierarchy.d.ts.map +1 -1
  15. package/dist/runtime/component-hierarchy.js +25 -25
  16. package/dist/types/index.d.ts +1 -0
  17. package/dist/types/index.d.ts.map +1 -1
  18. package/dist/types/index.js +15 -0
  19. package/dist/types/library-config.d.ts +32 -0
  20. package/dist/types/library-config.d.ts.map +1 -0
  21. package/dist/types/library-config.js +2 -0
  22. package/dist/utilities/library-loader.d.ts +3 -2
  23. package/dist/utilities/library-loader.d.ts.map +1 -1
  24. package/dist/utilities/library-loader.js +54 -76
  25. package/dist/utilities/standard-libraries.d.ts +13 -24
  26. package/dist/utilities/standard-libraries.d.ts.map +1 -1
  27. package/dist/utilities/standard-libraries.js +58 -47
  28. package/package.json +4 -4
  29. package/src/index.ts +1 -4
  30. package/src/registry/component-resolver.ts +21 -30
  31. package/src/registry/index.ts +2 -1
  32. package/src/runtime/component-hierarchy.ts +26 -26
  33. package/src/types/index.ts +4 -1
  34. package/src/types/library-config.ts +75 -0
  35. package/src/utilities/library-loader.ts +94 -93
  36. package/src/utilities/standard-libraries.ts +104 -71
  37. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"library-loader.d.ts","sourceRoot":"","sources":["../../src/utilities/library-loader.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,iBAAiB,EAIlB,MAAM,sBAAsB,CAAC;AAK9B,UAAU,cAAc;IACtB,OAAO,EAAE,iBAAiB,GAAG,eAAe,CAAC;IAC7C,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;CACvB;AAKD,MAAM,WAAW,kBAAkB;IAEjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,eAAe,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACzD;AAKD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,GAAG,CAAC;IACX,QAAQ,EAAE,GAAG,CAAC;IACd,KAAK,EAAE,GAAG,CAAC;IACX,SAAS,EAAE,iBAAiB,CAAC;CAC9B;AAKD,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,eAAe,CAAqC;WAMtD,gBAAgB,IAAI,OAAO,CAAC,iBAAiB,CAAC;WAW9C,aAAa,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;mBAqF9D,UAAU;IA+D/B,OAAO,CAAC,MAAM,CAAC,OAAO;IAwBtB,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAwChC,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAiBpC,MAAM,CAAC,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC;IAOxD,MAAM,CAAC,UAAU,IAAI,IAAI;CAG1B"}
1
+ {"version":3,"file":"library-loader.d.ts","sourceRoot":"","sources":["../../src/utilities/library-loader.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,iBAAiB,EAElB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAyB,kBAAkB,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAK/H,UAAU,cAAc;IACtB,OAAO,EAAE,iBAAiB,GAAG,eAAe,CAAC;IAC7C,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;CACvB;AAMD,MAAM,WAAW,kBAAkB;IAEjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,eAAe,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACzD;AAKD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,GAAG,CAAC;IACX,QAAQ,EAAE,GAAG,CAAC;IACd,KAAK,EAAE,GAAG,CAAC;IACX,SAAS,EAAE,iBAAiB,CAAC;CAC9B;AAKD,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,eAAe,CAAqC;WAMtD,gBAAgB,CAAC,MAAM,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,iBAAiB,CAAC;WAW3E,uBAAuB,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;WAgEhF,aAAa,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;mBAuC9D,UAAU;IA+D/B,OAAO,CAAC,MAAM,CAAC,OAAO;IAwBtB,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAyChC,MAAM,CAAC,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC;IAOxD,MAAM,CAAC,UAAU,IAAI,IAAI;CAG1B"}
@@ -3,75 +3,69 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LibraryLoader = void 0;
4
4
  const standard_libraries_1 = require("./standard-libraries");
5
5
  class LibraryLoader {
6
- static async loadAllLibraries() {
7
- return this.loadLibraries({
8
- loadCore: true,
9
- loadUI: true,
10
- loadCSS: true
6
+ static async loadAllLibraries(config) {
7
+ if (config) {
8
+ standard_libraries_1.StandardLibraryManager.setConfiguration(config);
9
+ }
10
+ return this.loadLibrariesFromConfig();
11
+ }
12
+ static async loadLibrariesFromConfig(options) {
13
+ const config = standard_libraries_1.StandardLibraryManager.getConfiguration();
14
+ const enabledLibraries = standard_libraries_1.StandardLibraryManager.getEnabledLibraries();
15
+ let librariesToLoad = enabledLibraries;
16
+ if (options) {
17
+ if (options.categories) {
18
+ librariesToLoad = librariesToLoad.filter(lib => options.categories.includes(lib.category));
19
+ }
20
+ if (options.excludeRuntimeOnly) {
21
+ librariesToLoad = librariesToLoad.filter(lib => !lib.isRuntimeOnly);
22
+ }
23
+ }
24
+ const runtimeLibs = librariesToLoad.filter(lib => lib.category === 'runtime');
25
+ const componentLibs = librariesToLoad.filter(lib => lib.category !== 'runtime');
26
+ const runtimePromises = runtimeLibs.map(lib => this.loadScript(lib.cdnUrl, lib.globalVariable));
27
+ const runtimeResults = await Promise.all(runtimePromises);
28
+ const React = runtimeResults.find((_, i) => runtimeLibs[i].globalVariable === 'React');
29
+ const ReactDOM = runtimeResults.find((_, i) => runtimeLibs[i].globalVariable === 'ReactDOM');
30
+ const Babel = runtimeResults.find((_, i) => runtimeLibs[i].globalVariable === 'Babel');
31
+ componentLibs.forEach(lib => {
32
+ if (lib.cdnCssUrl) {
33
+ this.loadCSS(lib.cdnCssUrl);
34
+ }
11
35
  });
36
+ const componentPromises = componentLibs.map(lib => this.loadScript(lib.cdnUrl, lib.globalVariable));
37
+ const componentResults = await Promise.all(componentPromises);
38
+ const libraries = {};
39
+ componentLibs.forEach((lib, index) => {
40
+ libraries[lib.globalVariable] = componentResults[index];
41
+ });
42
+ return {
43
+ React: React || window.React,
44
+ ReactDOM: ReactDOM || window.ReactDOM,
45
+ Babel: Babel || window.Babel,
46
+ libraries
47
+ };
12
48
  }
13
49
  static async loadLibraries(options) {
14
50
  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 = [];
51
+ const categoriesToLoad = ['runtime'];
25
52
  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
- });
53
+ categoriesToLoad.push('utility', 'charting');
32
54
  }
33
55
  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
- });
56
+ categoriesToLoad.push('ui');
40
57
  }
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
- }
58
+ const result = await this.loadLibrariesFromConfig({
59
+ categories: categoriesToLoad
56
60
  });
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
- };
61
+ if (customLibraries.length > 0) {
62
+ const customPromises = customLibraries.map(({ url, globalName }) => this.loadScript(url, globalName));
63
+ const customResults = await Promise.all(customPromises);
64
+ customLibraries.forEach(({ globalName }, index) => {
65
+ result.libraries[globalName] = customResults[index];
66
+ });
67
+ }
68
+ return result;
75
69
  }
76
70
  static async loadScript(url, globalName) {
77
71
  const existing = this.loadedResources.get(url);
@@ -166,22 +160,6 @@ class LibraryLoader {
166
160
  };
167
161
  script.addEventListener('load', loadHandler);
168
162
  }
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
163
  static getLoadedResources() {
186
164
  return this.loadedResources;
187
165
  }
@@ -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.73.0",
3
+ "version": "2.75.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.73.0",
29
- "@memberjunction/global": "2.73.0",
30
- "@memberjunction/interactive-component-types": "2.73.0",
28
+ "@memberjunction/core": "2.75.0",
29
+ "@memberjunction/global": "2.75.0",
30
+ "@memberjunction/interactive-component-types": "2.75.0",
31
31
  "@babel/standalone": "^7.23.5",
32
32
  "rxjs": "^7.8.1"
33
33
  },
package/src/index.ts CHANGED
@@ -87,11 +87,8 @@ export {
87
87
  } from './utilities/component-styles';
88
88
 
89
89
  export {
90
- STANDARD_LIBRARY_URLS,
91
90
  StandardLibraries,
92
- getCoreLibraryUrls,
93
- getUILibraryUrls,
94
- getCSSUrls,
91
+ StandardLibraryManager,
95
92
  createStandardLibraries
96
93
  } from './utilities/standard-libraries';
97
94
 
@@ -5,16 +5,7 @@
5
5
  */
6
6
 
7
7
  import { ComponentRegistry } from './component-registry';
8
-
9
- /**
10
- * Component specification interface matching Skip component structure
11
- */
12
- export interface ComponentSpec {
13
- componentName: string;
14
- componentCode?: string;
15
- childComponents?: ComponentSpec[];
16
- components?: ComponentSpec[]; // Alternative property name for children
17
- }
8
+ import { ComponentSpec } from '@memberjunction/interactive-component-types';
18
9
 
19
10
  /**
20
11
  * Resolved component map for passing to React components
@@ -67,20 +58,20 @@ export class ComponentResolver {
67
58
  visited: Set<string> = new Set()
68
59
  ): void {
69
60
  // Prevent circular dependencies
70
- if (visited.has(spec.componentName)) {
71
- console.warn(`Circular dependency detected for component: ${spec.componentName}`);
61
+ if (visited.has(spec.name)) {
62
+ console.warn(`Circular dependency detected for component: ${spec.name}`);
72
63
  return;
73
64
  }
74
- visited.add(spec.componentName);
65
+ visited.add(spec.name);
75
66
 
76
67
  // Try to get component from registry
77
- const component = this.registry.get(spec.componentName, namespace);
68
+ const component = this.registry.get(spec.name, namespace);
78
69
  if (component) {
79
- resolved[spec.componentName] = component;
70
+ resolved[spec.name] = component;
80
71
  }
81
72
 
82
- // Process child components (handle both property names)
83
- const children = spec.childComponents || spec.components || [];
73
+ // Process child components
74
+ const children = spec.dependencies || [];
84
75
  for (const child of children) {
85
76
  this.resolveComponentHierarchy(child, resolved, namespace, visited);
86
77
  }
@@ -114,16 +105,16 @@ export class ComponentResolver {
114
105
  missing: string[],
115
106
  checked: Set<string>
116
107
  ): void {
117
- if (checked.has(spec.componentName)) return;
118
- checked.add(spec.componentName);
108
+ if (checked.has(spec.name)) return;
109
+ checked.add(spec.name);
119
110
 
120
111
  // Check if component exists in registry
121
- if (!this.registry.has(spec.componentName, namespace)) {
122
- missing.push(spec.componentName);
112
+ if (!this.registry.has(spec.name, namespace)) {
113
+ missing.push(spec.name);
123
114
  }
124
115
 
125
116
  // Check children
126
- const children = spec.childComponents || spec.components || [];
117
+ const children = spec.dependencies || [];
127
118
  for (const child of children) {
128
119
  this.checkDependencies(child, namespace, missing, checked);
129
120
  }
@@ -154,13 +145,13 @@ export class ComponentResolver {
154
145
  graph: Map<string, string[]>,
155
146
  visited: Set<string>
156
147
  ): void {
157
- if (visited.has(spec.componentName)) return;
158
- visited.add(spec.componentName);
148
+ if (visited.has(spec.name)) return;
149
+ visited.add(spec.name);
159
150
 
160
- const children = spec.childComponents || spec.components || [];
161
- const dependencies = children.map(child => child.componentName);
151
+ const children = spec.dependencies || [];
152
+ const dependencies = children.map(child => child.name);
162
153
 
163
- graph.set(spec.componentName, dependencies);
154
+ graph.set(spec.name, dependencies);
164
155
 
165
156
  // Recursively process children
166
157
  for (const child of children) {
@@ -262,12 +253,12 @@ export class ComponentResolver {
262
253
  collected: ComponentSpec[],
263
254
  visited: Set<string>
264
255
  ): void {
265
- if (visited.has(spec.componentName)) return;
266
- visited.add(spec.componentName);
256
+ if (visited.has(spec.name)) return;
257
+ visited.add(spec.name);
267
258
 
268
259
  collected.push(spec);
269
260
 
270
- const children = spec.childComponents || spec.components || [];
261
+ const children = spec.dependencies || [];
271
262
  for (const child of children) {
272
263
  this.collectComponentSpecs(child, collected, visited);
273
264
  }
@@ -4,4 +4,5 @@
4
4
  */
5
5
 
6
6
  export { ComponentRegistry } from './component-registry';
7
- export { ComponentResolver, ComponentSpec, ResolvedComponents } from './component-resolver';
7
+ export { ComponentResolver, ResolvedComponents } from './component-resolver';
8
+ export { ComponentSpec } from '@memberjunction/interactive-component-types';
@@ -13,7 +13,7 @@ import {
13
13
  import { ComponentCompiler } from '../compiler';
14
14
  import { ComponentRegistry } from '../registry';
15
15
 
16
- import { ComponentSpec } from '../registry/component-resolver';
16
+ import { ComponentSpec } from '@memberjunction/interactive-component-types';
17
17
 
18
18
  /**
19
19
  * Result of a hierarchy registration operation
@@ -89,7 +89,7 @@ export class ComponentHierarchyRegistrar {
89
89
  );
90
90
 
91
91
  if (rootResult.success) {
92
- registeredComponents.push(rootSpec.componentName);
92
+ registeredComponents.push(rootSpec.name);
93
93
  } else {
94
94
  errors.push(rootResult.error!);
95
95
  if (!continueOnError) {
@@ -98,7 +98,7 @@ export class ComponentHierarchyRegistrar {
98
98
  }
99
99
 
100
100
  // Register child components recursively
101
- const childComponents = rootSpec.childComponents || rootSpec.components || [];
101
+ const childComponents = rootSpec.dependencies || [];
102
102
  if (childComponents.length > 0) {
103
103
  const childResult = await this.registerChildComponents(
104
104
  childComponents,
@@ -136,7 +136,7 @@ export class ComponentHierarchyRegistrar {
136
136
 
137
137
  try {
138
138
  // Skip if no component code
139
- if (!spec.componentCode) {
139
+ if (!spec.code) {
140
140
  return {
141
141
  success: true,
142
142
  error: undefined
@@ -144,12 +144,12 @@ export class ComponentHierarchyRegistrar {
144
144
  }
145
145
 
146
146
  // Check if component already exists
147
- const existingComponent = this.registry.get(spec.componentName, namespace, version);
147
+ const existingComponent = this.registry.get(spec.name, namespace, version);
148
148
  if (existingComponent && !allowOverride) {
149
149
  return {
150
150
  success: false,
151
151
  error: {
152
- componentName: spec.componentName,
152
+ componentName: spec.name,
153
153
  error: `Component already registered in ${namespace}/${version}`,
154
154
  phase: 'registration'
155
155
  }
@@ -158,8 +158,8 @@ export class ComponentHierarchyRegistrar {
158
158
 
159
159
  // Compile the component
160
160
  const compileOptions: CompileOptions = {
161
- componentName: spec.componentName,
162
- componentCode: spec.componentCode,
161
+ componentName: spec.name,
162
+ componentCode: spec.code,
163
163
  styles
164
164
  };
165
165
 
@@ -169,7 +169,7 @@ export class ComponentHierarchyRegistrar {
169
169
  return {
170
170
  success: false,
171
171
  error: {
172
- componentName: spec.componentName,
172
+ componentName: spec.name,
173
173
  error: compilationResult.error?.message || 'Unknown compilation error',
174
174
  phase: 'compilation'
175
175
  }
@@ -181,7 +181,7 @@ export class ComponentHierarchyRegistrar {
181
181
 
182
182
  // Register the component
183
183
  this.registry.register(
184
- spec.componentName,
184
+ spec.name,
185
185
  componentFactory.component,
186
186
  namespace,
187
187
  version
@@ -193,7 +193,7 @@ export class ComponentHierarchyRegistrar {
193
193
  return {
194
194
  success: false,
195
195
  error: {
196
- componentName: spec.componentName,
196
+ componentName: spec.name,
197
197
  error: error instanceof Error ? error.message : String(error),
198
198
  phase: 'registration'
199
199
  }
@@ -226,8 +226,8 @@ export class ComponentHierarchyRegistrar {
226
226
  });
227
227
 
228
228
  if (childResult.success) {
229
- if (child.componentCode) {
230
- registeredComponents.push(child.componentName);
229
+ if (child.code) {
230
+ registeredComponents.push(child.name);
231
231
  }
232
232
  } else {
233
233
  errors.push(childResult.error!);
@@ -237,7 +237,7 @@ export class ComponentHierarchyRegistrar {
237
237
  }
238
238
 
239
239
  // Register nested children recursively
240
- const nestedChildren = child.childComponents || child.components || [];
240
+ const nestedChildren = child.dependencies || [];
241
241
  if (nestedChildren.length > 0) {
242
242
  await this.registerChildComponents(
243
243
  nestedChildren,
@@ -279,26 +279,26 @@ export async function registerComponentHierarchy(
279
279
  export function validateComponentSpec(spec: ComponentSpec): string[] {
280
280
  const errors: string[] = [];
281
281
 
282
- if (!spec.componentName) {
283
- errors.push('Component specification must have a componentName');
282
+ if (!spec.name) {
283
+ errors.push('Component specification must have a name');
284
284
  }
285
285
 
286
286
  // If componentCode is provided, do basic validation
287
- if (spec.componentCode) {
288
- if (typeof spec.componentCode !== 'string') {
289
- errors.push(`Component code for ${spec.componentName} must be a string`);
287
+ if (spec.code) {
288
+ if (typeof spec.code !== 'string') {
289
+ errors.push(`Component code for ${spec.name} must be a string`);
290
290
  }
291
- if (spec.componentCode.trim().length === 0) {
292
- errors.push(`Component code for ${spec.componentName} cannot be empty`);
291
+ if (spec.code.trim().length === 0) {
292
+ errors.push(`Component code for ${spec.name} cannot be empty`);
293
293
  }
294
294
  }
295
295
 
296
296
  // Validate child components recursively
297
- const children = spec.childComponents || spec.components || [];
297
+ const children = spec.dependencies || [];
298
298
  children.forEach((child, index) => {
299
299
  const childErrors = validateComponentSpec(child);
300
300
  childErrors.forEach(error => {
301
- errors.push(`Child ${index} (${child.componentName || 'unnamed'}): ${error}`);
301
+ errors.push(`Child ${index} (${child.name || 'unnamed'}): ${error}`);
302
302
  });
303
303
  });
304
304
 
@@ -313,7 +313,7 @@ export function validateComponentSpec(spec: ComponentSpec): string[] {
313
313
  export function flattenComponentHierarchy(rootSpec: ComponentSpec): ComponentSpec[] {
314
314
  const components: ComponentSpec[] = [rootSpec];
315
315
 
316
- const children = rootSpec.childComponents || rootSpec.components || [];
316
+ const children = rootSpec.dependencies || [];
317
317
  children.forEach(child => {
318
318
  components.push(...flattenComponentHierarchy(child));
319
319
  });
@@ -333,11 +333,11 @@ export function countComponentsInHierarchy(
333
333
  ): number {
334
334
  let count = 0;
335
335
 
336
- if (includeEmpty || rootSpec.componentCode) {
336
+ if (includeEmpty || rootSpec.code) {
337
337
  count = 1;
338
338
  }
339
339
 
340
- const children = rootSpec.childComponents || rootSpec.components || [];
340
+ const children = rootSpec.dependencies || [];
341
341
  children.forEach(child => {
342
342
  count += countComponentsInHierarchy(child, includeEmpty);
343
343
  });
@@ -223,4 +223,7 @@ export interface ErrorBoundaryOptions {
223
223
  logErrors?: boolean;
224
224
  /** Error recovery strategy */
225
225
  recovery?: 'retry' | 'reset' | 'none';
226
- }
226
+ }
227
+
228
+ // Export library configuration types
229
+ export * from './library-config';