@weapp-core/shared 1.0.5 → 1.0.7

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 CHANGED
@@ -33,114 +33,13 @@ 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.3.5_@swc+core@1.10.4_jiti@2.4.2_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/cjs_shims.js
36
+ // ../../node_modules/.pnpm/tsup@8.4.0_@swc+core@1.11.21_jiti@2.4.2_postcss@8.5.3_tsx@4.19.3_typescript@5.8.3_yaml@2.7.1/node_modules/tsup/assets/cjs_shims.js
37
37
  var init_cjs_shims = __esm({
38
- "../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.10.4_jiti@2.4.2_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/cjs_shims.js"() {
38
+ "../../node_modules/.pnpm/tsup@8.4.0_@swc+core@1.11.21_jiti@2.4.2_postcss@8.5.3_tsx@4.19.3_typescript@5.8.3_yaml@2.7.1/node_modules/tsup/assets/cjs_shims.js"() {
39
39
  "use strict";
40
40
  }
41
41
  });
42
42
 
43
- // ../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js
44
- var require_isobject = __commonJS({
45
- "../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js"(exports2, module2) {
46
- "use strict";
47
- init_cjs_shims();
48
- module2.exports = function isObject2(val) {
49
- return val != null && typeof val === "object" && Array.isArray(val) === false;
50
- };
51
- }
52
- });
53
-
54
- // ../../node_modules/.pnpm/get-value@3.0.1/node_modules/get-value/index.js
55
- var require_get_value = __commonJS({
56
- "../../node_modules/.pnpm/get-value@3.0.1/node_modules/get-value/index.js"(exports2, module2) {
57
- "use strict";
58
- init_cjs_shims();
59
- var isObject2 = require_isobject();
60
- module2.exports = function(target, path, options) {
61
- if (!isObject2(options)) {
62
- options = { default: options };
63
- }
64
- if (!isValidObject(target)) {
65
- return typeof options.default !== "undefined" ? options.default : target;
66
- }
67
- if (typeof path === "number") {
68
- path = String(path);
69
- }
70
- const isArray = Array.isArray(path);
71
- const isString = typeof path === "string";
72
- const splitChar = options.separator || ".";
73
- const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : ".");
74
- if (!isString && !isArray) {
75
- return target;
76
- }
77
- if (isString && path in target) {
78
- return isValid(path, target, options) ? target[path] : options.default;
79
- }
80
- let segs = isArray ? path : split(path, splitChar, options);
81
- let len = segs.length;
82
- let idx = 0;
83
- do {
84
- let prop = segs[idx];
85
- if (typeof prop === "number") {
86
- prop = String(prop);
87
- }
88
- while (prop && prop.slice(-1) === "\\") {
89
- prop = join([prop.slice(0, -1), segs[++idx] || ""], joinChar, options);
90
- }
91
- if (prop in target) {
92
- if (!isValid(prop, target, options)) {
93
- return options.default;
94
- }
95
- target = target[prop];
96
- } else {
97
- let hasProp = false;
98
- let n = idx + 1;
99
- while (n < len) {
100
- prop = join([prop, segs[n++]], joinChar, options);
101
- if (hasProp = prop in target) {
102
- if (!isValid(prop, target, options)) {
103
- return options.default;
104
- }
105
- target = target[prop];
106
- idx = n - 1;
107
- break;
108
- }
109
- }
110
- if (!hasProp) {
111
- return options.default;
112
- }
113
- }
114
- } while (++idx < len && isValidObject(target));
115
- if (idx === len) {
116
- return target;
117
- }
118
- return options.default;
119
- };
120
- function join(segs, joinChar, options) {
121
- if (typeof options.join === "function") {
122
- return options.join(segs);
123
- }
124
- return segs[0] + joinChar + segs[1];
125
- }
126
- function split(path, splitChar, options) {
127
- if (typeof options.split === "function") {
128
- return options.split(path);
129
- }
130
- return path.split(splitChar);
131
- }
132
- function isValid(key, target, options) {
133
- if (typeof options.isValid === "function") {
134
- return options.isValid(key, target);
135
- }
136
- return true;
137
- }
138
- function isValidObject(val) {
139
- return isObject2(val) || Array.isArray(val) || typeof val === "function";
140
- }
141
- }
142
- });
143
-
144
43
  // ../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js
145
44
  var require_is_primitive = __commonJS({
146
45
  "../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js"(exports2, module2) {
@@ -155,14 +54,25 @@ var require_is_primitive = __commonJS({
155
54
  }
156
55
  });
157
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
+
158
68
  // ../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js
159
69
  var require_is_plain_object = __commonJS({
160
70
  "../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js"(exports2, module2) {
161
71
  "use strict";
162
72
  init_cjs_shims();
163
- var isObject2 = require_isobject();
73
+ var isObject3 = require_isobject();
164
74
  function isObjectObject(o) {
165
- return isObject2(o) === true && Object.prototype.toString.call(o) === "[object Object]";
75
+ return isObject3(o) === true && Object.prototype.toString.call(o) === "[object Object]";
166
76
  }
167
77
  module2.exports = function isPlainObject2(o) {
168
78
  var ctor, prot;
@@ -187,7 +97,7 @@ var require_set_value = __commonJS({
187
97
  var { deleteProperty } = Reflect;
188
98
  var isPrimitive = require_is_primitive();
189
99
  var isPlainObject2 = require_is_plain_object();
190
- var isObject2 = (value) => {
100
+ var isObject3 = (value) => {
191
101
  return typeof value === "object" && value !== null || typeof value === "function";
192
102
  };
193
103
  var isUnsafeKey = (key) => {
@@ -255,7 +165,7 @@ var require_set_value = __commonJS({
255
165
  }
256
166
  return parts;
257
167
  };
258
- var split = (input, options) => {
168
+ var split2 = (input, options) => {
259
169
  if (options && typeof options.split === "function") return options.split(input);
260
170
  if (typeof input === "symbol") return [input];
261
171
  if (Array.isArray(input)) return input;
@@ -278,8 +188,8 @@ var require_set_value = __commonJS({
278
188
  return obj;
279
189
  };
280
190
  var setValue = (target, path, value, options) => {
281
- if (!path || !isObject2(target)) return target;
282
- const keys = split(path, options);
191
+ if (!path || !isObject3(target)) return target;
192
+ const keys = split2(path, options);
283
193
  let obj = target;
284
194
  for (let i = 0; i < keys.length; i++) {
285
195
  const key = keys[i];
@@ -293,14 +203,14 @@ var require_set_value = __commonJS({
293
203
  obj = obj[key] = [];
294
204
  continue;
295
205
  }
296
- if (!isObject2(obj[key])) {
206
+ if (!isObject3(obj[key])) {
297
207
  obj[key] = {};
298
208
  }
299
209
  obj = obj[key];
300
210
  }
301
211
  return target;
302
212
  };
303
- setValue.split = split;
213
+ setValue.split = split2;
304
214
  setValue.cache = /* @__PURE__ */ new Map();
305
215
  setValue.clear = () => {
306
216
  setValue.cache = /* @__PURE__ */ new Map();
@@ -317,8 +227,9 @@ __export(index_exports, {
317
227
  defu: () => defu,
318
228
  defuOverrideArray: () => defuOverrideArray,
319
229
  escapeStringRegexp: () => escapeStringRegexp,
320
- get: () => import_get_value.default,
321
- isObject: () => isObject,
230
+ get: () => index_default,
231
+ isEmptyObject: () => isEmptyObject,
232
+ isObject: () => isObject2,
322
233
  objectHash: () => import_object_hash.default,
323
234
  removeExtension: () => removeExtension,
324
235
  removeExtensionDeep: () => removeExtensionDeep,
@@ -399,7 +310,96 @@ var defuArrayFn = createDefu((object, key, currentValue) => {
399
310
 
400
311
  // src/index.ts
401
312
  var import_object_hash = __toESM(require("object-hash"), 1);
402
- var import_get_value = __toESM(require_get_value(), 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
403
  var import_set_value = __toESM(require_set_value(), 1);
404
404
  function escapeStringRegexp(str) {
405
405
  return str.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
@@ -426,9 +426,19 @@ var defuOverrideArray = createDefu((obj, key, value) => {
426
426
  return true;
427
427
  }
428
428
  });
429
- function isObject(x) {
429
+ function isObject2(x) {
430
430
  return typeof x === "object" && x !== null;
431
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
+ }
432
442
  // Annotate the CommonJS export names for ESM import in node:
433
443
  0 && (module.exports = {
434
444
  addExtension,
@@ -437,6 +447,7 @@ function isObject(x) {
437
447
  defuOverrideArray,
438
448
  escapeStringRegexp,
439
449
  get,
450
+ isEmptyObject,
440
451
  isObject,
441
452
  objectHash,
442
453
  removeExtension,
@@ -445,27 +456,19 @@ function isObject(x) {
445
456
  });
446
457
  /*! Bundled license information:
447
458
 
448
- isobject/index.js:
449
- (*!
450
- * isobject <https://github.com/jonschlinkert/isobject>
451
- *
452
- * Copyright (c) 2014-2017, Jon Schlinkert.
453
- * Released under the MIT License.
454
- *)
455
-
456
- get-value/index.js:
459
+ is-primitive/index.js:
457
460
  (*!
458
- * get-value <https://github.com/jonschlinkert/get-value>
461
+ * is-primitive <https://github.com/jonschlinkert/is-primitive>
459
462
  *
460
- * Copyright (c) 2014-2018, Jon Schlinkert.
463
+ * Copyright (c) 2014-present, Jon Schlinkert.
461
464
  * Released under the MIT License.
462
465
  *)
463
466
 
464
- is-primitive/index.js:
467
+ isobject/index.js:
465
468
  (*!
466
- * is-primitive <https://github.com/jonschlinkert/is-primitive>
469
+ * isobject <https://github.com/jonschlinkert/isobject>
467
470
  *
468
- * Copyright (c) 2014-present, Jon Schlinkert.
471
+ * Copyright (c) 2014-2017, Jon Schlinkert.
469
472
  * Released under the MIT License.
470
473
  *)
471
474
 
@@ -484,4 +487,12 @@ set-value/index.js:
484
487
  * Copyright (c) Jon Schlinkert (https://github.com/jonschlinkert).
485
488
  * Released under the MIT License.
486
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
+ *)
487
498
  */
package/dist/index.d.cts CHANGED
@@ -20,5 +20,6 @@ declare const defuOverrideArray: <Source extends {
20
20
  [x: symbol]: any;
21
21
  } | (number | boolean | any[] | Record<never, any> | null | undefined)>>(source: Source, ...defaults: Defaults) => defu.Defu<Source, Defaults>;
22
22
  declare function isObject(x: unknown): x is Record<string | symbol | number, unknown>;
23
+ declare function isEmptyObject(obj: unknown): boolean;
23
24
 
24
- export { addExtension, arrify, defuOverrideArray, escapeStringRegexp, isObject, removeExtension, removeExtensionDeep };
25
+ export { addExtension, arrify, defuOverrideArray, escapeStringRegexp, isEmptyObject, isObject, removeExtension, removeExtensionDeep };
package/dist/index.d.ts CHANGED
@@ -20,5 +20,6 @@ declare const defuOverrideArray: <Source extends {
20
20
  [x: symbol]: any;
21
21
  } | (number | boolean | any[] | Record<never, any> | null | undefined)>>(source: Source, ...defaults: Defaults) => defu.Defu<Source, Defaults>;
22
22
  declare function isObject(x: unknown): x is Record<string | symbol | number, unknown>;
23
+ declare function isEmptyObject(obj: unknown): boolean;
23
24
 
24
- export { addExtension, arrify, defuOverrideArray, escapeStringRegexp, isObject, removeExtension, removeExtensionDeep };
25
+ export { addExtension, arrify, defuOverrideArray, escapeStringRegexp, isEmptyObject, isObject, removeExtension, removeExtensionDeep };
package/dist/index.js CHANGED
@@ -27,114 +27,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  mod
28
28
  ));
29
29
 
30
- // ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.10.4_jiti@2.4.2_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/esm_shims.js
30
+ // ../../node_modules/.pnpm/tsup@8.4.0_@swc+core@1.11.21_jiti@2.4.2_postcss@8.5.3_tsx@4.19.3_typescript@5.8.3_yaml@2.7.1/node_modules/tsup/assets/esm_shims.js
31
31
  var init_esm_shims = __esm({
32
- "../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.10.4_jiti@2.4.2_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/esm_shims.js"() {
32
+ "../../node_modules/.pnpm/tsup@8.4.0_@swc+core@1.11.21_jiti@2.4.2_postcss@8.5.3_tsx@4.19.3_typescript@5.8.3_yaml@2.7.1/node_modules/tsup/assets/esm_shims.js"() {
33
33
  "use strict";
34
34
  }
35
35
  });
36
36
 
37
- // ../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js
38
- var require_isobject = __commonJS({
39
- "../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js"(exports, module) {
40
- "use strict";
41
- init_esm_shims();
42
- module.exports = function isObject2(val) {
43
- return val != null && typeof val === "object" && Array.isArray(val) === false;
44
- };
45
- }
46
- });
47
-
48
- // ../../node_modules/.pnpm/get-value@3.0.1/node_modules/get-value/index.js
49
- var require_get_value = __commonJS({
50
- "../../node_modules/.pnpm/get-value@3.0.1/node_modules/get-value/index.js"(exports, module) {
51
- "use strict";
52
- init_esm_shims();
53
- var isObject2 = require_isobject();
54
- module.exports = function(target, path, options) {
55
- if (!isObject2(options)) {
56
- options = { default: options };
57
- }
58
- if (!isValidObject(target)) {
59
- return typeof options.default !== "undefined" ? options.default : target;
60
- }
61
- if (typeof path === "number") {
62
- path = String(path);
63
- }
64
- const isArray = Array.isArray(path);
65
- const isString = typeof path === "string";
66
- const splitChar = options.separator || ".";
67
- const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : ".");
68
- if (!isString && !isArray) {
69
- return target;
70
- }
71
- if (isString && path in target) {
72
- return isValid(path, target, options) ? target[path] : options.default;
73
- }
74
- let segs = isArray ? path : split(path, splitChar, options);
75
- let len = segs.length;
76
- let idx = 0;
77
- do {
78
- let prop = segs[idx];
79
- if (typeof prop === "number") {
80
- prop = String(prop);
81
- }
82
- while (prop && prop.slice(-1) === "\\") {
83
- prop = join([prop.slice(0, -1), segs[++idx] || ""], joinChar, options);
84
- }
85
- if (prop in target) {
86
- if (!isValid(prop, target, options)) {
87
- return options.default;
88
- }
89
- target = target[prop];
90
- } else {
91
- let hasProp = false;
92
- let n = idx + 1;
93
- while (n < len) {
94
- prop = join([prop, segs[n++]], joinChar, options);
95
- if (hasProp = prop in target) {
96
- if (!isValid(prop, target, options)) {
97
- return options.default;
98
- }
99
- target = target[prop];
100
- idx = n - 1;
101
- break;
102
- }
103
- }
104
- if (!hasProp) {
105
- return options.default;
106
- }
107
- }
108
- } while (++idx < len && isValidObject(target));
109
- if (idx === len) {
110
- return target;
111
- }
112
- return options.default;
113
- };
114
- function join(segs, joinChar, options) {
115
- if (typeof options.join === "function") {
116
- return options.join(segs);
117
- }
118
- return segs[0] + joinChar + segs[1];
119
- }
120
- function split(path, splitChar, options) {
121
- if (typeof options.split === "function") {
122
- return options.split(path);
123
- }
124
- return path.split(splitChar);
125
- }
126
- function isValid(key, target, options) {
127
- if (typeof options.isValid === "function") {
128
- return options.isValid(key, target);
129
- }
130
- return true;
131
- }
132
- function isValidObject(val) {
133
- return isObject2(val) || Array.isArray(val) || typeof val === "function";
134
- }
135
- }
136
- });
137
-
138
37
  // ../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js
139
38
  var require_is_primitive = __commonJS({
140
39
  "../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js"(exports, module) {
@@ -149,14 +48,25 @@ var require_is_primitive = __commonJS({
149
48
  }
150
49
  });
151
50
 
51
+ // ../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js
52
+ var require_isobject = __commonJS({
53
+ "../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js"(exports, module) {
54
+ "use strict";
55
+ init_esm_shims();
56
+ module.exports = function isObject3(val) {
57
+ return val != null && typeof val === "object" && Array.isArray(val) === false;
58
+ };
59
+ }
60
+ });
61
+
152
62
  // ../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js
153
63
  var require_is_plain_object = __commonJS({
154
64
  "../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js"(exports, module) {
155
65
  "use strict";
156
66
  init_esm_shims();
157
- var isObject2 = require_isobject();
67
+ var isObject3 = require_isobject();
158
68
  function isObjectObject(o) {
159
- return isObject2(o) === true && Object.prototype.toString.call(o) === "[object Object]";
69
+ return isObject3(o) === true && Object.prototype.toString.call(o) === "[object Object]";
160
70
  }
161
71
  module.exports = function isPlainObject2(o) {
162
72
  var ctor, prot;
@@ -181,7 +91,7 @@ var require_set_value = __commonJS({
181
91
  var { deleteProperty } = Reflect;
182
92
  var isPrimitive = require_is_primitive();
183
93
  var isPlainObject2 = require_is_plain_object();
184
- var isObject2 = (value) => {
94
+ var isObject3 = (value) => {
185
95
  return typeof value === "object" && value !== null || typeof value === "function";
186
96
  };
187
97
  var isUnsafeKey = (key) => {
@@ -249,7 +159,7 @@ var require_set_value = __commonJS({
249
159
  }
250
160
  return parts;
251
161
  };
252
- var split = (input, options) => {
162
+ var split2 = (input, options) => {
253
163
  if (options && typeof options.split === "function") return options.split(input);
254
164
  if (typeof input === "symbol") return [input];
255
165
  if (Array.isArray(input)) return input;
@@ -272,8 +182,8 @@ var require_set_value = __commonJS({
272
182
  return obj;
273
183
  };
274
184
  var setValue = (target, path, value, options) => {
275
- if (!path || !isObject2(target)) return target;
276
- const keys = split(path, options);
185
+ if (!path || !isObject3(target)) return target;
186
+ const keys = split2(path, options);
277
187
  let obj = target;
278
188
  for (let i = 0; i < keys.length; i++) {
279
189
  const key = keys[i];
@@ -287,14 +197,14 @@ var require_set_value = __commonJS({
287
197
  obj = obj[key] = [];
288
198
  continue;
289
199
  }
290
- if (!isObject2(obj[key])) {
200
+ if (!isObject3(obj[key])) {
291
201
  obj[key] = {};
292
202
  }
293
203
  obj = obj[key];
294
204
  }
295
205
  return target;
296
206
  };
297
- setValue.split = split;
207
+ setValue.split = split2;
298
208
  setValue.cache = /* @__PURE__ */ new Map();
299
209
  setValue.clear = () => {
300
210
  setValue.cache = /* @__PURE__ */ new Map();
@@ -377,9 +287,98 @@ var defuArrayFn = createDefu((object, key, currentValue) => {
377
287
  });
378
288
 
379
289
  // src/index.ts
380
- var import_get_value = __toESM(require_get_value(), 1);
381
- var import_set_value = __toESM(require_set_value(), 1);
382
290
  import objectHash from "object-hash";
291
+
292
+ // ../../node_modules/.pnpm/get-value@4.0.1/node_modules/get-value/dist/index.mjs
293
+ init_esm_shims();
294
+ var __defProp2 = Object.defineProperty;
295
+ var __name = (target, value) => __defProp2(target, "name", { value, configurable: true });
296
+ var isObject = /* @__PURE__ */ __name((v) => v !== null && typeof v === "object", "isObject");
297
+ var join = /* @__PURE__ */ __name((segs, joinChar, options) => {
298
+ if (typeof options.join === "function") {
299
+ return options.join(segs);
300
+ }
301
+ return segs[0] + joinChar + segs[1];
302
+ }, "join");
303
+ var split = /* @__PURE__ */ __name((path, splitChar, options) => {
304
+ if (typeof options.split === "function") {
305
+ return options.split(path);
306
+ }
307
+ return path.split(splitChar);
308
+ }, "split");
309
+ var isValid = /* @__PURE__ */ __name((key, target = {}, options) => {
310
+ if (typeof options?.isValid === "function") {
311
+ return options.isValid(key, target);
312
+ }
313
+ return true;
314
+ }, "isValid");
315
+ var isValidObject = /* @__PURE__ */ __name((v) => {
316
+ return isObject(v) || typeof v === "function";
317
+ }, "isValidObject");
318
+ var getValue = /* @__PURE__ */ __name((target, path, options = {}) => {
319
+ if (!isObject(options)) {
320
+ options = { default: options };
321
+ }
322
+ if (!isValidObject(target)) {
323
+ return typeof options.default !== "undefined" ? options.default : target;
324
+ }
325
+ if (typeof path === "number") {
326
+ path = String(path);
327
+ }
328
+ const pathIsArray = Array.isArray(path);
329
+ const pathIsString = typeof path === "string";
330
+ const splitChar = options.separator || ".";
331
+ const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : ".");
332
+ if (!pathIsString && !pathIsArray) {
333
+ return target;
334
+ }
335
+ if (target[path] !== void 0) {
336
+ return isValid(path, target, options) ? target[path] : options.default;
337
+ }
338
+ const segs = pathIsArray ? path : split(path, splitChar, options);
339
+ const len = segs.length;
340
+ let idx = 0;
341
+ do {
342
+ let prop = segs[idx];
343
+ if (typeof prop !== "string") {
344
+ prop = String(prop);
345
+ }
346
+ while (prop && prop.slice(-1) === "\\") {
347
+ prop = join([prop.slice(0, -1), segs[++idx] || ""], joinChar, options);
348
+ }
349
+ if (target[prop] !== void 0) {
350
+ if (!isValid(prop, target, options)) {
351
+ return options.default;
352
+ }
353
+ target = target[prop];
354
+ } else {
355
+ let hasProp = false;
356
+ let n = idx + 1;
357
+ while (n < len) {
358
+ prop = join([prop, segs[n++]], joinChar, options);
359
+ if (hasProp = target[prop] !== void 0) {
360
+ if (!isValid(prop, target, options)) {
361
+ return options.default;
362
+ }
363
+ target = target[prop];
364
+ idx = n - 1;
365
+ break;
366
+ }
367
+ }
368
+ if (!hasProp) {
369
+ return options.default;
370
+ }
371
+ }
372
+ } while (++idx < len && isValidObject(target));
373
+ if (idx === len) {
374
+ return target;
375
+ }
376
+ return options.default;
377
+ }, "getValue");
378
+ var index_default = getValue;
379
+
380
+ // src/index.ts
381
+ var import_set_value = __toESM(require_set_value(), 1);
383
382
  function escapeStringRegexp(str) {
384
383
  return str.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
385
384
  }
@@ -405,10 +404,19 @@ var defuOverrideArray = createDefu((obj, key, value) => {
405
404
  return true;
406
405
  }
407
406
  });
408
- function isObject(x) {
407
+ function isObject2(x) {
409
408
  return typeof x === "object" && x !== null;
410
409
  }
411
- var export_get = import_get_value.default;
410
+ function isEmptyObject(obj) {
411
+ if (isObject2(obj)) {
412
+ let name;
413
+ for (name in obj) {
414
+ return false;
415
+ }
416
+ return true;
417
+ }
418
+ return false;
419
+ }
412
420
  var export_set = import_set_value.default;
413
421
  export {
414
422
  addExtension,
@@ -416,8 +424,9 @@ export {
416
424
  defu,
417
425
  defuOverrideArray,
418
426
  escapeStringRegexp,
419
- export_get as get,
420
- isObject,
427
+ index_default as get,
428
+ isEmptyObject,
429
+ isObject2 as isObject,
421
430
  objectHash,
422
431
  removeExtension,
423
432
  removeExtensionDeep,
@@ -425,27 +434,19 @@ export {
425
434
  };
426
435
  /*! Bundled license information:
427
436
 
428
- isobject/index.js:
429
- (*!
430
- * isobject <https://github.com/jonschlinkert/isobject>
431
- *
432
- * Copyright (c) 2014-2017, Jon Schlinkert.
433
- * Released under the MIT License.
434
- *)
435
-
436
- get-value/index.js:
437
+ is-primitive/index.js:
437
438
  (*!
438
- * get-value <https://github.com/jonschlinkert/get-value>
439
+ * is-primitive <https://github.com/jonschlinkert/is-primitive>
439
440
  *
440
- * Copyright (c) 2014-2018, Jon Schlinkert.
441
+ * Copyright (c) 2014-present, Jon Schlinkert.
441
442
  * Released under the MIT License.
442
443
  *)
443
444
 
444
- is-primitive/index.js:
445
+ isobject/index.js:
445
446
  (*!
446
- * is-primitive <https://github.com/jonschlinkert/is-primitive>
447
+ * isobject <https://github.com/jonschlinkert/isobject>
447
448
  *
448
- * Copyright (c) 2014-present, Jon Schlinkert.
449
+ * Copyright (c) 2014-2017, Jon Schlinkert.
449
450
  * Released under the MIT License.
450
451
  *)
451
452
 
@@ -464,4 +465,12 @@ set-value/index.js:
464
465
  * Copyright (c) Jon Schlinkert (https://github.com/jonschlinkert).
465
466
  * Released under the MIT License.
466
467
  *)
468
+
469
+ get-value/dist/index.mjs:
470
+ (*!
471
+ * get-value <https://github.com/jonschlinkert/get-value>
472
+ *
473
+ * Copyright (c) 2014-present, Jon Schlinkert.
474
+ * Released under the MIT License.
475
+ *)
467
476
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@weapp-core/shared",
3
3
  "type": "module",
4
- "version": "1.0.5",
4
+ "version": "1.0.7",
5
5
  "description": "@weapp-core/shared",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",