@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.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +27 -0
- package/README.md +96 -4
- package/dist/compiler/component-compiler.d.ts +0 -1
- package/dist/compiler/component-compiler.d.ts.map +1 -1
- package/dist/compiler/component-compiler.js +34 -25
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -6
- package/dist/registry/component-resolver.d.ts +1 -6
- package/dist/registry/component-resolver.d.ts.map +1 -1
- package/dist/registry/component-resolver.js +19 -19
- package/dist/registry/index.d.ts +2 -1
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +3 -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 +25 -25
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -2
- package/dist/runtime/prop-builder.d.ts +1 -2
- package/dist/runtime/prop-builder.d.ts.map +1 -1
- package/dist/runtime/prop-builder.js +4 -76
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +15 -0
- package/dist/types/library-config.d.ts +32 -0
- package/dist/types/library-config.d.ts.map +1 -0
- package/dist/types/library-config.js +2 -0
- package/dist/utilities/core-libraries.d.ts +5 -0
- package/dist/utilities/core-libraries.d.ts.map +1 -0
- package/dist/utilities/core-libraries.js +52 -0
- package/dist/utilities/library-loader.d.ts +3 -2
- package/dist/utilities/library-loader.d.ts.map +1 -1
- package/dist/utilities/library-loader.js +65 -76
- package/dist/utilities/standard-libraries.d.ts +13 -24
- package/dist/utilities/standard-libraries.d.ts.map +1 -1
- package/dist/utilities/standard-libraries.js +58 -47
- package/package.json +4 -4
- package/samples/entities-1.js +493 -0
- package/src/compiler/component-compiler.ts +64 -35
- package/src/index.ts +1 -5
- package/src/registry/component-resolver.ts +21 -30
- package/src/registry/index.ts +2 -1
- package/src/runtime/component-hierarchy.ts +26 -26
- package/src/runtime/index.ts +0 -1
- package/src/runtime/prop-builder.ts +5 -112
- package/src/types/index.ts +6 -1
- package/src/types/library-config.ts +75 -0
- package/src/utilities/core-libraries.ts +61 -0
- package/src/utilities/library-loader.ts +113 -93
- package/src/utilities/standard-libraries.ts +104 -71
- 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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
42
|
-
|
|
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 (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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":"
|
|
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.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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.
|
|
51
|
+
exports.StandardLibraryManager = StandardLibraryManager;
|
|
52
|
+
StandardLibraryManager.configuration = DEFAULT_LIBRARY_CONFIG;
|
|
40
53
|
function createStandardLibraries() {
|
|
41
54
|
if (typeof window === 'undefined') {
|
|
42
|
-
return {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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.
|
|
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.
|
|
29
|
-
"@memberjunction/global": "2.
|
|
30
|
-
"@memberjunction/interactive-component-types": "2.
|
|
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
|
},
|