@memberjunction/react-runtime 2.76.0 → 2.77.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 +10 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/registry/component-registry.d.ts +1 -0
- package/dist/registry/component-registry.d.ts.map +1 -1
- package/dist/registry/component-registry.js +6 -3
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +4 -1
- package/dist/runtime/react-root-manager.d.ts +26 -0
- package/dist/runtime/react-root-manager.d.ts.map +1 -0
- package/dist/runtime/react-root-manager.js +122 -0
- package/dist/utilities/cache-manager.d.ts +38 -0
- package/dist/utilities/cache-manager.d.ts.map +1 -0
- package/dist/utilities/cache-manager.js +156 -0
- package/dist/utilities/index.d.ts +2 -0
- package/dist/utilities/index.d.ts.map +1 -1
- package/dist/utilities/index.js +2 -0
- package/dist/utilities/library-loader.d.ts.map +1 -1
- package/dist/utilities/library-loader.js +25 -8
- package/dist/utilities/resource-manager.d.ts +34 -0
- package/dist/utilities/resource-manager.d.ts.map +1 -0
- package/dist/utilities/resource-manager.js +174 -0
- package/package.json +4 -4
- package/src/index.ts +18 -0
- package/src/registry/component-registry.ts +14 -4
- package/src/runtime/index.ts +7 -1
- package/src/runtime/react-root-manager.ts +218 -0
- package/src/utilities/cache-manager.ts +253 -0
- package/src/utilities/index.ts +3 -1
- package/src/utilities/library-loader.ts +66 -21
- package/src/utilities/resource-manager.ts +305 -0
- package/tsconfig.tsbuildinfo +1 -1
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @memberjunction/react-runtime
|
|
2
2
|
|
|
3
|
+
## 2.77.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [d8f14a2]
|
|
8
|
+
- Updated dependencies [c91269e]
|
|
9
|
+
- @memberjunction/core@2.77.0
|
|
10
|
+
- @memberjunction/interactive-component-types@2.77.0
|
|
11
|
+
- @memberjunction/global@2.77.0
|
|
12
|
+
|
|
3
13
|
## 2.76.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -10,11 +10,14 @@ export { createErrorBoundary, withErrorBoundary, formatComponentError, createErr
|
|
|
10
10
|
export { wrapComponent, memoizeComponent, lazyComponent, injectProps, conditionalComponent, withErrorHandler, portalComponent, WrapperOptions } from './runtime';
|
|
11
11
|
export { buildComponentProps, normalizeCallbacks, normalizeStyles, validateComponentProps, mergeProps, createPropsTransformer, wrapCallbacksWithLogging, extractPropPaths, PropBuilderOptions } from './runtime';
|
|
12
12
|
export { ComponentHierarchyRegistrar, registerComponentHierarchy, validateComponentSpec, flattenComponentHierarchy, countComponentsInHierarchy, HierarchyRegistrationResult, ComponentRegistrationError, HierarchyRegistrationOptions } from './runtime';
|
|
13
|
+
export { ReactRootManager, reactRootManager, ManagedReactRoot } from './runtime';
|
|
13
14
|
export { RuntimeUtilities, createRuntimeUtilities } from './utilities/runtime-utilities';
|
|
14
15
|
export { SetupStyles, createDefaultComponentStyles } from './utilities/component-styles';
|
|
15
16
|
export { StandardLibraries, StandardLibraryManager, createStandardLibraries } from './utilities/standard-libraries';
|
|
16
17
|
export { LibraryLoader, LibraryLoadOptions, LibraryLoadResult } from './utilities/library-loader';
|
|
17
18
|
export { ComponentErrorAnalyzer, FailedComponentInfo } from './utilities/component-error-analyzer';
|
|
19
|
+
export { ResourceManager, resourceManager, ManagedResource } from './utilities/resource-manager';
|
|
20
|
+
export { CacheManager, CacheEntry, CacheOptions } from './utilities/cache-manager';
|
|
18
21
|
export declare const VERSION = "2.69.1";
|
|
19
22
|
export declare const DEFAULT_CONFIGS: {
|
|
20
23
|
compiler: {
|
package/dist/index.d.ts.map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0B,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC7B,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,WAAW,EACX,4BAA4B,EAC7B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,eAAe,EACf,eAAe,EACf,eAAe,EAChB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,YAAY,EACZ,UAAU,EACV,YAAY,EACb,MAAM,2BAA2B,CAAC;AAGnC,eAAO,MAAM,OAAO,WAAW,CAAC;AAGhC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;CAiB3B,CAAC;AAQF,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,GAAG,EAClB,MAAM,CAAC,EAAE;IACP,QAAQ,CAAC,EAAE,OAAO,CAAC,OAAO,SAAS,EAAE,cAAc,CAAC,CAAC;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC,OAAO,SAAS,EAAE,cAAc,CAAC,CAAC;CACtD;;;;;EAcF"}
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.DEFAULT_CONFIGS = exports.VERSION = exports.CacheManager = exports.resourceManager = exports.ResourceManager = exports.ComponentErrorAnalyzer = exports.LibraryLoader = exports.createStandardLibraries = exports.StandardLibraryManager = exports.createDefaultComponentStyles = exports.SetupStyles = exports.createRuntimeUtilities = exports.RuntimeUtilities = exports.reactRootManager = exports.ReactRootManager = exports.countComponentsInHierarchy = exports.flattenComponentHierarchy = exports.validateComponentSpec = exports.registerComponentHierarchy = exports.ComponentHierarchyRegistrar = exports.extractPropPaths = exports.wrapCallbacksWithLogging = exports.createPropsTransformer = exports.mergeProps = exports.validateComponentProps = exports.normalizeStyles = exports.normalizeCallbacks = exports.buildComponentProps = exports.portalComponent = exports.withErrorHandler = exports.conditionalComponent = exports.injectProps = exports.lazyComponent = exports.memoizeComponent = exports.wrapComponent = exports.createErrorLogger = exports.formatComponentError = exports.withErrorBoundary = exports.createErrorBoundary = exports.ComponentSpec = exports.ComponentResolver = exports.ComponentRegistry = exports.getJSXConfig = exports.validateBabelPresets = exports.getBabelConfig = exports.DEVELOPMENT_CONFIG = exports.PRODUCTION_CONFIG = exports.DEFAULT_PLUGINS = exports.DEFAULT_PRESETS = exports.ComponentCompiler = void 0;
|
|
18
|
+
exports.createReactRuntime = void 0;
|
|
18
19
|
const compiler_1 = require("./compiler");
|
|
19
20
|
const registry_1 = require("./registry");
|
|
20
21
|
const registry_2 = require("./registry");
|
|
@@ -62,6 +63,9 @@ Object.defineProperty(exports, "registerComponentHierarchy", { enumerable: true,
|
|
|
62
63
|
Object.defineProperty(exports, "validateComponentSpec", { enumerable: true, get: function () { return runtime_4.validateComponentSpec; } });
|
|
63
64
|
Object.defineProperty(exports, "flattenComponentHierarchy", { enumerable: true, get: function () { return runtime_4.flattenComponentHierarchy; } });
|
|
64
65
|
Object.defineProperty(exports, "countComponentsInHierarchy", { enumerable: true, get: function () { return runtime_4.countComponentsInHierarchy; } });
|
|
66
|
+
var runtime_5 = require("./runtime");
|
|
67
|
+
Object.defineProperty(exports, "ReactRootManager", { enumerable: true, get: function () { return runtime_5.ReactRootManager; } });
|
|
68
|
+
Object.defineProperty(exports, "reactRootManager", { enumerable: true, get: function () { return runtime_5.reactRootManager; } });
|
|
65
69
|
var runtime_utilities_1 = require("./utilities/runtime-utilities");
|
|
66
70
|
Object.defineProperty(exports, "RuntimeUtilities", { enumerable: true, get: function () { return runtime_utilities_1.RuntimeUtilities; } });
|
|
67
71
|
Object.defineProperty(exports, "createRuntimeUtilities", { enumerable: true, get: function () { return runtime_utilities_1.createRuntimeUtilities; } });
|
|
@@ -75,6 +79,11 @@ var library_loader_1 = require("./utilities/library-loader");
|
|
|
75
79
|
Object.defineProperty(exports, "LibraryLoader", { enumerable: true, get: function () { return library_loader_1.LibraryLoader; } });
|
|
76
80
|
var component_error_analyzer_1 = require("./utilities/component-error-analyzer");
|
|
77
81
|
Object.defineProperty(exports, "ComponentErrorAnalyzer", { enumerable: true, get: function () { return component_error_analyzer_1.ComponentErrorAnalyzer; } });
|
|
82
|
+
var resource_manager_1 = require("./utilities/resource-manager");
|
|
83
|
+
Object.defineProperty(exports, "ResourceManager", { enumerable: true, get: function () { return resource_manager_1.ResourceManager; } });
|
|
84
|
+
Object.defineProperty(exports, "resourceManager", { enumerable: true, get: function () { return resource_manager_1.resourceManager; } });
|
|
85
|
+
var cache_manager_1 = require("./utilities/cache-manager");
|
|
86
|
+
Object.defineProperty(exports, "CacheManager", { enumerable: true, get: function () { return cache_manager_1.CacheManager; } });
|
|
78
87
|
exports.VERSION = '2.69.1';
|
|
79
88
|
exports.DEFAULT_CONFIGS = {
|
|
80
89
|
compiler: {
|
|
@@ -3,6 +3,7 @@ export declare class ComponentRegistry {
|
|
|
3
3
|
private registry;
|
|
4
4
|
private config;
|
|
5
5
|
private cleanupTimer?;
|
|
6
|
+
private registryId;
|
|
6
7
|
constructor(config?: Partial<RegistryConfig>);
|
|
7
8
|
register(name: string, component: any, namespace?: string, version?: string, tags?: string[]): ComponentMetadata;
|
|
8
9
|
get(name: string, namespace?: string, version?: string): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-registry.d.ts","sourceRoot":"","sources":["../../src/registry/component-registry.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,iBAAiB,EACjB,cAAc,EACf,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"component-registry.d.ts","sourceRoot":"","sources":["../../src/registry/component-registry.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,iBAAiB,EACjB,cAAc,EACf,MAAM,UAAU,CAAC;AAiBlB,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAA6B;IAC7C,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,YAAY,CAAC,CAA0B;IAC/C,OAAO,CAAC,UAAU,CAAS;gBAMf,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAoB5C,QAAQ,CACN,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,GAAG,EACd,SAAS,GAAE,MAAiB,EAC5B,OAAO,GAAE,MAAa,EACtB,IAAI,CAAC,EAAE,MAAM,EAAE,GACd,iBAAiB;IAuCpB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,MAAiB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,GAAG;IAyBtE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,MAAiB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO;IAe1E,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,MAAiB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO;IAejF,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,iBAAiB,EAAE;IAgBpD,aAAa,IAAI,MAAM,EAAE;IAezB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,iBAAiB,EAAE;IAkB9C,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,MAAiB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAgB3E,KAAK,IAAI,IAAI;IAQb,IAAI,IAAI,MAAM;IASd,OAAO,CAAC,KAAK,GAAE,OAAe,GAAG,MAAM;IAyBvC,QAAQ,IAAI;QACV,eAAe,EAAE,MAAM,CAAC;QACxB,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,EAAE,MAAM,CAAC;QACtB,eAAe,CAAC,EAAE,IAAI,CAAC;QACvB,eAAe,CAAC,EAAE,IAAI,CAAC;KACxB;IA6BD,OAAO,IAAI,IAAI;IAcf,OAAO,CAAC,mBAAmB;IAa3B,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,QAAQ;IAsBhB,OAAO,CAAC,iBAAiB;IAczB,OAAO,CAAC,gBAAgB;CAMzB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ComponentRegistry = void 0;
|
|
4
|
+
const resource_manager_1 = require("../utilities/resource-manager");
|
|
4
5
|
const DEFAULT_REGISTRY_CONFIG = {
|
|
5
6
|
maxComponents: 1000,
|
|
6
7
|
cleanupInterval: 60000,
|
|
@@ -11,6 +12,7 @@ class ComponentRegistry {
|
|
|
11
12
|
constructor(config) {
|
|
12
13
|
this.config = { ...DEFAULT_REGISTRY_CONFIG, ...config };
|
|
13
14
|
this.registry = new Map();
|
|
15
|
+
this.registryId = `component-registry-${Date.now()}`;
|
|
14
16
|
if (this.config.cleanupInterval > 0) {
|
|
15
17
|
this.startCleanupTimer();
|
|
16
18
|
}
|
|
@@ -146,6 +148,7 @@ class ComponentRegistry {
|
|
|
146
148
|
destroy() {
|
|
147
149
|
this.stopCleanupTimer();
|
|
148
150
|
this.clear();
|
|
151
|
+
resource_manager_1.resourceManager.cleanupComponent(this.registryId);
|
|
149
152
|
}
|
|
150
153
|
generateRegistryKey(name, namespace, version) {
|
|
151
154
|
if (this.config.enableNamespaces) {
|
|
@@ -183,13 +186,13 @@ class ComponentRegistry {
|
|
|
183
186
|
}
|
|
184
187
|
}
|
|
185
188
|
startCleanupTimer() {
|
|
186
|
-
this.cleanupTimer = setInterval(() => {
|
|
189
|
+
this.cleanupTimer = resource_manager_1.resourceManager.setInterval(this.registryId, () => {
|
|
187
190
|
this.cleanup();
|
|
188
|
-
}, this.config.cleanupInterval);
|
|
191
|
+
}, this.config.cleanupInterval, { purpose: 'component-registry-cleanup' });
|
|
189
192
|
}
|
|
190
193
|
stopCleanupTimer() {
|
|
191
194
|
if (this.cleanupTimer) {
|
|
192
|
-
clearInterval(this.cleanupTimer);
|
|
195
|
+
resource_manager_1.resourceManager.clearInterval(this.registryId, this.cleanupTimer);
|
|
193
196
|
this.cleanupTimer = undefined;
|
|
194
197
|
}
|
|
195
198
|
}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { createErrorBoundary, withErrorBoundary, formatComponentError, createErr
|
|
|
2
2
|
export { wrapComponent, memoizeComponent, lazyComponent, injectProps, conditionalComponent, withErrorHandler, portalComponent, WrapperOptions } from './component-wrapper';
|
|
3
3
|
export { buildComponentProps, normalizeCallbacks, normalizeStyles, validateComponentProps, mergeProps, createPropsTransformer, wrapCallbacksWithLogging, extractPropPaths, PropBuilderOptions } from './prop-builder';
|
|
4
4
|
export { ComponentHierarchyRegistrar, registerComponentHierarchy, validateComponentSpec, flattenComponentHierarchy, countComponentsInHierarchy, HierarchyRegistrationResult, ComponentRegistrationError, HierarchyRegistrationOptions } from './component-hierarchy';
|
|
5
|
+
export { ReactRootManager, reactRootManager, ManagedReactRoot } from './react-root-manager';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,UAAU,EACV,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC7B,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,UAAU,EACV,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC7B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,sBAAsB,CAAC"}
|
package/dist/runtime/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.countComponentsInHierarchy = exports.flattenComponentHierarchy = exports.validateComponentSpec = exports.registerComponentHierarchy = exports.ComponentHierarchyRegistrar = exports.extractPropPaths = exports.wrapCallbacksWithLogging = exports.createPropsTransformer = exports.mergeProps = exports.validateComponentProps = exports.normalizeStyles = exports.normalizeCallbacks = exports.buildComponentProps = exports.portalComponent = exports.withErrorHandler = exports.conditionalComponent = exports.injectProps = exports.lazyComponent = exports.memoizeComponent = exports.wrapComponent = exports.createErrorLogger = exports.formatComponentError = exports.withErrorBoundary = exports.createErrorBoundary = void 0;
|
|
3
|
+
exports.reactRootManager = exports.ReactRootManager = exports.countComponentsInHierarchy = exports.flattenComponentHierarchy = exports.validateComponentSpec = exports.registerComponentHierarchy = exports.ComponentHierarchyRegistrar = exports.extractPropPaths = exports.wrapCallbacksWithLogging = exports.createPropsTransformer = exports.mergeProps = exports.validateComponentProps = exports.normalizeStyles = exports.normalizeCallbacks = exports.buildComponentProps = exports.portalComponent = exports.withErrorHandler = exports.conditionalComponent = exports.injectProps = exports.lazyComponent = exports.memoizeComponent = exports.wrapComponent = exports.createErrorLogger = exports.formatComponentError = exports.withErrorBoundary = exports.createErrorBoundary = void 0;
|
|
4
4
|
var error_boundary_1 = require("./error-boundary");
|
|
5
5
|
Object.defineProperty(exports, "createErrorBoundary", { enumerable: true, get: function () { return error_boundary_1.createErrorBoundary; } });
|
|
6
6
|
Object.defineProperty(exports, "withErrorBoundary", { enumerable: true, get: function () { return error_boundary_1.withErrorBoundary; } });
|
|
@@ -29,3 +29,6 @@ Object.defineProperty(exports, "registerComponentHierarchy", { enumerable: true,
|
|
|
29
29
|
Object.defineProperty(exports, "validateComponentSpec", { enumerable: true, get: function () { return component_hierarchy_1.validateComponentSpec; } });
|
|
30
30
|
Object.defineProperty(exports, "flattenComponentHierarchy", { enumerable: true, get: function () { return component_hierarchy_1.flattenComponentHierarchy; } });
|
|
31
31
|
Object.defineProperty(exports, "countComponentsInHierarchy", { enumerable: true, get: function () { return component_hierarchy_1.countComponentsInHierarchy; } });
|
|
32
|
+
var react_root_manager_1 = require("./react-root-manager");
|
|
33
|
+
Object.defineProperty(exports, "ReactRootManager", { enumerable: true, get: function () { return react_root_manager_1.ReactRootManager; } });
|
|
34
|
+
Object.defineProperty(exports, "reactRootManager", { enumerable: true, get: function () { return react_root_manager_1.reactRootManager; } });
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface ManagedReactRoot {
|
|
2
|
+
id: string;
|
|
3
|
+
root: any;
|
|
4
|
+
container: HTMLElement;
|
|
5
|
+
isRendering: boolean;
|
|
6
|
+
lastRenderTime?: Date;
|
|
7
|
+
componentId?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class ReactRootManager {
|
|
10
|
+
private roots;
|
|
11
|
+
private renderingRoots;
|
|
12
|
+
private unmountQueue;
|
|
13
|
+
createRoot(container: HTMLElement, createRootFn: (container: HTMLElement) => any, componentId?: string): string;
|
|
14
|
+
render(rootId: string, element: any, onComplete?: () => void): void;
|
|
15
|
+
unmountRoot(rootId: string, force?: boolean): Promise<void>;
|
|
16
|
+
unmountComponentRoots(componentId: string): Promise<void>;
|
|
17
|
+
isRendering(rootId: string): boolean;
|
|
18
|
+
getStats(): {
|
|
19
|
+
totalRoots: number;
|
|
20
|
+
renderingRoots: number;
|
|
21
|
+
pendingUnmounts: number;
|
|
22
|
+
};
|
|
23
|
+
cleanup(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export declare const reactRootManager: ReactRootManager;
|
|
26
|
+
//# sourceMappingURL=react-root-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-root-manager.d.ts","sourceRoot":"","sources":["../../src/runtime/react-root-manager.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,GAAG,CAAC;IACV,SAAS,EAAE,WAAW,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,IAAI,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAMD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAAuC;IACpD,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,YAAY,CAAiC;IASrD,UAAU,CACR,SAAS,EAAE,WAAW,EACtB,YAAY,EAAE,CAAC,SAAS,EAAE,WAAW,KAAK,GAAG,EAC7C,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM;IAgCT,MAAM,CACJ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,GAAG,EACZ,UAAU,CAAC,EAAE,MAAM,IAAI,GACtB,IAAI;IAkDP,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAiD5D,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB/D,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAOpC,QAAQ,IAAI;QACV,UAAU,EAAE,MAAM,CAAC;QACnB,cAAc,EAAE,MAAM,CAAC;QACvB,eAAe,EAAE,MAAM,CAAC;KACzB;IAWK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAI/B;AAGD,eAAO,MAAM,gBAAgB,kBAAyB,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reactRootManager = exports.ReactRootManager = void 0;
|
|
4
|
+
const resource_manager_1 = require("../utilities/resource-manager");
|
|
5
|
+
class ReactRootManager {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.roots = new Map();
|
|
8
|
+
this.renderingRoots = new Set();
|
|
9
|
+
this.unmountQueue = new Map();
|
|
10
|
+
}
|
|
11
|
+
createRoot(container, createRootFn, componentId) {
|
|
12
|
+
const rootId = `react-root-${Date.now()}-${Math.random()}`;
|
|
13
|
+
const root = createRootFn(container);
|
|
14
|
+
const managedRoot = {
|
|
15
|
+
id: rootId,
|
|
16
|
+
root,
|
|
17
|
+
container,
|
|
18
|
+
isRendering: false,
|
|
19
|
+
componentId
|
|
20
|
+
};
|
|
21
|
+
this.roots.set(rootId, managedRoot);
|
|
22
|
+
if (componentId) {
|
|
23
|
+
resource_manager_1.resourceManager.registerReactRoot(componentId, root, () => this.unmountRoot(rootId));
|
|
24
|
+
}
|
|
25
|
+
return rootId;
|
|
26
|
+
}
|
|
27
|
+
render(rootId, element, onComplete) {
|
|
28
|
+
const managedRoot = this.roots.get(rootId);
|
|
29
|
+
if (!managedRoot) {
|
|
30
|
+
console.warn(`React root ${rootId} not found`);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (this.unmountQueue.has(rootId)) {
|
|
34
|
+
console.warn(`React root ${rootId} is being unmounted, skipping render`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
managedRoot.isRendering = true;
|
|
38
|
+
this.renderingRoots.add(rootId);
|
|
39
|
+
try {
|
|
40
|
+
managedRoot.root.render(element);
|
|
41
|
+
managedRoot.lastRenderTime = new Date();
|
|
42
|
+
Promise.resolve().then(() => {
|
|
43
|
+
managedRoot.isRendering = false;
|
|
44
|
+
this.renderingRoots.delete(rootId);
|
|
45
|
+
const pendingUnmount = this.unmountQueue.get(rootId);
|
|
46
|
+
if (pendingUnmount) {
|
|
47
|
+
this.unmountQueue.delete(rootId);
|
|
48
|
+
pendingUnmount();
|
|
49
|
+
}
|
|
50
|
+
if (onComplete) {
|
|
51
|
+
onComplete();
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
managedRoot.isRendering = false;
|
|
57
|
+
this.renderingRoots.delete(rootId);
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
unmountRoot(rootId, force = false) {
|
|
62
|
+
return new Promise((resolve) => {
|
|
63
|
+
const managedRoot = this.roots.get(rootId);
|
|
64
|
+
if (!managedRoot) {
|
|
65
|
+
resolve();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const performUnmount = () => {
|
|
69
|
+
try {
|
|
70
|
+
managedRoot.root.unmount();
|
|
71
|
+
this.roots.delete(rootId);
|
|
72
|
+
this.renderingRoots.delete(rootId);
|
|
73
|
+
if (managedRoot.container) {
|
|
74
|
+
delete managedRoot.container._reactRootContainer;
|
|
75
|
+
const newContainer = managedRoot.container.cloneNode(false);
|
|
76
|
+
managedRoot.container.parentNode?.replaceChild(newContainer, managedRoot.container);
|
|
77
|
+
}
|
|
78
|
+
resolve();
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
console.error(`Error unmounting React root ${rootId}:`, error);
|
|
82
|
+
this.roots.delete(rootId);
|
|
83
|
+
this.renderingRoots.delete(rootId);
|
|
84
|
+
resolve();
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
if (!managedRoot.isRendering || force) {
|
|
88
|
+
performUnmount();
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
this.unmountQueue.set(rootId, () => {
|
|
92
|
+
performUnmount();
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
async unmountComponentRoots(componentId) {
|
|
98
|
+
const rootIds = [];
|
|
99
|
+
for (const [rootId, managedRoot] of this.roots) {
|
|
100
|
+
if (managedRoot.componentId === componentId) {
|
|
101
|
+
rootIds.push(rootId);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
await Promise.all(rootIds.map(id => this.unmountRoot(id)));
|
|
105
|
+
}
|
|
106
|
+
isRendering(rootId) {
|
|
107
|
+
return this.renderingRoots.has(rootId);
|
|
108
|
+
}
|
|
109
|
+
getStats() {
|
|
110
|
+
return {
|
|
111
|
+
totalRoots: this.roots.size,
|
|
112
|
+
renderingRoots: this.renderingRoots.size,
|
|
113
|
+
pendingUnmounts: this.unmountQueue.size
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
async cleanup() {
|
|
117
|
+
const allRootIds = Array.from(this.roots.keys());
|
|
118
|
+
await Promise.all(allRootIds.map(id => this.unmountRoot(id, true)));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.ReactRootManager = ReactRootManager;
|
|
122
|
+
exports.reactRootManager = new ReactRootManager();
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface CacheEntry<T> {
|
|
2
|
+
value: T;
|
|
3
|
+
timestamp: number;
|
|
4
|
+
size?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface CacheOptions {
|
|
7
|
+
maxSize?: number;
|
|
8
|
+
maxMemory?: number;
|
|
9
|
+
defaultTTL?: number;
|
|
10
|
+
cleanupInterval?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class CacheManager<T = any> {
|
|
13
|
+
private cache;
|
|
14
|
+
private memoryUsage;
|
|
15
|
+
private cleanupTimer?;
|
|
16
|
+
private readonly options;
|
|
17
|
+
constructor(options?: CacheOptions);
|
|
18
|
+
set(key: string, value: T, ttl?: number): void;
|
|
19
|
+
get(key: string): T | undefined;
|
|
20
|
+
has(key: string): boolean;
|
|
21
|
+
delete(key: string): boolean;
|
|
22
|
+
clear(): void;
|
|
23
|
+
getStats(): {
|
|
24
|
+
size: number;
|
|
25
|
+
memoryUsage: number;
|
|
26
|
+
maxSize: number;
|
|
27
|
+
maxMemory: number;
|
|
28
|
+
};
|
|
29
|
+
cleanup(): number;
|
|
30
|
+
destroy(): void;
|
|
31
|
+
private isExpired;
|
|
32
|
+
private evictLRU;
|
|
33
|
+
private evictByMemory;
|
|
34
|
+
private estimateSize;
|
|
35
|
+
private startCleanupTimer;
|
|
36
|
+
private stopCleanupTimer;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=cache-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-manager.d.ts","sourceRoot":"","sources":["../../src/utilities/cache-manager.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,KAAK,EAAE,CAAC,CAAC;IACT,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAMD,qBAAa,YAAY,CAAC,CAAC,GAAG,GAAG;IAC/B,OAAO,CAAC,KAAK,CAAoC;IACjD,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;gBAErC,OAAO,GAAE,YAAiB;IAgBtC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI;IAqC9C,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAkB/B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAezB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAY5B,KAAK,IAAI,IAAI;IAQb,QAAQ,IAAI;QACV,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;KACnB;IAYD,OAAO,IAAI,MAAM;IAiBjB,OAAO,IAAI,IAAI;IAQf,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,QAAQ;IAmBhB,OAAO,CAAC,aAAa;IAerB,OAAO,CAAC,YAAY;IAkBpB,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,gBAAgB;CAMzB"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CacheManager = void 0;
|
|
4
|
+
class CacheManager {
|
|
5
|
+
constructor(options = {}) {
|
|
6
|
+
this.cache = new Map();
|
|
7
|
+
this.memoryUsage = 0;
|
|
8
|
+
this.options = {
|
|
9
|
+
maxSize: options.maxSize || 1000,
|
|
10
|
+
maxMemory: options.maxMemory || 50 * 1024 * 1024,
|
|
11
|
+
defaultTTL: options.defaultTTL || 5 * 60 * 1000,
|
|
12
|
+
cleanupInterval: options.cleanupInterval || 60 * 1000
|
|
13
|
+
};
|
|
14
|
+
if (this.options.cleanupInterval > 0) {
|
|
15
|
+
this.startCleanupTimer();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
set(key, value, ttl) {
|
|
19
|
+
const size = this.estimateSize(value);
|
|
20
|
+
const entry = {
|
|
21
|
+
value,
|
|
22
|
+
timestamp: Date.now(),
|
|
23
|
+
size
|
|
24
|
+
};
|
|
25
|
+
if (this.cache.size >= this.options.maxSize) {
|
|
26
|
+
this.evictLRU();
|
|
27
|
+
}
|
|
28
|
+
if (this.memoryUsage + size > this.options.maxMemory) {
|
|
29
|
+
this.evictByMemory(size);
|
|
30
|
+
}
|
|
31
|
+
const oldEntry = this.cache.get(key);
|
|
32
|
+
if (oldEntry) {
|
|
33
|
+
this.memoryUsage -= oldEntry.size || 0;
|
|
34
|
+
}
|
|
35
|
+
this.cache.set(key, entry);
|
|
36
|
+
this.memoryUsage += size;
|
|
37
|
+
if (ttl || this.options.defaultTTL) {
|
|
38
|
+
const timeout = ttl || this.options.defaultTTL;
|
|
39
|
+
setTimeout(() => this.delete(key), timeout);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
get(key) {
|
|
43
|
+
const entry = this.cache.get(key);
|
|
44
|
+
if (!entry)
|
|
45
|
+
return undefined;
|
|
46
|
+
if (this.isExpired(entry)) {
|
|
47
|
+
this.delete(key);
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
entry.timestamp = Date.now();
|
|
51
|
+
return entry.value;
|
|
52
|
+
}
|
|
53
|
+
has(key) {
|
|
54
|
+
const entry = this.cache.get(key);
|
|
55
|
+
if (!entry)
|
|
56
|
+
return false;
|
|
57
|
+
if (this.isExpired(entry)) {
|
|
58
|
+
this.delete(key);
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
delete(key) {
|
|
64
|
+
const entry = this.cache.get(key);
|
|
65
|
+
if (entry) {
|
|
66
|
+
this.memoryUsage -= entry.size || 0;
|
|
67
|
+
return this.cache.delete(key);
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
clear() {
|
|
72
|
+
this.cache.clear();
|
|
73
|
+
this.memoryUsage = 0;
|
|
74
|
+
}
|
|
75
|
+
getStats() {
|
|
76
|
+
return {
|
|
77
|
+
size: this.cache.size,
|
|
78
|
+
memoryUsage: this.memoryUsage,
|
|
79
|
+
maxSize: this.options.maxSize,
|
|
80
|
+
maxMemory: this.options.maxMemory
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
cleanup() {
|
|
84
|
+
let removed = 0;
|
|
85
|
+
const now = Date.now();
|
|
86
|
+
for (const [key, entry] of this.cache) {
|
|
87
|
+
if (this.isExpired(entry, now)) {
|
|
88
|
+
this.delete(key);
|
|
89
|
+
removed++;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return removed;
|
|
93
|
+
}
|
|
94
|
+
destroy() {
|
|
95
|
+
this.stopCleanupTimer();
|
|
96
|
+
this.clear();
|
|
97
|
+
}
|
|
98
|
+
isExpired(entry, now) {
|
|
99
|
+
if (!this.options.defaultTTL)
|
|
100
|
+
return false;
|
|
101
|
+
const currentTime = now || Date.now();
|
|
102
|
+
return currentTime - entry.timestamp > this.options.defaultTTL;
|
|
103
|
+
}
|
|
104
|
+
evictLRU() {
|
|
105
|
+
let lruKey;
|
|
106
|
+
let lruTime = Infinity;
|
|
107
|
+
for (const [key, entry] of this.cache) {
|
|
108
|
+
if (entry.timestamp < lruTime) {
|
|
109
|
+
lruTime = entry.timestamp;
|
|
110
|
+
lruKey = key;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (lruKey) {
|
|
114
|
+
this.delete(lruKey);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
evictByMemory(requiredSize) {
|
|
118
|
+
const entries = Array.from(this.cache.entries())
|
|
119
|
+
.sort((a, b) => a[1].timestamp - b[1].timestamp);
|
|
120
|
+
let freedMemory = 0;
|
|
121
|
+
for (const [key, entry] of entries) {
|
|
122
|
+
if (freedMemory >= requiredSize)
|
|
123
|
+
break;
|
|
124
|
+
freedMemory += entry.size || 0;
|
|
125
|
+
this.delete(key);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
estimateSize(value) {
|
|
129
|
+
if (typeof value === 'string') {
|
|
130
|
+
return value.length * 2;
|
|
131
|
+
}
|
|
132
|
+
else if (typeof value === 'object' && value !== null) {
|
|
133
|
+
try {
|
|
134
|
+
return JSON.stringify(value).length * 2;
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return 1024;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
return 8;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
startCleanupTimer() {
|
|
145
|
+
this.cleanupTimer = window.setInterval(() => {
|
|
146
|
+
this.cleanup();
|
|
147
|
+
}, this.options.cleanupInterval);
|
|
148
|
+
}
|
|
149
|
+
stopCleanupTimer() {
|
|
150
|
+
if (this.cleanupTimer) {
|
|
151
|
+
window.clearInterval(this.cleanupTimer);
|
|
152
|
+
this.cleanupTimer = undefined;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.CacheManager = CacheManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAKA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAKA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
|
package/dist/utilities/index.js
CHANGED
|
@@ -19,3 +19,5 @@ __exportStar(require("./component-styles"), exports);
|
|
|
19
19
|
__exportStar(require("./standard-libraries"), exports);
|
|
20
20
|
__exportStar(require("./library-loader"), exports);
|
|
21
21
|
__exportStar(require("./component-error-analyzer"), exports);
|
|
22
|
+
__exportStar(require("./resource-manager"), exports);
|
|
23
|
+
__exportStar(require("./cache-manager"), exports);
|
|
@@ -1 +1 @@
|
|
|
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,EAAE,qBAAqB,EAAE,kBAAkB,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"library-loader.d.ts","sourceRoot":"","sources":["../../src/utilities/library-loader.ts"],"names":[],"mappings":"AAMA,O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