react-arbiter
Advanced tools
Comparing version 0.5.0 to 0.6.0
# React Arbiter Changelog | ||
## 0.6.0 | ||
- Changed `setupModules` to `createModules` | ||
- Updated dependencies | ||
## 0.5.0 | ||
@@ -4,0 +9,0 @@ |
@@ -22,3 +22,3 @@ "use strict"; | ||
loaded: true, | ||
modules: utils_1.setupModules(createApi, [...oldModules, ...newModules]), | ||
modules: utils_1.createModules(createApi, [...oldModules, ...newModules]), | ||
}); | ||
@@ -25,0 +25,0 @@ } |
@@ -146,3 +146,3 @@ import { ComponentType, Ref } from 'react'; | ||
* Optionally, some already existing evaluated modules, e.g., | ||
* helpful when debugging. | ||
* helpful when debugging or in SSR scenarios. | ||
*/ | ||
@@ -165,3 +165,3 @@ modules?: Array<ArbiterModule<TApi>>; | ||
/** | ||
* Optionally uses the defined cache. For a default implementation | ||
* Optionally uses a defined cache. For a default implementation | ||
* use the `openCache` method, which is based on IndexDB. | ||
@@ -168,0 +168,0 @@ */ |
@@ -14,5 +14,12 @@ import { defaultFetchDependency } from './fetch'; | ||
* @param createApi The function to create an API object for a module. | ||
* @param modules The available evaluated modules. | ||
* @param modules The available evaluated app modules. | ||
* @returns The integrated modules. | ||
*/ | ||
export declare function setupModules<TApi>(createApi: ApiCreator<TApi>, modules: Array<ArbiterModule<TApi>>): ArbiterModule<TApi>[]; | ||
export declare function createModules<TApi>(createApi: ApiCreator<TApi>, modules: Array<ArbiterModule<TApi>>): ArbiterModule<TApi>[]; | ||
/** | ||
* Sets up an evaluated module to become an integrated module. | ||
* @param createApi The function to create an API object for the module. | ||
* @param app The available evaluated app module. | ||
* @returns The integrated module. | ||
*/ | ||
export declare function createModule<TApi>(createApi: ApiCreator<TApi>, app: ArbiterModule<TApi>): ArbiterModule<TApi>; |
@@ -17,2 +17,16 @@ "use strict"; | ||
}; | ||
function checkCreateApi(createApi) { | ||
if (!isfunc_1.isfunc(createApi)) { | ||
console.warn('Invalid `createApi` function. Skipping module installation.'); | ||
return false; | ||
} | ||
return true; | ||
} | ||
function checkFetchModules(fetchModules) { | ||
if (!isfunc_1.isfunc(fetchModules)) { | ||
console.error('Could not get the modules. Provide a valid `getModules` function as prop.'); | ||
return false; | ||
} | ||
return true; | ||
} | ||
/** | ||
@@ -26,3 +40,3 @@ * Loads the modules by first getting them, then evaluating the raw content. | ||
function loadModules(fetchModules, fetchDependency = fetch_1.defaultFetchDependency, globalDependencies = defaultGlobalDependencies, getLocalDependencies = defaultGetDependencies, cache = defaultCache) { | ||
if (isfunc_1.isfunc(fetchModules)) { | ||
if (checkFetchModules(fetchModules)) { | ||
const getDependencies = target => { | ||
@@ -35,6 +49,3 @@ return getLocalDependencies(target) || globalDependencies; | ||
} | ||
else { | ||
console.error('Could not get the modules. Provide a valid `getModules` function as prop.'); | ||
return Promise.resolve([]); | ||
} | ||
return Promise.resolve([]); | ||
} | ||
@@ -45,7 +56,7 @@ exports.loadModules = loadModules; | ||
* @param createApi The function to create an API object for a module. | ||
* @param modules The available evaluated modules. | ||
* @param modules The available evaluated app modules. | ||
* @returns The integrated modules. | ||
*/ | ||
function setupModules(createApi, modules) { | ||
if (isfunc_1.isfunc(createApi)) { | ||
function createModules(createApi, modules) { | ||
if (checkCreateApi(createApi)) { | ||
for (const app of modules) { | ||
@@ -56,7 +67,18 @@ const api = createApi(app); | ||
} | ||
else { | ||
console.warn('Invalid `createApi` function. Skipping module installation.'); | ||
} | ||
return modules; | ||
} | ||
exports.setupModules = setupModules; | ||
exports.createModules = createModules; | ||
/** | ||
* Sets up an evaluated module to become an integrated module. | ||
* @param createApi The function to create an API object for the module. | ||
* @param app The available evaluated app module. | ||
* @returns The integrated module. | ||
*/ | ||
function createModule(createApi, app) { | ||
if (checkCreateApi(createApi)) { | ||
const api = createApi(app); | ||
setup_1.setupModule(app, api); | ||
} | ||
return app; | ||
} | ||
exports.createModule = createModule; |
@@ -8,5 +8,4 @@ import * as React from 'react'; | ||
* @param options The options to consider. | ||
* @param contextTypes The available context types for non-React components. | ||
* @returns A React component wrapping the value. | ||
*/ | ||
export declare function wrapComponent<T, U>(value: ComponentDefinition<T & U>, options?: WrapComponentOptions<U>): React.ComponentType<T>; |
@@ -7,4 +7,6 @@ "use strict"; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) | ||
t[p[i]] = s[p[i]]; | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
@@ -54,3 +56,2 @@ }; | ||
* @param options The options to consider. | ||
* @param contextTypes The available context types for non-React components. | ||
* @returns A React component wrapping the value. | ||
@@ -57,0 +58,0 @@ */ |
@@ -7,4 +7,6 @@ "use strict"; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) | ||
t[p[i]] = s[p[i]]; | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
@@ -11,0 +13,0 @@ }; |
{ | ||
"name": "react-arbiter", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Recall all your modules to extend your SPA dynamically at runtime.", | ||
@@ -34,20 +34,20 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@types/enzyme": "^3.1.17", | ||
"@types/enzyme": "^3.9.3", | ||
"@types/enzyme-adapter-react-16": "^1.0.5", | ||
"@types/jest": "^24.0.3", | ||
"@types/react": "^16.8.2", | ||
"@types/react-dom": "^16.8.0", | ||
"enzyme": "^3.9.0", | ||
"enzyme-adapter-react-16": "^1.9.1", | ||
"@types/jest": "^24.0.13", | ||
"@types/react": "^16.8.19", | ||
"@types/react-dom": "^16.8.4", | ||
"enzyme": "^3.10.0", | ||
"enzyme-adapter-react-16": "^1.14.0", | ||
"enzyme-to-json": "^3.3.5", | ||
"jest": "^24.1.0", | ||
"jest-cli": "^24.1.0", | ||
"prettier": "^1.16.4", | ||
"react": "^16.8.1", | ||
"react-dom": "^16.8.1", | ||
"ts-jest": "^24.0.0", | ||
"tslint": "^5.12.1", | ||
"jest": "^24.8.0", | ||
"jest-cli": "^24.8.0", | ||
"prettier": "^1.17.1", | ||
"react": "^16.8.6", | ||
"react-dom": "^16.8.6", | ||
"ts-jest": "^24.0.2", | ||
"tslint": "^5.17.0", | ||
"tslint-config-prettier": "^1.18.0", | ||
"tslint-plugin-prettier": "^2.0.1", | ||
"typescript": "^3.3.3" | ||
"typescript": "^3.5.1" | ||
}, | ||
@@ -54,0 +54,0 @@ "peerDependencies": { |
75048
1038