cascade-extend 1.0.2 → 1.0.3
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/LICENSE +3 -0
- package/README.md +0 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -237
- package/dist/index.js.map +1 -1
- package/package.json +21 -67
- package/babel.config.js +0 -13
- package/build/config.js +0 -4
- package/build/front/build.js +0 -41
- package/build/front/config.js +0 -19
- package/build/front/utils.js +0 -64
- package/build/front/webpack.base.conf.js +0 -74
- package/build/front/webpack.prod.conf.js +0 -36
- package/src/main.mjs +0 -30
- package/test/test.mjs +0 -28
package/LICENSE
ADDED
package/README.md
CHANGED
|
File without changes
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function cascadeExtendKeys(scope: object, source: object | undefined, prefix?: string, sep?: string): string[] | undefined;
|
|
2
|
+
export declare function cascadeExtend(scope: object, source: object | undefined, prefix?: string, sep?: string): object | undefined;
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,MAAM,CAAC,EAAE,MAAM,EACf,GAAG,GAAE,MAAY,GAChB,MAAM,EAAE,GAAG,SAAS,CAqBtB;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,MAAM,CAAC,EAAE,MAAM,EACf,GAAG,GAAE,MAAY,GAChB,MAAM,GAAG,SAAS,CAapB"}
|
package/dist/index.js
CHANGED
|
@@ -1,240 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
configurable: true,
|
|
48
|
-
value: options.newValue,
|
|
49
|
-
writable: true
|
|
50
|
-
});
|
|
51
|
-
} else {
|
|
52
|
-
// eslint-disable-next-line no-param-reassign
|
|
53
|
-
target[options.name] = options.newValue;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// Return undefined instead of __proto__ if '__proto__' is not an own property
|
|
58
|
-
var getProperty = function getProperty(obj, name) {
|
|
59
|
-
if (name === '__proto__') {
|
|
60
|
-
if (!hasOwn.call(obj, name)) {
|
|
61
|
-
return void 0;
|
|
62
|
-
} else if (gOPD) {
|
|
63
|
-
// In early versions of node, obj['__proto__'] is buggy when obj has __proto__ as an own property. Object.getOwnPropertyDescriptor() works.
|
|
64
|
-
return gOPD(obj, name).value;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return obj[name];
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
module.exports = function extend() {
|
|
72
|
-
var options, name, src, copy, copyIsArray, clone;
|
|
73
|
-
var target = arguments[0];
|
|
74
|
-
var i = 1;
|
|
75
|
-
var length = arguments.length;
|
|
76
|
-
var deep = false;
|
|
77
|
-
|
|
78
|
-
// Handle a deep copy situation
|
|
79
|
-
if (typeof target === 'boolean') {
|
|
80
|
-
deep = target;
|
|
81
|
-
target = arguments[1] || {};
|
|
82
|
-
// skip the boolean and the target
|
|
83
|
-
i = 2;
|
|
84
|
-
}
|
|
85
|
-
if (target == null || (typeof target !== 'object' && typeof target !== 'function')) {
|
|
86
|
-
target = {};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
for (; i < length; ++i) {
|
|
90
|
-
options = arguments[i];
|
|
91
|
-
// Only deal with non-null/undefined values
|
|
92
|
-
if (options != null) {
|
|
93
|
-
// Extend the base object
|
|
94
|
-
for (name in options) {
|
|
95
|
-
src = getProperty(target, name);
|
|
96
|
-
copy = getProperty(options, name);
|
|
97
|
-
|
|
98
|
-
// Prevent never-ending loop
|
|
99
|
-
if (target !== copy) {
|
|
100
|
-
// Recurse if we're merging plain objects or arrays
|
|
101
|
-
if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
|
|
102
|
-
if (copyIsArray) {
|
|
103
|
-
copyIsArray = false;
|
|
104
|
-
clone = []; //clone = src && isArray(src) ? src : [];
|
|
105
|
-
} else {
|
|
106
|
-
clone = src && isPlainObject(src) ? src : {};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Never move original objects, clone them
|
|
110
|
-
setProperty(target, { name: name, newValue: extend(deep, clone, copy) });
|
|
111
|
-
|
|
112
|
-
// Don't bring in undefined values
|
|
113
|
-
} else if (typeof copy !== 'undefined') {
|
|
114
|
-
setProperty(target, { name: name, newValue: copy });
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Return the modified object
|
|
122
|
-
return target;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
/***/ })
|
|
127
|
-
|
|
128
|
-
/******/ });
|
|
129
|
-
/************************************************************************/
|
|
130
|
-
/******/ // The module cache
|
|
131
|
-
/******/ var __webpack_module_cache__ = {};
|
|
132
|
-
/******/
|
|
133
|
-
/******/ // The require function
|
|
134
|
-
/******/ function __webpack_require__(moduleId) {
|
|
135
|
-
/******/ // Check if module is in cache
|
|
136
|
-
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
137
|
-
/******/ if (cachedModule !== undefined) {
|
|
138
|
-
/******/ return cachedModule.exports;
|
|
139
|
-
/******/ }
|
|
140
|
-
/******/ // Create a new module (and put it into the cache)
|
|
141
|
-
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
142
|
-
/******/ // no module.id needed
|
|
143
|
-
/******/ // no module.loaded needed
|
|
144
|
-
/******/ exports: {}
|
|
145
|
-
/******/ };
|
|
146
|
-
/******/
|
|
147
|
-
/******/ // Execute the module function
|
|
148
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
149
|
-
/******/
|
|
150
|
-
/******/ // Return the exports of the module
|
|
151
|
-
/******/ return module.exports;
|
|
152
|
-
/******/ }
|
|
153
|
-
/******/
|
|
154
|
-
/************************************************************************/
|
|
155
|
-
/******/ /* webpack/runtime/define property getters */
|
|
156
|
-
/******/ (() => {
|
|
157
|
-
/******/ // define getter functions for harmony exports
|
|
158
|
-
/******/ __webpack_require__.d = (exports, definition) => {
|
|
159
|
-
/******/ for(var key in definition) {
|
|
160
|
-
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
161
|
-
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
162
|
-
/******/ }
|
|
163
|
-
/******/ }
|
|
164
|
-
/******/ };
|
|
165
|
-
/******/ })();
|
|
166
|
-
/******/
|
|
167
|
-
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
168
|
-
/******/ (() => {
|
|
169
|
-
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
170
|
-
/******/ })();
|
|
171
|
-
/******/
|
|
172
|
-
/******/ /* webpack/runtime/make namespace object */
|
|
173
|
-
/******/ (() => {
|
|
174
|
-
/******/ // define __esModule on exports
|
|
175
|
-
/******/ __webpack_require__.r = (exports) => {
|
|
176
|
-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
177
|
-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
178
|
-
/******/ }
|
|
179
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
180
|
-
/******/ };
|
|
181
|
-
/******/ })();
|
|
182
|
-
/******/
|
|
183
|
-
/************************************************************************/
|
|
184
|
-
var __webpack_exports__ = {};
|
|
185
|
-
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
186
|
-
(() => {
|
|
187
|
-
__webpack_require__.r(__webpack_exports__);
|
|
188
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
189
|
-
/* harmony export */ "default": () => (/* binding */ cascadeExtend)
|
|
190
|
-
/* harmony export */ });
|
|
191
|
-
/* harmony import */ var _zhennann_extend__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(381);
|
|
192
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
193
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
194
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
195
|
-
|
|
196
|
-
function cascadeExtend(_ref) {
|
|
197
|
-
var scope = _ref.scope,
|
|
198
|
-
source = _ref.source,
|
|
199
|
-
name = _ref.name;
|
|
200
|
-
if (!source || !name) return null;
|
|
201
|
-
var keys = Object.keys(source).filter(function (key) {
|
|
202
|
-
return key === name || key.indexOf(name + '_') === 0;
|
|
203
|
-
});
|
|
204
|
-
if (keys.length === 0) return null;
|
|
205
|
-
if (keys.length === 1 && keys[0] === name) return source[keys[0]];
|
|
206
|
-
keys.sort(function (a, b) {
|
|
207
|
-
return a.split('_').length - b.split('_').length;
|
|
208
|
-
});
|
|
209
|
-
var result = {};
|
|
210
|
-
var nameLength = name.length;
|
|
211
|
-
var _iterator = _createForOfIteratorHelper(keys),
|
|
212
|
-
_step;
|
|
213
|
-
try {
|
|
214
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
215
|
-
var key = _step.value;
|
|
216
|
-
if (key === name) {
|
|
217
|
-
_zhennann_extend__WEBPACK_IMPORTED_MODULE_0__(true, result, source[key]);
|
|
218
|
-
} else {
|
|
219
|
-
var parts = key.substring(nameLength + 1).split('_');
|
|
220
|
-
var test = parts.every(function (part) {
|
|
221
|
-
return !!scope[part];
|
|
222
|
-
});
|
|
223
|
-
if (test) {
|
|
224
|
-
_zhennann_extend__WEBPACK_IMPORTED_MODULE_0__(true, result, source[key]);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cascadeExtend = exports.cascadeExtendKeys = void 0;
|
|
4
|
+
const extend_1 = require("@cabloy/extend");
|
|
5
|
+
function cascadeExtendKeys(scope, source, prefix, sep = '_') {
|
|
6
|
+
if (!source)
|
|
7
|
+
return undefined;
|
|
8
|
+
if (prefix === undefined)
|
|
9
|
+
prefix = '';
|
|
10
|
+
// filter
|
|
11
|
+
let keys = Object.keys(source).filter(key => {
|
|
12
|
+
return key === prefix || key.indexOf(prefix + sep) === 0;
|
|
13
|
+
});
|
|
14
|
+
if (keys.length === 0)
|
|
15
|
+
return undefined;
|
|
16
|
+
if (keys.length === 1 && keys[0] === prefix)
|
|
17
|
+
return keys;
|
|
18
|
+
// sort
|
|
19
|
+
keys.sort((a, b) => {
|
|
20
|
+
return a.split('_').length - b.split('_').length;
|
|
21
|
+
});
|
|
22
|
+
// filter
|
|
23
|
+
keys = keys.filter(key => {
|
|
24
|
+
if (key === prefix)
|
|
25
|
+
return true;
|
|
26
|
+
const parts = key.substring(prefix.length + 1).split(sep);
|
|
27
|
+
return parts.every(part => !!scope[part]);
|
|
28
|
+
});
|
|
29
|
+
// ok
|
|
30
|
+
return keys.length === 0 ? undefined : keys;
|
|
31
|
+
}
|
|
32
|
+
exports.cascadeExtendKeys = cascadeExtendKeys;
|
|
33
|
+
function cascadeExtend(scope, source, prefix, sep = '_') {
|
|
34
|
+
if (!source)
|
|
35
|
+
return undefined;
|
|
36
|
+
// keys
|
|
37
|
+
const keys = cascadeExtendKeys(scope, source, prefix, sep);
|
|
38
|
+
if (!keys)
|
|
39
|
+
return undefined;
|
|
40
|
+
// special
|
|
41
|
+
if (keys.length === 1)
|
|
42
|
+
return source[keys[0]];
|
|
43
|
+
// extend
|
|
44
|
+
const result = {};
|
|
45
|
+
for (const key of keys) {
|
|
46
|
+
(0, extend_1.extend)(true, result, source[key]);
|
|
227
47
|
}
|
|
228
|
-
|
|
229
|
-
_iterator.e(err);
|
|
230
|
-
} finally {
|
|
231
|
-
_iterator.f();
|
|
232
|
-
}
|
|
233
|
-
return result;
|
|
48
|
+
return result;
|
|
234
49
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
module.exports = __webpack_exports__;
|
|
238
|
-
/******/ })()
|
|
239
|
-
;
|
|
50
|
+
exports.cascadeExtend = cascadeExtend;
|
|
240
51
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAExC,SAAgB,iBAAiB,CAC/B,KAAa,EACb,MAA0B,EAC1B,MAAe,EACf,MAAc,GAAG;IAEjB,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,IAAI,MAAM,KAAK,SAAS;QAAE,MAAM,GAAG,EAAE,CAAC;IACtC,SAAS;IACT,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;QAC1C,OAAO,GAAG,KAAK,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IACH,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACxC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACzD,OAAO;IACP,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACjB,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IACnD,CAAC,CAAC,CAAC;IACH,SAAS;IACT,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;QACvB,IAAI,GAAG,KAAK,MAAM;YAAE,OAAO,IAAI,CAAC;QAChC,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,MAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3D,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IACH,KAAK;IACL,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9C,CAAC;AA1BD,8CA0BC;AAED,SAAgB,aAAa,CAC3B,KAAa,EACb,MAA0B,EAC1B,MAAe,EACf,MAAc,GAAG;IAEjB,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,OAAO;IACP,MAAM,IAAI,GAAG,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3D,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,UAAU;IACV,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,SAAS;IACT,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAA,eAAM,EAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAlBD,sCAkBC"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cascade-extend",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "cascade-extend",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
5
|
"publishConfig": {
|
|
7
6
|
"access": "public"
|
|
8
7
|
},
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": [
|
|
11
|
+
"./src/index.ts",
|
|
12
|
+
"./dist/index.d.ts"
|
|
13
|
+
],
|
|
14
|
+
"import": "./src/index.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json"
|
|
12
18
|
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
13
22
|
"repository": {
|
|
14
23
|
"type": "git",
|
|
15
24
|
"url": "git+https://github.com/zhennann/cascade-extend.git"
|
|
@@ -27,65 +36,10 @@
|
|
|
27
36
|
},
|
|
28
37
|
"homepage": "https://github.com/zhennann/cascade-extend#readme",
|
|
29
38
|
"devDependencies": {
|
|
30
|
-
"@
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"@
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"@vue/babel-preset-jsx": "^1.1.2",
|
|
38
|
-
"@zhennann/babel-generator": "^7.17.3",
|
|
39
|
-
"@zhennann/babel-helper-wrap-function": "^7.16.8",
|
|
40
|
-
"@zhennann/babel-plugin-transform-async-to-generator": "^7.16.8",
|
|
41
|
-
"@zhennann/extend":"^3.0.2",
|
|
42
|
-
"autoprefixer": "^9.7.4",
|
|
43
|
-
"babel-eslint": "^10.1.0",
|
|
44
|
-
"babel-loader": "^8.2.2",
|
|
45
|
-
"babel-plugin-jsx-v-model": "^2.0.3",
|
|
46
|
-
"babel-plugin-syntax-jsx": "^6.18.0",
|
|
47
|
-
"bluebird": "^3.7.2",
|
|
48
|
-
"chalk": "^3.0.0",
|
|
49
|
-
"connect-history-api-fallback": "^1.6.0",
|
|
50
|
-
"copy-webpack-plugin": "^7.0.0",
|
|
51
|
-
"css-loader": "^5.0.1",
|
|
52
|
-
"egg-born-mglob": "^3.0.1",
|
|
53
|
-
"egg-born-mparse": "^2.1.5",
|
|
54
|
-
"eslint": "^7.21.0",
|
|
55
|
-
"eslint-config-egg-born": "^1.1.2",
|
|
56
|
-
"eslint-config-prettier": "^8.3.0",
|
|
57
|
-
"eslint-plugin-jsdoc": "^37.9.1",
|
|
58
|
-
"eslint-plugin-node": "^11.1.0",
|
|
59
|
-
"eslint-plugin-prettier": "^3.4.0",
|
|
60
|
-
"eslint-plugin-vue": "^7.17.0",
|
|
61
|
-
"eventsource-polyfill": "^0.9.6",
|
|
62
|
-
"express": "^4.15.4",
|
|
63
|
-
"extend2": "^1.0.1",
|
|
64
|
-
"file-loader": "^6.2.0",
|
|
65
|
-
"fs-extra": "^10.1.0",
|
|
66
|
-
"function-bind": "^1.1.1",
|
|
67
|
-
"globby": "^11.0.0",
|
|
68
|
-
"html-webpack-plugin": "^5.3.1",
|
|
69
|
-
"http-proxy-middleware": "^1.0.6",
|
|
70
|
-
"is-type-of": "^1.2.0",
|
|
71
|
-
"less": "^3.13.0",
|
|
72
|
-
"less-loader": "^7.1.0",
|
|
73
|
-
"mini-css-extract-plugin": "^1.3.3",
|
|
74
|
-
"module-alias": "^2.2.2",
|
|
75
|
-
"open": "^7.0.2",
|
|
76
|
-
"ora": "^4.0.3",
|
|
77
|
-
"prettier": "2.3.2",
|
|
78
|
-
"rimraf": "^3.0.2",
|
|
79
|
-
"semver": "^7.3.7",
|
|
80
|
-
"url-loader": "^4.1.1",
|
|
81
|
-
"vue-eslint-parser": "^7.10.0",
|
|
82
|
-
"vue-loader": "^15.9.5",
|
|
83
|
-
"vue-style-loader": "^4.1.2",
|
|
84
|
-
"vue-template-compiler": "^2.6.14",
|
|
85
|
-
"webpack": "^5.61.0",
|
|
86
|
-
"webpack-bundle-analyzer": "^4.2.0",
|
|
87
|
-
"webpack-dev-middleware": "^4.0.2",
|
|
88
|
-
"webpack-hot-middleware": "^2.25.0",
|
|
89
|
-
"webpack-merge": "^5.7.0"
|
|
90
|
-
}
|
|
91
|
-
}
|
|
39
|
+
"@cabloy/lint": "^4.0.5"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@cabloy/extend": "^3.0.5"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {}
|
|
45
|
+
}
|
package/babel.config.js
DELETED
package/build/config.js
DELETED
package/build/front/build.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
process.env.NODE_ENV = 'production';
|
|
2
|
-
|
|
3
|
-
const ora = require('ora');
|
|
4
|
-
const rm = require('rimraf');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
const chalk = require('chalk');
|
|
7
|
-
const webpack = require('webpack');
|
|
8
|
-
const config = require('./config.js');
|
|
9
|
-
const webpackConfig = require('./webpack.prod.conf');
|
|
10
|
-
|
|
11
|
-
const spinner = ora('building for production...');
|
|
12
|
-
spinner.start();
|
|
13
|
-
|
|
14
|
-
rm(path.join(config.build.assetsRoot, 'index.*'), err => {
|
|
15
|
-
if (err) throw err;
|
|
16
|
-
|
|
17
|
-
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
|
|
18
|
-
if (err) throw err;
|
|
19
|
-
webpack(webpackConfig, function (err, stats) {
|
|
20
|
-
spinner.stop();
|
|
21
|
-
if (err) throw err;
|
|
22
|
-
process.stdout.write(
|
|
23
|
-
stats.toString({
|
|
24
|
-
colors: true,
|
|
25
|
-
modules: false,
|
|
26
|
-
children: false,
|
|
27
|
-
chunks: false,
|
|
28
|
-
chunkModules: false,
|
|
29
|
-
}) + '\n\n'
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
console.log(chalk.cyan(' Build complete.\n'));
|
|
33
|
-
console.log(
|
|
34
|
-
chalk.yellow(
|
|
35
|
-
' Tip: built files are meant to be served over an HTTP server.\n' +
|
|
36
|
-
" Opening index.html over file:// won't work.\n"
|
|
37
|
-
)
|
|
38
|
-
);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
});
|
package/build/front/config.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const { merge } = require('webpack-merge');
|
|
3
|
-
const config = require('../config.js');
|
|
4
|
-
|
|
5
|
-
module.exports = merge(
|
|
6
|
-
{
|
|
7
|
-
build: {
|
|
8
|
-
env: {
|
|
9
|
-
NODE_ENV: '"production"',
|
|
10
|
-
},
|
|
11
|
-
assetsRoot: path.resolve(__dirname, '../../dist'),
|
|
12
|
-
assetsSubDirectory: 'static',
|
|
13
|
-
assetsPublicPath: '',
|
|
14
|
-
productionSourceMap: true,
|
|
15
|
-
uglify: false,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
{ build: config }
|
|
19
|
-
);
|
package/build/front/utils.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const config = require('./config.js');
|
|
3
|
-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
4
|
-
|
|
5
|
-
exports.assetsPath = function (_path) {
|
|
6
|
-
return path.join(config.build.assetsSubDirectory, _path);
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
exports.cssLoaders = function (options) {
|
|
10
|
-
options = options || {};
|
|
11
|
-
|
|
12
|
-
const cssLoader = {
|
|
13
|
-
loader: 'css-loader',
|
|
14
|
-
options: {
|
|
15
|
-
minimize: process.env.NODE_ENV === 'production',
|
|
16
|
-
sourceMap: options.sourceMap,
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// generate loader string to be used with extract text plugin
|
|
21
|
-
function generateLoaders(loader, loaderOptions) {
|
|
22
|
-
const loaders = [cssLoader];
|
|
23
|
-
if (loader) {
|
|
24
|
-
loaders.push({
|
|
25
|
-
loader: loader + '-loader',
|
|
26
|
-
options: Object.assign({}, loaderOptions, {
|
|
27
|
-
sourceMap: options.sourceMap,
|
|
28
|
-
}),
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Extract CSS when that option is specified
|
|
33
|
-
// (which is the case during production build)
|
|
34
|
-
if (options.extract) {
|
|
35
|
-
return [MiniCssExtractPlugin.loader].concat(loaders);
|
|
36
|
-
}
|
|
37
|
-
return ['vue-style-loader'].concat(loaders);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// http://vuejs.github.io/vue-loader/en/configurations/extract-css.html
|
|
41
|
-
return {
|
|
42
|
-
css: generateLoaders(),
|
|
43
|
-
postcss: generateLoaders(),
|
|
44
|
-
less: generateLoaders('less'),
|
|
45
|
-
sass: generateLoaders('sass', { indentedSyntax: true }),
|
|
46
|
-
scss: generateLoaders('sass'),
|
|
47
|
-
stylus: generateLoaders('stylus'),
|
|
48
|
-
styl: generateLoaders('stylus'),
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// Generate loaders for standalone style files (outside of .vue)
|
|
53
|
-
exports.styleLoaders = function (options) {
|
|
54
|
-
const output = [];
|
|
55
|
-
const loaders = exports.cssLoaders(options);
|
|
56
|
-
for (const extension in loaders) {
|
|
57
|
-
const loader = loaders[extension];
|
|
58
|
-
output.push({
|
|
59
|
-
test: new RegExp('\\.' + extension + '$'),
|
|
60
|
-
use: loader,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return output;
|
|
64
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const utils = require('./utils');
|
|
3
|
-
const config = require('./config.js');
|
|
4
|
-
|
|
5
|
-
function resolve(dir) {
|
|
6
|
-
return path.join(__dirname, '../..', dir);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
entry: {
|
|
11
|
-
index: resolve('src/main.mjs'),
|
|
12
|
-
},
|
|
13
|
-
output: {
|
|
14
|
-
path: config.build.assetsRoot,
|
|
15
|
-
filename: '[name].js',
|
|
16
|
-
publicPath: config.build.assetsPublicPath,
|
|
17
|
-
libraryTarget: 'commonjs2',
|
|
18
|
-
},
|
|
19
|
-
externals: {
|
|
20
|
-
vue: 'vue',
|
|
21
|
-
},
|
|
22
|
-
resolve: {
|
|
23
|
-
extensions: ['.js', '.vue', '.json'],
|
|
24
|
-
alias: {
|
|
25
|
-
'@': resolve('src'),
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
module: {
|
|
29
|
-
rules: [
|
|
30
|
-
{
|
|
31
|
-
test: /\.vue$/,
|
|
32
|
-
loader: 'vue-loader',
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
test: /\.esm\.js$/,
|
|
36
|
-
loader: 'babel-loader',
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
test: /\.esm\.bundle\.js$/,
|
|
40
|
-
loader: 'babel-loader',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
test: /\.module\.js$/,
|
|
44
|
-
loader: 'babel-loader',
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
test: /\.js$/,
|
|
48
|
-
loader: 'babel-loader',
|
|
49
|
-
include: [resolve('src')],
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
test: /\.mjs$/,
|
|
53
|
-
loader: 'babel-loader',
|
|
54
|
-
include: [resolve('src')],
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
|
|
58
|
-
loader: 'url-loader',
|
|
59
|
-
options: {
|
|
60
|
-
limit: 10000,
|
|
61
|
-
name: utils.assetsPath('img/[name].[hash].[ext]'),
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
|
|
66
|
-
loader: 'url-loader',
|
|
67
|
-
options: {
|
|
68
|
-
limit: 10000,
|
|
69
|
-
name: utils.assetsPath('fonts/[name].[hash].[ext]'),
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
},
|
|
74
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const utils = require('./utils');
|
|
2
|
-
const webpack = require('webpack');
|
|
3
|
-
const config = require('./config.js');
|
|
4
|
-
const { merge } = require('webpack-merge');
|
|
5
|
-
const baseWebpackConfig = require('./webpack.base.conf');
|
|
6
|
-
const { VueLoaderPlugin } = require('vue-loader');
|
|
7
|
-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
8
|
-
|
|
9
|
-
const env = config.build.env;
|
|
10
|
-
|
|
11
|
-
const plugins = [
|
|
12
|
-
new webpack.DefinePlugin({
|
|
13
|
-
'process.env': env,
|
|
14
|
-
}),
|
|
15
|
-
new VueLoaderPlugin(),
|
|
16
|
-
new MiniCssExtractPlugin({
|
|
17
|
-
filename: utils.assetsPath('[name].css'),
|
|
18
|
-
}),
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
const webpackConfig = merge(baseWebpackConfig, {
|
|
22
|
-
mode: 'production',
|
|
23
|
-
module: {
|
|
24
|
-
rules: utils.styleLoaders({
|
|
25
|
-
sourceMap: config.build.productionSourceMap,
|
|
26
|
-
extract: true,
|
|
27
|
-
}),
|
|
28
|
-
},
|
|
29
|
-
devtool: config.build.productionSourceMap ? 'source-map' : false,
|
|
30
|
-
plugins,
|
|
31
|
-
optimization: {
|
|
32
|
-
minimize: config.build.uglify,
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
module.exports = webpackConfig;
|
package/src/main.mjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import extend from '@zhennann/extend';
|
|
2
|
-
|
|
3
|
-
export default function cascadeExtend({ scope, source, name }) {
|
|
4
|
-
if (!source || !name) return null;
|
|
5
|
-
// filter
|
|
6
|
-
const keys = Object.keys(source).filter(key => {
|
|
7
|
-
return key === name || key.indexOf(name + '_') === 0
|
|
8
|
-
});
|
|
9
|
-
if (keys.length === 0) return null;
|
|
10
|
-
if (keys.length === 1 && keys[0] === name) return source[keys[0]];
|
|
11
|
-
// sort
|
|
12
|
-
keys.sort((a, b) => {
|
|
13
|
-
return a.split('_').length - b.split('_').length;
|
|
14
|
-
})
|
|
15
|
-
// extend
|
|
16
|
-
const result = {};
|
|
17
|
-
const nameLength = name.length;
|
|
18
|
-
for (const key of keys) {
|
|
19
|
-
if (key === name) {
|
|
20
|
-
extend(true, result, source[key]);
|
|
21
|
-
} else {
|
|
22
|
-
const parts = key.substring(nameLength + 1).split('_');
|
|
23
|
-
const test = parts.every(part => !!scope[part]);
|
|
24
|
-
if (test) {
|
|
25
|
-
extend(true, result, source[key]);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
}
|
package/test/test.mjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import cascadeExtend from '../src/main.mjs';
|
|
2
|
-
|
|
3
|
-
const scope = {
|
|
4
|
-
group: true,
|
|
5
|
-
mobile: true,
|
|
6
|
-
small: true,
|
|
7
|
-
view: true,
|
|
8
|
-
}
|
|
9
|
-
const source = {
|
|
10
|
-
ebParams_mobile: {
|
|
11
|
-
size: 'small',
|
|
12
|
-
scene: 'mobile',
|
|
13
|
-
group: true,
|
|
14
|
-
},
|
|
15
|
-
ebParams: {
|
|
16
|
-
size: 'large',
|
|
17
|
-
scene: 'pc',
|
|
18
|
-
name: 'yang',
|
|
19
|
-
},
|
|
20
|
-
ebParams_pc: {
|
|
21
|
-
size: 'large',
|
|
22
|
-
scene: 'pc',
|
|
23
|
-
name: 'kevin',
|
|
24
|
-
group: true,
|
|
25
|
-
},
|
|
26
|
-
}
|
|
27
|
-
const res = cascadeExtend({ scope, source, name: 'ebParams' });
|
|
28
|
-
console.log(res);
|