@weapp-core/shared 2.0.1 → 3.0.1
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/README.md +41 -0
- package/dist/index.d.ts +25 -1
- package/dist/index.js +6 -3
- package/package.json +6 -4
- package/dist/index.cjs +0 -498
- package/dist/index.d.cts +0 -25
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @weapp-core/shared
|
|
2
|
+
|
|
3
|
+
## 简介
|
|
4
|
+
|
|
5
|
+
`@weapp-core/shared` 汇总 weapp-vite 生态内的通用工具函数与依赖封装,供多个包复用。
|
|
6
|
+
|
|
7
|
+
## 特性
|
|
8
|
+
|
|
9
|
+
- 常用字符串与路径处理工具
|
|
10
|
+
- 对象合并与判定工具
|
|
11
|
+
- 统一导出常用第三方工具(`defu`、`get`、`set`、`object-hash`)
|
|
12
|
+
|
|
13
|
+
## 安装
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @weapp-core/shared
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 使用
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import {
|
|
23
|
+
addExtension,
|
|
24
|
+
defu,
|
|
25
|
+
escapeStringRegexp,
|
|
26
|
+
objectHash,
|
|
27
|
+
removeExtension,
|
|
28
|
+
} from '@weapp-core/shared'
|
|
29
|
+
|
|
30
|
+
const name = addExtension('pages/index/index')
|
|
31
|
+
const cleaned = removeExtension('app.json')
|
|
32
|
+
const hash = objectHash({ foo: 'bar' })
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 配置
|
|
36
|
+
|
|
37
|
+
暂无额外配置。
|
|
38
|
+
|
|
39
|
+
## 相关链接
|
|
40
|
+
|
|
41
|
+
- 仓库:https://github.com/weapp-vite/weapp-vite
|
package/dist/index.d.ts
CHANGED
|
@@ -4,12 +4,30 @@ export { default as objectHash } from 'object-hash';
|
|
|
4
4
|
export { default as get } from 'get-value';
|
|
5
5
|
export { default as set } from 'set-value';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* @description 转义字符串中的正则特殊字符
|
|
9
|
+
*/
|
|
7
10
|
declare function escapeStringRegexp(str: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* @description 移除文件名的最后一个扩展名
|
|
13
|
+
*/
|
|
8
14
|
declare function removeExtension(file: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* @description 移除文件名的所有扩展名(多重后缀)
|
|
17
|
+
*/
|
|
9
18
|
declare function removeExtensionDeep(file: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* @description 若缺少扩展名则追加(默认 .js)
|
|
21
|
+
*/
|
|
10
22
|
declare function addExtension(filename: string, ext?: string): string;
|
|
11
|
-
|
|
23
|
+
/**
|
|
24
|
+
* @description 将单个值转换为数组
|
|
25
|
+
*/
|
|
26
|
+
declare function arrify<T>(val: T | readonly T[]): T[];
|
|
12
27
|
|
|
28
|
+
/**
|
|
29
|
+
* @description defu 合并策略:当目标/来源为数组时直接覆盖
|
|
30
|
+
*/
|
|
13
31
|
declare const defuOverrideArray: <Source extends {
|
|
14
32
|
[x: string]: any;
|
|
15
33
|
[x: number]: any;
|
|
@@ -19,7 +37,13 @@ declare const defuOverrideArray: <Source extends {
|
|
|
19
37
|
[x: number]: any;
|
|
20
38
|
[x: symbol]: any;
|
|
21
39
|
} | (number | boolean | any[] | Record<never, any> | null | undefined)>>(source: Source, ...defaults: Defaults) => defu.Defu<Source, Defaults>;
|
|
40
|
+
/**
|
|
41
|
+
* @description 判断是否为非 null 的对象
|
|
42
|
+
*/
|
|
22
43
|
declare function isObject(x: unknown): x is Record<string | symbol | number, unknown>;
|
|
44
|
+
/**
|
|
45
|
+
* @description 判断对象是否为空对象
|
|
46
|
+
*/
|
|
23
47
|
declare function isEmptyObject(obj: unknown): boolean;
|
|
24
48
|
|
|
25
49
|
export { addExtension, arrify, defuOverrideArray, escapeStringRegexp, isEmptyObject, isObject, removeExtension, removeExtensionDeep };
|
package/dist/index.js
CHANGED
|
@@ -27,11 +27,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
mod
|
|
28
28
|
));
|
|
29
29
|
|
|
30
|
-
// ../../node_modules/.pnpm/tsup@8.5.
|
|
30
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.56.0_@types+node@25.2.0__@swc+core@1.15.11_jiti@2_1af55e4e1e3a88da689103a99e6896b3/node_modules/tsup/assets/esm_shims.js
|
|
31
31
|
import path from "path";
|
|
32
32
|
import { fileURLToPath } from "url";
|
|
33
33
|
var init_esm_shims = __esm({
|
|
34
|
-
"../../node_modules/.pnpm/tsup@8.5.
|
|
34
|
+
"../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.56.0_@types+node@25.2.0__@swc+core@1.15.11_jiti@2_1af55e4e1e3a88da689103a99e6896b3/node_modules/tsup/assets/esm_shims.js"() {
|
|
35
35
|
"use strict";
|
|
36
36
|
}
|
|
37
37
|
});
|
|
@@ -398,7 +398,10 @@ function addExtension(filename, ext = ".js") {
|
|
|
398
398
|
return result;
|
|
399
399
|
}
|
|
400
400
|
function arrify(val) {
|
|
401
|
-
|
|
401
|
+
if (Array.isArray(val)) {
|
|
402
|
+
return [...val];
|
|
403
|
+
}
|
|
404
|
+
return [val];
|
|
402
405
|
}
|
|
403
406
|
var defuOverrideArray = createDefu((obj, key, value) => {
|
|
404
407
|
if (Array.isArray(obj[key]) && Array.isArray(value)) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-core/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.1",
|
|
5
5
|
"description": "@weapp-core/shared",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -29,16 +29,18 @@
|
|
|
29
29
|
"exports": {
|
|
30
30
|
".": {
|
|
31
31
|
"types": "./dist/index.d.ts",
|
|
32
|
-
"import": "./dist/index.js"
|
|
33
|
-
"require": "./dist/index.cjs"
|
|
32
|
+
"import": "./dist/index.js"
|
|
34
33
|
}
|
|
35
34
|
},
|
|
36
|
-
"main": "./dist/index.
|
|
35
|
+
"main": "./dist/index.js",
|
|
37
36
|
"module": "./dist/index.js",
|
|
38
37
|
"types": "./dist/index.d.ts",
|
|
39
38
|
"files": [
|
|
40
39
|
"dist"
|
|
41
40
|
],
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
43
|
+
},
|
|
42
44
|
"dependencies": {
|
|
43
45
|
"object-hash": "^3.0.0"
|
|
44
46
|
},
|
package/dist/index.cjs
DELETED
|
@@ -1,498 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __esm = (fn, res) => function __init() {
|
|
9
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
-
};
|
|
11
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
12
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
|
-
};
|
|
14
|
-
var __export = (target, all) => {
|
|
15
|
-
for (var name in all)
|
|
16
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
-
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
-
for (let key of __getOwnPropNames(from))
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
-
}
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
|
-
mod
|
|
33
|
-
));
|
|
34
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
-
|
|
36
|
-
// ../../node_modules/.pnpm/tsup@8.5.0_@swc+core@1.12.1_jiti@2.4.2_postcss@8.5.5_tsx@4.20.3_typescript@5.8.3_yaml@2.8.0/node_modules/tsup/assets/cjs_shims.js
|
|
37
|
-
var init_cjs_shims = __esm({
|
|
38
|
-
"../../node_modules/.pnpm/tsup@8.5.0_@swc+core@1.12.1_jiti@2.4.2_postcss@8.5.5_tsx@4.20.3_typescript@5.8.3_yaml@2.8.0/node_modules/tsup/assets/cjs_shims.js"() {
|
|
39
|
-
"use strict";
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// ../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js
|
|
44
|
-
var require_is_primitive = __commonJS({
|
|
45
|
-
"../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js"(exports2, module2) {
|
|
46
|
-
"use strict";
|
|
47
|
-
init_cjs_shims();
|
|
48
|
-
module2.exports = function isPrimitive(val) {
|
|
49
|
-
if (typeof val === "object") {
|
|
50
|
-
return val === null;
|
|
51
|
-
}
|
|
52
|
-
return typeof val !== "function";
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// ../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js
|
|
58
|
-
var require_isobject = __commonJS({
|
|
59
|
-
"../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js"(exports2, module2) {
|
|
60
|
-
"use strict";
|
|
61
|
-
init_cjs_shims();
|
|
62
|
-
module2.exports = function isObject3(val) {
|
|
63
|
-
return val != null && typeof val === "object" && Array.isArray(val) === false;
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// ../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js
|
|
69
|
-
var require_is_plain_object = __commonJS({
|
|
70
|
-
"../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js"(exports2, module2) {
|
|
71
|
-
"use strict";
|
|
72
|
-
init_cjs_shims();
|
|
73
|
-
var isObject3 = require_isobject();
|
|
74
|
-
function isObjectObject(o) {
|
|
75
|
-
return isObject3(o) === true && Object.prototype.toString.call(o) === "[object Object]";
|
|
76
|
-
}
|
|
77
|
-
module2.exports = function isPlainObject2(o) {
|
|
78
|
-
var ctor, prot;
|
|
79
|
-
if (isObjectObject(o) === false) return false;
|
|
80
|
-
ctor = o.constructor;
|
|
81
|
-
if (typeof ctor !== "function") return false;
|
|
82
|
-
prot = ctor.prototype;
|
|
83
|
-
if (isObjectObject(prot) === false) return false;
|
|
84
|
-
if (prot.hasOwnProperty("isPrototypeOf") === false) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
return true;
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
// ../../node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js
|
|
93
|
-
var require_set_value = __commonJS({
|
|
94
|
-
"../../node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js"(exports2, module2) {
|
|
95
|
-
"use strict";
|
|
96
|
-
init_cjs_shims();
|
|
97
|
-
var { deleteProperty } = Reflect;
|
|
98
|
-
var isPrimitive = require_is_primitive();
|
|
99
|
-
var isPlainObject2 = require_is_plain_object();
|
|
100
|
-
var isObject3 = (value) => {
|
|
101
|
-
return typeof value === "object" && value !== null || typeof value === "function";
|
|
102
|
-
};
|
|
103
|
-
var isUnsafeKey = (key) => {
|
|
104
|
-
return key === "__proto__" || key === "constructor" || key === "prototype";
|
|
105
|
-
};
|
|
106
|
-
var validateKey = (key) => {
|
|
107
|
-
if (!isPrimitive(key)) {
|
|
108
|
-
throw new TypeError("Object keys must be strings or symbols");
|
|
109
|
-
}
|
|
110
|
-
if (isUnsafeKey(key)) {
|
|
111
|
-
throw new Error(`Cannot set unsafe key: "${key}"`);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
var toStringKey = (input) => {
|
|
115
|
-
return Array.isArray(input) ? input.flat().map(String).join(",") : input;
|
|
116
|
-
};
|
|
117
|
-
var createMemoKey = (input, options) => {
|
|
118
|
-
if (typeof input !== "string" || !options) return input;
|
|
119
|
-
let key = input + ";";
|
|
120
|
-
if (options.arrays !== void 0) key += `arrays=${options.arrays};`;
|
|
121
|
-
if (options.separator !== void 0) key += `separator=${options.separator};`;
|
|
122
|
-
if (options.split !== void 0) key += `split=${options.split};`;
|
|
123
|
-
if (options.merge !== void 0) key += `merge=${options.merge};`;
|
|
124
|
-
if (options.preservePaths !== void 0) key += `preservePaths=${options.preservePaths};`;
|
|
125
|
-
return key;
|
|
126
|
-
};
|
|
127
|
-
var memoize = (input, options, fn) => {
|
|
128
|
-
const key = toStringKey(options ? createMemoKey(input, options) : input);
|
|
129
|
-
validateKey(key);
|
|
130
|
-
const value = setValue.cache.get(key) || fn();
|
|
131
|
-
setValue.cache.set(key, value);
|
|
132
|
-
return value;
|
|
133
|
-
};
|
|
134
|
-
var splitString = (input, options = {}) => {
|
|
135
|
-
const sep = options.separator || ".";
|
|
136
|
-
const preserve = sep === "/" ? false : options.preservePaths;
|
|
137
|
-
if (typeof input === "string" && preserve !== false && /\//.test(input)) {
|
|
138
|
-
return [input];
|
|
139
|
-
}
|
|
140
|
-
const parts = [];
|
|
141
|
-
let part = "";
|
|
142
|
-
const push = (part2) => {
|
|
143
|
-
let number;
|
|
144
|
-
if (part2.trim() !== "" && Number.isInteger(number = Number(part2))) {
|
|
145
|
-
parts.push(number);
|
|
146
|
-
} else {
|
|
147
|
-
parts.push(part2);
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
for (let i = 0; i < input.length; i++) {
|
|
151
|
-
const value = input[i];
|
|
152
|
-
if (value === "\\") {
|
|
153
|
-
part += input[++i];
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
if (value === sep) {
|
|
157
|
-
push(part);
|
|
158
|
-
part = "";
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
part += value;
|
|
162
|
-
}
|
|
163
|
-
if (part) {
|
|
164
|
-
push(part);
|
|
165
|
-
}
|
|
166
|
-
return parts;
|
|
167
|
-
};
|
|
168
|
-
var split2 = (input, options) => {
|
|
169
|
-
if (options && typeof options.split === "function") return options.split(input);
|
|
170
|
-
if (typeof input === "symbol") return [input];
|
|
171
|
-
if (Array.isArray(input)) return input;
|
|
172
|
-
return memoize(input, options, () => splitString(input, options));
|
|
173
|
-
};
|
|
174
|
-
var assignProp = (obj, prop, value, options) => {
|
|
175
|
-
validateKey(prop);
|
|
176
|
-
if (value === void 0) {
|
|
177
|
-
deleteProperty(obj, prop);
|
|
178
|
-
} else if (options && options.merge) {
|
|
179
|
-
const merge = options.merge === "function" ? options.merge : Object.assign;
|
|
180
|
-
if (merge && isPlainObject2(obj[prop]) && isPlainObject2(value)) {
|
|
181
|
-
obj[prop] = merge(obj[prop], value);
|
|
182
|
-
} else {
|
|
183
|
-
obj[prop] = value;
|
|
184
|
-
}
|
|
185
|
-
} else {
|
|
186
|
-
obj[prop] = value;
|
|
187
|
-
}
|
|
188
|
-
return obj;
|
|
189
|
-
};
|
|
190
|
-
var setValue = (target, path, value, options) => {
|
|
191
|
-
if (!path || !isObject3(target)) return target;
|
|
192
|
-
const keys = split2(path, options);
|
|
193
|
-
let obj = target;
|
|
194
|
-
for (let i = 0; i < keys.length; i++) {
|
|
195
|
-
const key = keys[i];
|
|
196
|
-
const next = keys[i + 1];
|
|
197
|
-
validateKey(key);
|
|
198
|
-
if (next === void 0) {
|
|
199
|
-
assignProp(obj, key, value, options);
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
if (typeof next === "number" && !Array.isArray(obj[key])) {
|
|
203
|
-
obj = obj[key] = [];
|
|
204
|
-
continue;
|
|
205
|
-
}
|
|
206
|
-
if (!isObject3(obj[key])) {
|
|
207
|
-
obj[key] = {};
|
|
208
|
-
}
|
|
209
|
-
obj = obj[key];
|
|
210
|
-
}
|
|
211
|
-
return target;
|
|
212
|
-
};
|
|
213
|
-
setValue.split = split2;
|
|
214
|
-
setValue.cache = /* @__PURE__ */ new Map();
|
|
215
|
-
setValue.clear = () => {
|
|
216
|
-
setValue.cache = /* @__PURE__ */ new Map();
|
|
217
|
-
};
|
|
218
|
-
module2.exports = setValue;
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
// src/index.ts
|
|
223
|
-
var index_exports = {};
|
|
224
|
-
__export(index_exports, {
|
|
225
|
-
addExtension: () => addExtension,
|
|
226
|
-
arrify: () => arrify,
|
|
227
|
-
defu: () => defu,
|
|
228
|
-
defuOverrideArray: () => defuOverrideArray,
|
|
229
|
-
escapeStringRegexp: () => escapeStringRegexp,
|
|
230
|
-
get: () => index_default,
|
|
231
|
-
isEmptyObject: () => isEmptyObject,
|
|
232
|
-
isObject: () => isObject2,
|
|
233
|
-
objectHash: () => import_object_hash.default,
|
|
234
|
-
removeExtension: () => removeExtension,
|
|
235
|
-
removeExtensionDeep: () => removeExtensionDeep,
|
|
236
|
-
set: () => import_set_value.default
|
|
237
|
-
});
|
|
238
|
-
module.exports = __toCommonJS(index_exports);
|
|
239
|
-
init_cjs_shims();
|
|
240
|
-
var import_node_path = require("path");
|
|
241
|
-
|
|
242
|
-
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
243
|
-
init_cjs_shims();
|
|
244
|
-
function isPlainObject(value) {
|
|
245
|
-
if (value === null || typeof value !== "object") {
|
|
246
|
-
return false;
|
|
247
|
-
}
|
|
248
|
-
const prototype = Object.getPrototypeOf(value);
|
|
249
|
-
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
250
|
-
return false;
|
|
251
|
-
}
|
|
252
|
-
if (Symbol.iterator in value) {
|
|
253
|
-
return false;
|
|
254
|
-
}
|
|
255
|
-
if (Symbol.toStringTag in value) {
|
|
256
|
-
return Object.prototype.toString.call(value) === "[object Module]";
|
|
257
|
-
}
|
|
258
|
-
return true;
|
|
259
|
-
}
|
|
260
|
-
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
261
|
-
if (!isPlainObject(defaults)) {
|
|
262
|
-
return _defu(baseObject, {}, namespace, merger);
|
|
263
|
-
}
|
|
264
|
-
const object = Object.assign({}, defaults);
|
|
265
|
-
for (const key in baseObject) {
|
|
266
|
-
if (key === "__proto__" || key === "constructor") {
|
|
267
|
-
continue;
|
|
268
|
-
}
|
|
269
|
-
const value = baseObject[key];
|
|
270
|
-
if (value === null || value === void 0) {
|
|
271
|
-
continue;
|
|
272
|
-
}
|
|
273
|
-
if (merger && merger(object, key, value, namespace)) {
|
|
274
|
-
continue;
|
|
275
|
-
}
|
|
276
|
-
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
277
|
-
object[key] = [...value, ...object[key]];
|
|
278
|
-
} else if (isPlainObject(value) && isPlainObject(object[key])) {
|
|
279
|
-
object[key] = _defu(
|
|
280
|
-
value,
|
|
281
|
-
object[key],
|
|
282
|
-
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
283
|
-
merger
|
|
284
|
-
);
|
|
285
|
-
} else {
|
|
286
|
-
object[key] = value;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
return object;
|
|
290
|
-
}
|
|
291
|
-
function createDefu(merger) {
|
|
292
|
-
return (...arguments_) => (
|
|
293
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
294
|
-
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
295
|
-
);
|
|
296
|
-
}
|
|
297
|
-
var defu = createDefu();
|
|
298
|
-
var defuFn = createDefu((object, key, currentValue) => {
|
|
299
|
-
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
300
|
-
object[key] = currentValue(object[key]);
|
|
301
|
-
return true;
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
var defuArrayFn = createDefu((object, key, currentValue) => {
|
|
305
|
-
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
306
|
-
object[key] = currentValue(object[key]);
|
|
307
|
-
return true;
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
// src/index.ts
|
|
312
|
-
var import_object_hash = __toESM(require("object-hash"), 1);
|
|
313
|
-
|
|
314
|
-
// ../../node_modules/.pnpm/get-value@4.0.1/node_modules/get-value/dist/index.mjs
|
|
315
|
-
init_cjs_shims();
|
|
316
|
-
var __defProp2 = Object.defineProperty;
|
|
317
|
-
var __name = (target, value) => __defProp2(target, "name", { value, configurable: true });
|
|
318
|
-
var isObject = /* @__PURE__ */ __name((v) => v !== null && typeof v === "object", "isObject");
|
|
319
|
-
var join = /* @__PURE__ */ __name((segs, joinChar, options) => {
|
|
320
|
-
if (typeof options.join === "function") {
|
|
321
|
-
return options.join(segs);
|
|
322
|
-
}
|
|
323
|
-
return segs[0] + joinChar + segs[1];
|
|
324
|
-
}, "join");
|
|
325
|
-
var split = /* @__PURE__ */ __name((path, splitChar, options) => {
|
|
326
|
-
if (typeof options.split === "function") {
|
|
327
|
-
return options.split(path);
|
|
328
|
-
}
|
|
329
|
-
return path.split(splitChar);
|
|
330
|
-
}, "split");
|
|
331
|
-
var isValid = /* @__PURE__ */ __name((key, target = {}, options) => {
|
|
332
|
-
if (typeof options?.isValid === "function") {
|
|
333
|
-
return options.isValid(key, target);
|
|
334
|
-
}
|
|
335
|
-
return true;
|
|
336
|
-
}, "isValid");
|
|
337
|
-
var isValidObject = /* @__PURE__ */ __name((v) => {
|
|
338
|
-
return isObject(v) || typeof v === "function";
|
|
339
|
-
}, "isValidObject");
|
|
340
|
-
var getValue = /* @__PURE__ */ __name((target, path, options = {}) => {
|
|
341
|
-
if (!isObject(options)) {
|
|
342
|
-
options = { default: options };
|
|
343
|
-
}
|
|
344
|
-
if (!isValidObject(target)) {
|
|
345
|
-
return typeof options.default !== "undefined" ? options.default : target;
|
|
346
|
-
}
|
|
347
|
-
if (typeof path === "number") {
|
|
348
|
-
path = String(path);
|
|
349
|
-
}
|
|
350
|
-
const pathIsArray = Array.isArray(path);
|
|
351
|
-
const pathIsString = typeof path === "string";
|
|
352
|
-
const splitChar = options.separator || ".";
|
|
353
|
-
const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : ".");
|
|
354
|
-
if (!pathIsString && !pathIsArray) {
|
|
355
|
-
return target;
|
|
356
|
-
}
|
|
357
|
-
if (target[path] !== void 0) {
|
|
358
|
-
return isValid(path, target, options) ? target[path] : options.default;
|
|
359
|
-
}
|
|
360
|
-
const segs = pathIsArray ? path : split(path, splitChar, options);
|
|
361
|
-
const len = segs.length;
|
|
362
|
-
let idx = 0;
|
|
363
|
-
do {
|
|
364
|
-
let prop = segs[idx];
|
|
365
|
-
if (typeof prop !== "string") {
|
|
366
|
-
prop = String(prop);
|
|
367
|
-
}
|
|
368
|
-
while (prop && prop.slice(-1) === "\\") {
|
|
369
|
-
prop = join([prop.slice(0, -1), segs[++idx] || ""], joinChar, options);
|
|
370
|
-
}
|
|
371
|
-
if (target[prop] !== void 0) {
|
|
372
|
-
if (!isValid(prop, target, options)) {
|
|
373
|
-
return options.default;
|
|
374
|
-
}
|
|
375
|
-
target = target[prop];
|
|
376
|
-
} else {
|
|
377
|
-
let hasProp = false;
|
|
378
|
-
let n = idx + 1;
|
|
379
|
-
while (n < len) {
|
|
380
|
-
prop = join([prop, segs[n++]], joinChar, options);
|
|
381
|
-
if (hasProp = target[prop] !== void 0) {
|
|
382
|
-
if (!isValid(prop, target, options)) {
|
|
383
|
-
return options.default;
|
|
384
|
-
}
|
|
385
|
-
target = target[prop];
|
|
386
|
-
idx = n - 1;
|
|
387
|
-
break;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
if (!hasProp) {
|
|
391
|
-
return options.default;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
} while (++idx < len && isValidObject(target));
|
|
395
|
-
if (idx === len) {
|
|
396
|
-
return target;
|
|
397
|
-
}
|
|
398
|
-
return options.default;
|
|
399
|
-
}, "getValue");
|
|
400
|
-
var index_default = getValue;
|
|
401
|
-
|
|
402
|
-
// src/index.ts
|
|
403
|
-
var import_set_value = __toESM(require_set_value(), 1);
|
|
404
|
-
function escapeStringRegexp(str) {
|
|
405
|
-
return str.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
406
|
-
}
|
|
407
|
-
function removeExtension(file) {
|
|
408
|
-
return file.replace(/\.[^/.]+$/, "");
|
|
409
|
-
}
|
|
410
|
-
function removeExtensionDeep(file) {
|
|
411
|
-
return file.replace(/(\.[^/.]+)+$/, "");
|
|
412
|
-
}
|
|
413
|
-
function addExtension(filename, ext = ".js") {
|
|
414
|
-
let result = `${filename}`;
|
|
415
|
-
if (!(0, import_node_path.extname)(filename)) {
|
|
416
|
-
result += ext;
|
|
417
|
-
}
|
|
418
|
-
return result;
|
|
419
|
-
}
|
|
420
|
-
function arrify(val) {
|
|
421
|
-
return Array.isArray(val) ? val : [val];
|
|
422
|
-
}
|
|
423
|
-
var defuOverrideArray = createDefu((obj, key, value) => {
|
|
424
|
-
if (Array.isArray(obj[key]) && Array.isArray(value)) {
|
|
425
|
-
obj[key] = value;
|
|
426
|
-
return true;
|
|
427
|
-
}
|
|
428
|
-
});
|
|
429
|
-
function isObject2(x) {
|
|
430
|
-
return typeof x === "object" && x !== null;
|
|
431
|
-
}
|
|
432
|
-
function isEmptyObject(obj) {
|
|
433
|
-
if (isObject2(obj)) {
|
|
434
|
-
let name;
|
|
435
|
-
for (name in obj) {
|
|
436
|
-
return false;
|
|
437
|
-
}
|
|
438
|
-
return true;
|
|
439
|
-
}
|
|
440
|
-
return false;
|
|
441
|
-
}
|
|
442
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
443
|
-
0 && (module.exports = {
|
|
444
|
-
addExtension,
|
|
445
|
-
arrify,
|
|
446
|
-
defu,
|
|
447
|
-
defuOverrideArray,
|
|
448
|
-
escapeStringRegexp,
|
|
449
|
-
get,
|
|
450
|
-
isEmptyObject,
|
|
451
|
-
isObject,
|
|
452
|
-
objectHash,
|
|
453
|
-
removeExtension,
|
|
454
|
-
removeExtensionDeep,
|
|
455
|
-
set
|
|
456
|
-
});
|
|
457
|
-
/*! Bundled license information:
|
|
458
|
-
|
|
459
|
-
is-primitive/index.js:
|
|
460
|
-
(*!
|
|
461
|
-
* is-primitive <https://github.com/jonschlinkert/is-primitive>
|
|
462
|
-
*
|
|
463
|
-
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
464
|
-
* Released under the MIT License.
|
|
465
|
-
*)
|
|
466
|
-
|
|
467
|
-
isobject/index.js:
|
|
468
|
-
(*!
|
|
469
|
-
* isobject <https://github.com/jonschlinkert/isobject>
|
|
470
|
-
*
|
|
471
|
-
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
472
|
-
* Released under the MIT License.
|
|
473
|
-
*)
|
|
474
|
-
|
|
475
|
-
is-plain-object/index.js:
|
|
476
|
-
(*!
|
|
477
|
-
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
478
|
-
*
|
|
479
|
-
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
480
|
-
* Released under the MIT License.
|
|
481
|
-
*)
|
|
482
|
-
|
|
483
|
-
set-value/index.js:
|
|
484
|
-
(*!
|
|
485
|
-
* set-value <https://github.com/jonschlinkert/set-value>
|
|
486
|
-
*
|
|
487
|
-
* Copyright (c) Jon Schlinkert (https://github.com/jonschlinkert).
|
|
488
|
-
* Released under the MIT License.
|
|
489
|
-
*)
|
|
490
|
-
|
|
491
|
-
get-value/dist/index.mjs:
|
|
492
|
-
(*!
|
|
493
|
-
* get-value <https://github.com/jonschlinkert/get-value>
|
|
494
|
-
*
|
|
495
|
-
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
496
|
-
* Released under the MIT License.
|
|
497
|
-
*)
|
|
498
|
-
*/
|
package/dist/index.d.cts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as defu from 'defu';
|
|
2
|
-
export { default as defu } from 'defu';
|
|
3
|
-
export { default as objectHash } from 'object-hash';
|
|
4
|
-
export { default as get } from 'get-value';
|
|
5
|
-
export { default as set } from 'set-value';
|
|
6
|
-
|
|
7
|
-
declare function escapeStringRegexp(str: string): string;
|
|
8
|
-
declare function removeExtension(file: string): string;
|
|
9
|
-
declare function removeExtensionDeep(file: string): string;
|
|
10
|
-
declare function addExtension(filename: string, ext?: string): string;
|
|
11
|
-
declare function arrify<T>(val: T): T | T[];
|
|
12
|
-
|
|
13
|
-
declare const defuOverrideArray: <Source extends {
|
|
14
|
-
[x: string]: any;
|
|
15
|
-
[x: number]: any;
|
|
16
|
-
[x: symbol]: any;
|
|
17
|
-
}, Defaults extends Array<{
|
|
18
|
-
[x: string]: any;
|
|
19
|
-
[x: number]: any;
|
|
20
|
-
[x: symbol]: any;
|
|
21
|
-
} | (number | boolean | any[] | Record<never, any> | null | undefined)>>(source: Source, ...defaults: Defaults) => defu.Defu<Source, Defaults>;
|
|
22
|
-
declare function isObject(x: unknown): x is Record<string | symbol | number, unknown>;
|
|
23
|
-
declare function isEmptyObject(obj: unknown): boolean;
|
|
24
|
-
|
|
25
|
-
export { addExtension, arrify, defuOverrideArray, escapeStringRegexp, isEmptyObject, isObject, removeExtension, removeExtensionDeep };
|