@jhqn/utils-core 0.0.2-beta.4 → 0.0.2-beta.6

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
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const detectBrowserEs = require('detect-browser-es');
3
+ const detectBrowser = require('detect-browser');
4
4
  const dayjs = require('dayjs');
5
5
  const localeData = require('dayjs/plugin/localeData');
6
6
  const duration = require('dayjs/plugin/duration');
@@ -329,14 +329,13 @@ const fixiOSInputAutoZoomIn = () => {
329
329
  const userAgent = inBrowser ? window.navigator.userAgent : "";
330
330
  const getHostEnv = () => {
331
331
  const ua = userAgent.toLowerCase();
332
- const baseInfo = detectBrowserEs.parseUserAgent(ua);
333
332
  const zlb = ua.includes("@zlb");
334
333
  const zyd = ua.includes("saas");
335
334
  const zzd = ua.includes("zhejiang") || ua.includes("tauruszjd");
336
335
  const wx = ua.includes("micromessenger");
337
336
  const zfb = ua.includes("alipay");
338
337
  const mini = ua.includes("miniprogram");
339
- const additionalInfo = {
338
+ const info = {
340
339
  zlb,
341
340
  zyd,
342
341
  zzd,
@@ -344,10 +343,7 @@ const getHostEnv = () => {
344
343
  zfb,
345
344
  mini
346
345
  };
347
- return {
348
- ...baseInfo,
349
- ...additionalInfo
350
- };
346
+ return info;
351
347
  };
352
348
 
353
349
  const parseToJSON = (str, reviver2) => isJSONStr(str) ? JSON.parse(str, reviver2) : null;
@@ -477,6 +473,7 @@ const attachFmt = (data) => {
477
473
  return attachList.map(recoverFile);
478
474
  };
479
475
 
476
+ exports.detect = detectBrowser.detect;
480
477
  exports.dayjs = dayjs__default;
481
478
  exports.attachFmt = attachFmt;
482
479
  exports.camel2Kebab = camel2Kebab;
package/dist/index.d.cts CHANGED
@@ -3,9 +3,9 @@
3
3
  /// <reference types="dayjs/plugin/relativeTime" />
4
4
  /// <reference types="dayjs/plugin/customParseFormat" />
5
5
  /// <reference types="dayjs/plugin/objectSupport" />
6
- import * as detect_browser_es from 'detect-browser-es';
7
6
  import { ConfigType } from 'dayjs';
8
7
  export { Dayjs, default as dayjs } from 'dayjs';
8
+ export { detect } from 'detect-browser';
9
9
 
10
10
  /**
11
11
  * snake2Kebab
@@ -183,7 +183,10 @@ declare const jGroupC: (...args: any[]) => void;
183
183
  /**
184
184
  * jade console.groupEnd
185
185
  */
186
- declare const jGroupE: () => void;
186
+ declare const jGroupE: {
187
+ (): void;
188
+ (): void;
189
+ };
187
190
  /**
188
191
  * jade console.time
189
192
  * @param str
@@ -197,7 +200,10 @@ declare const jTimeEnd: (str: string) => void;
197
200
  /**
198
201
  * jade console.clear
199
202
  */
200
- declare const jClear: () => void;
203
+ declare const jClear: {
204
+ (): void;
205
+ (): void;
206
+ };
201
207
 
202
208
  /**
203
209
  * 不连续打印相同的值
@@ -308,6 +314,33 @@ declare const hideEmail: (email: UnDef<string>) => string;
308
314
  */
309
315
  declare const hideBankCard: (bankCard: UnDef<string>) => string;
310
316
 
317
+ interface HostEnv {
318
+ /**
319
+ * 是否是浙里办
320
+ */
321
+ readonly zlb: boolean
322
+ /**
323
+ * 是否是专有钉
324
+ */
325
+ readonly zyd: boolean
326
+ /**
327
+ * 是否是浙政钉
328
+ */
329
+ readonly zzd: boolean
330
+ /**
331
+ * 是否是微信
332
+ */
333
+ readonly wx: boolean
334
+ /**
335
+ * 是否是支付宝
336
+ */
337
+ readonly zfb: boolean
338
+ /**
339
+ * 是否是小程序
340
+ */
341
+ readonly mini: boolean
342
+ }
343
+
311
344
  /**
312
345
  * 判断是否是浏览器环境
313
346
  */
@@ -330,52 +363,7 @@ declare const userAgent: string;
330
363
  /**
331
364
  * 获取宿主环境信息
332
365
  */
333
- declare const getHostEnv: () => {
334
- zlb: boolean;
335
- zyd: boolean;
336
- zzd: boolean;
337
- wx: boolean;
338
- zfb: boolean;
339
- mini: boolean;
340
- } | {
341
- zlb: boolean;
342
- zyd: boolean;
343
- zzd: boolean;
344
- wx: boolean;
345
- zfb: boolean;
346
- mini: boolean;
347
- name: detect_browser_es.Browser;
348
- version: string;
349
- os: detect_browser_es.OperatingSystem | null;
350
- ua?: detect_browser_es.UserAgentDataInfo | undefined;
351
- type: "browser";
352
- } | {
353
- zlb: boolean;
354
- zyd: boolean;
355
- zzd: boolean;
356
- wx: boolean;
357
- zfb: boolean;
358
- mini: boolean;
359
- name: detect_browser_es.Browser;
360
- version: string;
361
- os: detect_browser_es.OperatingSystem | null;
362
- bot: string;
363
- type: "bot-device";
364
- ua?: detect_browser_es.UserAgentDataInfo | undefined;
365
- } | {
366
- zlb: boolean;
367
- zyd: boolean;
368
- zzd: boolean;
369
- wx: boolean;
370
- zfb: boolean;
371
- mini: boolean;
372
- type: "bot";
373
- bot: true;
374
- name: "bot";
375
- version: null;
376
- os: null;
377
- ua?: detect_browser_es.UserAgentDataInfo | undefined;
378
- };
366
+ declare const getHostEnv: () => HostEnv;
379
367
 
380
368
  /**
381
369
  * Json字符串转对象
package/dist/index.d.mts CHANGED
@@ -3,9 +3,9 @@
3
3
  /// <reference types="dayjs/plugin/relativeTime" />
4
4
  /// <reference types="dayjs/plugin/customParseFormat" />
5
5
  /// <reference types="dayjs/plugin/objectSupport" />
6
- import * as detect_browser_es from 'detect-browser-es';
7
6
  import { ConfigType } from 'dayjs';
8
7
  export { Dayjs, default as dayjs } from 'dayjs';
8
+ export { detect } from 'detect-browser';
9
9
 
10
10
  /**
11
11
  * snake2Kebab
@@ -183,7 +183,10 @@ declare const jGroupC: (...args: any[]) => void;
183
183
  /**
184
184
  * jade console.groupEnd
185
185
  */
186
- declare const jGroupE: () => void;
186
+ declare const jGroupE: {
187
+ (): void;
188
+ (): void;
189
+ };
187
190
  /**
188
191
  * jade console.time
189
192
  * @param str
@@ -197,7 +200,10 @@ declare const jTimeEnd: (str: string) => void;
197
200
  /**
198
201
  * jade console.clear
199
202
  */
200
- declare const jClear: () => void;
203
+ declare const jClear: {
204
+ (): void;
205
+ (): void;
206
+ };
201
207
 
202
208
  /**
203
209
  * 不连续打印相同的值
@@ -308,6 +314,33 @@ declare const hideEmail: (email: UnDef<string>) => string;
308
314
  */
309
315
  declare const hideBankCard: (bankCard: UnDef<string>) => string;
310
316
 
317
+ interface HostEnv {
318
+ /**
319
+ * 是否是浙里办
320
+ */
321
+ readonly zlb: boolean
322
+ /**
323
+ * 是否是专有钉
324
+ */
325
+ readonly zyd: boolean
326
+ /**
327
+ * 是否是浙政钉
328
+ */
329
+ readonly zzd: boolean
330
+ /**
331
+ * 是否是微信
332
+ */
333
+ readonly wx: boolean
334
+ /**
335
+ * 是否是支付宝
336
+ */
337
+ readonly zfb: boolean
338
+ /**
339
+ * 是否是小程序
340
+ */
341
+ readonly mini: boolean
342
+ }
343
+
311
344
  /**
312
345
  * 判断是否是浏览器环境
313
346
  */
@@ -330,52 +363,7 @@ declare const userAgent: string;
330
363
  /**
331
364
  * 获取宿主环境信息
332
365
  */
333
- declare const getHostEnv: () => {
334
- zlb: boolean;
335
- zyd: boolean;
336
- zzd: boolean;
337
- wx: boolean;
338
- zfb: boolean;
339
- mini: boolean;
340
- } | {
341
- zlb: boolean;
342
- zyd: boolean;
343
- zzd: boolean;
344
- wx: boolean;
345
- zfb: boolean;
346
- mini: boolean;
347
- name: detect_browser_es.Browser;
348
- version: string;
349
- os: detect_browser_es.OperatingSystem | null;
350
- ua?: detect_browser_es.UserAgentDataInfo | undefined;
351
- type: "browser";
352
- } | {
353
- zlb: boolean;
354
- zyd: boolean;
355
- zzd: boolean;
356
- wx: boolean;
357
- zfb: boolean;
358
- mini: boolean;
359
- name: detect_browser_es.Browser;
360
- version: string;
361
- os: detect_browser_es.OperatingSystem | null;
362
- bot: string;
363
- type: "bot-device";
364
- ua?: detect_browser_es.UserAgentDataInfo | undefined;
365
- } | {
366
- zlb: boolean;
367
- zyd: boolean;
368
- zzd: boolean;
369
- wx: boolean;
370
- zfb: boolean;
371
- mini: boolean;
372
- type: "bot";
373
- bot: true;
374
- name: "bot";
375
- version: null;
376
- os: null;
377
- ua?: detect_browser_es.UserAgentDataInfo | undefined;
378
- };
366
+ declare const getHostEnv: () => HostEnv;
379
367
 
380
368
  /**
381
369
  * Json字符串转对象
package/dist/index.d.ts CHANGED
@@ -3,9 +3,9 @@
3
3
  /// <reference types="dayjs/plugin/relativeTime" />
4
4
  /// <reference types="dayjs/plugin/customParseFormat" />
5
5
  /// <reference types="dayjs/plugin/objectSupport" />
6
- import * as detect_browser_es from 'detect-browser-es';
7
6
  import { ConfigType } from 'dayjs';
8
7
  export { Dayjs, default as dayjs } from 'dayjs';
8
+ export { detect } from 'detect-browser';
9
9
 
10
10
  /**
11
11
  * snake2Kebab
@@ -183,7 +183,10 @@ declare const jGroupC: (...args: any[]) => void;
183
183
  /**
184
184
  * jade console.groupEnd
185
185
  */
186
- declare const jGroupE: () => void;
186
+ declare const jGroupE: {
187
+ (): void;
188
+ (): void;
189
+ };
187
190
  /**
188
191
  * jade console.time
189
192
  * @param str
@@ -197,7 +200,10 @@ declare const jTimeEnd: (str: string) => void;
197
200
  /**
198
201
  * jade console.clear
199
202
  */
200
- declare const jClear: () => void;
203
+ declare const jClear: {
204
+ (): void;
205
+ (): void;
206
+ };
201
207
 
202
208
  /**
203
209
  * 不连续打印相同的值
@@ -308,6 +314,33 @@ declare const hideEmail: (email: UnDef<string>) => string;
308
314
  */
309
315
  declare const hideBankCard: (bankCard: UnDef<string>) => string;
310
316
 
317
+ interface HostEnv {
318
+ /**
319
+ * 是否是浙里办
320
+ */
321
+ readonly zlb: boolean
322
+ /**
323
+ * 是否是专有钉
324
+ */
325
+ readonly zyd: boolean
326
+ /**
327
+ * 是否是浙政钉
328
+ */
329
+ readonly zzd: boolean
330
+ /**
331
+ * 是否是微信
332
+ */
333
+ readonly wx: boolean
334
+ /**
335
+ * 是否是支付宝
336
+ */
337
+ readonly zfb: boolean
338
+ /**
339
+ * 是否是小程序
340
+ */
341
+ readonly mini: boolean
342
+ }
343
+
311
344
  /**
312
345
  * 判断是否是浏览器环境
313
346
  */
@@ -330,52 +363,7 @@ declare const userAgent: string;
330
363
  /**
331
364
  * 获取宿主环境信息
332
365
  */
333
- declare const getHostEnv: () => {
334
- zlb: boolean;
335
- zyd: boolean;
336
- zzd: boolean;
337
- wx: boolean;
338
- zfb: boolean;
339
- mini: boolean;
340
- } | {
341
- zlb: boolean;
342
- zyd: boolean;
343
- zzd: boolean;
344
- wx: boolean;
345
- zfb: boolean;
346
- mini: boolean;
347
- name: detect_browser_es.Browser;
348
- version: string;
349
- os: detect_browser_es.OperatingSystem | null;
350
- ua?: detect_browser_es.UserAgentDataInfo | undefined;
351
- type: "browser";
352
- } | {
353
- zlb: boolean;
354
- zyd: boolean;
355
- zzd: boolean;
356
- wx: boolean;
357
- zfb: boolean;
358
- mini: boolean;
359
- name: detect_browser_es.Browser;
360
- version: string;
361
- os: detect_browser_es.OperatingSystem | null;
362
- bot: string;
363
- type: "bot-device";
364
- ua?: detect_browser_es.UserAgentDataInfo | undefined;
365
- } | {
366
- zlb: boolean;
367
- zyd: boolean;
368
- zzd: boolean;
369
- wx: boolean;
370
- zfb: boolean;
371
- mini: boolean;
372
- type: "bot";
373
- bot: true;
374
- name: "bot";
375
- version: null;
376
- os: null;
377
- ua?: detect_browser_es.UserAgentDataInfo | undefined;
378
- };
366
+ declare const getHostEnv: () => HostEnv;
379
367
 
380
368
  /**
381
369
  * Json字符串转对象
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { parseUserAgent } from 'detect-browser-es';
1
+ export { detect } from 'detect-browser';
2
2
  import dayjs from 'dayjs';
3
3
  export { default as dayjs } from 'dayjs';
4
4
  import localeData from 'dayjs/plugin/localeData';
@@ -318,14 +318,13 @@ const fixiOSInputAutoZoomIn = () => {
318
318
  const userAgent = inBrowser ? window.navigator.userAgent : "";
319
319
  const getHostEnv = () => {
320
320
  const ua = userAgent.toLowerCase();
321
- const baseInfo = parseUserAgent(ua);
322
321
  const zlb = ua.includes("@zlb");
323
322
  const zyd = ua.includes("saas");
324
323
  const zzd = ua.includes("zhejiang") || ua.includes("tauruszjd");
325
324
  const wx = ua.includes("micromessenger");
326
325
  const zfb = ua.includes("alipay");
327
326
  const mini = ua.includes("miniprogram");
328
- const additionalInfo = {
327
+ const info = {
329
328
  zlb,
330
329
  zyd,
331
330
  zzd,
@@ -333,10 +332,7 @@ const getHostEnv = () => {
333
332
  zfb,
334
333
  mini
335
334
  };
336
- return {
337
- ...baseInfo,
338
- ...additionalInfo
339
- };
335
+ return info;
340
336
  };
341
337
 
342
338
  const parseToJSON = (str, reviver2) => isJSONStr(str) ? JSON.parse(str, reviver2) : null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jhqn/utils-core",
3
3
  "type": "module",
4
- "version": "0.0.2-beta.4",
4
+ "version": "0.0.2-beta.6",
5
5
  "author": "jade-gjz <jiangang.zhang@jaderd.com>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/jaderd-jh/utils/tree/main/packages/core#readme",
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "dayjs": "^1.11.10",
41
- "detect-browser-es": "^0.1.0"
41
+ "detect-browser": "^5.3.0"
42
42
  },
43
43
  "scripts": {
44
44
  "test": "vitest",