qidian-shared 1.0.74 → 1.0.76

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.
@@ -1,7 +1,6 @@
1
1
  import { noop, isEmpty } from "../utils/common.mjs";
2
- const __vite_import_meta_env__ = { "BASE_URL": "/", "DEV": false, "MODE": "production", "PROD": true, "SSR": false };
3
2
  const cslType = ["log", "warn", "error"];
4
- const isDev = import.meta.env?.NODE_ENV !== "production" || __vite_import_meta_env__ && false;
3
+ const isDev = import.meta.env?.NODE_ENV !== "production";
5
4
  function useCsl(module) {
6
5
  const toStr = (data) => {
7
6
  if (typeof data === "object") return data.join(".");
@@ -36,7 +36,7 @@ export declare function extractSlotsWithPrefix(slots: SetupContext['slots'], pre
36
36
  }[];
37
37
  export declare function extractSlotsWithoutPrefix(slots: SetupContext['slots'], prefix: string): string[];
38
38
  export declare function filterSlots(slots: SetupContext['slots'], filterName: string[]): string[];
39
- export declare function easyCopy<T>(data: T): T;
39
+ export declare function easyCopy<T>(data: T, reviver?: (key: string, value: any) => any): T;
40
40
  export declare function checkSameObject(newData: unknown, oldData: unknown): boolean;
41
41
  export declare function valueFillter(val: string, keys: string, data: Record<string, string | number>): string;
42
42
  type Simplify<T> = T extends any ? {
@@ -66,8 +66,25 @@ function filterSlots(slots, filterName) {
66
66
  }
67
67
  return res;
68
68
  }
69
- function easyCopy(data) {
70
- return JSON.parse(JSON.stringify(data));
69
+ function easyCopy(data, reviver) {
70
+ if (!data) return data;
71
+ const undefinedKey = `__QD_EASY_COPY_UNDEFINED_${(/* @__PURE__ */ new Date()).getTime()}__`;
72
+ const res = JSON.parse(
73
+ JSON.stringify(data, (key, value) => {
74
+ const reVal = reviver ? reviver(key, value) : value;
75
+ return reVal === void 0 ? undefinedKey : reVal;
76
+ })
77
+ );
78
+ return restoreUndefined(res);
79
+ function restoreUndefined(value) {
80
+ if (value === undefinedKey) return void 0;
81
+ if (Array.isArray(value)) {
82
+ for (let i = 0; i < value.length; i++) value[i] = restoreUndefined(value[i]);
83
+ } else if (value && typeof value === "object") {
84
+ for (const key in value) value[key] = restoreUndefined(value[key]);
85
+ }
86
+ return value;
87
+ }
71
88
  }
72
89
  function checkSameObject(newData, oldData) {
73
90
  if (newData && !oldData || !newData && oldData || typeof newData !== typeof oldData) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qidian-shared",
3
- "version": "1.0.74",
3
+ "version": "1.0.76",
4
4
  "description": "QiDian 共享工具函数和钩子",
5
5
  "type": "module",
6
6
  "author": "qidian",