@common-stack/client-react 0.1.23 → 0.1.24
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/lib/__tests__/fill-register-test.d.ts +1 -0
- package/lib/__tests__/fill-register-test.js +66 -0
- package/lib/__tests__/fill-register-test.js.map +1 -0
- package/lib/__tests__/helpers/sample-menu.d.ts +79 -0
- package/lib/__tests__/helpers/sample-menu.js +78 -0
- package/lib/__tests__/helpers/sample-menu.js.map +1 -0
- package/lib/__tests__/integrated-routes.test.d.ts +1 -0
- package/lib/__tests__/integrated-routes.test.js +83 -0
- package/lib/__tests__/integrated-routes.test.js.map +1 -0
- package/lib/__tests__/render-routes.test.d.ts +3 -0
- package/lib/__tests__/render-routes.test.js +89 -0
- package/lib/__tests__/render-routes.test.js.map +1 -0
- package/lib/connector/base-connector.d.ts +52 -0
- package/lib/connector/base-connector.js +148 -0
- package/lib/connector/base-connector.js.map +1 -0
- package/lib/connector/connector.d.ts +7 -43
- package/lib/connector/connector.js +15 -0
- package/lib/connector/connector.js.map +1 -0
- package/lib/connector/connector.native.d.ts +7 -0
- package/lib/connector/connector.native.js +14 -0
- package/lib/connector/connector.native.js.map +1 -0
- package/lib/connector/connector.test.d.ts +1 -0
- package/lib/connector/connector.test.js +32 -0
- package/lib/connector/connector.test.js.map +1 -0
- package/lib/connector/index.js +14 -0
- package/lib/connector/index.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +9 -1722
- package/lib/index.js.map +1 -1
- package/lib/index.native.d.ts +9 -0
- package/lib/index.native.js +24 -0
- package/lib/index.native.js.map +1 -0
- package/lib/interfaces/extended-feature.js +3 -0
- package/lib/interfaces/extended-feature.js.map +1 -0
- package/lib/interfaces/index.js +17 -0
- package/lib/interfaces/index.js.map +1 -0
- package/lib/interfaces/menu.js +12 -0
- package/lib/interfaces/menu.js.map +1 -0
- package/lib/interfaces/new-router.d.ts +18 -1
- package/lib/interfaces/new-router.js +3 -0
- package/lib/interfaces/new-router.js.map +1 -0
- package/lib/interfaces/router.js +3 -0
- package/lib/interfaces/router.js.map +1 -0
- package/lib/inversify/InversifyContext.js +37 -0
- package/lib/inversify/InversifyContext.js.map +1 -0
- package/lib/inversify/index.js +14 -0
- package/lib/inversify/index.js.map +1 -0
- package/lib/plugin-area/__tests__/higher-order-component-util.test.d.ts +1 -0
- package/lib/plugin-area/__tests__/higher-order-component-util.test.js +60 -0
- package/lib/plugin-area/__tests__/higher-order-component-util.test.js.map +1 -0
- package/lib/plugin-area/__tests__/plugin-api.test.d.ts +1 -0
- package/lib/plugin-area/__tests__/plugin-api.test.js +54 -0
- package/lib/plugin-area/__tests__/plugin-api.test.js.map +1 -0
- package/lib/plugin-area/{plugin-area.d.ts → base-plugin-area.d.ts} +1 -1
- package/lib/plugin-area/base-plugin-area.js +68 -0
- package/lib/plugin-area/base-plugin-area.js.map +1 -0
- package/lib/plugin-area/higher-order-component-util.js +23 -0
- package/lib/plugin-area/higher-order-component-util.js.map +1 -0
- package/lib/plugin-area/index.d.ts +2 -2
- package/lib/plugin-area/index.js +34 -0
- package/lib/plugin-area/index.js.map +1 -0
- package/lib/plugin-area/index.native.d.ts +2 -0
- package/lib/plugin-area/index.native.js +31 -0
- package/lib/plugin-area/index.native.js.map +1 -0
- package/lib/plugin-area/plugin-api.js +79 -0
- package/lib/plugin-area/plugin-api.js.map +1 -0
- package/lib/plugin-area/plugin-context.js +44 -0
- package/lib/plugin-area/plugin-context.js.map +1 -0
- package/lib/route/__tests__/admin-new-routes.test.d.ts +1 -0
- package/lib/route/__tests__/admin-new-routes.test.js +175 -0
- package/lib/route/__tests__/admin-new-routes.test.js.map +1 -0
- package/lib/route/__tests__/config-routes.test.d.ts +0 -0
- package/lib/route/__tests__/config-routes.test.js +326 -0
- package/lib/route/__tests__/config-routes.test.js.map +1 -0
- package/lib/route/__tests__/getFlatMenus.test.d.ts +1 -0
- package/lib/route/__tests__/getFlatMenus.test.js +96 -0
- package/lib/route/__tests__/getFlatMenus.test.js.map +1 -0
- package/lib/route/__tests__/render-routes-config.test.d.ts +2 -0
- package/lib/route/__tests__/render-routes-config.test.js +69 -0
- package/lib/route/__tests__/render-routes-config.test.js.map +1 -0
- package/lib/route/__tests__/route-type.test.d.ts +1 -0
- package/lib/route/__tests__/route-type.test.js +9 -0
- package/lib/route/__tests__/route-type.test.js.map +1 -0
- package/lib/route/get-routes.d.ts +3 -0
- package/lib/route/get-routes.js +86 -0
- package/lib/route/get-routes.js.map +1 -0
- package/lib/route/get-routes.test.d.ts +1 -0
- package/lib/route/get-routes.test.js +170 -0
- package/lib/route/get-routes.test.js.map +1 -0
- package/lib/route/index.js +14 -0
- package/lib/route/index.js.map +1 -0
- package/lib/route/index.native.d.ts +1 -0
- package/lib/route/index.native.js +14 -0
- package/lib/route/index.native.js.map +1 -0
- package/lib/route/old/__tests__/config-sidebar-menu.test.d.ts +1 -0
- package/lib/route/old/__tests__/config-sidebar-menu.test.js +198 -0
- package/lib/route/old/__tests__/config-sidebar-menu.test.js.map +1 -0
- package/lib/route/old/get-menus.d.ts +2 -0
- package/lib/route/old/get-menus.js +63 -0
- package/lib/route/old/get-menus.js.map +1 -0
- package/lib/route/old/get-routes-notused.d.ts +11 -0
- package/lib/route/old/get-routes-notused.js +61 -0
- package/lib/route/old/get-routes-notused.js.map +1 -0
- package/lib/route/old/render.d.ts +2 -0
- package/lib/route/old/render.js +30 -0
- package/lib/route/old/render.js.map +1 -0
- package/lib/route/render-routes-test.d.ts +1 -0
- package/lib/route/render-routes-test.js +40 -0
- package/lib/route/render-routes-test.js.map +1 -0
- package/lib/route/render-routes.d.ts +2 -14
- package/lib/route/render-routes.js +164 -0
- package/lib/route/render-routes.js.map +1 -0
- package/lib/route/render-routes.native.d.ts +4 -0
- package/lib/route/render-routes.native.js +158 -0
- package/lib/route/render-routes.native.js.map +1 -0
- package/lib/route-based-plugin-area/__tests__/higher-order-component-util.test.d.ts +1 -0
- package/lib/route-based-plugin-area/__tests__/higher-order-component-util.test.js +60 -0
- package/lib/route-based-plugin-area/__tests__/higher-order-component-util.test.js.map +1 -0
- package/lib/route-based-plugin-area/__tests__/plugin-api.test.d.ts +1 -0
- package/lib/route-based-plugin-area/__tests__/plugin-api.test.js +54 -0
- package/lib/route-based-plugin-area/__tests__/plugin-api.test.js.map +1 -0
- package/lib/route-based-plugin-area/higher-order-component-util.js +23 -0
- package/lib/route-based-plugin-area/higher-order-component-util.js.map +1 -0
- package/lib/route-based-plugin-area/index.js +15 -0
- package/lib/route-based-plugin-area/index.js.map +1 -0
- package/lib/route-based-plugin-area/plugin-api.js +79 -0
- package/lib/route-based-plugin-area/plugin-api.js.map +1 -0
- package/lib/route-based-plugin-area/plugin-context.js +44 -0
- package/lib/route-based-plugin-area/plugin-context.js.map +1 -0
- package/lib/route-based-plugin-area/route-based-plugin-area.js +68 -0
- package/lib/route-based-plugin-area/route-based-plugin-area.js.map +1 -0
- package/lib/{router/router.d.ts → router-factory/index.d.ts} +0 -0
- package/lib/router-factory/index.js +30 -0
- package/lib/router-factory/index.js.map +1 -0
- package/lib/router-factory/index.native.d.ts +2 -0
- package/lib/router-factory/index.native.js +30 -0
- package/lib/router-factory/index.native.js.map +1 -0
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +15 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/sort-keys.d.ts +1 -0
- package/lib/utils/sort-keys.js +73 -0
- package/lib/utils/sort-keys.js.map +1 -0
- package/lib/utils/sort-keys.test.d.ts +1 -0
- package/lib/utils/sort-keys.test.js +30 -0
- package/lib/utils/sort-keys.test.js.map +1 -0
- package/lib/utils/utils.d.ts +4 -0
- package/lib/utils/utils.js +13 -0
- package/lib/utils/utils.js.map +1 -0
- package/package.json +5 -4
- package/lib/plugin-area/browser-plugin-area.d.ts +0 -2
- package/lib/router/index.d.ts +0 -1
- package/lib/utils/route-utils.d.ts +0 -17
package/lib/index.js
CHANGED
|
@@ -1,275 +1,4 @@
|
|
|
1
|
-
module.exports =
|
|
2
|
-
/******/ (function(modules) { // webpackBootstrap
|
|
3
|
-
/******/ // The module cache
|
|
4
|
-
/******/ var installedModules = {};
|
|
5
|
-
/******/
|
|
6
|
-
/******/ // The require function
|
|
7
|
-
/******/ function __webpack_require__(moduleId) {
|
|
8
|
-
/******/
|
|
9
|
-
/******/ // Check if module is in cache
|
|
10
|
-
/******/ if(installedModules[moduleId]) {
|
|
11
|
-
/******/ return installedModules[moduleId].exports;
|
|
12
|
-
/******/ }
|
|
13
|
-
/******/ // Create a new module (and put it into the cache)
|
|
14
|
-
/******/ var module = installedModules[moduleId] = {
|
|
15
|
-
/******/ i: moduleId,
|
|
16
|
-
/******/ l: false,
|
|
17
|
-
/******/ exports: {}
|
|
18
|
-
/******/ };
|
|
19
|
-
/******/
|
|
20
|
-
/******/ // Execute the module function
|
|
21
|
-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
22
|
-
/******/
|
|
23
|
-
/******/ // Flag the module as loaded
|
|
24
|
-
/******/ module.l = true;
|
|
25
|
-
/******/
|
|
26
|
-
/******/ // Return the exports of the module
|
|
27
|
-
/******/ return module.exports;
|
|
28
|
-
/******/ }
|
|
29
|
-
/******/
|
|
30
|
-
/******/
|
|
31
|
-
/******/ // expose the modules object (__webpack_modules__)
|
|
32
|
-
/******/ __webpack_require__.m = modules;
|
|
33
|
-
/******/
|
|
34
|
-
/******/ // expose the module cache
|
|
35
|
-
/******/ __webpack_require__.c = installedModules;
|
|
36
|
-
/******/
|
|
37
|
-
/******/ // define getter function for harmony exports
|
|
38
|
-
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
39
|
-
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
40
|
-
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
41
|
-
/******/ }
|
|
42
|
-
/******/ };
|
|
43
|
-
/******/
|
|
44
|
-
/******/ // define __esModule on exports
|
|
45
|
-
/******/ __webpack_require__.r = function(exports) {
|
|
46
|
-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
47
|
-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
48
|
-
/******/ }
|
|
49
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
50
|
-
/******/ };
|
|
51
|
-
/******/
|
|
52
|
-
/******/ // create a fake namespace object
|
|
53
|
-
/******/ // mode & 1: value is a module id, require it
|
|
54
|
-
/******/ // mode & 2: merge all properties of value into the ns
|
|
55
|
-
/******/ // mode & 4: return value when already ns object
|
|
56
|
-
/******/ // mode & 8|1: behave like require
|
|
57
|
-
/******/ __webpack_require__.t = function(value, mode) {
|
|
58
|
-
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
59
|
-
/******/ if(mode & 8) return value;
|
|
60
|
-
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
61
|
-
/******/ var ns = Object.create(null);
|
|
62
|
-
/******/ __webpack_require__.r(ns);
|
|
63
|
-
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
64
|
-
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
65
|
-
/******/ return ns;
|
|
66
|
-
/******/ };
|
|
67
|
-
/******/
|
|
68
|
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
69
|
-
/******/ __webpack_require__.n = function(module) {
|
|
70
|
-
/******/ var getter = module && module.__esModule ?
|
|
71
|
-
/******/ function getDefault() { return module['default']; } :
|
|
72
|
-
/******/ function getModuleExports() { return module; };
|
|
73
|
-
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
74
|
-
/******/ return getter;
|
|
75
|
-
/******/ };
|
|
76
|
-
/******/
|
|
77
|
-
/******/ // Object.prototype.hasOwnProperty.call
|
|
78
|
-
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
79
|
-
/******/
|
|
80
|
-
/******/ // __webpack_public_path__
|
|
81
|
-
/******/ __webpack_require__.p = "";
|
|
82
|
-
/******/
|
|
83
|
-
/******/
|
|
84
|
-
/******/ // Load entry module and return exports
|
|
85
|
-
/******/ return __webpack_require__(__webpack_require__.s = "./src/index.ts");
|
|
86
|
-
/******/ })
|
|
87
|
-
/************************************************************************/
|
|
88
|
-
/******/ ({
|
|
89
|
-
|
|
90
|
-
/***/ "./src/connector/connector.tsx":
|
|
91
|
-
/*!*************************************!*\
|
|
92
|
-
!*** ./src/connector/connector.tsx ***!
|
|
93
|
-
\*************************************/
|
|
94
|
-
/*! no static exports found */
|
|
95
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
96
|
-
|
|
97
1
|
"use strict";
|
|
98
|
-
|
|
99
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
100
|
-
if (k2 === undefined) k2 = k;
|
|
101
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
102
|
-
}) : (function(o, m, k, k2) {
|
|
103
|
-
if (k2 === undefined) k2 = k;
|
|
104
|
-
o[k2] = m[k];
|
|
105
|
-
}));
|
|
106
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
107
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
108
|
-
}) : function(o, v) {
|
|
109
|
-
o["default"] = v;
|
|
110
|
-
});
|
|
111
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
112
|
-
if (mod && mod.__esModule) return mod;
|
|
113
|
-
var result = {};
|
|
114
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
115
|
-
__setModuleDefault(result, mod);
|
|
116
|
-
return result;
|
|
117
|
-
};
|
|
118
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
119
|
-
exports.Feature = void 0;
|
|
120
|
-
const React = __importStar(__webpack_require__(/*! react */ "react"));
|
|
121
|
-
const client_core_1 = __webpack_require__(/*! @common-stack/client-core */ "@common-stack/client-core");
|
|
122
|
-
const utils_1 = __webpack_require__(/*! ../utils */ "./src/utils/index.ts");
|
|
123
|
-
const lodash_1 = __webpack_require__(/*! lodash */ "lodash");
|
|
124
|
-
const plugin_area_1 = __webpack_require__(/*! ../plugin-area */ "./src/plugin-area/index.ts");
|
|
125
|
-
const combine = (features, extractor) => lodash_1.without(lodash_1.union(...lodash_1.map(features, res => lodash_1.castArray(extractor(res)))), undefined);
|
|
126
|
-
const getFirst = (features, extractor) => extractor(lodash_1.find(features, (res) => extractor(res)) || {});
|
|
127
|
-
class Feature extends client_core_1.AbstractFeature {
|
|
128
|
-
constructor(feature,
|
|
129
|
-
// tslint:disable:trailing-comma
|
|
130
|
-
...features) {
|
|
131
|
-
super(feature, ...features);
|
|
132
|
-
/* tslint:disable:jsx-no-lambda */
|
|
133
|
-
this.renderRoutes = utils_1.renderRoutes;
|
|
134
|
-
this.sortMenusByPriority = (menus) => {
|
|
135
|
-
return lodash_1.sortBy(menus, (obj) => parseInt(obj.priority, 10));
|
|
136
|
-
};
|
|
137
|
-
this.sortMenus = (sortByPriority, menus) => {
|
|
138
|
-
if (sortByPriority) {
|
|
139
|
-
const menuData = this.sortMenusByPriority(menus);
|
|
140
|
-
return menuData.map(menu => {
|
|
141
|
-
return Object.assign(Object.assign({}, menu), { children: menu.children && this.sortMenus(sortByPriority, menu.children) });
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
return menus;
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
// this.logger = makeLogger(Feature.name);
|
|
149
|
-
// Navigation
|
|
150
|
-
this.routerFactory = combine(arguments, (arg) => arg.routerFactory)
|
|
151
|
-
.slice(-1)
|
|
152
|
-
.pop();
|
|
153
|
-
this.route = combine(arguments, (arg) => arg.route);
|
|
154
|
-
this.routeConfig = combine(arguments, (arg) => arg.routeConfig);
|
|
155
|
-
this.menuConfig = combine(arguments, (arg) => arg.menuConfig);
|
|
156
|
-
this.componentFillPlugins = this.registerComponentFillPlugins(combine(arguments, (arg) => arg.componentFillPlugins));
|
|
157
|
-
this.authWrapper = getFirst(arguments, (arg) => arg.authWrapper);
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Get the routes
|
|
161
|
-
*/
|
|
162
|
-
getRoutes(searchPath) {
|
|
163
|
-
const configuredRoutes = this.getConfiguredRoutes(searchPath);
|
|
164
|
-
const solidRoutes = this.route.map((component, idx) => React.cloneElement(component, { key: component.props.path }));
|
|
165
|
-
return this.renderRoutes(configuredRoutes, solidRoutes);
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Get menus
|
|
169
|
-
*/
|
|
170
|
-
getMenus(sortByPriority = true) {
|
|
171
|
-
const menus = this.getConfiguredMenus();
|
|
172
|
-
return this.sortMenus(sortByPriority, menus);
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* get configured routes.
|
|
176
|
-
* Note: It overwrites the any duplicate key with latest loaded key.
|
|
177
|
-
* TODO: Find a way to warn when there are duplicate keys.
|
|
178
|
-
*/
|
|
179
|
-
getConfiguredRoutes(searchPath = '/') {
|
|
180
|
-
return utils_1.getSortedRoutes(searchPath, Object.assign({}, ...this.routeConfig), this.authWrapper);
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* get configured menus.
|
|
184
|
-
* Note: It overwrites the any duplicate key with latest loaded key.
|
|
185
|
-
* TODO: Find a way to warn when there are duplicate keys.
|
|
186
|
-
*/
|
|
187
|
-
getConfiguredMenus(searchPath = '/') {
|
|
188
|
-
const routes = Object.assign({}, ...this.menuConfig);
|
|
189
|
-
return utils_1.getMenus(searchPath, Object.assign({}, routes));
|
|
190
|
-
}
|
|
191
|
-
get navItems() {
|
|
192
|
-
return this.navItem.map((component, idx) => React.cloneElement(component, {
|
|
193
|
-
key: component.key ? component.key : idx + this.navItem.length,
|
|
194
|
-
}));
|
|
195
|
-
}
|
|
196
|
-
get navItemsRight() {
|
|
197
|
-
return this.navItemsRight.map((component, idx) => React.cloneElement(component, {
|
|
198
|
-
key: component.key ? component.key : idx + this.navItems.length,
|
|
199
|
-
}));
|
|
200
|
-
}
|
|
201
|
-
getWrappedRoot(root, req) {
|
|
202
|
-
let nestedRoot = root;
|
|
203
|
-
for (const componentFactory of this.rootComponentFactory) {
|
|
204
|
-
nestedRoot = React.cloneElement(componentFactory(req), {}, nestedRoot);
|
|
205
|
-
}
|
|
206
|
-
return nestedRoot;
|
|
207
|
-
}
|
|
208
|
-
getDataRoot(root) {
|
|
209
|
-
let nestedRoot = root;
|
|
210
|
-
for (const component of this.dataRootComponent) {
|
|
211
|
-
nestedRoot = React.createElement(component, {}, nestedRoot);
|
|
212
|
-
}
|
|
213
|
-
return nestedRoot;
|
|
214
|
-
}
|
|
215
|
-
registerLanguages(monaco) {
|
|
216
|
-
for (const func of this.languagesFuncs) {
|
|
217
|
-
func(monaco);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
registerComponentFillPlugins(plugins) {
|
|
221
|
-
plugins.forEach((i) => {
|
|
222
|
-
const { name } = i;
|
|
223
|
-
const isFound = !!plugin_area_1.getPlugin(name);
|
|
224
|
-
if (!isFound) {
|
|
225
|
-
plugin_area_1.registerPlugin(name, i);
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
return plugins;
|
|
229
|
-
}
|
|
230
|
-
getComponentFillPlugins() {
|
|
231
|
-
return plugin_area_1.getPlugins();
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
exports.Feature = Feature;
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
/***/ }),
|
|
238
|
-
|
|
239
|
-
/***/ "./src/connector/index.ts":
|
|
240
|
-
/*!********************************!*\
|
|
241
|
-
!*** ./src/connector/index.ts ***!
|
|
242
|
-
\********************************/
|
|
243
|
-
/*! no static exports found */
|
|
244
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
245
|
-
|
|
246
|
-
"use strict";
|
|
247
|
-
|
|
248
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
249
|
-
if (k2 === undefined) k2 = k;
|
|
250
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
251
|
-
}) : (function(o, m, k, k2) {
|
|
252
|
-
if (k2 === undefined) k2 = k;
|
|
253
|
-
o[k2] = m[k];
|
|
254
|
-
}));
|
|
255
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
256
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
257
|
-
};
|
|
258
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
259
|
-
__exportStar(__webpack_require__(/*! ./connector */ "./src/connector/connector.tsx"), exports);
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
/***/ }),
|
|
263
|
-
|
|
264
|
-
/***/ "./src/index.ts":
|
|
265
|
-
/*!**********************!*\
|
|
266
|
-
!*** ./src/index.ts ***!
|
|
267
|
-
\**********************/
|
|
268
|
-
/*! no static exports found */
|
|
269
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
270
|
-
|
|
271
|
-
"use strict";
|
|
272
|
-
|
|
273
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
274
3
|
if (k2 === undefined) k2 = k;
|
|
275
4
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -282,1456 +11,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
282
11
|
};
|
|
283
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
284
13
|
exports.ClientTypes = void 0;
|
|
285
|
-
var client_core_1 =
|
|
14
|
+
var client_core_1 = require("@common-stack/client-core");
|
|
286
15
|
Object.defineProperty(exports, "ClientTypes", { enumerable: true, get: function () { return client_core_1.ClientTypes; } });
|
|
287
|
-
__exportStar(
|
|
288
|
-
__exportStar(
|
|
289
|
-
__exportStar(
|
|
290
|
-
__exportStar(
|
|
291
|
-
__exportStar(
|
|
292
|
-
__exportStar(
|
|
293
|
-
__exportStar(
|
|
294
|
-
__exportStar(
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
/***/ }),
|
|
298
|
-
|
|
299
|
-
/***/ "./src/interfaces/extended-feature.ts":
|
|
300
|
-
/*!********************************************!*\
|
|
301
|
-
!*** ./src/interfaces/extended-feature.ts ***!
|
|
302
|
-
\********************************************/
|
|
303
|
-
/*! no static exports found */
|
|
304
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
305
|
-
|
|
306
|
-
"use strict";
|
|
307
|
-
|
|
308
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
/***/ }),
|
|
312
|
-
|
|
313
|
-
/***/ "./src/interfaces/index.ts":
|
|
314
|
-
/*!*********************************!*\
|
|
315
|
-
!*** ./src/interfaces/index.ts ***!
|
|
316
|
-
\*********************************/
|
|
317
|
-
/*! no static exports found */
|
|
318
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
319
|
-
|
|
320
|
-
"use strict";
|
|
321
|
-
|
|
322
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
323
|
-
if (k2 === undefined) k2 = k;
|
|
324
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
325
|
-
}) : (function(o, m, k, k2) {
|
|
326
|
-
if (k2 === undefined) k2 = k;
|
|
327
|
-
o[k2] = m[k];
|
|
328
|
-
}));
|
|
329
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
330
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
331
|
-
};
|
|
332
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
333
|
-
__exportStar(__webpack_require__(/*! ./router */ "./src/interfaces/router.ts"), exports);
|
|
334
|
-
__exportStar(__webpack_require__(/*! ./extended-feature */ "./src/interfaces/extended-feature.ts"), exports);
|
|
335
|
-
__exportStar(__webpack_require__(/*! ./menu */ "./src/interfaces/menu.tsx"), exports);
|
|
336
|
-
__exportStar(__webpack_require__(/*! ./new-router */ "./src/interfaces/new-router.tsx"), exports);
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
/***/ }),
|
|
340
|
-
|
|
341
|
-
/***/ "./src/interfaces/menu.tsx":
|
|
342
|
-
/*!*********************************!*\
|
|
343
|
-
!*** ./src/interfaces/menu.tsx ***!
|
|
344
|
-
\*********************************/
|
|
345
|
-
/*! no static exports found */
|
|
346
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
347
|
-
|
|
348
|
-
"use strict";
|
|
349
|
-
|
|
350
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
351
|
-
exports.IMenuPosition = void 0;
|
|
352
|
-
var IMenuPosition;
|
|
353
|
-
(function (IMenuPosition) {
|
|
354
|
-
IMenuPosition["LOGO"] = "LOGO";
|
|
355
|
-
IMenuPosition["UPPER"] = "UPPER";
|
|
356
|
-
IMenuPosition["MIDDLE"] = "MIDDLE";
|
|
357
|
-
IMenuPosition["LOWER"] = "LOWER";
|
|
358
|
-
IMenuPosition["BOTTOM"] = "BOTTOM";
|
|
359
|
-
})(IMenuPosition = exports.IMenuPosition || (exports.IMenuPosition = {}));
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
/***/ }),
|
|
363
|
-
|
|
364
|
-
/***/ "./src/interfaces/new-router.tsx":
|
|
365
|
-
/*!***************************************!*\
|
|
366
|
-
!*** ./src/interfaces/new-router.tsx ***!
|
|
367
|
-
\***************************************/
|
|
368
|
-
/*! no static exports found */
|
|
369
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
370
|
-
|
|
371
|
-
"use strict";
|
|
372
|
-
|
|
373
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
/***/ }),
|
|
377
|
-
|
|
378
|
-
/***/ "./src/interfaces/router.ts":
|
|
379
|
-
/*!**********************************!*\
|
|
380
|
-
!*** ./src/interfaces/router.ts ***!
|
|
381
|
-
\**********************************/
|
|
382
|
-
/*! no static exports found */
|
|
383
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
384
|
-
|
|
385
|
-
"use strict";
|
|
386
|
-
|
|
387
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
/***/ }),
|
|
391
|
-
|
|
392
|
-
/***/ "./src/inversify/InversifyContext.tsx":
|
|
393
|
-
/*!********************************************!*\
|
|
394
|
-
!*** ./src/inversify/InversifyContext.tsx ***!
|
|
395
|
-
\********************************************/
|
|
396
|
-
/*! no static exports found */
|
|
397
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
398
|
-
|
|
399
|
-
"use strict";
|
|
400
|
-
|
|
401
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
402
|
-
if (k2 === undefined) k2 = k;
|
|
403
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
404
|
-
}) : (function(o, m, k, k2) {
|
|
405
|
-
if (k2 === undefined) k2 = k;
|
|
406
|
-
o[k2] = m[k];
|
|
407
|
-
}));
|
|
408
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
409
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
410
|
-
}) : function(o, v) {
|
|
411
|
-
o["default"] = v;
|
|
412
|
-
});
|
|
413
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
414
|
-
if (mod && mod.__esModule) return mod;
|
|
415
|
-
var result = {};
|
|
416
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
417
|
-
__setModuleDefault(result, mod);
|
|
418
|
-
return result;
|
|
419
|
-
};
|
|
420
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
421
|
-
exports.useInjection = exports.InversifyProvider = exports.InversifyContext = void 0;
|
|
422
|
-
const React = __importStar(__webpack_require__(/*! react */ "react"));
|
|
423
|
-
exports.InversifyContext = React.createContext({ container: null, modules: null });
|
|
424
|
-
const InversifyProvider = (props) => {
|
|
425
|
-
return (React.createElement(exports.InversifyContext.Provider, { value: { container: props.container, modules: props.modules } }, props.children));
|
|
426
|
-
};
|
|
427
|
-
exports.InversifyProvider = InversifyProvider;
|
|
428
|
-
function useInjection(identifier) {
|
|
429
|
-
const { container } = React.useContext(exports.InversifyContext);
|
|
430
|
-
if (!container) {
|
|
431
|
-
throw new Error('Container is null');
|
|
432
|
-
}
|
|
433
|
-
return container.get(identifier);
|
|
434
|
-
}
|
|
435
|
-
exports.useInjection = useInjection;
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
/***/ }),
|
|
439
|
-
|
|
440
|
-
/***/ "./src/inversify/index.ts":
|
|
441
|
-
/*!********************************!*\
|
|
442
|
-
!*** ./src/inversify/index.ts ***!
|
|
443
|
-
\********************************/
|
|
444
|
-
/*! no static exports found */
|
|
445
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
446
|
-
|
|
447
|
-
"use strict";
|
|
448
|
-
|
|
449
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
450
|
-
if (k2 === undefined) k2 = k;
|
|
451
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
452
|
-
}) : (function(o, m, k, k2) {
|
|
453
|
-
if (k2 === undefined) k2 = k;
|
|
454
|
-
o[k2] = m[k];
|
|
455
|
-
}));
|
|
456
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
457
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
458
|
-
};
|
|
459
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
460
|
-
__exportStar(__webpack_require__(/*! ./InversifyContext */ "./src/inversify/InversifyContext.tsx"), exports);
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
/***/ }),
|
|
464
|
-
|
|
465
|
-
/***/ "./src/plugin-area/browser-plugin-area.tsx":
|
|
466
|
-
/*!*************************************************!*\
|
|
467
|
-
!*** ./src/plugin-area/browser-plugin-area.tsx ***!
|
|
468
|
-
\*************************************************/
|
|
469
|
-
/*! no static exports found */
|
|
470
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
471
|
-
|
|
472
|
-
"use strict";
|
|
473
|
-
|
|
474
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
475
|
-
if (k2 === undefined) k2 = k;
|
|
476
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
477
|
-
}) : (function(o, m, k, k2) {
|
|
478
|
-
if (k2 === undefined) k2 = k;
|
|
479
|
-
o[k2] = m[k];
|
|
480
|
-
}));
|
|
481
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
482
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
483
|
-
}) : function(o, v) {
|
|
484
|
-
o["default"] = v;
|
|
485
|
-
});
|
|
486
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
487
|
-
if (mod && mod.__esModule) return mod;
|
|
488
|
-
var result = {};
|
|
489
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
490
|
-
__setModuleDefault(result, mod);
|
|
491
|
-
return result;
|
|
492
|
-
};
|
|
493
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
494
|
-
exports.BrowserPluginArea = void 0;
|
|
495
|
-
const React = __importStar(__webpack_require__(/*! react */ "react"));
|
|
496
|
-
const plugin_area_1 = __webpack_require__(/*! ./plugin-area */ "./src/plugin-area/plugin-area.tsx");
|
|
497
|
-
const BrowserPluginArea = () => {
|
|
498
|
-
return React.createElement("div", { style: { display: "none" } },
|
|
499
|
-
React.createElement(plugin_area_1.PluginArea, null));
|
|
500
|
-
};
|
|
501
|
-
exports.BrowserPluginArea = BrowserPluginArea;
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
/***/ }),
|
|
505
|
-
|
|
506
|
-
/***/ "./src/plugin-area/higher-order-component-util.ts":
|
|
507
|
-
/*!********************************************************!*\
|
|
508
|
-
!*** ./src/plugin-area/higher-order-component-util.ts ***!
|
|
509
|
-
\********************************************************/
|
|
510
|
-
/*! no static exports found */
|
|
511
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
512
|
-
|
|
513
|
-
"use strict";
|
|
514
|
-
|
|
515
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
516
|
-
exports.createHigherOrderComponent = void 0;
|
|
517
|
-
const lodash_1 = __webpack_require__(/*! lodash */ "lodash");
|
|
518
|
-
/**
|
|
519
|
-
* Given a function mapping a component to an enhanced component and modifier
|
|
520
|
-
* name, returns the enhanced component augmented with a generated displayName.
|
|
521
|
-
*
|
|
522
|
-
* @param mapComponentToEnhancedComponent Function mapping component to enhanced component.
|
|
523
|
-
* @param modifierName Seed name from which to generated display name.
|
|
524
|
-
*
|
|
525
|
-
* @return Component class with generated display name assigned.
|
|
526
|
-
*/
|
|
527
|
-
function createHigherOrderComponent(mapComponentToEnhancedComponent, modifierName) {
|
|
528
|
-
return (OriginalComponent) => {
|
|
529
|
-
const EnhancedComponent = mapComponentToEnhancedComponent(OriginalComponent);
|
|
530
|
-
const { displayName = OriginalComponent.name || 'Component', } = OriginalComponent;
|
|
531
|
-
EnhancedComponent.displayName = `${lodash_1.upperFirst(lodash_1.camelCase(modifierName))}(${displayName})`;
|
|
532
|
-
return EnhancedComponent;
|
|
533
|
-
};
|
|
534
|
-
}
|
|
535
|
-
exports.createHigherOrderComponent = createHigherOrderComponent;
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
/***/ }),
|
|
539
|
-
|
|
540
|
-
/***/ "./src/plugin-area/index.ts":
|
|
541
|
-
/*!**********************************!*\
|
|
542
|
-
!*** ./src/plugin-area/index.ts ***!
|
|
543
|
-
\**********************************/
|
|
544
|
-
/*! no static exports found */
|
|
545
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
546
|
-
|
|
547
|
-
"use strict";
|
|
548
|
-
|
|
549
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
550
|
-
if (k2 === undefined) k2 = k;
|
|
551
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
552
|
-
}) : (function(o, m, k, k2) {
|
|
553
|
-
if (k2 === undefined) k2 = k;
|
|
554
|
-
o[k2] = m[k];
|
|
555
|
-
}));
|
|
556
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
557
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
558
|
-
};
|
|
559
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
560
|
-
__exportStar(__webpack_require__(/*! ./plugin-area */ "./src/plugin-area/plugin-area.tsx"), exports);
|
|
561
|
-
__exportStar(__webpack_require__(/*! ./plugin-api */ "./src/plugin-area/plugin-api.ts"), exports);
|
|
562
|
-
__exportStar(__webpack_require__(/*! ./browser-plugin-area */ "./src/plugin-area/browser-plugin-area.tsx"), exports);
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
/***/ }),
|
|
566
|
-
|
|
567
|
-
/***/ "./src/plugin-area/plugin-api.ts":
|
|
568
|
-
/*!***************************************!*\
|
|
569
|
-
!*** ./src/plugin-area/plugin-api.ts ***!
|
|
570
|
-
\***************************************/
|
|
571
|
-
/*! no static exports found */
|
|
572
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
573
|
-
|
|
574
|
-
"use strict";
|
|
575
|
-
|
|
576
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
577
|
-
exports.getPlugins = exports.getPlugin = exports.unregisterPlugin = exports.registerPlugin = void 0;
|
|
578
|
-
const lodash_1 = __webpack_require__(/*! lodash */ "lodash");
|
|
579
|
-
const hooks_1 = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks");
|
|
580
|
-
/**
|
|
581
|
-
* Plugin definitions keyed by plugin name.
|
|
582
|
-
*/
|
|
583
|
-
const plugins = {};
|
|
584
|
-
/**
|
|
585
|
-
* Registeres a plugin to the App.
|
|
586
|
-
*
|
|
587
|
-
* @param name A string identifying the plugin. Must be unique across all registered plugins.
|
|
588
|
-
* @param settings The settings for this plugin.
|
|
589
|
-
*/
|
|
590
|
-
function registerPlugin(name, settings) {
|
|
591
|
-
if (typeof settings !== 'object') {
|
|
592
|
-
console.error('No settings object provided!');
|
|
593
|
-
return null;
|
|
594
|
-
}
|
|
595
|
-
if (typeof name !== 'string') {
|
|
596
|
-
console.error('Plugin names must be strings.');
|
|
597
|
-
return null;
|
|
598
|
-
}
|
|
599
|
-
if (!/^[a-z][a-z0-9-]*$/.test(name)) {
|
|
600
|
-
console.error('Plugin names must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-pluin".');
|
|
601
|
-
return null;
|
|
602
|
-
}
|
|
603
|
-
if (plugins[name]) {
|
|
604
|
-
console.error(`Plugin "${name}" is alread registered.`);
|
|
605
|
-
}
|
|
606
|
-
settings = hooks_1.applyFilters('plugins.registerPlugin', settings, name);
|
|
607
|
-
if (!lodash_1.isFunction(settings.render)) {
|
|
608
|
-
console.error('The "render" property must be specified and must be a valid function.');
|
|
609
|
-
return null;
|
|
610
|
-
}
|
|
611
|
-
plugins[name] = Object.assign({ name, icon: 'admin-plugins' }, settings);
|
|
612
|
-
hooks_1.doAction('plugins.pluginRegistered', settings, name);
|
|
613
|
-
return settings;
|
|
614
|
-
}
|
|
615
|
-
exports.registerPlugin = registerPlugin;
|
|
616
|
-
/**
|
|
617
|
-
* Unregisteres a plugin by name.
|
|
618
|
-
* @param name Plugin name.
|
|
619
|
-
*
|
|
620
|
-
* @return The previous plugin settings object, if it has been successfully unregistered; otherwise `undefined`.
|
|
621
|
-
*/
|
|
622
|
-
function unregisterPlugin(name) {
|
|
623
|
-
if (!plugins[name]) {
|
|
624
|
-
console.error('Plugin "' + name + '" is not registered.');
|
|
625
|
-
return;
|
|
626
|
-
}
|
|
627
|
-
const oldPlugin = plugins[name];
|
|
628
|
-
delete plugins[name];
|
|
629
|
-
hooks_1.doAction('plugin.pluginUnregistered', oldPlugin, name);
|
|
630
|
-
return oldPlugin;
|
|
631
|
-
}
|
|
632
|
-
exports.unregisterPlugin = unregisterPlugin;
|
|
633
|
-
/**
|
|
634
|
-
* Returns a registered plugin settings.
|
|
635
|
-
*
|
|
636
|
-
* @param name Plugin name.
|
|
637
|
-
*
|
|
638
|
-
* @returns Plugin setting.
|
|
639
|
-
*/
|
|
640
|
-
function getPlugin(name) {
|
|
641
|
-
return plugins[name];
|
|
642
|
-
}
|
|
643
|
-
exports.getPlugin = getPlugin;
|
|
644
|
-
/**
|
|
645
|
-
* Return all registered plugins.
|
|
646
|
-
*
|
|
647
|
-
* @return Plugin settings.
|
|
648
|
-
*/
|
|
649
|
-
function getPlugins() {
|
|
650
|
-
return Object.values(plugins);
|
|
651
|
-
}
|
|
652
|
-
exports.getPlugins = getPlugins;
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
/***/ }),
|
|
656
|
-
|
|
657
|
-
/***/ "./src/plugin-area/plugin-area.tsx":
|
|
658
|
-
/*!*****************************************!*\
|
|
659
|
-
!*** ./src/plugin-area/plugin-area.tsx ***!
|
|
660
|
-
\*****************************************/
|
|
661
|
-
/*! no static exports found */
|
|
662
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
663
|
-
|
|
664
|
-
"use strict";
|
|
665
|
-
|
|
666
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
667
|
-
if (k2 === undefined) k2 = k;
|
|
668
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
669
|
-
}) : (function(o, m, k, k2) {
|
|
670
|
-
if (k2 === undefined) k2 = k;
|
|
671
|
-
o[k2] = m[k];
|
|
672
|
-
}));
|
|
673
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
674
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
675
|
-
}) : function(o, v) {
|
|
676
|
-
o["default"] = v;
|
|
677
|
-
});
|
|
678
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
679
|
-
if (mod && mod.__esModule) return mod;
|
|
680
|
-
var result = {};
|
|
681
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
682
|
-
__setModuleDefault(result, mod);
|
|
683
|
-
return result;
|
|
684
|
-
};
|
|
685
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
686
|
-
exports.PluginArea = void 0;
|
|
687
|
-
const lodash_1 = __webpack_require__(/*! lodash */ "lodash");
|
|
688
|
-
const React = __importStar(__webpack_require__(/*! react */ "react"));
|
|
689
|
-
const hooks_1 = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks");
|
|
690
|
-
const plugin_context_1 = __webpack_require__(/*! ./plugin-context */ "./src/plugin-area/plugin-context.tsx");
|
|
691
|
-
const plugin_api_1 = __webpack_require__(/*! ./plugin-api */ "./src/plugin-area/plugin-api.ts");
|
|
692
|
-
/**
|
|
693
|
-
* A component that renders all plugin fills in a hidden div.
|
|
694
|
-
*/
|
|
695
|
-
class PluginArea extends React.Component {
|
|
696
|
-
constructor(args) {
|
|
697
|
-
super(args);
|
|
698
|
-
this.setPlugins = this.setPlugins.bind(this);
|
|
699
|
-
this.state = { plugins: [] };
|
|
700
|
-
}
|
|
701
|
-
getCurrentPluginsState() {
|
|
702
|
-
return {
|
|
703
|
-
plugins: lodash_1.map(plugin_api_1.getPlugins(), ({ icon, name, render }) => {
|
|
704
|
-
return {
|
|
705
|
-
Plugin: render,
|
|
706
|
-
context: {
|
|
707
|
-
name,
|
|
708
|
-
icon,
|
|
709
|
-
},
|
|
710
|
-
};
|
|
711
|
-
}),
|
|
712
|
-
};
|
|
713
|
-
}
|
|
714
|
-
componentDidMount() {
|
|
715
|
-
hooks_1.addAction('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered', this.setPlugins);
|
|
716
|
-
hooks_1.addAction('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered', this.setPlugins);
|
|
717
|
-
this.setPlugins();
|
|
718
|
-
}
|
|
719
|
-
componentWillUnMount() {
|
|
720
|
-
hooks_1.removeAction('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered');
|
|
721
|
-
hooks_1.removeAction('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered');
|
|
722
|
-
}
|
|
723
|
-
setPlugins() {
|
|
724
|
-
this.setState(this.getCurrentPluginsState);
|
|
725
|
-
}
|
|
726
|
-
render() {
|
|
727
|
-
return (React.createElement(React.Fragment, null, lodash_1.map(this.state.plugins, ({ context, Plugin }) => (React.createElement(plugin_context_1.PluginContextProvider, { key: context.name, value: context },
|
|
728
|
-
React.createElement(Plugin, null))))));
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
exports.PluginArea = PluginArea;
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
/***/ }),
|
|
735
|
-
|
|
736
|
-
/***/ "./src/plugin-area/plugin-context.tsx":
|
|
737
|
-
/*!********************************************!*\
|
|
738
|
-
!*** ./src/plugin-area/plugin-context.tsx ***!
|
|
739
|
-
\********************************************/
|
|
740
|
-
/*! no static exports found */
|
|
741
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
742
|
-
|
|
743
|
-
"use strict";
|
|
744
|
-
|
|
745
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
746
|
-
if (k2 === undefined) k2 = k;
|
|
747
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
748
|
-
}) : (function(o, m, k, k2) {
|
|
749
|
-
if (k2 === undefined) k2 = k;
|
|
750
|
-
o[k2] = m[k];
|
|
751
|
-
}));
|
|
752
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
753
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
754
|
-
}) : function(o, v) {
|
|
755
|
-
o["default"] = v;
|
|
756
|
-
});
|
|
757
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
758
|
-
if (mod && mod.__esModule) return mod;
|
|
759
|
-
var result = {};
|
|
760
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
761
|
-
__setModuleDefault(result, mod);
|
|
762
|
-
return result;
|
|
763
|
-
};
|
|
764
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
765
|
-
exports.withPluginContext = exports.PluginContextProvider = void 0;
|
|
766
|
-
const React = __importStar(__webpack_require__(/*! react */ "react"));
|
|
767
|
-
const higher_order_component_util_1 = __webpack_require__(/*! ./higher-order-component-util */ "./src/plugin-area/higher-order-component-util.ts");
|
|
768
|
-
const { createContext } = React;
|
|
769
|
-
const { Consumer, Provider } = createContext({
|
|
770
|
-
name: null,
|
|
771
|
-
icon: null,
|
|
772
|
-
});
|
|
773
|
-
exports.PluginContextProvider = Provider;
|
|
774
|
-
/**
|
|
775
|
-
* A Higher Order Component used to inject Plugin context to the
|
|
776
|
-
* wrapped component.
|
|
777
|
-
*
|
|
778
|
-
* @param mapContextToProps Function called on every context change, expected to return object of
|
|
779
|
-
* props to merge with the component's own props.
|
|
780
|
-
*
|
|
781
|
-
* @return Enhanced component with injected context as props.
|
|
782
|
-
*/
|
|
783
|
-
const withPluginContext = (mapContextToProps) => higher_order_component_util_1.createHigherOrderComponent((OriginalComponent) => {
|
|
784
|
-
return (props) => (React.createElement(Consumer, null, (context) => (React.createElement(OriginalComponent, Object.assign({}, props, mapContextToProps(context, props))))));
|
|
785
|
-
}, 'withPluginContext');
|
|
786
|
-
exports.withPluginContext = withPluginContext;
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
/***/ }),
|
|
790
|
-
|
|
791
|
-
/***/ "./src/route-based-plugin-area/higher-order-component-util.ts":
|
|
792
|
-
/*!********************************************************************!*\
|
|
793
|
-
!*** ./src/route-based-plugin-area/higher-order-component-util.ts ***!
|
|
794
|
-
\********************************************************************/
|
|
795
|
-
/*! no static exports found */
|
|
796
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
797
|
-
|
|
798
|
-
"use strict";
|
|
799
|
-
|
|
800
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
801
|
-
exports.createHigherOrderComponent = void 0;
|
|
802
|
-
const lodash_1 = __webpack_require__(/*! lodash */ "lodash");
|
|
803
|
-
/**
|
|
804
|
-
* Given a function mapping a component to an enhanced component and modifier
|
|
805
|
-
* name, returns the enhanced component augmented with a generated displayName.
|
|
806
|
-
*
|
|
807
|
-
* @param mapComponentToEnhancedComponent Function mapping component to enhanced component.
|
|
808
|
-
* @param modifierName Seed name from which to generated display name.
|
|
809
|
-
*
|
|
810
|
-
* @return Component class with generated display name assigned.
|
|
811
|
-
*/
|
|
812
|
-
function createHigherOrderComponent(mapComponentToEnhancedComponent, modifierName) {
|
|
813
|
-
return (OriginalComponent) => {
|
|
814
|
-
const EnhancedComponent = mapComponentToEnhancedComponent(OriginalComponent);
|
|
815
|
-
const { displayName = OriginalComponent.name || 'Component', } = OriginalComponent;
|
|
816
|
-
EnhancedComponent.displayName = `${lodash_1.upperFirst(lodash_1.camelCase(modifierName))}(${displayName})`;
|
|
817
|
-
return EnhancedComponent;
|
|
818
|
-
};
|
|
819
|
-
}
|
|
820
|
-
exports.createHigherOrderComponent = createHigherOrderComponent;
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
/***/ }),
|
|
824
|
-
|
|
825
|
-
/***/ "./src/route-based-plugin-area/index.ts":
|
|
826
|
-
/*!**********************************************!*\
|
|
827
|
-
!*** ./src/route-based-plugin-area/index.ts ***!
|
|
828
|
-
\**********************************************/
|
|
829
|
-
/*! no static exports found */
|
|
830
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
831
|
-
|
|
832
|
-
"use strict";
|
|
833
|
-
|
|
834
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
835
|
-
if (k2 === undefined) k2 = k;
|
|
836
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
837
|
-
}) : (function(o, m, k, k2) {
|
|
838
|
-
if (k2 === undefined) k2 = k;
|
|
839
|
-
o[k2] = m[k];
|
|
840
|
-
}));
|
|
841
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
842
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
843
|
-
};
|
|
844
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
845
|
-
__exportStar(__webpack_require__(/*! ./route-based-plugin-area */ "./src/route-based-plugin-area/route-based-plugin-area.tsx"), exports);
|
|
846
|
-
__exportStar(__webpack_require__(/*! ./plugin-api */ "./src/route-based-plugin-area/plugin-api.ts"), exports);
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
/***/ }),
|
|
850
|
-
|
|
851
|
-
/***/ "./src/route-based-plugin-area/plugin-api.ts":
|
|
852
|
-
/*!***************************************************!*\
|
|
853
|
-
!*** ./src/route-based-plugin-area/plugin-api.ts ***!
|
|
854
|
-
\***************************************************/
|
|
855
|
-
/*! no static exports found */
|
|
856
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
857
|
-
|
|
858
|
-
"use strict";
|
|
859
|
-
|
|
860
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
861
|
-
exports.getRouteBasePlugins = exports.getRouteBasePlugin = exports.unregisterRouteBasePlugin = exports.registerRouteBasePlugin = void 0;
|
|
862
|
-
const lodash_1 = __webpack_require__(/*! lodash */ "lodash");
|
|
863
|
-
const hooks_1 = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks");
|
|
864
|
-
/**
|
|
865
|
-
* Plugin definitions keyed by plugin name.
|
|
866
|
-
*/
|
|
867
|
-
const plugins = {};
|
|
868
|
-
/**
|
|
869
|
-
* Registeres a plugin to the App.
|
|
870
|
-
*
|
|
871
|
-
* @param name A string identifying the plugin. Must be unique across all registered plugins.
|
|
872
|
-
* @param settings The settings for this plugin.
|
|
873
|
-
*/
|
|
874
|
-
function registerRouteBasePlugin(name, settings) {
|
|
875
|
-
if (typeof settings !== 'object') {
|
|
876
|
-
console.error('No settings object provided!');
|
|
877
|
-
return null;
|
|
878
|
-
}
|
|
879
|
-
if (typeof name !== 'string') {
|
|
880
|
-
console.error('Plugin names must be strings.');
|
|
881
|
-
return null;
|
|
882
|
-
}
|
|
883
|
-
if (!/^[a-z][a-z0-9-]*$/.test(name)) {
|
|
884
|
-
console.error('Plugin names must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-pluin".');
|
|
885
|
-
return null;
|
|
886
|
-
}
|
|
887
|
-
if (plugins[name]) {
|
|
888
|
-
console.error(`Plugin "${name}" is alread registered.`);
|
|
889
|
-
}
|
|
890
|
-
settings = hooks_1.applyFilters('plugins.registerPlugin', settings, name);
|
|
891
|
-
if (!lodash_1.isFunction(settings.render)) {
|
|
892
|
-
console.error('The "render" property must be specified and must be a valid function.');
|
|
893
|
-
return null;
|
|
894
|
-
}
|
|
895
|
-
plugins[name] = Object.assign({ name, icon: 'admin-plugins' }, settings);
|
|
896
|
-
hooks_1.doAction('plugins.pluginRegistered', settings, name);
|
|
897
|
-
return settings;
|
|
898
|
-
}
|
|
899
|
-
exports.registerRouteBasePlugin = registerRouteBasePlugin;
|
|
900
|
-
/**
|
|
901
|
-
* Unregisteres a plugin by name.
|
|
902
|
-
* @param name Plugin name.
|
|
903
|
-
*
|
|
904
|
-
* @return The previous plugin settings object, if it has been successfully unregistered; otherwise `undefined`.
|
|
905
|
-
*/
|
|
906
|
-
function unregisterRouteBasePlugin(name) {
|
|
907
|
-
if (!plugins[name]) {
|
|
908
|
-
console.error('Plugin "' + name + '" is not registered.');
|
|
909
|
-
return;
|
|
910
|
-
}
|
|
911
|
-
const oldPlugin = plugins[name];
|
|
912
|
-
delete plugins[name];
|
|
913
|
-
hooks_1.doAction('plugin.pluginUnregistered', oldPlugin, name);
|
|
914
|
-
return oldPlugin;
|
|
915
|
-
}
|
|
916
|
-
exports.unregisterRouteBasePlugin = unregisterRouteBasePlugin;
|
|
917
|
-
/**
|
|
918
|
-
* Returns a registered plugin settings.
|
|
919
|
-
*
|
|
920
|
-
* @param name Plugin name.
|
|
921
|
-
*
|
|
922
|
-
* @returns Plugin setting.
|
|
923
|
-
*/
|
|
924
|
-
function getRouteBasePlugin(name) {
|
|
925
|
-
return plugins[name];
|
|
926
|
-
}
|
|
927
|
-
exports.getRouteBasePlugin = getRouteBasePlugin;
|
|
928
|
-
/**
|
|
929
|
-
* Return all registered plugins.
|
|
930
|
-
*
|
|
931
|
-
* @return Plugin settings.
|
|
932
|
-
*/
|
|
933
|
-
function getRouteBasePlugins() {
|
|
934
|
-
return Object.values(plugins);
|
|
935
|
-
}
|
|
936
|
-
exports.getRouteBasePlugins = getRouteBasePlugins;
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
/***/ }),
|
|
940
|
-
|
|
941
|
-
/***/ "./src/route-based-plugin-area/plugin-context.tsx":
|
|
942
|
-
/*!********************************************************!*\
|
|
943
|
-
!*** ./src/route-based-plugin-area/plugin-context.tsx ***!
|
|
944
|
-
\********************************************************/
|
|
945
|
-
/*! no static exports found */
|
|
946
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
947
|
-
|
|
948
|
-
"use strict";
|
|
949
|
-
|
|
950
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
951
|
-
if (k2 === undefined) k2 = k;
|
|
952
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
953
|
-
}) : (function(o, m, k, k2) {
|
|
954
|
-
if (k2 === undefined) k2 = k;
|
|
955
|
-
o[k2] = m[k];
|
|
956
|
-
}));
|
|
957
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
958
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
959
|
-
}) : function(o, v) {
|
|
960
|
-
o["default"] = v;
|
|
961
|
-
});
|
|
962
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
963
|
-
if (mod && mod.__esModule) return mod;
|
|
964
|
-
var result = {};
|
|
965
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
966
|
-
__setModuleDefault(result, mod);
|
|
967
|
-
return result;
|
|
968
|
-
};
|
|
969
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
970
|
-
exports.withPluginContext = exports.PluginContextProvider = void 0;
|
|
971
|
-
const React = __importStar(__webpack_require__(/*! react */ "react"));
|
|
972
|
-
const higher_order_component_util_1 = __webpack_require__(/*! ./higher-order-component-util */ "./src/route-based-plugin-area/higher-order-component-util.ts");
|
|
973
|
-
const { createContext } = React;
|
|
974
|
-
const { Consumer, Provider } = createContext({
|
|
975
|
-
name: null,
|
|
976
|
-
icon: null,
|
|
977
|
-
});
|
|
978
|
-
exports.PluginContextProvider = Provider;
|
|
979
|
-
/**
|
|
980
|
-
* A Higher Order Component used to inject Plugin context to the
|
|
981
|
-
* wrapped component.
|
|
982
|
-
*
|
|
983
|
-
* @param mapContextToProps Function called on every context change, expected to return object of
|
|
984
|
-
* props to merge with the component's own props.
|
|
985
|
-
*
|
|
986
|
-
* @return Enhanced component with injected context as props.
|
|
987
|
-
*/
|
|
988
|
-
const withPluginContext = (mapContextToProps) => higher_order_component_util_1.createHigherOrderComponent((OriginalComponent) => {
|
|
989
|
-
return (props) => (React.createElement(Consumer, null, (context) => (React.createElement(OriginalComponent, Object.assign({}, props, mapContextToProps(context, props))))));
|
|
990
|
-
}, 'withPluginContext');
|
|
991
|
-
exports.withPluginContext = withPluginContext;
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
/***/ }),
|
|
995
|
-
|
|
996
|
-
/***/ "./src/route-based-plugin-area/route-based-plugin-area.tsx":
|
|
997
|
-
/*!*****************************************************************!*\
|
|
998
|
-
!*** ./src/route-based-plugin-area/route-based-plugin-area.tsx ***!
|
|
999
|
-
\*****************************************************************/
|
|
1000
|
-
/*! no static exports found */
|
|
1001
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1002
|
-
|
|
1003
|
-
"use strict";
|
|
1004
|
-
|
|
1005
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1006
|
-
if (k2 === undefined) k2 = k;
|
|
1007
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
1008
|
-
}) : (function(o, m, k, k2) {
|
|
1009
|
-
if (k2 === undefined) k2 = k;
|
|
1010
|
-
o[k2] = m[k];
|
|
1011
|
-
}));
|
|
1012
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
1013
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1014
|
-
}) : function(o, v) {
|
|
1015
|
-
o["default"] = v;
|
|
1016
|
-
});
|
|
1017
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
1018
|
-
if (mod && mod.__esModule) return mod;
|
|
1019
|
-
var result = {};
|
|
1020
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
1021
|
-
__setModuleDefault(result, mod);
|
|
1022
|
-
return result;
|
|
1023
|
-
};
|
|
1024
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1025
|
-
exports.RouteBasedPluginArea = void 0;
|
|
1026
|
-
const lodash_1 = __webpack_require__(/*! lodash */ "lodash");
|
|
1027
|
-
const React = __importStar(__webpack_require__(/*! react */ "react"));
|
|
1028
|
-
const hooks_1 = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks");
|
|
1029
|
-
const plugin_context_1 = __webpack_require__(/*! ./plugin-context */ "./src/route-based-plugin-area/plugin-context.tsx");
|
|
1030
|
-
const plugin_api_1 = __webpack_require__(/*! ./plugin-api */ "./src/route-based-plugin-area/plugin-api.ts");
|
|
1031
|
-
/**
|
|
1032
|
-
* A component that renders all plugin fills in a hidden div.
|
|
1033
|
-
*/
|
|
1034
|
-
class RouteBasedPluginArea extends React.Component {
|
|
1035
|
-
constructor(args) {
|
|
1036
|
-
super(args);
|
|
1037
|
-
this.setPlugins = this.setPlugins.bind(this);
|
|
1038
|
-
this.state = { plugins: [] };
|
|
1039
|
-
}
|
|
1040
|
-
getCurrentPluginsState() {
|
|
1041
|
-
return {
|
|
1042
|
-
plugins: lodash_1.map(plugin_api_1.getRouteBasePlugins(), ({ icon, name, render }) => {
|
|
1043
|
-
return {
|
|
1044
|
-
Plugin: render,
|
|
1045
|
-
context: {
|
|
1046
|
-
name,
|
|
1047
|
-
icon,
|
|
1048
|
-
},
|
|
1049
|
-
};
|
|
1050
|
-
}),
|
|
1051
|
-
};
|
|
1052
|
-
}
|
|
1053
|
-
componentDidMount() {
|
|
1054
|
-
hooks_1.addAction('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered', this.setPlugins);
|
|
1055
|
-
hooks_1.addAction('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered', this.setPlugins);
|
|
1056
|
-
this.setPlugins();
|
|
1057
|
-
}
|
|
1058
|
-
componentWillUnMount() {
|
|
1059
|
-
hooks_1.removeAction('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered');
|
|
1060
|
-
hooks_1.removeAction('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered');
|
|
1061
|
-
}
|
|
1062
|
-
setPlugins() {
|
|
1063
|
-
this.setState(this.getCurrentPluginsState);
|
|
1064
|
-
}
|
|
1065
|
-
render() {
|
|
1066
|
-
return (React.createElement("div", { style: { display: 'none' } }, lodash_1.map(this.state.plugins, ({ context, Plugin }) => (React.createElement(plugin_context_1.PluginContextProvider, { key: context.name, value: context },
|
|
1067
|
-
React.createElement(Plugin, null))))));
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
exports.RouteBasedPluginArea = RouteBasedPluginArea;
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
/***/ }),
|
|
1074
|
-
|
|
1075
|
-
/***/ "./src/route/index.ts":
|
|
1076
|
-
/*!****************************!*\
|
|
1077
|
-
!*** ./src/route/index.ts ***!
|
|
1078
|
-
\****************************/
|
|
1079
|
-
/*! no static exports found */
|
|
1080
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1081
|
-
|
|
1082
|
-
"use strict";
|
|
1083
|
-
|
|
1084
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1085
|
-
if (k2 === undefined) k2 = k;
|
|
1086
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
1087
|
-
}) : (function(o, m, k, k2) {
|
|
1088
|
-
if (k2 === undefined) k2 = k;
|
|
1089
|
-
o[k2] = m[k];
|
|
1090
|
-
}));
|
|
1091
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
1092
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1093
|
-
};
|
|
1094
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1095
|
-
__exportStar(__webpack_require__(/*! ./render-routes */ "./src/route/render-routes.tsx"), exports);
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
/***/ }),
|
|
1099
|
-
|
|
1100
|
-
/***/ "./src/route/render-routes.tsx":
|
|
1101
|
-
/*!*************************************!*\
|
|
1102
|
-
!*** ./src/route/render-routes.tsx ***!
|
|
1103
|
-
\*************************************/
|
|
1104
|
-
/*! no static exports found */
|
|
1105
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1106
|
-
|
|
1107
|
-
"use strict";
|
|
1108
|
-
|
|
1109
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1110
|
-
if (k2 === undefined) k2 = k;
|
|
1111
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
1112
|
-
}) : (function(o, m, k, k2) {
|
|
1113
|
-
if (k2 === undefined) k2 = k;
|
|
1114
|
-
o[k2] = m[k];
|
|
1115
|
-
}));
|
|
1116
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
1117
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1118
|
-
}) : function(o, v) {
|
|
1119
|
-
o["default"] = v;
|
|
1120
|
-
});
|
|
1121
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
1122
|
-
if (mod && mod.__esModule) return mod;
|
|
1123
|
-
var result = {};
|
|
1124
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
1125
|
-
__setModuleDefault(result, mod);
|
|
1126
|
-
return result;
|
|
1127
|
-
};
|
|
1128
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
1129
|
-
var t = {};
|
|
1130
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
1131
|
-
t[p] = s[p];
|
|
1132
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
1133
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
1134
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
1135
|
-
t[p[i]] = s[p[i]];
|
|
1136
|
-
}
|
|
1137
|
-
return t;
|
|
1138
|
-
};
|
|
1139
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1140
|
-
exports.renderRoutes2 = void 0;
|
|
1141
|
-
const React = __importStar(__webpack_require__(/*! react */ "react"));
|
|
1142
|
-
const react_1 = __webpack_require__(/*! react */ "react");
|
|
1143
|
-
const react_router_1 = __webpack_require__(/*! react-router */ "react-router");
|
|
1144
|
-
function wrapInitialPropsFetch(route, opts) {
|
|
1145
|
-
const { component } = route, restRouteParams = __rest(route, ["component"]);
|
|
1146
|
-
let Component = route.component;
|
|
1147
|
-
function ComponentWithInitialPropsFetch(props) {
|
|
1148
|
-
const [initialProps, setInitialProps] = react_1.useState(() => window.g_initialProps);
|
|
1149
|
-
react_1.useEffect(() => {
|
|
1150
|
-
/**
|
|
1151
|
-
* 1. 首次渲染时,此时 window.g_initialProps 变量存在,不需要再走一次 getInitialProps,这样一次 SSR 就走了 2 次 getInitialProps
|
|
1152
|
-
* 2. 但是路由切换时,window.getInitialProps 会被赋为 null,这时候就走 getInitialProps 逻辑
|
|
1153
|
-
* 3. 如果任何时候都走 2 次,配置 forceInitial: true,这个场景用于静态站点的首屏加载希望走最新数据
|
|
1154
|
-
* 4. 开启动态加载后,会在执行 getInitialProps 前预加载下
|
|
1155
|
-
*/
|
|
1156
|
-
const handleGetInitialProps = async () => {
|
|
1157
|
-
// preload when enalbe dynamicImport
|
|
1158
|
-
if (Component.preload) {
|
|
1159
|
-
const preloadComponent = await Component.preload();
|
|
1160
|
-
// for test case, really use .default
|
|
1161
|
-
Component = preloadComponent.default || preloadComponent;
|
|
1162
|
-
}
|
|
1163
|
-
//@sri not suppported
|
|
1164
|
-
// const defaultCtx = {
|
|
1165
|
-
// isServer: false,
|
|
1166
|
-
// match: props?.match,
|
|
1167
|
-
// route,
|
|
1168
|
-
// ...(opts.getInitialPropsCtx || {}),
|
|
1169
|
-
// ...restRouteParams,
|
|
1170
|
-
// };
|
|
1171
|
-
//@sri not suppported
|
|
1172
|
-
// if (Component?.getInitialProps) {
|
|
1173
|
-
// const ctx = await opts.plugin.applyPlugins({
|
|
1174
|
-
// key: 'ssr.modifyGetInitialPropsCtx',
|
|
1175
|
-
// type: ApplyPluginsType.modify,
|
|
1176
|
-
// initialValue: defaultCtx,
|
|
1177
|
-
// async: true,
|
|
1178
|
-
// });
|
|
1179
|
-
// const initialProps = await Component!.getInitialProps!(
|
|
1180
|
-
// ctx || defaultCtx,
|
|
1181
|
-
// );
|
|
1182
|
-
// setInitialProps(initialProps);
|
|
1183
|
-
// }
|
|
1184
|
-
};
|
|
1185
|
-
// null 时,一定会触发 getInitialProps 执行
|
|
1186
|
-
if (!window.g_initialProps) {
|
|
1187
|
-
handleGetInitialProps();
|
|
1188
|
-
}
|
|
1189
|
-
}, [window.location.pathname, window.location.search]);
|
|
1190
|
-
return React.createElement(Component, Object.assign({}, props, initialProps));
|
|
1191
|
-
}
|
|
1192
|
-
// flag for having wrappered
|
|
1193
|
-
ComponentWithInitialPropsFetch.wrapInitialPropsLoaded = true;
|
|
1194
|
-
ComponentWithInitialPropsFetch.displayName = 'ComponentWithInitialPropsFetch';
|
|
1195
|
-
return ComponentWithInitialPropsFetch;
|
|
1196
|
-
}
|
|
1197
|
-
function render({ route, opts, props, }) {
|
|
1198
|
-
const routes = renderRoutes(Object.assign(Object.assign({}, opts), { routes: route.routes || [], rootRoutes: opts.rootRoutes }));
|
|
1199
|
-
let { component: Component, wrappers } = route;
|
|
1200
|
-
if (Component) {
|
|
1201
|
-
const defaultPageInitialProps = opts.isServer
|
|
1202
|
-
? {}
|
|
1203
|
-
: window.g_initialProps;
|
|
1204
|
-
const newProps = Object.assign(Object.assign(Object.assign(Object.assign({}, props), opts.extraProps), (opts.pageInitialProps || defaultPageInitialProps)), { route, routes: opts.rootRoutes });
|
|
1205
|
-
// @ts-ignore
|
|
1206
|
-
let ret = React.createElement(Component, Object.assign({}, newProps), routes);
|
|
1207
|
-
// route.wrappers
|
|
1208
|
-
if (wrappers) {
|
|
1209
|
-
let len = wrappers.length - 1;
|
|
1210
|
-
while (len >= 0) {
|
|
1211
|
-
ret = react_1.createElement(wrappers[len], newProps, ret);
|
|
1212
|
-
len -= 1;
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
return ret;
|
|
1216
|
-
}
|
|
1217
|
-
else {
|
|
1218
|
-
return routes;
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
function getRouteElement({ route, index, opts }) {
|
|
1222
|
-
const routeProps = {
|
|
1223
|
-
key: route.key || index,
|
|
1224
|
-
exact: route.exact,
|
|
1225
|
-
strict: route.strict,
|
|
1226
|
-
sensitive: route.sensitive,
|
|
1227
|
-
path: route.path,
|
|
1228
|
-
};
|
|
1229
|
-
if (route.redirect) {
|
|
1230
|
-
return React.createElement(react_router_1.Redirect, Object.assign({}, routeProps, { from: route.path, to: route.redirect }));
|
|
1231
|
-
}
|
|
1232
|
-
else {
|
|
1233
|
-
// avoid mount and unmount with url hash change
|
|
1234
|
-
// @sri not supproted yet
|
|
1235
|
-
// if (
|
|
1236
|
-
// // only when SSR config enable
|
|
1237
|
-
// opts.ssrProps &&
|
|
1238
|
-
// !opts.isServer &&
|
|
1239
|
-
// // make sure loaded once
|
|
1240
|
-
// !(route.component as any)?.wrapInitialPropsLoaded &&
|
|
1241
|
-
// (route.component?.getInitialProps || route.component?.preload)
|
|
1242
|
-
// ) {
|
|
1243
|
-
// // client Render for enable ssr, but not sure SSR success
|
|
1244
|
-
// route.component = wrapInitialPropsFetch(route, opts);
|
|
1245
|
-
// }
|
|
1246
|
-
return (React.createElement(react_router_1.Route, Object.assign({}, routeProps, { render: (props) => {
|
|
1247
|
-
return render({ route, opts, props });
|
|
1248
|
-
} })));
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
function renderRoutes(opts) {
|
|
1252
|
-
return opts.routes ? (React.createElement(react_router_1.Switch, null, opts.routes.map((route, index) => {
|
|
1253
|
-
const renderedR = getRouteElement({
|
|
1254
|
-
route,
|
|
1255
|
-
index,
|
|
1256
|
-
opts: Object.assign(Object.assign({}, opts), { rootRoutes: opts.rootRoutes || opts.routes }),
|
|
1257
|
-
});
|
|
1258
|
-
return renderedR;
|
|
1259
|
-
}))) : null;
|
|
1260
|
-
}
|
|
1261
|
-
exports.renderRoutes2 = renderRoutes;
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
/***/ }),
|
|
1265
|
-
|
|
1266
|
-
/***/ "./src/router/index.ts":
|
|
1267
|
-
/*!*****************************!*\
|
|
1268
|
-
!*** ./src/router/index.ts ***!
|
|
1269
|
-
\*****************************/
|
|
1270
|
-
/*! no static exports found */
|
|
1271
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1272
|
-
|
|
1273
|
-
"use strict";
|
|
1274
|
-
|
|
1275
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1276
|
-
if (k2 === undefined) k2 = k;
|
|
1277
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
1278
|
-
}) : (function(o, m, k, k2) {
|
|
1279
|
-
if (k2 === undefined) k2 = k;
|
|
1280
|
-
o[k2] = m[k];
|
|
1281
|
-
}));
|
|
1282
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
1283
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1284
|
-
};
|
|
1285
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1286
|
-
__exportStar(__webpack_require__(/*! ./router */ "./src/router/router.tsx"), exports);
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
/***/ }),
|
|
1290
|
-
|
|
1291
|
-
/***/ "./src/router/router.tsx":
|
|
1292
|
-
/*!*******************************!*\
|
|
1293
|
-
!*** ./src/router/router.tsx ***!
|
|
1294
|
-
\*******************************/
|
|
1295
|
-
/*! no static exports found */
|
|
1296
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1297
|
-
|
|
1298
|
-
"use strict";
|
|
1299
|
-
|
|
1300
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1301
|
-
if (k2 === undefined) k2 = k;
|
|
1302
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
1303
|
-
}) : (function(o, m, k, k2) {
|
|
1304
|
-
if (k2 === undefined) k2 = k;
|
|
1305
|
-
o[k2] = m[k];
|
|
1306
|
-
}));
|
|
1307
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
1308
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1309
|
-
}) : function(o, v) {
|
|
1310
|
-
o["default"] = v;
|
|
1311
|
-
});
|
|
1312
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
1313
|
-
if (mod && mod.__esModule) return mod;
|
|
1314
|
-
var result = {};
|
|
1315
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
1316
|
-
__setModuleDefault(result, mod);
|
|
1317
|
-
return result;
|
|
1318
|
-
};
|
|
1319
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1320
|
-
exports.FeatureWithRouterFactory = void 0;
|
|
1321
|
-
const React = __importStar(__webpack_require__(/*! react */ "react"));
|
|
1322
|
-
const react_router_dom_1 = __webpack_require__(/*! react-router-dom */ "react-router-dom");
|
|
1323
|
-
const connector_1 = __webpack_require__(/*! ../connector */ "./src/connector/index.ts");
|
|
1324
|
-
const routerFactory = (routes) => React.createElement(react_router_dom_1.Switch, null, routes);
|
|
1325
|
-
exports.FeatureWithRouterFactory = new connector_1.Feature({
|
|
1326
|
-
routerFactory,
|
|
1327
|
-
});
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
/***/ }),
|
|
1331
|
-
|
|
1332
|
-
/***/ "./src/utils/index.ts":
|
|
1333
|
-
/*!****************************!*\
|
|
1334
|
-
!*** ./src/utils/index.ts ***!
|
|
1335
|
-
\****************************/
|
|
1336
|
-
/*! no static exports found */
|
|
1337
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1338
|
-
|
|
1339
|
-
"use strict";
|
|
1340
|
-
|
|
1341
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1342
|
-
if (k2 === undefined) k2 = k;
|
|
1343
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
1344
|
-
}) : (function(o, m, k, k2) {
|
|
1345
|
-
if (k2 === undefined) k2 = k;
|
|
1346
|
-
o[k2] = m[k];
|
|
1347
|
-
}));
|
|
1348
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
1349
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1350
|
-
};
|
|
1351
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1352
|
-
__exportStar(__webpack_require__(/*! ./route-utils */ "./src/utils/route-utils.tsx"), exports);
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
/***/ }),
|
|
1356
|
-
|
|
1357
|
-
/***/ "./src/utils/route-utils.tsx":
|
|
1358
|
-
/*!***********************************!*\
|
|
1359
|
-
!*** ./src/utils/route-utils.tsx ***!
|
|
1360
|
-
\***********************************/
|
|
1361
|
-
/*! no static exports found */
|
|
1362
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1363
|
-
|
|
1364
|
-
"use strict";
|
|
1365
|
-
|
|
1366
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1367
|
-
if (k2 === undefined) k2 = k;
|
|
1368
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
1369
|
-
}) : (function(o, m, k, k2) {
|
|
1370
|
-
if (k2 === undefined) k2 = k;
|
|
1371
|
-
o[k2] = m[k];
|
|
1372
|
-
}));
|
|
1373
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
1374
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1375
|
-
}) : function(o, v) {
|
|
1376
|
-
o["default"] = v;
|
|
1377
|
-
});
|
|
1378
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
1379
|
-
if (mod && mod.__esModule) return mod;
|
|
1380
|
-
var result = {};
|
|
1381
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
1382
|
-
__setModuleDefault(result, mod);
|
|
1383
|
-
return result;
|
|
1384
|
-
};
|
|
1385
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
1386
|
-
var t = {};
|
|
1387
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
1388
|
-
t[p] = s[p];
|
|
1389
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
1390
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
1391
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
1392
|
-
t[p[i]] = s[p[i]];
|
|
1393
|
-
}
|
|
1394
|
-
return t;
|
|
1395
|
-
};
|
|
1396
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1397
|
-
exports.getSortedRoutes = exports.sortKeys = exports.renderRoutes = exports.getMenus = exports.getRoutes = exports.getRoutes2 = exports.isUrl = void 0;
|
|
1398
|
-
const React = __importStar(__webpack_require__(/*! react */ "react"));
|
|
1399
|
-
const interfaces_1 = __webpack_require__(/*! ../interfaces */ "./src/interfaces/index.ts");
|
|
1400
|
-
const react_router_dom_1 = __webpack_require__(/*! react-router-dom */ "react-router-dom");
|
|
1401
|
-
const defaultSortKeys = __webpack_require__(/*! sort-keys */ "sort-keys");
|
|
1402
|
-
/* eslint no-useless-escape:0 */
|
|
1403
|
-
const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/g;
|
|
1404
|
-
function isUrl(path) {
|
|
1405
|
-
return reg.test(path);
|
|
1406
|
-
}
|
|
1407
|
-
exports.isUrl = isUrl;
|
|
1408
|
-
/**
|
|
1409
|
-
* Generates Routes based on the key value, where key has the path of the route and value
|
|
1410
|
-
* has rest of the values for building a `<Router ../>` component.
|
|
1411
|
-
*
|
|
1412
|
-
* @param path: RegExp
|
|
1413
|
-
* @param routerData
|
|
1414
|
-
* @deprecated
|
|
1415
|
-
*/
|
|
1416
|
-
function getRoutes2(path, routerData) {
|
|
1417
|
-
const routes = Object.keys(routerData).filter(routePath => {
|
|
1418
|
-
return routePath.match(path);
|
|
1419
|
-
});
|
|
1420
|
-
const mappedRoutes = routes.map(paths => {
|
|
1421
|
-
return Object.assign({ route: paths }, routerData[paths]);
|
|
1422
|
-
});
|
|
1423
|
-
const root = {};
|
|
1424
|
-
mappedRoutes.forEach(eachRoute => {
|
|
1425
|
-
const children = eachRoute.route.split('/');
|
|
1426
|
-
children.shift();
|
|
1427
|
-
// if the route is `/` then add this correction.
|
|
1428
|
-
if (eachRoute.route === '/') {
|
|
1429
|
-
children.shift();
|
|
1430
|
-
children.push('/');
|
|
1431
|
-
}
|
|
1432
|
-
const depth = children.length;
|
|
1433
|
-
let lastNode = root;
|
|
1434
|
-
for (let i = 0; i <= depth; i++) {
|
|
1435
|
-
const lastIndex = (lastNode.routes || []).findIndex(item => {
|
|
1436
|
-
if (eachRoute.route.startsWith(item.path)) {
|
|
1437
|
-
return eachRoute.route[item.path.length] === '/';
|
|
1438
|
-
}
|
|
1439
|
-
});
|
|
1440
|
-
if (lastIndex === -1) {
|
|
1441
|
-
break;
|
|
1442
|
-
}
|
|
1443
|
-
lastNode = lastNode.routes[lastIndex];
|
|
1444
|
-
// do not overwrite the route's exact value
|
|
1445
|
-
lastNode.exact = routerData[lastNode.path].hasOwnProperty('exact') ? routerData[lastNode.path].exact : false;
|
|
1446
|
-
}
|
|
1447
|
-
if (!lastNode.routes) {
|
|
1448
|
-
lastNode.routes = [];
|
|
1449
|
-
}
|
|
1450
|
-
const modfiedRoute = formatSlash(eachRoute.route);
|
|
1451
|
-
lastNode.routes.push(Object.assign(Object.assign({}, eachRoute), {
|
|
1452
|
-
// route: modfiedRoute,
|
|
1453
|
-
path: modfiedRoute, exact: routerData[eachRoute.route].hasOwnProperty('exact') ? routerData[eachRoute.route].exact : true, component: eachRoute.component }));
|
|
1454
|
-
});
|
|
1455
|
-
return root.routes;
|
|
1456
|
-
}
|
|
1457
|
-
exports.getRoutes2 = getRoutes2;
|
|
1458
|
-
const startWithMoreThanOneSlash = /^(\/)\1+/; // for exame `//abc, ///abc, ...`
|
|
1459
|
-
const formatSlash = (route) => {
|
|
1460
|
-
// replaced `//` with `/` in the routes.
|
|
1461
|
-
return {
|
|
1462
|
-
path: route.replace(startWithMoreThanOneSlash, '/'),
|
|
1463
|
-
_pathPrefix: (route.match(/^\/(\/{1,})/) || ['', ''])[1],
|
|
1464
|
-
};
|
|
1465
|
-
};
|
|
1466
|
-
function getRoutes(path, routeData, authWrapper = null) {
|
|
1467
|
-
if (!path.startsWith('/')) {
|
|
1468
|
-
throw new Error('Invalid path!');
|
|
1469
|
-
}
|
|
1470
|
-
let searchPath = path;
|
|
1471
|
-
if (path[path.length - 1] !== '/') {
|
|
1472
|
-
searchPath = path + '/';
|
|
1473
|
-
}
|
|
1474
|
-
const routes = Object.keys(routeData).filter(menuPath => {
|
|
1475
|
-
return menuPath.indexOf(searchPath) === 0 || menuPath === path;
|
|
1476
|
-
});
|
|
1477
|
-
const mappedMenuPaths = routes.map(mPath => {
|
|
1478
|
-
return Object.assign({ route: mPath, position: interfaces_1.IMenuPosition.MIDDLE }, routeData[mPath]);
|
|
1479
|
-
});
|
|
1480
|
-
const root = {
|
|
1481
|
-
// just to satisfy types added following
|
|
1482
|
-
// TOOD need to correct types so we don't have to enter them.
|
|
1483
|
-
name: 'root',
|
|
1484
|
-
position: interfaces_1.IMenuPosition.LOGO,
|
|
1485
|
-
};
|
|
1486
|
-
mappedMenuPaths.forEach(routeItem => {
|
|
1487
|
-
const children = routeItem.route.split('/');
|
|
1488
|
-
children.shift();
|
|
1489
|
-
// if the route is `/` then add this correction.
|
|
1490
|
-
if (routeItem.path === '/') {
|
|
1491
|
-
children.shift();
|
|
1492
|
-
children.push('/');
|
|
1493
|
-
}
|
|
1494
|
-
const depth = children.length;
|
|
1495
|
-
let lastNode = root;
|
|
1496
|
-
for (let i = 0; i < depth; i++) {
|
|
1497
|
-
const lastIndex = (lastNode.routes || []).findIndex(item => {
|
|
1498
|
-
const routePath = `${item._pathPrefix}${item.path}`;
|
|
1499
|
-
if (routeItem.route.startsWith(routePath)) {
|
|
1500
|
-
return routeItem.route[routePath.length] === '/';
|
|
1501
|
-
}
|
|
1502
|
-
});
|
|
1503
|
-
if (lastIndex === -1) {
|
|
1504
|
-
break;
|
|
1505
|
-
}
|
|
1506
|
-
lastNode = lastNode.routes[lastIndex];
|
|
1507
|
-
const lastNodePath = `${lastNode._pathPrefix}${lastNode.path}`;
|
|
1508
|
-
lastNode.exact = routeData[lastNodePath].hasOwnProperty('exact') ? routeData[lastNodePath].exact : false;
|
|
1509
|
-
}
|
|
1510
|
-
if (!lastNode.routes) {
|
|
1511
|
-
lastNode.routes = [];
|
|
1512
|
-
}
|
|
1513
|
-
const { route: ignore, auth } = routeItem, rest = __rest(routeItem, ["route", "auth"]);
|
|
1514
|
-
const pathParams = formatSlash(routeItem.route);
|
|
1515
|
-
lastNode.routes.push(Object.assign(Object.assign(Object.assign({}, rest), pathParams), { exact: routeData[routeItem.route].hasOwnProperty('exact') ? routeData[routeItem.route].exact : true,
|
|
1516
|
-
/**
|
|
1517
|
-
* Here we are checking whether auth property is being
|
|
1518
|
-
* set by this route and if authWrapper is declared
|
|
1519
|
-
* which is a high order component that can take a component
|
|
1520
|
-
* and its props as argument then perform some
|
|
1521
|
-
* computation and return a component
|
|
1522
|
-
*/
|
|
1523
|
-
component: auth && authWrapper
|
|
1524
|
-
? (props) => authWrapper(routeItem.component, props)
|
|
1525
|
-
: routeItem.component }));
|
|
1526
|
-
});
|
|
1527
|
-
return root.routes;
|
|
1528
|
-
}
|
|
1529
|
-
exports.getRoutes = getRoutes;
|
|
1530
|
-
function getMenus(path, menuData) {
|
|
1531
|
-
if (!path.startsWith('/')) {
|
|
1532
|
-
throw new Error('Invalid path!');
|
|
1533
|
-
}
|
|
1534
|
-
let searchPath = path;
|
|
1535
|
-
if (path[path.length - 1] !== '/') {
|
|
1536
|
-
searchPath = path + '/';
|
|
1537
|
-
}
|
|
1538
|
-
const routes = Object.keys(menuData).filter(menuPath => {
|
|
1539
|
-
return menuPath.indexOf(searchPath) === 0 || menuPath === path;
|
|
1540
|
-
});
|
|
1541
|
-
const mappedMenuPaths = routes.map(mPath => {
|
|
1542
|
-
return Object.assign({ route: mPath, position: interfaces_1.IMenuPosition.MIDDLE }, menuData[mPath]);
|
|
1543
|
-
});
|
|
1544
|
-
const root = {
|
|
1545
|
-
// just to satisfy types added following
|
|
1546
|
-
// TOOD need to correct types so we don't have to enter them.
|
|
1547
|
-
name: 'root',
|
|
1548
|
-
position: interfaces_1.IMenuPosition.LOGO,
|
|
1549
|
-
};
|
|
1550
|
-
mappedMenuPaths.forEach(menutItem => {
|
|
1551
|
-
const children = menutItem.route.split('/');
|
|
1552
|
-
children.shift();
|
|
1553
|
-
const depth = children.length;
|
|
1554
|
-
let lastNode = root;
|
|
1555
|
-
for (let i = 0; i < depth; i++) {
|
|
1556
|
-
const lastIndex = (lastNode.children || []).findIndex(item => {
|
|
1557
|
-
if (menutItem.route.startsWith(item.path)) {
|
|
1558
|
-
return menutItem.route[item.path.length] === '/';
|
|
1559
|
-
}
|
|
1560
|
-
});
|
|
1561
|
-
if (lastIndex === -1) {
|
|
1562
|
-
break;
|
|
1563
|
-
}
|
|
1564
|
-
lastNode = lastNode.children[lastIndex];
|
|
1565
|
-
// do not overwrite the route's exact value
|
|
1566
|
-
lastNode.exact = menuData[lastNode.path].hasOwnProperty('exact') ? menuData[lastNode.path].exact : false;
|
|
1567
|
-
}
|
|
1568
|
-
if (!lastNode.children) {
|
|
1569
|
-
lastNode.children = [];
|
|
1570
|
-
}
|
|
1571
|
-
const { route: ignore } = menutItem, rest = __rest(menutItem, ["route"]);
|
|
1572
|
-
lastNode.children.push(Object.assign(Object.assign({ path: menutItem.route }, rest), { exact: menuData[menutItem.route].hasOwnProperty('exact') ? menuData[menutItem.route].exact : true }));
|
|
1573
|
-
});
|
|
1574
|
-
return root.children;
|
|
1575
|
-
}
|
|
1576
|
-
exports.getMenus = getMenus;
|
|
1577
|
-
const renderRoutes = (routes, solidRoutes, extraProps = {}, switchProps = {}) => routes ? (React.createElement(React.Fragment, null, [
|
|
1578
|
-
...solidRoutes,
|
|
1579
|
-
...routes.map((route, i) => (React.createElement(react_router_dom_1.Route, { key: route.key || i, path: route.path, exact: route.exact, strict: route.strict, render: props => route.render ? (route.render(Object.assign(Object.assign(Object.assign({}, props), extraProps), { route: route }))) : (React.createElement(route.component, Object.assign({}, props, extraProps, { route: route }))) }))),
|
|
1580
|
-
])) : null;
|
|
1581
|
-
exports.renderRoutes = renderRoutes;
|
|
1582
|
-
function sortKeys(routeData) {
|
|
1583
|
-
return defaultSortKeys(routeData, { compare });
|
|
1584
|
-
}
|
|
1585
|
-
exports.sortKeys = sortKeys;
|
|
1586
|
-
const getSortedRoutes = (path, routeData, authWrapper = null) => {
|
|
1587
|
-
const sortedRoutes = sortKeys(routeData);
|
|
1588
|
-
return getRoutes(path, sortedRoutes, authWrapper);
|
|
1589
|
-
};
|
|
1590
|
-
exports.getSortedRoutes = getSortedRoutes;
|
|
1591
|
-
const compare = ((a, b) => {
|
|
1592
|
-
const aStr = String(a).toLowerCase();
|
|
1593
|
-
const bStr = String(b).toLowerCase();
|
|
1594
|
-
// Alphanumeric elements always come before non-alphanumeric elements
|
|
1595
|
-
const aIsAlphanumeric = notStartWithColon(aStr);
|
|
1596
|
-
const bIsAlphanumeric = notStartWithColon(bStr);
|
|
1597
|
-
if (aIsAlphanumeric + bIsAlphanumeric !== -2) {
|
|
1598
|
-
if (aIsAlphanumeric * bIsAlphanumeric > 0) {
|
|
1599
|
-
if (aIsAlphanumeric === bIsAlphanumeric) {
|
|
1600
|
-
return aStr.localeCompare(bStr);
|
|
1601
|
-
}
|
|
1602
|
-
return aIsAlphanumeric - bIsAlphanumeric;
|
|
1603
|
-
}
|
|
1604
|
-
if (aIsAlphanumeric > 0) {
|
|
1605
|
-
return -1;
|
|
1606
|
-
}
|
|
1607
|
-
else if (bIsAlphanumeric > 0) {
|
|
1608
|
-
return 1;
|
|
1609
|
-
}
|
|
1610
|
-
}
|
|
1611
|
-
// Numerical elements always come before alphabetic elements
|
|
1612
|
-
const aNum = Number(a);
|
|
1613
|
-
const bNum = Number(b);
|
|
1614
|
-
// If both are numerical, sort in the usual fashion (smaller goes first)
|
|
1615
|
-
if (aNum && bNum) {
|
|
1616
|
-
return aNum - bNum;
|
|
1617
|
-
// If a is numerical but b isn't, put a first.
|
|
1618
|
-
}
|
|
1619
|
-
else if (aNum) {
|
|
1620
|
-
return -1;
|
|
1621
|
-
// If b is numerical but a isn't, put b first.
|
|
1622
|
-
}
|
|
1623
|
-
else if (bNum) {
|
|
1624
|
-
return 1;
|
|
1625
|
-
}
|
|
1626
|
-
// In all other cases, default to usual sort order.
|
|
1627
|
-
return aStr.localeCompare(bStr);
|
|
1628
|
-
});
|
|
1629
|
-
function notStartWithColon(str) {
|
|
1630
|
-
const match = (str.match(/^[\/, *, :]{1,}/) || [-1])[0];
|
|
1631
|
-
if (match === -1) {
|
|
1632
|
-
return -1;
|
|
1633
|
-
}
|
|
1634
|
-
var i = match.length;
|
|
1635
|
-
let count = 0;
|
|
1636
|
-
while (i--) {
|
|
1637
|
-
const char = match[i];
|
|
1638
|
-
if (char === '/') {
|
|
1639
|
-
if (str === '/') { // if it is root only we put at the last
|
|
1640
|
-
count = count + 6;
|
|
1641
|
-
}
|
|
1642
|
-
else {
|
|
1643
|
-
count = count + 3;
|
|
1644
|
-
}
|
|
1645
|
-
}
|
|
1646
|
-
else if (char === ':') {
|
|
1647
|
-
count = count + 1;
|
|
1648
|
-
}
|
|
1649
|
-
else if (char === '*') {
|
|
1650
|
-
count = count + 2;
|
|
1651
|
-
}
|
|
1652
|
-
}
|
|
1653
|
-
return count;
|
|
1654
|
-
}
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
/***/ }),
|
|
1658
|
-
|
|
1659
|
-
/***/ "@common-stack/client-core":
|
|
1660
|
-
/*!********************************************!*\
|
|
1661
|
-
!*** external "@common-stack/client-core" ***!
|
|
1662
|
-
\********************************************/
|
|
1663
|
-
/*! no static exports found */
|
|
1664
|
-
/***/ (function(module, exports) {
|
|
1665
|
-
|
|
1666
|
-
module.exports = require("@common-stack/client-core");
|
|
1667
|
-
|
|
1668
|
-
/***/ }),
|
|
1669
|
-
|
|
1670
|
-
/***/ "@wordpress/hooks":
|
|
1671
|
-
/*!***********************************!*\
|
|
1672
|
-
!*** external "@wordpress/hooks" ***!
|
|
1673
|
-
\***********************************/
|
|
1674
|
-
/*! no static exports found */
|
|
1675
|
-
/***/ (function(module, exports) {
|
|
1676
|
-
|
|
1677
|
-
module.exports = require("@wordpress/hooks");
|
|
1678
|
-
|
|
1679
|
-
/***/ }),
|
|
1680
|
-
|
|
1681
|
-
/***/ "lodash":
|
|
1682
|
-
/*!*************************!*\
|
|
1683
|
-
!*** external "lodash" ***!
|
|
1684
|
-
\*************************/
|
|
1685
|
-
/*! no static exports found */
|
|
1686
|
-
/***/ (function(module, exports) {
|
|
1687
|
-
|
|
1688
|
-
module.exports = require("lodash");
|
|
1689
|
-
|
|
1690
|
-
/***/ }),
|
|
1691
|
-
|
|
1692
|
-
/***/ "react":
|
|
1693
|
-
/*!************************!*\
|
|
1694
|
-
!*** external "react" ***!
|
|
1695
|
-
\************************/
|
|
1696
|
-
/*! no static exports found */
|
|
1697
|
-
/***/ (function(module, exports) {
|
|
1698
|
-
|
|
1699
|
-
module.exports = require("react");
|
|
1700
|
-
|
|
1701
|
-
/***/ }),
|
|
1702
|
-
|
|
1703
|
-
/***/ "react-router":
|
|
1704
|
-
/*!*******************************!*\
|
|
1705
|
-
!*** external "react-router" ***!
|
|
1706
|
-
\*******************************/
|
|
1707
|
-
/*! no static exports found */
|
|
1708
|
-
/***/ (function(module, exports) {
|
|
1709
|
-
|
|
1710
|
-
module.exports = require("react-router");
|
|
1711
|
-
|
|
1712
|
-
/***/ }),
|
|
1713
|
-
|
|
1714
|
-
/***/ "react-router-dom":
|
|
1715
|
-
/*!***********************************!*\
|
|
1716
|
-
!*** external "react-router-dom" ***!
|
|
1717
|
-
\***********************************/
|
|
1718
|
-
/*! no static exports found */
|
|
1719
|
-
/***/ (function(module, exports) {
|
|
1720
|
-
|
|
1721
|
-
module.exports = require("react-router-dom");
|
|
1722
|
-
|
|
1723
|
-
/***/ }),
|
|
1724
|
-
|
|
1725
|
-
/***/ "sort-keys":
|
|
1726
|
-
/*!****************************!*\
|
|
1727
|
-
!*** external "sort-keys" ***!
|
|
1728
|
-
\****************************/
|
|
1729
|
-
/*! no static exports found */
|
|
1730
|
-
/***/ (function(module, exports) {
|
|
1731
|
-
|
|
1732
|
-
module.exports = require("sort-keys");
|
|
1733
|
-
|
|
1734
|
-
/***/ })
|
|
1735
|
-
|
|
1736
|
-
/******/ });
|
|
16
|
+
__exportStar(require("./connector"), exports);
|
|
17
|
+
__exportStar(require("./router-factory"), exports);
|
|
18
|
+
__exportStar(require("./route"), exports);
|
|
19
|
+
__exportStar(require("./utils"), exports);
|
|
20
|
+
__exportStar(require("./interfaces"), exports);
|
|
21
|
+
__exportStar(require("./plugin-area"), exports);
|
|
22
|
+
__exportStar(require("./route-based-plugin-area"), exports);
|
|
23
|
+
__exportStar(require("./inversify"), exports);
|
|
1737
24
|
//# sourceMappingURL=index.js.map
|