@fast-china/utils 1.0.11 → 1.0.12
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/identity/index.d.ts
CHANGED
|
@@ -2,7 +2,13 @@ declare const state: {
|
|
|
2
2
|
cacheKey: string;
|
|
3
3
|
deviceId: string;
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* 生成设备Id
|
|
7
|
+
* @param deviceID 覆盖的设备Id
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
declare const makeIdentity: (deviceID?: string) => string;
|
|
5
11
|
export declare const useIdentity: () => typeof state & {
|
|
6
|
-
makeIdentity:
|
|
12
|
+
makeIdentity: typeof makeIdentity;
|
|
7
13
|
};
|
|
8
14
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../src/identity/index.ts"],"sourcesContent":["import { reactive } from \"vue\";\nimport { Local } from \"../storage\";\nimport { stringUtil } from \"../string\";\n\nconst state = reactive({\n\tcacheKey: \"__DEVICE_ID\",\n\tdeviceId: \"\",\n});\n\nconst uuidRegExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\n/**\n * 生成设备Id\n * @param deviceID 覆盖的设备Id\n * @returns\n */\nconst makeIdentity = (deviceID?: string): string => {\n\tdeviceID ??= state.deviceId;\n\t// 判断是否存在\n\tif (deviceID && uuidRegExp.test(deviceID)) {\n\t\tLocal.set(state.cacheKey, deviceID);\n\t\tstate.deviceId = deviceID;\n\t\treturn state.deviceId;\n\t}\n\t// 生成浏览器唯一 UUID\n\tdeviceID = Local.get(state.cacheKey);\n\tif (deviceID && uuidRegExp.test(deviceID)) {\n\t\tstate.deviceId = deviceID;\n\t\treturn deviceID;\n\t}\n\tdeviceID = stringUtil.generateUUID();\n\tLocal.set(state.cacheKey, deviceID);\n\tstate.deviceId = deviceID;\n\treturn deviceID;\n};\n\nexport const useIdentity = (): typeof state & { makeIdentity:
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../src/identity/index.ts"],"sourcesContent":["import { reactive } from \"vue\";\nimport { Local } from \"../storage\";\nimport { stringUtil } from \"../string\";\n\nconst state = reactive({\n\tcacheKey: \"__DEVICE_ID\",\n\tdeviceId: \"\",\n});\n\nconst uuidRegExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\n/**\n * 生成设备Id\n * @param deviceID 覆盖的设备Id\n * @returns\n */\nconst makeIdentity = (deviceID?: string): string => {\n\tdeviceID ??= state.deviceId;\n\t// 判断是否存在\n\tif (deviceID && uuidRegExp.test(deviceID)) {\n\t\tLocal.set(state.cacheKey, deviceID);\n\t\tstate.deviceId = deviceID;\n\t\treturn state.deviceId;\n\t}\n\t// 生成浏览器唯一 UUID\n\tdeviceID = Local.get(state.cacheKey);\n\tif (deviceID && uuidRegExp.test(deviceID)) {\n\t\tstate.deviceId = deviceID;\n\t\treturn deviceID;\n\t}\n\tdeviceID = stringUtil.generateUUID();\n\tLocal.set(state.cacheKey, deviceID);\n\tstate.deviceId = deviceID;\n\treturn deviceID;\n};\n\nexport const useIdentity = (): typeof state & { makeIdentity: typeof makeIdentity } => {\n\treturn {\n\t\t...state,\n\t\tmakeIdentity,\n\t};\n};\n"],"names":[],"mappings":";;;AAIA,MAAM,QAAQ,SAAS;AAAA,EACtB,UAAU;AAAA,EACV,UAAU;AACX,CAAC;AAED,MAAM,aAAa;AAOnB,MAAM,eAAe,CAAC,aAA8B;AACnD,0BAAa,MAAM;AAEnB,MAAI,YAAY,WAAW,KAAK,QAAQ,GAAG;AACpC,UAAA,IAAI,MAAM,UAAU,QAAQ;AAClC,UAAM,WAAW;AACjB,WAAO,MAAM;AAAA,EAAA;AAGH,aAAA,MAAM,IAAI,MAAM,QAAQ;AACnC,MAAI,YAAY,WAAW,KAAK,QAAQ,GAAG;AAC1C,UAAM,WAAW;AACV,WAAA;AAAA,EAAA;AAER,aAAW,WAAW,aAAa;AAC7B,QAAA,IAAI,MAAM,UAAU,QAAQ;AAClC,QAAM,WAAW;AACV,SAAA;AACR;AAEO,MAAM,cAAc,MAA4D;AAC/E,SAAA;AAAA,IACN,GAAG;AAAA,IACH;AAAA,EACD;AACD;"}
|
package/lib/identity/index.d.ts
CHANGED
|
@@ -2,7 +2,13 @@ declare const state: {
|
|
|
2
2
|
cacheKey: string;
|
|
3
3
|
deviceId: string;
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* 生成设备Id
|
|
7
|
+
* @param deviceID 覆盖的设备Id
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
declare const makeIdentity: (deviceID?: string) => string;
|
|
5
11
|
export declare const useIdentity: () => typeof state & {
|
|
6
|
-
makeIdentity:
|
|
12
|
+
makeIdentity: typeof makeIdentity;
|
|
7
13
|
};
|
|
8
14
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/identity/index.ts"],"sourcesContent":["import { reactive } from \"vue\";\nimport { Local } from \"../storage\";\nimport { stringUtil } from \"../string\";\n\nconst state = reactive({\n\tcacheKey: \"__DEVICE_ID\",\n\tdeviceId: \"\",\n});\n\nconst uuidRegExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\n/**\n * 生成设备Id\n * @param deviceID 覆盖的设备Id\n * @returns\n */\nconst makeIdentity = (deviceID?: string): string => {\n\tdeviceID ??= state.deviceId;\n\t// 判断是否存在\n\tif (deviceID && uuidRegExp.test(deviceID)) {\n\t\tLocal.set(state.cacheKey, deviceID);\n\t\tstate.deviceId = deviceID;\n\t\treturn state.deviceId;\n\t}\n\t// 生成浏览器唯一 UUID\n\tdeviceID = Local.get(state.cacheKey);\n\tif (deviceID && uuidRegExp.test(deviceID)) {\n\t\tstate.deviceId = deviceID;\n\t\treturn deviceID;\n\t}\n\tdeviceID = stringUtil.generateUUID();\n\tLocal.set(state.cacheKey, deviceID);\n\tstate.deviceId = deviceID;\n\treturn deviceID;\n};\n\nexport const useIdentity = (): typeof state & { makeIdentity:
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/identity/index.ts"],"sourcesContent":["import { reactive } from \"vue\";\nimport { Local } from \"../storage\";\nimport { stringUtil } from \"../string\";\n\nconst state = reactive({\n\tcacheKey: \"__DEVICE_ID\",\n\tdeviceId: \"\",\n});\n\nconst uuidRegExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\n/**\n * 生成设备Id\n * @param deviceID 覆盖的设备Id\n * @returns\n */\nconst makeIdentity = (deviceID?: string): string => {\n\tdeviceID ??= state.deviceId;\n\t// 判断是否存在\n\tif (deviceID && uuidRegExp.test(deviceID)) {\n\t\tLocal.set(state.cacheKey, deviceID);\n\t\tstate.deviceId = deviceID;\n\t\treturn state.deviceId;\n\t}\n\t// 生成浏览器唯一 UUID\n\tdeviceID = Local.get(state.cacheKey);\n\tif (deviceID && uuidRegExp.test(deviceID)) {\n\t\tstate.deviceId = deviceID;\n\t\treturn deviceID;\n\t}\n\tdeviceID = stringUtil.generateUUID();\n\tLocal.set(state.cacheKey, deviceID);\n\tstate.deviceId = deviceID;\n\treturn deviceID;\n};\n\nexport const useIdentity = (): typeof state & { makeIdentity: typeof makeIdentity } => {\n\treturn {\n\t\t...state,\n\t\tmakeIdentity,\n\t};\n};\n"],"names":["state","reactive","cacheKey","deviceId","uuidRegExp","makeIdentity","deviceID","test","Local","set","get","stringUtil","generateUUID"],"mappings":"wKAIMA,EAAQC,EAAAA,SAAS,CACtBC,SAAU,cACVC,SAAU,KAGLC,EAAa,kEAObC,EAAgBC,IACrBA,IAAAA,EAAaN,EAAMG,UAEfG,GAAYF,EAAWG,KAAKD,IACzBE,EAAAA,MAAAC,IAAIT,EAAME,SAAUI,GAC1BN,EAAMG,SAAWG,EACVN,EAAMG,WAGHG,EAAAE,EAAAA,MAAME,IAAIV,EAAME,YACXE,EAAWG,KAAKD,IAC/BN,EAAMG,SAAWG,EACVA,IAEGK,EAAAA,aAAWC,eAChBJ,EAAAA,MAAAC,IAAIT,EAAME,SAAUI,GAC1BN,EAAMG,SAAWG,EACVA,wBAGmB,KACnB,IACHN,EACHK"}
|