@talend/react-cmf
Version:
A framework built on top of best react libraries
1,213 lines (1,079 loc) • 506 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["TalendReactCmf"] = factory();
else
root["TalendReactCmf"] = factory();
})(this, () => {
return /******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./src/App.js":
/*!********************!*\
!*** ./src/App.js ***!
\********************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ App)
/* harmony export */ });
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! prop-types */ "prop-types");
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-redux */ "react-redux");
/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_redux__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _RegistryProvider__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./RegistryProvider */ "./src/RegistryProvider.js");
/* harmony import */ var _settings__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./settings */ "./src/settings.js");
/* harmony import */ var _components_ErrorBoundary_ErrorBoundary_component__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./components/ErrorBoundary/ErrorBoundary.component */ "./src/components/ErrorBoundary/ErrorBoundary.component.js");
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ "../../node_modules/react/jsx-runtime.js");
/**
* Internal module, you should not use it directly
* @module react-cmf/lib/App
*/
/**
* The React component that render your app and provide CMF environment.
* @param {object} props { store }
* @return {object} ReactElement
*/
function App(props) {
let content = props.children;
if (props.withSettings) {
content = /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_settings__WEBPACK_IMPORTED_MODULE_3__.WaitForSettings, {
loading: props.loading,
children: content
});
}
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(react_redux__WEBPACK_IMPORTED_MODULE_1__.Provider, {
store: props.store,
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_RegistryProvider__WEBPACK_IMPORTED_MODULE_2__["default"], {
value: props.registry,
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_components_ErrorBoundary_ErrorBoundary_component__WEBPACK_IMPORTED_MODULE_4__["default"], {
fullPage: true,
children: content
})
})
});
}
App.displayName = 'CMFApp';
App.propTypes = {
store: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().object).isRequired,
registry: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().object),
children: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().node),
withSettings: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().bool),
loading: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().func)
};
App.defaultProps = {
loading: () => 'loading'
};
/***/ }),
/***/ "./src/Dispatcher.js":
/*!***************************!*\
!*** ./src/Dispatcher.js ***!
\***************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ Dispatcher: () => (/* binding */ Dispatcher),
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! prop-types */ "prop-types");
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _cmfConnect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cmfConnect */ "./src/cmfConnect.js");
/* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./src/action.js");
/* harmony import */ var _actionCreator__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./actionCreator */ "./src/actionCreator.js");
/* harmony import */ var _RegistryProvider__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./RegistryProvider */ "./src/RegistryProvider.js");
/**
* This module expose Dispatcher component.
* @module react-cmf/lib/Dispatcher
* @see module:react-cmf/lib/action
*/
/**
* This component purpose is to decorate any component and map an user event
* to an action to be dispatched
* @example
function myfunc(event, props, context) {
}
<Dispatcher onClick={myfunc}>
<ChildrenElement />
</Dispatcher>
*/
function Dispatcher(props) {
const registry = (0,react__WEBPACK_IMPORTED_MODULE_1__.useContext)(_RegistryProvider__WEBPACK_IMPORTED_MODULE_5__.RegistryContext);
// console.log('@@@ registry', registry);
/**
* on any even just try to find a onTHEEVENT props.
* If found execute it with the common stuff
* (event, props, context)
* @param {object} event the react event dispatched event
* @param {string} eventName the name of the event
*/
function onEvent(event, eventName) {
if (props.stopPropagation) {
event.stopPropagation();
}
if (props.preventDefault) {
event.preventDefault();
}
if (props[eventName]) {
props.dispatchActionCreator(props[eventName], event, props);
}
}
function checkIfActionInfoExist() {
_action__WEBPACK_IMPORTED_MODULE_3__["default"].getOnProps(props).forEach(name => {
if (typeof props[name] === 'string') {
_actionCreator__WEBPACK_IMPORTED_MODULE_4__["default"].get({
registry
}, props[name]);
}
});
}
checkIfActionInfoExist();
const onProps = _action__WEBPACK_IMPORTED_MODULE_3__["default"].getOnProps(props);
const childrenWithProps = react__WEBPACK_IMPORTED_MODULE_1__.Children.map(props.children, child => {
const newProps = {};
onProps.forEach(name => {
newProps[name] = event => onEvent(event, name);
});
return /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_1__.cloneElement)(child, newProps);
});
return react__WEBPACK_IMPORTED_MODULE_1__.Children.only(childrenWithProps[0]);
}
Dispatcher.propTypes = {
children: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().node).isRequired,
stopPropagation: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().bool),
preventDefault: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().bool),
dispatchActionCreator: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().func)
};
Dispatcher.displayName = 'Dispatcher';
Dispatcher.defaultProps = {
stopPropagation: false,
preventDefault: false
};
const ConnectedDispatcher = (0,_cmfConnect__WEBPACK_IMPORTED_MODULE_2__["default"])({
withDispatchActionCreator: true
})(Dispatcher);
/**
* This component purpose is to decorate any component and map an user event
* to an action to be dispatched
* @example
<Dispatcher onClick="actionCreator:identifier" onDrag="actionCreator:anotherid">
<ChildrenElement />
</Dispatcher>
*/
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ConnectedDispatcher);
/***/ }),
/***/ "./src/Inject.component.js":
/*!*********************************!*\
!*** ./src/Inject.component.js ***!
\*********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! prop-types */ "prop-types");
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _component__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./component */ "./src/component.js");
/* harmony import */ var _useContext__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./useContext */ "./src/useContext.js");
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "../../node_modules/react/jsx-runtime.js");
/**
* The Inject component let you use the registry to render named component
* using the registry. It will not break the app if component is not found
* but it will display an error.
* @module react-cmf/lib/Inject
* @example
import { Inject } from '@talend/react-cmf';
// this is not the best example but it show the concept
function MyComponent(props) {
return (
<Inject component="Action" onClick={props.onClick}>
<Inject component="Icon" icon={props.icon} />
</Inject>
);
}
*/
function NotFoundComponent({
error
}) {
// eslint-disable-next-line no-console
console.error(error);
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("div", {
className: "alert alert-danger",
children: error.message
});
}
NotFoundComponent.propTypes = {
error: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().string).isRequired
};
function Inject({
component,
...props
}) {
const context = (0,_useContext__WEBPACK_IMPORTED_MODULE_2__.useCMFContext)();
try {
const Component = _component__WEBPACK_IMPORTED_MODULE_1__["default"].get(component, context);
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(Component, {
...props
});
} catch (error) {
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(NotFoundComponent, {
error: error
});
}
}
Inject.propTypes = {
component: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().string).isRequired
};
Inject.NotFoundComponent = NotFoundComponent;
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Inject);
/***/ }),
/***/ "./src/RegistryProvider.js":
/*!*********************************!*\
!*** ./src/RegistryProvider.js ***!
\*********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ RegistryContext: () => (/* binding */ RegistryContext),
/* harmony export */ RegistryProvider: () => (/* binding */ RegistryProvider),
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _registry__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./registry */ "./src/registry.js");
/**
* Internal. This is the component which inject the registry as child context.
* It is called by the App component
* @module react-cmf/lib/RegistryProvider
* @see module:react-cmf/lib/App
*/
const RegistryContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(_registry__WEBPACK_IMPORTED_MODULE_1__["default"].getRegistry());
const RegistryProvider = RegistryContext.Provider;
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (RegistryContext.Provider);
/***/ }),
/***/ "./src/action.js":
/*!***********************!*\
!*** ./src/action.js ***!
\***********************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _deprecated__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./deprecated */ "./src/deprecated.js");
/* harmony import */ var _actionCreator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actionCreator */ "./src/actionCreator.js");
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lodash */ "lodash");
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_2__);
/**
* This module is DEPRECATED and will be removed in future version.
* it provide low level api to register and handle action in a CMF App.
* @module react-cmf/lib/action
* @see module:react-cmf/lib/Dispatcher
*/
/**
* get the global actions registered in the settings
* @param {object} context
* @return {object} actions with key === action id
*/
function getActionsById(context) {
const state = context.store.getState();
return (0,lodash__WEBPACK_IMPORTED_MODULE_2__.get)(state, 'cmf.settings.actions', {});
}
/**
* return actions registered for a given content type
* @param {object} context
* @param {String} contentType
* @param {String} category
* @return {Array} actions
*/
function getContentTypeActions(context, contentType, category) {
const state = context.store.getState();
return (0,lodash__WEBPACK_IMPORTED_MODULE_2__.get)(state, `cmf.settings.contentTypes[${contentType}.actions[${category}]`, []);
}
/**
* Return information available about this action
* @param {object} context
* @param {String} id
* @return {object}
*/
function getActionInfo(context, id) {
const action = getActionsById(context)[id];
if (!action) {
throw new Error(`action not found id: ${id}`);
}
return {
...action
};
}
/**
* Return the action object ready to be dispatched
* This is supposed to be used outside of content type
* @param {object} context
* @param {String|Object} action or the action
* @param {object} event event which have trigger this action
* @param {object} data data attached to the action
*/
function getActionObject(context, action, event, data) {
let actionInfo;
if (typeof action === 'string') {
actionInfo = getActionInfo(context, action);
} else {
actionInfo = action;
}
if (actionInfo.actionCreator) {
const actionCreator = _actionCreator__WEBPACK_IMPORTED_MODULE_1__["default"].get(context, actionInfo.actionCreator);
return actionCreator(event, data, {
store: context.store,
getState: context.store.getState,
registry: context.registry,
actionInfo
});
}
return {
...actionInfo.payload,
event,
data,
context
};
}
/**
* return every props name that start with 'on'
* @param {object} props react props
* @return {Array} of string
*/
function getOnProps(props) {
return Object.keys(props).filter(name => ({}).hasOwnProperty.call(props, name) && /^on.+/.test(name));
}
/**
* create a map dispatchable action function expecting event object, props, and context information
* merge this map with non event properties
* @param {Function} dispatch the dispatch function
* @param {object} props props object containing maybe on(event) with string
* or action creator function]
* @return {object} the connected object
* @throws if an action is unknown in configuration, throw
*/
function mapDispatchToProps(dispatch, props) {
const resolvedActions = {};
getOnProps(props).forEach(name => {
resolvedActions[name] = (event, data, context) => {
let action = props[name];
if (typeof action === 'string') {
action = getActionObject(context, action, event, data);
}
dispatch(action);
};
});
return {
...props,
...resolvedActions
};
}
const registerActionCreator = (0,_deprecated__WEBPACK_IMPORTED_MODULE_0__["default"])((id, actionCreator, context) => _actionCreator__WEBPACK_IMPORTED_MODULE_1__["default"].register(id, actionCreator, context), 'stop use cmf.action.registerActionCreator. please use cmf.actionCreator.register');
const getActionCreatorFunction = (0,_deprecated__WEBPACK_IMPORTED_MODULE_0__["default"])((context, id) => _actionCreator__WEBPACK_IMPORTED_MODULE_1__["default"].get(context, id), 'stop use cmf.action.getActionCreatorFunction. please use cmf.actionCreator.get');
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
getActionsById,
getActionCreatorFunction,
getActionInfo,
getActionObject,
getContentTypeActions,
getOnProps,
mapDispatchToProps,
registerActionCreator
});
/***/ }),
/***/ "./src/actionCreator.js":
/*!******************************!*\
!*** ./src/actionCreator.js ***!
\******************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _registry__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./registry */ "./src/registry.js");
/* harmony import */ var _constant__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constant */ "./src/constant.js");
/**
* return a function from the registry
* @param {object} context
* @param {string} id the id of the action creator
* @return {function}
*/
function get(context, id) {
const creator = context.registry[`${_constant__WEBPACK_IMPORTED_MODULE_1__["default"].REGISTRY_ACTION_CREATOR_PREFIX}:${id}`];
if (!creator) {
// console.log('@@ registry', id, Object.keys(context.registry));
throw new Error(`actionCreator not found in the registry: ${id}`);
}
return creator;
}
/**
* register your action creator. The action creator is a function with
* the following arguments:
* - event which trigger this action
* - data attached to the action (could contains anything)
* - context of the current react app (could contains registry, getState, ...)
* @param {String} id
* @param {Function} actionCreator (event, data, context)
*/
function register(id, actionCreator, context) {
if (actionCreator === undefined) {
throw new Error(`CMF: you can't register an undefined value for the following action creator: '${id}'.
You may have an import error in your code. Check the stack trace and your bootstrap config imports.
https://github.com/Talend/ui/tree/master/packages/cmf/src/bootstrap.md`);
}
_registry__WEBPACK_IMPORTED_MODULE_0__["default"].addToRegistry(`${_constant__WEBPACK_IMPORTED_MODULE_1__["default"].REGISTRY_ACTION_CREATOR_PREFIX}:${id}`, actionCreator, context);
}
/**
* This function allow to register an object with some action creators
* @param {object} actionCreators map of action creators
* @param {object} context optional context to get the registry
*/
const registerMany = _registry__WEBPACK_IMPORTED_MODULE_0__["default"].getRegisterMany(register);
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
get,
register,
registerMany
});
/***/ }),
/***/ "./src/actions/collectionsActions.js":
/*!*******************************************!*\
!*** ./src/actions/collectionsActions.js ***!
\*******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ COLLECTION_ADD_OR_REPLACE: () => (/* binding */ COLLECTION_ADD_OR_REPLACE),
/* harmony export */ COLLECTION_MUTATE: () => (/* binding */ COLLECTION_MUTATE),
/* harmony export */ COLLECTION_REMOVE: () => (/* binding */ COLLECTION_REMOVE),
/* harmony export */ addOrReplace: () => (/* binding */ addOrReplace),
/* harmony export */ addOrReplaceCollection: () => (/* binding */ addOrReplaceCollection),
/* harmony export */ mutate: () => (/* binding */ mutate),
/* harmony export */ mutateCollection: () => (/* binding */ mutateCollection),
/* harmony export */ remove: () => (/* binding */ remove),
/* harmony export */ removeCollection: () => (/* binding */ removeCollection)
/* harmony export */ });
/* harmony import */ var _constant__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../constant */ "./src/constant.js");
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash */ "lodash");
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_1__);
/**
* @module react-cmf/lib/actions/collectionsActions
*/
// keep backward compatibility
const {
COLLECTION_ADD_OR_REPLACE,
COLLECTION_REMOVE,
COLLECTION_MUTATE
} = _constant__WEBPACK_IMPORTED_MODULE_0__["default"];
/**
* Add or replace collection data in store
* curried function
* @param {string | Array<string>} collectionId - path to collection
* @param {any} data element that represent business data
*/
const addOrReplace = (0,lodash__WEBPACK_IMPORTED_MODULE_1__.curry)((collectionId, data) => ({
type: _constant__WEBPACK_IMPORTED_MODULE_0__["default"].COLLECTION_ADD_OR_REPLACE,
collectionId,
data
}));
/**
* Remove collection data in store to free space
* @param {string | Array<string>} collectionId - path to collection
*
* @throws if you try to remove non existent collection
*/
function remove(collectionId) {
return {
type: _constant__WEBPACK_IMPORTED_MODULE_0__["default"].COLLECTION_REMOVE,
collectionId
};
}
/**
* mutateCollection let's you apply operations on a given collection
* curried function
* @param {string | Array<string>} collectionId - path to collection
* @param {object} operations operations to be applied on the collection
* {
* add: [],
* update: {},
* delete: []
* }
*/
const mutate = (0,lodash__WEBPACK_IMPORTED_MODULE_1__.curry)((id, operations) => ({
type: _constant__WEBPACK_IMPORTED_MODULE_0__["default"].COLLECTION_MUTATE,
id,
operations
}));
// backward compatibility
const addOrReplaceCollection = addOrReplace;
const mutateCollection = mutate;
const removeCollection = remove;
/***/ }),
/***/ "./src/actions/componentsActions.js":
/*!******************************************!*\
!*** ./src/actions/componentsActions.js ***!
\******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ COMPONENT_ADD_STATE: () => (/* binding */ COMPONENT_ADD_STATE),
/* harmony export */ COMPONENT_MERGE_STATE: () => (/* binding */ COMPONENT_MERGE_STATE),
/* harmony export */ COMPONENT_REMOVE_STATE: () => (/* binding */ COMPONENT_REMOVE_STATE),
/* harmony export */ addComponentState: () => (/* binding */ addComponentState),
/* harmony export */ addState: () => (/* binding */ addState),
/* harmony export */ mergeComponentState: () => (/* binding */ mergeComponentState),
/* harmony export */ mergeState: () => (/* binding */ mergeState),
/* harmony export */ removeComponentState: () => (/* binding */ removeComponentState),
/* harmony export */ removeState: () => (/* binding */ removeState)
/* harmony export */ });
/* harmony import */ var _constant__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../constant */ "./src/constant.js");
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash */ "lodash");
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_1__);
/**
* @module react-cmf/lib/actions/componentsActions
*/
// keep backward compatibility
const {
COMPONENT_ADD_STATE,
COMPONENT_MERGE_STATE,
COMPONENT_REMOVE_STATE
} = _constant__WEBPACK_IMPORTED_MODULE_0__["default"];
/**
* add a new component state with optional initialComponentState to the store
*
* @param {string} componentName : name of the component
* @param {string} key : identifier of state used by this component
* @param {object} initialComponentState : initial state of the component if required
*
* @throw if a component with this componentName associated to this key already exist
*/
function addState(componentName, key, initialComponentState) {
return {
type: _constant__WEBPACK_IMPORTED_MODULE_0__["default"].COMPONENT_ADD_STATE,
componentName,
key,
initialComponentState
};
}
/**
* Merge new component state into actual component state in the store
* curried function
* @param {string} componentName : name of the component
* @param {string} key : identifier of state used by this component
* @param {object} componentState : initial state of the component if required
*
* @throw if no componentName associated with this collectionId exist
*/
const mergeState = (0,lodash__WEBPACK_IMPORTED_MODULE_1__.curry)((componentName, key, componentState) => ({
type: _constant__WEBPACK_IMPORTED_MODULE_0__["default"].COMPONENT_MERGE_STATE,
componentName,
key,
componentState
}));
/**
* Remove component state from the store
* curried function
* @param {string} componentName : name of the component
* @param {string} key : identifier of collection used by the component
*
* @throw if no componentName associated with this collectionId exist
*/
const removeState = (0,lodash__WEBPACK_IMPORTED_MODULE_1__.curry)((componentName, key) => ({
type: _constant__WEBPACK_IMPORTED_MODULE_0__["default"].COMPONENT_REMOVE_STATE,
componentName,
key
}));
// backward compatbility
const addComponentState = addState;
const removeComponentState = removeState;
const mergeComponentState = mergeState;
/***/ }),
/***/ "./src/actions/http.js":
/*!*****************************!*\
!*** ./src/actions/http.js ***!
\*****************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ DEFAULT_HTTP_HEADERS: () => (/* binding */ DEFAULT_HTTP_HEADERS),
/* harmony export */ "default": () => (/* binding */ http)
/* harmony export */ });
/* harmony import */ var _middlewares_http_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../middlewares/http/constants */ "./src/middlewares/http/constants.js");
const DEFAULT_HTTP_HEADERS = {
Accept: 'application/json',
'Content-Type': 'application/json'
};
function onError(error) {
return {
type: _middlewares_http_constants__WEBPACK_IMPORTED_MODULE_0__.ACTION_TYPE_HTTP_ERRORS,
error
};
}
function onRequest(url, config) {
return {
type: _middlewares_http_constants__WEBPACK_IMPORTED_MODULE_0__.ACTION_TYPE_HTTP_REQUEST,
url,
config
};
}
function onJSError(error, action) {
console.error(error); // eslint-disable-line no-console
return {
type: _middlewares_http_constants__WEBPACK_IMPORTED_MODULE_0__.ACTION_TYPE_HTTP_REDUCER_ERROR,
error,
action
};
}
function onResponse(response) {
return {
type: _middlewares_http_constants__WEBPACK_IMPORTED_MODULE_0__.ACTION_TYPE_HTTP_RESPONSE,
data: response
};
}
function onActionResponse(action, response, headers) {
if (typeof action.onResponse === 'function') {
return action.onResponse(response, headers);
}
return {
type: action.onResponse,
response,
headers
};
}
function onActionError(action, error) {
if (typeof action.onError === 'function') {
return action.onError(error);
}
return {
type: action.onError,
error
};
}
function http(config) {
const {
method,
url,
data,
...rest
} = config;
return {
type: _middlewares_http_constants__WEBPACK_IMPORTED_MODULE_0__.HTTP_METHODS[method],
body: data,
url,
...rest
};
}
http.get = function get(url, config) {
return http({
method: _middlewares_http_constants__WEBPACK_IMPORTED_MODULE_0__.HTTP_METHODS.GET,
url,
...config
});
};
http.post = function post(url, data, config) {
return http({
method: _middlewares_http_constants__WEBPACK_IMPORTED_MODULE_0__.HTTP_METHODS.POST,
body: data,
url,
...config
});
};
http.delete = function httpDelete(url, config) {
return http({
method: _middlewares_http_constants__WEBPACK_IMPORTED_MODULE_0__.HTTP_METHODS.DELETE,
url,
...config
});
};
http.patch = function patch(url, data, config) {
return http({
method: _middlewares_http_constants__WEBPACK_IMPORTED_MODULE_0__.HTTP_METHODS.PATCH,
body: data,
url,
...config
});
};
http.put = function put(url, data, config) {
return http({
method: _middlewares_http_constants__WEBPACK_IMPORTED_MODULE_0__.HTTP_METHODS.PUT,
url,
body: data,
...config
});
};
http.head = function head(url, config) {
return http({
method: _middlewares_http_constants__WEBPACK_IMPORTED_MODULE_0__.HTTP_METHODS.HEAD,
url,
...config
});
};
http.onError = onError;
http.onActionError = onActionError;
http.onJSError = onJSError;
http.onRequest = onRequest;
http.onResponse = onResponse;
http.onActionResponse = onActionResponse;
/***/ }),
/***/ "./src/actions/index.js":
/*!******************************!*\
!*** ./src/actions/index.js ***!
\******************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _collectionsActions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collectionsActions */ "./src/actions/collectionsActions.js");
/* harmony import */ var _componentsActions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./componentsActions */ "./src/actions/componentsActions.js");
/* harmony import */ var _settingsActions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./settingsActions */ "./src/actions/settingsActions.js");
/* harmony import */ var _saga__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./saga */ "./src/actions/saga.js");
/* harmony import */ var _http__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./http */ "./src/actions/http.js");
/**
* @module react-cmf/lib/actions
* @see module:react-cmf/lib/actions/collectionsActions
* @see module:react-cmf/lib/actions/componentsActions
* @see module:react-cmf/lib/actions/settingsActions
*/
/**
* exported API
* @example
import {
collectionsActions,
componentsActions,
settingsActions
} from 'react-cmf/lib/actions';
* @type {Object}
*/
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
collectionsActions: _collectionsActions__WEBPACK_IMPORTED_MODULE_0__,
componentsActions: _componentsActions__WEBPACK_IMPORTED_MODULE_1__,
settingsActions: _settingsActions__WEBPACK_IMPORTED_MODULE_2__,
http: _http__WEBPACK_IMPORTED_MODULE_4__["default"],
collections: _collectionsActions__WEBPACK_IMPORTED_MODULE_0__,
components: _componentsActions__WEBPACK_IMPORTED_MODULE_1__,
settings: _settingsActions__WEBPACK_IMPORTED_MODULE_2__,
saga: _saga__WEBPACK_IMPORTED_MODULE_3__
});
/***/ }),
/***/ "./src/actions/saga.js":
/*!*****************************!*\
!*** ./src/actions/saga.js ***!
\*****************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ start: () => (/* binding */ start),
/* harmony export */ stop: () => (/* binding */ stop)
/* harmony export */ });
/* harmony import */ var _constant__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../constant */ "./src/constant.js");
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash */ "lodash");
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_1__);
const propsToOmit = ['children', 'getComponent'].concat(_constant__WEBPACK_IMPORTED_MODULE_0__["default"].INJECTED_PROPS, _constant__WEBPACK_IMPORTED_MODULE_0__["default"].CMF_PROPS);
function start(event = {}, data) {
return {
type: _constant__WEBPACK_IMPORTED_MODULE_0__["default"].DID_MOUNT_SAGA_START,
saga: data.saga,
componentId: data.componentId,
props: (0,lodash__WEBPACK_IMPORTED_MODULE_1__.omit)(data, propsToOmit),
// deprecated
event
};
}
function stop(event, data) {
return {
type: `${_constant__WEBPACK_IMPORTED_MODULE_0__["default"].WILL_UNMOUNT_SAGA_STOP}_${data.saga}`,
event
};
}
/***/ }),
/***/ "./src/actions/settingsActions.js":
/*!****************************************!*\
!*** ./src/actions/settingsActions.js ***!
\****************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ REQUEST_KO: () => (/* binding */ REQUEST_KO),
/* harmony export */ REQUEST_OK: () => (/* binding */ REQUEST_OK),
/* harmony export */ REQUEST_SETTINGS: () => (/* binding */ REQUEST_SETTINGS),
/* harmony export */ errorWithSettings: () => (/* binding */ errorWithSettings),
/* harmony export */ fetchSettings: () => (/* binding */ fetchSettings),
/* harmony export */ receiveSettings: () => (/* binding */ receiveSettings),
/* harmony export */ requestSettings: () => (/* binding */ requestSettings)
/* harmony export */ });
/* harmony import */ var _http__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./http */ "./src/actions/http.js");
/* harmony import */ var _constant__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../constant */ "./src/constant.js");
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lodash */ "lodash");
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_2__);
/**
* @module react-cmf/lib/actions/settingsActions
*/
// keep backward compatibility
const {
REQUEST_OK,
REQUEST_KO,
REQUEST_SETTINGS
} = _constant__WEBPACK_IMPORTED_MODULE_1__["default"];
function requestSettings() {
return {
type: _constant__WEBPACK_IMPORTED_MODULE_1__["default"].REQUEST_SETTINGS
};
}
function receiveSettings(json) {
return {
type: _constant__WEBPACK_IMPORTED_MODULE_1__["default"].REQUEST_OK,
settings: json,
receivedAt: Date.now()
};
}
function errorWithSettings(error) {
return {
type: _constant__WEBPACK_IMPORTED_MODULE_1__["default"].REQUEST_KO,
error: {
message: (0,lodash__WEBPACK_IMPORTED_MODULE_2__.get)(error, 'message'),
stack: (0,lodash__WEBPACK_IMPORTED_MODULE_2__.get)(error, 'stack')
}
};
}
/**
* get the settings on the server and dispatch the corresponding actions
* this should be executed during the bootstrap of the App.
* @param path Path of the settings.json file to fetch. Default 'settings.json'
* @return {function} with the fetch process results
*/
function fetchSettings(path = 'settings.json') {
return _http__WEBPACK_IMPORTED_MODULE_0__["default"].get(path, {
onResponse: response => receiveSettings(response),
onError: error => errorWithSettings(error)
});
}
/***/ }),
/***/ "./src/assert.js":
/*!***********************!*\
!*** ./src/assert.js ***!
\***********************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ assertTypeOf: () => (/* binding */ assertTypeOf),
/* harmony export */ assertValueTypeOf: () => (/* binding */ assertValueTypeOf)
/* harmony export */ });
function assertValueTypeOf(value, type, toThrow = true) {
if (value === undefined) {
return true;
}
if (type === 'Array' && Array.isArray(value)) {
return true;
}
let isTypeCorrect;
if (Array.isArray(type)) {
isTypeCorrect = type.some(currentType => assertValueTypeOf(value, currentType, false));
} else {
// eslint-disable-next-line valid-typeof
isTypeCorrect = typeof value === type && !Array.isArray(value);
}
if (toThrow && isTypeCorrect === false) {
throw new Error(`${value} must be a ${type} but got ${typeof value}`);
}
return isTypeCorrect;
}
function assertTypeOf(options, attr, type) {
const isTypeCorrect = assertValueTypeOf(options[attr], type, false);
if (isTypeCorrect === false) {
throw new Error(`${attr} must be a ${type} but got ${typeof options[attr]}`);
}
return isTypeCorrect;
}
/***/ }),
/***/ "./src/bootstrap.js":
/*!**************************!*\
!*** ./src/bootstrap.js ***!
\**************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ bactchedSubscribe: () => (/* binding */ bactchedSubscribe),
/* harmony export */ bootstrapRedux: () => (/* binding */ bootstrapRedux),
/* harmony export */ bootstrapRegistry: () => (/* binding */ bootstrapRegistry),
/* harmony export */ bootstrapSaga: () => (/* binding */ bootstrapSaga),
/* harmony export */ "default": () => (/* binding */ bootstrap)
/* harmony export */ });
/* harmony import */ var react_dom_client__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react-dom/client */ "../../node_modules/react-dom/client.js");
/* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! redux */ "redux");
/* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(redux__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var redux_batched_subscribe__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! redux-batched-subscribe */ "../../node_modules/redux-batched-subscribe/lib/index.js");
/* harmony import */ var redux_saga__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! redux-saga */ "redux-saga");
/* harmony import */ var redux_saga__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(redux_saga__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var redux_saga_effects__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! redux-saga/effects */ "redux-saga/effects");
/* harmony import */ var redux_saga_effects__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(redux_saga_effects__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _actionCreator__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./actionCreator */ "./src/actionCreator.js");
/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./actions */ "./src/actions/index.js");
/* harmony import */ var _App__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./App */ "./src/App.js");
/* harmony import */ var _assert__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./assert */ "./src/assert.js");
/* harmony import */ var _cmfModule__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./cmfModule */ "./src/cmfModule.js");
/* harmony import */ var _component__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./component */ "./src/component.js");
/* harmony import */ var _components_Saga__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./components/Saga */ "./src/components/Saga/index.js");
/* harmony import */ var _expression__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./expression */ "./src/expression.js");
/* harmony import */ var _httpInterceptors__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./httpInterceptors */ "./src/httpInterceptors.js");
/* harmony import */ var _onError__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./onError */ "./src/onError.js");
/* harmony import */ var _register__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./register */ "./src/register.js");
/* harmony import */ var _registry__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./registry */ "./src/registry.js");
/* harmony import */ var _sagas__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./sagas */ "./src/sagas/index.js");
/* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./store */ "./src/store.js");
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! react/jsx-runtime */ "../../node_modules/react/jsx-runtime.js");
const bactchedSubscribe = (0,redux_batched_subscribe__WEBPACK_IMPORTED_MODULE_2__.batchedSubscribe)(notify => {
requestAnimationFrame(notify);
});
function bootstrapRegistry(options) {
(0,_assert__WEBPACK_IMPORTED_MODULE_8__.assertTypeOf)(options, 'sagas', 'object');
(0,_assert__WEBPACK_IMPORTED_MODULE_8__.assertTypeOf)(options, 'components', 'object');
(0,_assert__WEBPACK_IMPORTED_MODULE_8__.assertTypeOf)(options, 'expressions', 'object');
(0,_assert__WEBPACK_IMPORTED_MODULE_8__.assertTypeOf)(options, 'actionCreators', 'object');
(0,_assert__WEBPACK_IMPORTED_MODULE_8__.assertTypeOf)(options, 'registry', 'object');
(0,_register__WEBPACK_IMPORTED_MODULE_15__.registerInternals)();
if (options.registry) {
_registry__WEBPACK_IMPORTED_MODULE_16__["default"].registerMany(options.registry);
}
if (options.components) {
_component__WEBPACK_IMPORTED_MODULE_10__["default"].registerMany(options.components);
}
if (options.expressions) {
_expression__WEBPACK_IMPORTED_MODULE_12__["default"].registerMany(options.expressions);
}
if (options.actionCreators) {
_actionCreator__WEBPACK_IMPORTED_MODULE_5__["default"].registerMany(options.actionCreators);
}
if (options.sagas) {
_sagas__WEBPACK_IMPORTED_MODULE_17__["default"].registerMany(options.sagas);
}
}
function bootstrapSaga(options) {
(0,_assert__WEBPACK_IMPORTED_MODULE_8__.assertTypeOf)(options, 'saga', 'function');
function* cmfSaga() {
yield (0,redux_saga_effects__WEBPACK_IMPORTED_MODULE_4__.spawn)(_components_Saga__WEBPACK_IMPORTED_MODULE_11__.handleSagaComponent);
yield (0,redux_saga_effects__WEBPACK_IMPORTED_MODULE_4__.spawn)(_sagas__WEBPACK_IMPORTED_MODULE_17__["default"].component.handle);
if (typeof options.saga === 'function') {
yield (0,redux_saga_effects__WEBPACK_IMPORTED_MODULE_4__.spawn)(options.saga);
}
}
// https://chrome.google.com/webstore/detail/redux-saga-dev-tools/kclmpmjofefcpjlommdpokoccidafnbi
// eslint-disable-next-line no-underscore-dangle
const sagaMonitor = window.__SAGA_MONITOR_EXTENSION__;
const middleware = redux_saga__WEBPACK_IMPORTED_MODULE_3___default()({
onError: _onError__WEBPACK_IMPORTED_MODULE_14__["default"].report,
sagaMonitor
});
return {
middleware,
run: () => middleware.run(cmfSaga)
};
}
function bootstrapRedux(options, sagaMiddleware) {
(0,_assert__WEBPACK_IMPORTED_MODULE_8__.assertTypeOf)(options, 'settingsURL', 'string');
(0,_assert__WEBPACK_IMPORTED_MODULE_8__.assertTypeOf)(options, 'preReducer', ['Array', 'function']);
(0,_assert__WEBPACK_IMPORTED_MODULE_8__.assertTypeOf)(options, 'httpMiddleware', 'function');
(0,_assert__WEBPACK_IMPORTED_MODULE_8__.assertTypeOf)(options, 'enhancer', 'function');
(0,_assert__WEBPACK_IMPORTED_MODULE_8__.assertTypeOf)(options, 'preloadedState', 'object');
(0,_assert__WEBPACK_IMPORTED_MODULE_8__.assertTypeOf)(options, 'middlewares', 'Array');
(0,_assert__WEBPACK_IMPORTED_MODULE_8__.assertTypeOf)(options, 'storeCallback', 'function');
(0,_assert__WEBPACK_IMPORTED_MODULE_8__.assertTypeOf)(options, 'reducer', 'object');
if (options.preReducer) {
_store__WEBPACK_IMPORTED_MODULE_18__["default"].addPreReducer(options.preReducer);
}
if (typeof options.httpMiddleware === 'function') {
_store__WEBPACK_IMPORTED_MODULE_18__["default"].setHttpMiddleware(options.httpMiddleware);
}
let enhancer = bactchedSubscribe;
if (typeof options.enhancer === 'function') {
enhancer = (0,redux__WEBPACK_IMPORTED_MODULE_1__.compose)(options.enhancer, bactchedSubscribe);
}
const middlewares = options.middlewares || [];
const store = _store__WEBPACK_IMPORTED_MODULE_18__["default"].initialize(options.reducer, options.preloadedState, enhancer, [...middlewares, sagaMiddleware]);
if (options.settingsURL) {
store.dispatch(_actions__WEBPACK_IMPORTED_MODULE_6__["default"].settings.fetchSettings(options.settingsURL));
}
if (typeof options.storeCallback === 'function') {
options.storeCallback(store);
}
return store;
}
function bootstrapInterceptors(options) {
if (options.httpInterceptors) {
options.httpInterceptors.forEach(_httpInterceptors__WEBPACK_IMPORTED_MODULE_13__["default"].push);
}
}
function DefaultRootComponent() {
return 'RootComponent is required';
}
/**
* Bootstrap your cmf app
* It takes your configuration and provides a very good default one.
* By default it starts react with the following addons:
* - redux
* - redux-saga
* @param {object} options the set of supported options
* @returns {object} app object with render function
*/
async function bootstrap(appOptions = {}) {
// setup asap
const options = await (0,_cmfModule__WEBPACK_IMPORTED_MODULE_9__["default"])(appOptions);
(0,_assert__WEBPACK_IMPORTED_MODULE_8__.assertTypeOf)(options, 'root', 'object');
(0,_assert__WEBPACK_IMPORTED_MODULE_8__.assertTypeOf)(options, 'appId', 'string');
(0,_assert__WEBPACK_IMPORTED_MODULE_8__.assertTypeOf)(options, 'RootComponent', 'function');
bootstrapRegistry(options);
bootstrapInterceptors(options);
const appId = options.appId || 'app';
const saga = bootstrapSaga(options);
const store = bootstrapRedux(options, saga.middleware);
_onError__WEBPACK_IMPORTED_MODULE_14__["default"].bootstrap(options, store);
const RootComponent = options.RootComponent || DefaultRootComponent;
const element = options.root || document.getElementById(appId);
const config = {
store,
saga,
App: _App__WEBPACK_IMPORTED_MODULE_7__["default"],
cmfModule: options
};
if (options.render !== false) {
saga.run();
const root = react_dom_client__WEBPACK_IMPORTED_MODULE_0__.createRoot(element);
root.render(/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_19__.jsx)(_App__WEBPACK_IMPORTED_MODULE_7__["default"], {
store: store,
loading: options.AppLoader,
withSettings: !!options.settingsURL,
registry: _registry__WEBPACK_IMPORTED_MODULE_16__["default"].getRegistry(),
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_19__.jsx)(RootComponent, {})
}));
}
return config;
}
/***/ }),
/***/ "./src/cmfConnect.js":
/*!***************************!*\
!*** ./src/cmfConnect.js ***!
\***************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ cmfConnect),
/* harmony export */ getComponentId: () => (/* binding */ getComponentId),
/* harmony export */ getComponentName: () => (/* binding */ getComponentName),
/* harmony export */ getDispatchToProps: () => (/* binding */ getDispatchToProps),
/* harmony export */ getMergeProps: () => (/* binding */ getMergeProps),
/* harmony export */ getStateToProps: () => (/* binding */ getStateToProps)
/* harmony export */ });
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! prop-types */ "prop-types");
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! hoist-non-react-statics */ "hoist-non-react-statics");
/* harmony import */ var hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var react_immutable_proptypes__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-immutable-proptypes */ "../../node_modules/react-immutable-proptypes/dist/ImmutablePropTypes.js");
/* harmony import */ var react_immutable_proptypes__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_immutable_proptypes__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-redux */ "react-redux");
/* harmony import */ var react_redux__WEBPACK_IMPORTE