@pisell/utils 1.0.22 → 1.0.24

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/es/locales.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare const locales: {
1
+ export declare const locales: {
2
2
  init: (_localeMaps: any, _locale: string) => void;
3
3
  getText: (id: string) => any;
4
4
  locale: string;
@@ -10,4 +10,3 @@ declare const locales: {
10
10
  };
11
11
  formatLocale: (_locale: string) => string;
12
12
  };
13
- export default locales;
package/es/locales.js CHANGED
@@ -51,6 +51,7 @@ var init = function init(_localeMaps, _locale) {
51
51
 
52
52
  // 更新当前语言对应的多语言
53
53
  localeMap = localeMaps[locale];
54
+ console.log('多语言注入成功, 当前语言为:' + locale);
54
55
  };
55
56
 
56
57
  /**
@@ -64,12 +65,11 @@ var init = function init(_localeMaps, _locale) {
64
65
  var getText = function getText(id) {
65
66
  return localeMap[id] || id;
66
67
  };
67
- var locales = {
68
+ export var locales = {
68
69
  init: init,
69
70
  getText: getText,
70
71
  locale: locale,
71
72
  localeMap: localeMap,
72
73
  localeMaps: localeMaps,
73
74
  formatLocale: formatLocale
74
- };
75
- export default locales;
75
+ };
package/es/miniRedux.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  interface MiniReduxProps<State, Namespace> {
3
2
  namespace?: Namespace;
4
3
  state?: State;
@@ -12,6 +11,6 @@ export declare const miniRedux: <State extends Record<string, any>, Namespace ex
12
11
  payload: any;
13
12
  }) => void;
14
13
  }>;
15
- Provider: (ComponentUi: any) => (props: any) => JSX.Element;
14
+ Provider: (ComponentUi: any) => (props: any) => any;
16
15
  };
17
16
  export {};
@@ -28,3 +28,8 @@ export declare const changeArray: <T>(list: T[] | undefined, item: T, key?: stri
28
28
  */
29
29
  export declare const getItemByArray: <T>(list: T[] | undefined, item: T, key?: string) => boolean;
30
30
  export declare const createArray: (length: number, returnItem: any) => any;
31
+ /**
32
+ * 根据对象内容生成唯一id
33
+ * @param obj
34
+ */
35
+ export declare const generateUniqueIdByObj: (obj: Record<string, any>) => any;
package/es/otherUtils.js CHANGED
@@ -1,3 +1,8 @@
1
+ // @ts-ignore
2
+ import md5 from "crypto-js/md5";
3
+ // @ts-ignore
4
+ import enc from "crypto-js/enc-hex";
5
+
1
6
  /**
2
7
  * @Description: 生成唯一id
3
8
  * @Author: wzw
@@ -74,4 +79,14 @@ export var getItemByArray = function getItemByArray() {
74
79
  };
75
80
  export var createArray = function createArray(length, returnItem) {
76
81
  return Array.from(new Array(length)).map(returnItem);
82
+ };
83
+
84
+ /**
85
+ * 根据对象内容生成唯一id
86
+ * @param obj
87
+ */
88
+ export var generateUniqueIdByObj = function generateUniqueIdByObj(obj) {
89
+ var jsonString = JSON.stringify(obj);
90
+ var hash = md5(jsonString);
91
+ return hash.toString(enc.Hex);
77
92
  };
package/lib/locales.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare const locales: {
1
+ export declare const locales: {
2
2
  init: (_localeMaps: any, _locale: string) => void;
3
3
  getText: (id: string) => any;
4
4
  locale: string;
@@ -10,4 +10,3 @@ declare const locales: {
10
10
  };
11
11
  formatLocale: (_locale: string) => string;
12
12
  };
13
- export default locales;
package/lib/locales.js CHANGED
@@ -19,7 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/locales.ts
20
20
  var locales_exports = {};
21
21
  __export(locales_exports, {
22
- default: () => locales_default
22
+ locales: () => locales
23
23
  });
24
24
  module.exports = __toCommonJS(locales_exports);
25
25
  var localeMaps = {
@@ -50,6 +50,7 @@ var init = (_localeMaps, _locale) => {
50
50
  }
51
51
  localeMaps = allLocales;
52
52
  localeMap = localeMaps[locale];
53
+ console.log("\u591A\u8BED\u8A00\u6CE8\u5165\u6210\u529F, \u5F53\u524D\u8BED\u8A00\u4E3A:" + locale);
53
54
  };
54
55
  var getText = (id) => {
55
56
  return localeMap[id] || id;
@@ -62,4 +63,7 @@ var locales = {
62
63
  localeMaps,
63
64
  formatLocale
64
65
  };
65
- var locales_default = locales;
66
+ // Annotate the CommonJS export names for ESM import in node:
67
+ 0 && (module.exports = {
68
+ locales
69
+ });
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  interface MiniReduxProps<State, Namespace> {
3
2
  namespace?: Namespace;
4
3
  state?: State;
@@ -12,6 +11,6 @@ export declare const miniRedux: <State extends Record<string, any>, Namespace ex
12
11
  payload: any;
13
12
  }) => void;
14
13
  }>;
15
- Provider: (ComponentUi: any) => (props: any) => JSX.Element;
14
+ Provider: (ComponentUi: any) => (props: any) => any;
16
15
  };
17
16
  export {};
@@ -28,3 +28,8 @@ export declare const changeArray: <T>(list: T[] | undefined, item: T, key?: stri
28
28
  */
29
29
  export declare const getItemByArray: <T>(list: T[] | undefined, item: T, key?: string) => boolean;
30
30
  export declare const createArray: (length: number, returnItem: any) => any;
31
+ /**
32
+ * 根据对象内容生成唯一id
33
+ * @param obj
34
+ */
35
+ export declare const generateUniqueIdByObj: (obj: Record<string, any>) => any;
package/lib/otherUtils.js CHANGED
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
17
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
28
 
19
29
  // src/otherUtils.ts
@@ -21,10 +31,13 @@ var otherUtils_exports = {};
21
31
  __export(otherUtils_exports, {
22
32
  changeArray: () => changeArray,
23
33
  createArray: () => createArray,
34
+ generateUniqueIdByObj: () => generateUniqueIdByObj,
24
35
  getItemByArray: () => getItemByArray,
25
36
  getUniqueId: () => getUniqueId
26
37
  });
27
38
  module.exports = __toCommonJS(otherUtils_exports);
39
+ var import_md5 = __toESM(require("crypto-js/md5"));
40
+ var import_enc_hex = __toESM(require("crypto-js/enc-hex"));
28
41
  var getUniqueId = (prefix = "", maxLength = 11) => {
29
42
  return prefix + (Math.random() + "").replace(/\D/g, "").substring(0, maxLength);
30
43
  };
@@ -57,10 +70,16 @@ var getItemByArray = (list = [], item, key = "this") => {
57
70
  var createArray = (length, returnItem) => {
58
71
  return Array.from(new Array(length)).map(returnItem);
59
72
  };
73
+ var generateUniqueIdByObj = (obj) => {
74
+ const jsonString = JSON.stringify(obj);
75
+ const hash = (0, import_md5.default)(jsonString);
76
+ return hash.toString(import_enc_hex.default.Hex);
77
+ };
60
78
  // Annotate the CommonJS export names for ESM import in node:
61
79
  0 && (module.exports = {
62
80
  changeArray,
63
81
  createArray,
82
+ generateUniqueIdByObj,
64
83
  getItemByArray,
65
84
  getUniqueId
66
85
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/utils",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "sideEffects": false,
5
5
  "main": "./lib/index.js",
6
6
  "module": "./es/index.js",
@@ -12,7 +12,8 @@
12
12
  "dayjs": "^1.11.9"
13
13
  },
14
14
  "dependencies": {
15
- "firebase": "10.5.0"
15
+ "firebase": "10.5.0",
16
+ "crypto-js": "^4.2.0"
16
17
  },
17
18
  "files": [
18
19
  "es",