@weapp-core/shared 0.0.0 → 0.0.2-alpha.0
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/dist/index.cjs +111 -5
- package/dist/index.d.cts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +105 -5
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -33,9 +33,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
33
|
));
|
|
34
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
35
|
|
|
36
|
-
// ../../node_modules/.pnpm/tsup@8.2.
|
|
36
|
+
// ../../node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.40_tsx@4.16.5_typescript@5.4.5_yaml@2.5.0/node_modules/tsup/assets/cjs_shims.js
|
|
37
37
|
var init_cjs_shims = __esm({
|
|
38
|
-
"../../node_modules/.pnpm/tsup@8.2.
|
|
38
|
+
"../../node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.40_tsx@4.16.5_typescript@5.4.5_yaml@2.5.0/node_modules/tsup/assets/cjs_shims.js"() {
|
|
39
39
|
"use strict";
|
|
40
40
|
}
|
|
41
41
|
});
|
|
@@ -74,7 +74,7 @@ var require_is_plain_object = __commonJS({
|
|
|
74
74
|
function isObjectObject(o) {
|
|
75
75
|
return isObject(o) === true && Object.prototype.toString.call(o) === "[object Object]";
|
|
76
76
|
}
|
|
77
|
-
module2.exports = function
|
|
77
|
+
module2.exports = function isPlainObject2(o) {
|
|
78
78
|
var ctor, prot;
|
|
79
79
|
if (isObjectObject(o) === false) return false;
|
|
80
80
|
ctor = o.constructor;
|
|
@@ -96,7 +96,7 @@ var require_set_value = __commonJS({
|
|
|
96
96
|
init_cjs_shims();
|
|
97
97
|
var { deleteProperty } = Reflect;
|
|
98
98
|
var isPrimitive = require_is_primitive();
|
|
99
|
-
var
|
|
99
|
+
var isPlainObject2 = require_is_plain_object();
|
|
100
100
|
var isObject = (value) => {
|
|
101
101
|
return typeof value === "object" && value !== null || typeof value === "function";
|
|
102
102
|
};
|
|
@@ -177,7 +177,7 @@ var require_set_value = __commonJS({
|
|
|
177
177
|
deleteProperty(obj, prop);
|
|
178
178
|
} else if (options && options.merge) {
|
|
179
179
|
const merge = options.merge === "function" ? options.merge : Object.assign;
|
|
180
|
-
if (merge &&
|
|
180
|
+
if (merge && isPlainObject2(obj[prop]) && isPlainObject2(value)) {
|
|
181
181
|
obj[prop] = merge(obj[prop], value);
|
|
182
182
|
} else {
|
|
183
183
|
obj[prop] = value;
|
|
@@ -312,16 +312,122 @@ var require_get_value = __commonJS({
|
|
|
312
312
|
// src/index.ts
|
|
313
313
|
var src_exports = {};
|
|
314
314
|
__export(src_exports, {
|
|
315
|
+
addExtension: () => addExtension,
|
|
316
|
+
arrify: () => arrify,
|
|
317
|
+
defu: () => defu,
|
|
318
|
+
defuOverrideArray: () => defuOverrideArray,
|
|
319
|
+
escapeStringRegexp: () => escapeStringRegexp,
|
|
315
320
|
get: () => import_get_value.default,
|
|
321
|
+
removeExtension: () => removeExtension,
|
|
316
322
|
set: () => import_set_value.default
|
|
317
323
|
});
|
|
318
324
|
module.exports = __toCommonJS(src_exports);
|
|
319
325
|
init_cjs_shims();
|
|
326
|
+
var import_node_path = require("path");
|
|
327
|
+
|
|
328
|
+
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
329
|
+
init_cjs_shims();
|
|
330
|
+
function isPlainObject(value) {
|
|
331
|
+
if (value === null || typeof value !== "object") {
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
const prototype = Object.getPrototypeOf(value);
|
|
335
|
+
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
if (Symbol.iterator in value) {
|
|
339
|
+
return false;
|
|
340
|
+
}
|
|
341
|
+
if (Symbol.toStringTag in value) {
|
|
342
|
+
return Object.prototype.toString.call(value) === "[object Module]";
|
|
343
|
+
}
|
|
344
|
+
return true;
|
|
345
|
+
}
|
|
346
|
+
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
347
|
+
if (!isPlainObject(defaults)) {
|
|
348
|
+
return _defu(baseObject, {}, namespace, merger);
|
|
349
|
+
}
|
|
350
|
+
const object = Object.assign({}, defaults);
|
|
351
|
+
for (const key in baseObject) {
|
|
352
|
+
if (key === "__proto__" || key === "constructor") {
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
const value = baseObject[key];
|
|
356
|
+
if (value === null || value === void 0) {
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
if (merger && merger(object, key, value, namespace)) {
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
363
|
+
object[key] = [...value, ...object[key]];
|
|
364
|
+
} else if (isPlainObject(value) && isPlainObject(object[key])) {
|
|
365
|
+
object[key] = _defu(
|
|
366
|
+
value,
|
|
367
|
+
object[key],
|
|
368
|
+
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
369
|
+
merger
|
|
370
|
+
);
|
|
371
|
+
} else {
|
|
372
|
+
object[key] = value;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return object;
|
|
376
|
+
}
|
|
377
|
+
function createDefu(merger) {
|
|
378
|
+
return (...arguments_) => (
|
|
379
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
380
|
+
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
var defu = createDefu();
|
|
384
|
+
var defuFn = createDefu((object, key, currentValue) => {
|
|
385
|
+
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
386
|
+
object[key] = currentValue(object[key]);
|
|
387
|
+
return true;
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
var defuArrayFn = createDefu((object, key, currentValue) => {
|
|
391
|
+
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
392
|
+
object[key] = currentValue(object[key]);
|
|
393
|
+
return true;
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
// src/index.ts
|
|
320
398
|
var import_set_value = __toESM(require_set_value(), 1);
|
|
321
399
|
var import_get_value = __toESM(require_get_value(), 1);
|
|
400
|
+
function escapeStringRegexp(str) {
|
|
401
|
+
return str.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
402
|
+
}
|
|
403
|
+
function removeExtension(file) {
|
|
404
|
+
return file.replace(/\.[^/.]+$/, "");
|
|
405
|
+
}
|
|
406
|
+
function addExtension(filename, ext = ".js") {
|
|
407
|
+
let result = `${filename}`;
|
|
408
|
+
if (!(0, import_node_path.extname)(filename)) {
|
|
409
|
+
result += ext;
|
|
410
|
+
}
|
|
411
|
+
return result;
|
|
412
|
+
}
|
|
413
|
+
function arrify(val) {
|
|
414
|
+
return Array.isArray(val) ? val : [val];
|
|
415
|
+
}
|
|
416
|
+
var defuOverrideArray = createDefu((obj, key, value) => {
|
|
417
|
+
if (Array.isArray(obj[key]) && Array.isArray(value)) {
|
|
418
|
+
obj[key] = value;
|
|
419
|
+
return true;
|
|
420
|
+
}
|
|
421
|
+
});
|
|
322
422
|
// Annotate the CommonJS export names for ESM import in node:
|
|
323
423
|
0 && (module.exports = {
|
|
424
|
+
addExtension,
|
|
425
|
+
arrify,
|
|
426
|
+
defu,
|
|
427
|
+
defuOverrideArray,
|
|
428
|
+
escapeStringRegexp,
|
|
324
429
|
get,
|
|
430
|
+
removeExtension,
|
|
325
431
|
set
|
|
326
432
|
});
|
|
327
433
|
/*! Bundled license information:
|
package/dist/index.d.cts
CHANGED
|
@@ -1,2 +1,21 @@
|
|
|
1
|
+
import * as defu from 'defu';
|
|
2
|
+
export { default as defu } from 'defu';
|
|
1
3
|
export { default as set } from 'set-value';
|
|
2
4
|
export { default as get } from 'get-value';
|
|
5
|
+
|
|
6
|
+
declare function escapeStringRegexp(str: string): string;
|
|
7
|
+
declare function removeExtension(file: string): string;
|
|
8
|
+
declare function addExtension(filename: string, ext?: string): string;
|
|
9
|
+
declare function arrify<T>(val: T): T | T[];
|
|
10
|
+
|
|
11
|
+
declare const defuOverrideArray: <Source extends {
|
|
12
|
+
[x: string]: any;
|
|
13
|
+
[x: number]: any;
|
|
14
|
+
[x: symbol]: any;
|
|
15
|
+
}, Defaults extends ({
|
|
16
|
+
[x: string]: any;
|
|
17
|
+
[x: number]: any;
|
|
18
|
+
[x: symbol]: any;
|
|
19
|
+
} | (number | boolean | any[] | Record<never, any> | null | undefined))[]>(source: Source, ...defaults: Defaults) => defu.Defu<Source, Defaults>;
|
|
20
|
+
|
|
21
|
+
export { addExtension, arrify, defuOverrideArray, escapeStringRegexp, removeExtension };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,21 @@
|
|
|
1
|
+
import * as defu from 'defu';
|
|
2
|
+
export { default as defu } from 'defu';
|
|
1
3
|
export { default as set } from 'set-value';
|
|
2
4
|
export { default as get } from 'get-value';
|
|
5
|
+
|
|
6
|
+
declare function escapeStringRegexp(str: string): string;
|
|
7
|
+
declare function removeExtension(file: string): string;
|
|
8
|
+
declare function addExtension(filename: string, ext?: string): string;
|
|
9
|
+
declare function arrify<T>(val: T): T | T[];
|
|
10
|
+
|
|
11
|
+
declare const defuOverrideArray: <Source extends {
|
|
12
|
+
[x: string]: any;
|
|
13
|
+
[x: number]: any;
|
|
14
|
+
[x: symbol]: any;
|
|
15
|
+
}, Defaults extends ({
|
|
16
|
+
[x: string]: any;
|
|
17
|
+
[x: number]: any;
|
|
18
|
+
[x: symbol]: any;
|
|
19
|
+
} | (number | boolean | any[] | Record<never, any> | null | undefined))[]>(source: Source, ...defaults: Defaults) => defu.Defu<Source, Defaults>;
|
|
20
|
+
|
|
21
|
+
export { addExtension, arrify, defuOverrideArray, escapeStringRegexp, removeExtension };
|
package/dist/index.js
CHANGED
|
@@ -27,9 +27,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
mod
|
|
28
28
|
));
|
|
29
29
|
|
|
30
|
-
// ../../node_modules/.pnpm/tsup@8.2.
|
|
30
|
+
// ../../node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.40_tsx@4.16.5_typescript@5.4.5_yaml@2.5.0/node_modules/tsup/assets/esm_shims.js
|
|
31
31
|
var init_esm_shims = __esm({
|
|
32
|
-
"../../node_modules/.pnpm/tsup@8.2.
|
|
32
|
+
"../../node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.40_tsx@4.16.5_typescript@5.4.5_yaml@2.5.0/node_modules/tsup/assets/esm_shims.js"() {
|
|
33
33
|
"use strict";
|
|
34
34
|
}
|
|
35
35
|
});
|
|
@@ -68,7 +68,7 @@ var require_is_plain_object = __commonJS({
|
|
|
68
68
|
function isObjectObject(o) {
|
|
69
69
|
return isObject(o) === true && Object.prototype.toString.call(o) === "[object Object]";
|
|
70
70
|
}
|
|
71
|
-
module.exports = function
|
|
71
|
+
module.exports = function isPlainObject2(o) {
|
|
72
72
|
var ctor, prot;
|
|
73
73
|
if (isObjectObject(o) === false) return false;
|
|
74
74
|
ctor = o.constructor;
|
|
@@ -90,7 +90,7 @@ var require_set_value = __commonJS({
|
|
|
90
90
|
init_esm_shims();
|
|
91
91
|
var { deleteProperty } = Reflect;
|
|
92
92
|
var isPrimitive = require_is_primitive();
|
|
93
|
-
var
|
|
93
|
+
var isPlainObject2 = require_is_plain_object();
|
|
94
94
|
var isObject = (value) => {
|
|
95
95
|
return typeof value === "object" && value !== null || typeof value === "function";
|
|
96
96
|
};
|
|
@@ -171,7 +171,7 @@ var require_set_value = __commonJS({
|
|
|
171
171
|
deleteProperty(obj, prop);
|
|
172
172
|
} else if (options && options.merge) {
|
|
173
173
|
const merge = options.merge === "function" ? options.merge : Object.assign;
|
|
174
|
-
if (merge &&
|
|
174
|
+
if (merge && isPlainObject2(obj[prop]) && isPlainObject2(value)) {
|
|
175
175
|
obj[prop] = merge(obj[prop], value);
|
|
176
176
|
} else {
|
|
177
177
|
obj[prop] = value;
|
|
@@ -305,12 +305,112 @@ var require_get_value = __commonJS({
|
|
|
305
305
|
|
|
306
306
|
// src/index.ts
|
|
307
307
|
init_esm_shims();
|
|
308
|
+
import { extname } from "node:path";
|
|
309
|
+
|
|
310
|
+
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
311
|
+
init_esm_shims();
|
|
312
|
+
function isPlainObject(value) {
|
|
313
|
+
if (value === null || typeof value !== "object") {
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
const prototype = Object.getPrototypeOf(value);
|
|
317
|
+
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
if (Symbol.iterator in value) {
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
if (Symbol.toStringTag in value) {
|
|
324
|
+
return Object.prototype.toString.call(value) === "[object Module]";
|
|
325
|
+
}
|
|
326
|
+
return true;
|
|
327
|
+
}
|
|
328
|
+
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
329
|
+
if (!isPlainObject(defaults)) {
|
|
330
|
+
return _defu(baseObject, {}, namespace, merger);
|
|
331
|
+
}
|
|
332
|
+
const object = Object.assign({}, defaults);
|
|
333
|
+
for (const key in baseObject) {
|
|
334
|
+
if (key === "__proto__" || key === "constructor") {
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
const value = baseObject[key];
|
|
338
|
+
if (value === null || value === void 0) {
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
if (merger && merger(object, key, value, namespace)) {
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
345
|
+
object[key] = [...value, ...object[key]];
|
|
346
|
+
} else if (isPlainObject(value) && isPlainObject(object[key])) {
|
|
347
|
+
object[key] = _defu(
|
|
348
|
+
value,
|
|
349
|
+
object[key],
|
|
350
|
+
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
351
|
+
merger
|
|
352
|
+
);
|
|
353
|
+
} else {
|
|
354
|
+
object[key] = value;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return object;
|
|
358
|
+
}
|
|
359
|
+
function createDefu(merger) {
|
|
360
|
+
return (...arguments_) => (
|
|
361
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
362
|
+
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
var defu = createDefu();
|
|
366
|
+
var defuFn = createDefu((object, key, currentValue) => {
|
|
367
|
+
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
368
|
+
object[key] = currentValue(object[key]);
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
var defuArrayFn = createDefu((object, key, currentValue) => {
|
|
373
|
+
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
374
|
+
object[key] = currentValue(object[key]);
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
// src/index.ts
|
|
308
380
|
var import_set_value = __toESM(require_set_value(), 1);
|
|
309
381
|
var import_get_value = __toESM(require_get_value(), 1);
|
|
382
|
+
function escapeStringRegexp(str) {
|
|
383
|
+
return str.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
384
|
+
}
|
|
385
|
+
function removeExtension(file) {
|
|
386
|
+
return file.replace(/\.[^/.]+$/, "");
|
|
387
|
+
}
|
|
388
|
+
function addExtension(filename, ext = ".js") {
|
|
389
|
+
let result = `${filename}`;
|
|
390
|
+
if (!extname(filename)) {
|
|
391
|
+
result += ext;
|
|
392
|
+
}
|
|
393
|
+
return result;
|
|
394
|
+
}
|
|
395
|
+
function arrify(val) {
|
|
396
|
+
return Array.isArray(val) ? val : [val];
|
|
397
|
+
}
|
|
398
|
+
var defuOverrideArray = createDefu((obj, key, value) => {
|
|
399
|
+
if (Array.isArray(obj[key]) && Array.isArray(value)) {
|
|
400
|
+
obj[key] = value;
|
|
401
|
+
return true;
|
|
402
|
+
}
|
|
403
|
+
});
|
|
310
404
|
var export_get = import_get_value.default;
|
|
311
405
|
var export_set = import_set_value.default;
|
|
312
406
|
export {
|
|
407
|
+
addExtension,
|
|
408
|
+
arrify,
|
|
409
|
+
defu,
|
|
410
|
+
defuOverrideArray,
|
|
411
|
+
escapeStringRegexp,
|
|
313
412
|
export_get as get,
|
|
413
|
+
removeExtension,
|
|
314
414
|
export_set as set
|
|
315
415
|
};
|
|
316
416
|
/*! Bundled license information:
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-core/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0",
|
|
4
|
+
"version": "0.0.2-alpha.0",
|
|
5
5
|
"description": "@weapp-core/shared",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "ISC",
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
"require": "./dist/index.cjs"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
+
"main": "./dist/index.cjs",
|
|
18
|
+
"module": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
17
20
|
"files": [
|
|
18
21
|
"dist"
|
|
19
22
|
],
|
|
@@ -25,8 +28,5 @@
|
|
|
25
28
|
"release": "pnpm publish",
|
|
26
29
|
"lint": "eslint .",
|
|
27
30
|
"lint:fix": "eslint . --fix"
|
|
28
|
-
}
|
|
29
|
-
"main": "./dist/index.cjs",
|
|
30
|
-
"module": "./dist/index.js",
|
|
31
|
-
"types": "./dist/index.d.ts"
|
|
31
|
+
}
|
|
32
32
|
}
|