react-arbiter
Advanced tools
Comparing version 0.7.2 to 0.8.0
# React Arbiter Changelog | ||
## 0.8.0 | ||
- Removed `dependencies` field from metadata | ||
- Added `custom` field to metadata | ||
## 0.7.2 | ||
- Expose package typings | ||
- Expose package typings | ||
@@ -7,0 +12,0 @@ ## 0.7.1 |
@@ -12,12 +12,2 @@ import { ComponentType, Ref } from 'react'; | ||
/** | ||
* The dependency map of the module. | ||
*/ | ||
dependencies: { | ||
/** | ||
* The name of the dependency and the related location, which | ||
* defines where to get (i.e., fetch) it from. | ||
*/ | ||
[name: string]: string; | ||
}; | ||
/** | ||
* The content of the module. If the content is not available | ||
@@ -43,2 +33,6 @@ * the link will be used (unless caching has been activated). | ||
noCache?: boolean | string; | ||
/** | ||
* Optionally provides some custom metadata for the module. | ||
*/ | ||
custom?: any; | ||
} | ||
@@ -45,0 +39,0 @@ export interface ArbiterModuleApp<TApi> { |
@@ -7,28 +7,7 @@ "use strict"; | ||
} | ||
function loadDependencies(meta, fetchDependency, getDependencies) { | ||
function loadFromContent(meta, content, getDependencies, link) { | ||
const dependencies = Object.assign({}, (getDependencies(meta) || {})); | ||
const existingDependencies = Object.keys(dependencies); | ||
const dependencyMap = Object.keys(meta.dependencies || {}) | ||
.filter(name => existingDependencies.indexOf(name) === -1) | ||
.map(name => ({ | ||
name, | ||
url: meta.dependencies[name], | ||
content: '', | ||
})); | ||
return Promise.all(dependencyMap.map(m => fetchDependency(m.url).then(c => (m.content = c)))).then(() => { | ||
for (const item of dependencyMap) { | ||
dependencies[item.name] = dependency_1.evalDependency(item.name, item.content, item.url, dependencies); | ||
} | ||
return dependencies; | ||
}); | ||
const app = dependency_1.compileDependency(meta.name, content, link, dependencies); | ||
return Object.assign({}, app, meta); | ||
} | ||
function loadFromContent(meta, content, fetchDependency, getDependencies, link) { | ||
return loadDependencies(meta, fetchDependency, getDependencies).then(dependencies => { | ||
const app = dependency_1.compileDependency(meta.name, content, link, dependencies); | ||
return Object.assign({}, app, meta); | ||
}, error => { | ||
console.error(`Could not load the dependencies of ${meta.name}.`, error); | ||
return createEmptyModule(meta); | ||
}); | ||
} | ||
/** | ||
@@ -44,8 +23,6 @@ * Loads the given raw module content by resolving its dependencies and | ||
const { link, content } = meta; | ||
if (link) { | ||
return fetchDependency(link).then(content => loadFromContent(meta, content, fetchDependency, getDependencies, link)); | ||
const retrieve = link ? fetchDependency(link) : content ? Promise.resolve(content) : undefined; | ||
if (retrieve) { | ||
return retrieve.then(content => loadFromContent(meta, content, getDependencies, link)); | ||
} | ||
else if (content) { | ||
return loadFromContent(meta, content, fetchDependency, getDependencies); | ||
} | ||
else { | ||
@@ -52,0 +29,0 @@ console.warn('Empty module found!', meta.name); |
{ | ||
"name": "react-arbiter", | ||
"version": "0.7.2", | ||
"version": "0.8.0", | ||
"description": "Recall all your modules to extend your SPA dynamically at runtime.", | ||
@@ -35,7 +35,7 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@types/enzyme": "^3.10.2", | ||
"@types/enzyme": "^3.10.3", | ||
"@types/enzyme-adapter-react-16": "^1.0.5", | ||
"@types/jest": "^24.0.15", | ||
"@types/react": "^16.8.23", | ||
"@types/react-dom": "^16.8.4", | ||
"@types/react-dom": "^16.8.5", | ||
"enzyme": "^3.10.0", | ||
@@ -42,0 +42,0 @@ "enzyme-adapter-react-16": "^1.14.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76838
1070