@secret-momo/utils 1.0.4 → 1.0.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.
@@ -1 +1 @@
1
- import{mkdirSync as i,createWriteStream as a}from"node:fs";import{join as m}from"node:path";import{Readable as c}from"node:stream";import{pipeline as s}from"node:stream/promises";import d from"consola";import{dateTimeToNow as p}from"../date-time.js";import{pickImageExtension as f,pickVideoExtension as y}from"./extension.js";async function u({url:r,dir:e}){try{i(e,{recursive:!0});const o=await fetch(r);if(!o.body)throw new Error("Response has no body");const n=y(r,o.headers.get("content-type")),t=m(e,`${p("YYYYMMDD_HHmmss")}.${n}`);return await s(c.fromWeb(o.body),a(t)),t}catch(o){return d.error(o),null}}async function w({url:r,dir:e}){try{i(e,{recursive:!0});const o=await fetch(r);if(!o.body)throw new Error("Response has no body");const n=f(r,o.headers.get("content-type")),t=m(e,`${p("YYYYMMDD_HHmmss")}.${n}`);return await s(c.fromWeb(o.body),a(t)),t}catch(o){return d.error(o),null}}export{w as downloadImage,u as downloadVideo};
1
+ import{mkdirSync as i,createWriteStream as m}from"node:fs";import{join as a}from"node:path";import{Readable as s}from"node:stream";import{pipeline as c}from"node:stream/promises";import d from"consola";import{fetch as p}from"../fetch.js";import{dateTimeToNow as f}from"../date-time.js";import{pickImageExtension as y,pickVideoExtension as u}from"./extension.js";async function w({url:r,dir:e}){try{i(e,{recursive:!0});const o=await p(r);if(!o.body)throw new Error("Response has no body");const n=u(r,o.headers.get("content-type")),t=a(e,`${f("YYYYMMDD_HHmmss")}.${n}`);return await c(s.fromWeb(o.body),m(t)),t}catch(o){return d.error(o),null}}async function l({url:r,dir:e}){try{i(e,{recursive:!0});const o=await p(r);if(!o.body)throw new Error("Response has no body");const n=y(r,o.headers.get("content-type")),t=a(e,`${f("YYYYMMDD_HHmmss")}.${n}`);return await c(s.fromWeb(o.body),m(t)),t}catch(o){return d.error(o),null}}export{l as downloadImage,w as downloadVideo};
package/lib/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * from './env';
4
4
  export * from './fetch';
5
5
  export * from './log';
6
6
  export * from './num';
7
+ export * from './pino';
7
8
  export * from './sleep';
8
9
  export * from './uuid';
9
10
  export * from './url';
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- import{downloadImage as r,downloadVideo as t}from"./download/index.js";import{dateTimeToNow as a,dateToNow as f,timestampToDate as d,yesterdayDate as p}from"./date-time.js";import{getNodeName as x}from"./env.js";import{fetch as l,fetchHtml as c,fetchJson as i,fetchText as g,mobileUserAgent as u,userAgent as w}from"./fetch.js";import{error as h,info as N,log as y,success as v,warn as A}from"./log.js";import{fixed2 as I,fixed4 as P,toPercentage as U}from"./num.js";import{sleep as H,sleep_random as J}from"./sleep.js";import{genId as R,uuidv4 as V}from"./uuid.js";import{getRedirectUrl as j,removeQueryParams as k}from"./url.js";import{default as z}from"consola";export{z as consola,a as dateTimeToNow,f as dateToNow,r as downloadImage,t as downloadVideo,h as error,l as fetch,c as fetchHtml,i as fetchJson,g as fetchText,I as fixed2,P as fixed4,R as genId,x as getNodeName,j as getRedirectUrl,N as info,y as log,u as mobileUserAgent,k as removeQueryParams,H as sleep,J as sleep_random,v as success,d as timestampToDate,U as toPercentage,w as userAgent,V as uuidv4,A as warn,p as yesterdayDate};
1
+ import{downloadImage as r,downloadVideo as t}from"./download/index.js";import{dateTimeToNow as f,dateToNow as a,timestampToDate as d,yesterdayDate as p}from"./date-time.js";import{getNodeName as s}from"./env.js";import{fetch as n,fetchHtml as g,fetchJson as i,fetchText as c,mobileUserAgent as u,userAgent as w}from"./fetch.js";import{error as h,info as N,log as y,success as v,warn as A}from"./log.js";import{fixed2 as I,fixed4 as P,toPercentage as U}from"./num.js";import{logger as H}from"./pino.js";import{sleep as Q,sleep_random as R}from"./sleep.js";import{genId as _,uuidv4 as j}from"./uuid.js";import{getRedirectUrl as q,removeQueryParams as z}from"./url.js";import{default as C}from"consola";import{default as F}from"pino";export{C as consola,f as dateTimeToNow,a as dateToNow,r as downloadImage,t as downloadVideo,h as error,n as fetch,g as fetchHtml,i as fetchJson,c as fetchText,I as fixed2,P as fixed4,_ as genId,s as getNodeName,q as getRedirectUrl,N as info,y as log,H as logger,u as mobileUserAgent,F as pino,z as removeQueryParams,Q as sleep,R as sleep_random,v as success,d as timestampToDate,U as toPercentage,w as userAgent,j as uuidv4,A as warn,p as yesterdayDate};
package/lib/pino.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import pino from 'pino';
2
+ declare const logger: pino.Logger<never, boolean>;
3
+ export { pino, logger };
package/lib/pino.js ADDED
@@ -0,0 +1 @@
1
+ import o from"pino";import{default as n}from"pino";const t=o({level:"info",transport:{target:"pino-pretty",options:{colorize:!0,translateTime:"SYS:yyyy-mm-dd HH:MM:ss",ignore:"pid,hostname"}}});export{t as logger,n as pino};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@secret-momo/utils",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "module": "src/index.ts",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -44,13 +44,15 @@
44
44
  "jiti": "2.7.0",
45
45
  "lint-staged": "17.0.7",
46
46
  "prettier": "3.8.4",
47
- "rollup": "4.62.0",
47
+ "rollup": "4.62.2",
48
48
  "rollup-plugin-esbuild": "6.2.1",
49
49
  "typescript": "6.0.3",
50
- "typescript-eslint": "8.61.0"
50
+ "typescript-eslint": "8.61.1"
51
51
  },
52
52
  "dependencies": {
53
53
  "consola": "3.4.2",
54
- "dayjs": "1.11.21"
54
+ "dayjs": "1.11.21",
55
+ "pino": "10.3.1",
56
+ "pino-pretty": "13.1.3"
55
57
  }
56
58
  }