@jayfong/x-utils 1.0.0-202407020937 → 1.0.0-202407021032
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/_cjs/env.js +6 -4
- package/_cjs/ksb.js +3 -2
- package/_cjs/pinyin.js +5 -0
- package/env.js +6 -4
- package/ksb.d.ts +5 -0
- package/ksb.js +3 -2
- package/ocr.d.ts +7 -0
- package/package.json +1 -1
- package/pinyin.d.ts +5 -0
- package/pinyin.js +5 -0
- package/upload.d.ts +6 -0
package/_cjs/env.js
CHANGED
|
@@ -37,20 +37,22 @@ var import_fs = require("./fs.js");
|
|
|
37
37
|
var import_path = require("./path.js");
|
|
38
38
|
var import_yaml = require("./yaml.js");
|
|
39
39
|
class XEnv {
|
|
40
|
-
static getEnvVarsFromFile = (0, import_vtils.memoize)(async ()
|
|
41
|
-
const
|
|
40
|
+
static getEnvVarsFromFile = (0, import_vtils.memoize)(async function get(local = true) {
|
|
41
|
+
const baseName = local ? ".env.local" : ".env";
|
|
42
|
+
const envYmlFile = import_path.XPath.join(process.cwd(), `${baseName}.yml`);
|
|
42
43
|
if (await import_fs.XFs.pathExists(envYmlFile)) {
|
|
43
44
|
return import_yaml.XYaml.read(envYmlFile);
|
|
44
45
|
}
|
|
45
|
-
const envYamlFile = import_path.XPath.join(process.cwd(),
|
|
46
|
+
const envYamlFile = import_path.XPath.join(process.cwd(), `${baseName}.yaml`);
|
|
46
47
|
if (await import_fs.XFs.pathExists(envYamlFile)) {
|
|
47
48
|
return import_yaml.XYaml.read(envYamlFile);
|
|
48
49
|
}
|
|
49
|
-
const dotenvFile = import_path.XPath.join(process.cwd(),
|
|
50
|
+
const dotenvFile = import_path.XPath.join(process.cwd(), baseName);
|
|
50
51
|
if (await import_fs.XFs.pathExists(dotenvFile)) {
|
|
51
52
|
const dotenvContent = await import_fs.XFs.readFile(dotenvFile, "utf-8");
|
|
52
53
|
return import_dotenv.default.parse(dotenvContent);
|
|
53
54
|
}
|
|
55
|
+
if (local) return get(false);
|
|
54
56
|
});
|
|
55
57
|
static async getEnvVar(name) {
|
|
56
58
|
if (process.env[name] != null) {
|
package/_cjs/ksb.js
CHANGED
|
@@ -23,9 +23,10 @@ __export(ksb_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(ksb_exports);
|
|
24
24
|
var import_x_request = require("@jayfong/x-request");
|
|
25
25
|
var import_vtils = require("vtils");
|
|
26
|
+
var import_env = require("./env.js");
|
|
26
27
|
class XKsb {
|
|
27
|
-
static request(url, data) {
|
|
28
|
-
const token = "
|
|
28
|
+
static async request(url, data) {
|
|
29
|
+
const token = await import_env.XEnv.getEnvVar("X_KSB_USER_TOKEN");
|
|
29
30
|
const key = "12b6bb84e093532fb72b4d65fec3f00b";
|
|
30
31
|
const clientId = "ca37dd67-f885-4678-91a7-6531bb153ef2";
|
|
31
32
|
const ts = (/* @__PURE__ */ new Date()).getTime();
|
package/_cjs/pinyin.js
CHANGED
|
@@ -23,6 +23,11 @@ __export(pinyin_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(pinyin_exports);
|
|
24
24
|
var import_pinyin_pro = require("pinyin-pro");
|
|
25
25
|
class XPinyin {
|
|
26
|
+
/**
|
|
27
|
+
* - `我们` => `['wo', 'men']`
|
|
28
|
+
*
|
|
29
|
+
* - `2` => `['2']`
|
|
30
|
+
*/
|
|
26
31
|
static getTonelessPinyin(text) {
|
|
27
32
|
return (0, import_pinyin_pro.pinyin)(text, {
|
|
28
33
|
type: "array",
|
package/env.js
CHANGED
|
@@ -4,20 +4,22 @@ import { XFs } from "./fs.js";
|
|
|
4
4
|
import { XPath } from "./path.js";
|
|
5
5
|
import { XYaml } from "./yaml.js";
|
|
6
6
|
class XEnv {
|
|
7
|
-
static getEnvVarsFromFile = memoize(async ()
|
|
8
|
-
const
|
|
7
|
+
static getEnvVarsFromFile = memoize(async function get(local = true) {
|
|
8
|
+
const baseName = local ? ".env.local" : ".env";
|
|
9
|
+
const envYmlFile = XPath.join(process.cwd(), `${baseName}.yml`);
|
|
9
10
|
if (await XFs.pathExists(envYmlFile)) {
|
|
10
11
|
return XYaml.read(envYmlFile);
|
|
11
12
|
}
|
|
12
|
-
const envYamlFile = XPath.join(process.cwd(),
|
|
13
|
+
const envYamlFile = XPath.join(process.cwd(), `${baseName}.yaml`);
|
|
13
14
|
if (await XFs.pathExists(envYamlFile)) {
|
|
14
15
|
return XYaml.read(envYamlFile);
|
|
15
16
|
}
|
|
16
|
-
const dotenvFile = XPath.join(process.cwd(),
|
|
17
|
+
const dotenvFile = XPath.join(process.cwd(), baseName);
|
|
17
18
|
if (await XFs.pathExists(dotenvFile)) {
|
|
18
19
|
const dotenvContent = await XFs.readFile(dotenvFile, "utf-8");
|
|
19
20
|
return dotenv.parse(dotenvContent);
|
|
20
21
|
}
|
|
22
|
+
if (local) return get(false);
|
|
21
23
|
});
|
|
22
24
|
static async getEnvVar(name) {
|
|
23
25
|
if (process.env[name] != null) {
|
package/ksb.d.ts
CHANGED
package/ksb.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { xr } from "@jayfong/x-request";
|
|
2
2
|
import { castArray, md5, memoize } from "vtils";
|
|
3
|
+
import { XEnv } from "./env.js";
|
|
3
4
|
class XKsb {
|
|
4
|
-
static request(url, data) {
|
|
5
|
-
const token = "
|
|
5
|
+
static async request(url, data) {
|
|
6
|
+
const token = await XEnv.getEnvVar("X_KSB_USER_TOKEN");
|
|
6
7
|
const key = "12b6bb84e093532fb72b4d65fec3f00b";
|
|
7
8
|
const clientId = "ca37dd67-f885-4678-91a7-6531bb153ef2";
|
|
8
9
|
const ts = (/* @__PURE__ */ new Date()).getTime();
|
package/ocr.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* 环境变量:
|
|
4
|
+
*
|
|
5
|
+
* - `X_OCR_RECOGNIZE_SERVER_URL`: 文字识别服务地址
|
|
6
|
+
* - `X_OCR_RECOGNIZE_CAPTCHA_SERVER_URL`: 验证码识别服务地址
|
|
7
|
+
* - `X_OCR_RECOGNIZE_CAPTCHA_SERVER_TOKEN`: 验证码识别服务令牌
|
|
8
|
+
*/
|
|
2
9
|
export declare class XOcr {
|
|
3
10
|
static recognize(url: string, { serverUrl, }?: {
|
|
4
11
|
serverUrl?: string;
|
package/package.json
CHANGED
package/pinyin.d.ts
CHANGED
package/pinyin.js
CHANGED