@wzyjs/utils 0.3.4 → 0.3.7

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/node.cjs.js CHANGED
@@ -373,9 +373,9 @@ var require_lodash = __commonJS((exports2, module2) => {
373
373
  var freeProcess = moduleExports && freeGlobal.process;
374
374
  var nodeUtil = function() {
375
375
  try {
376
- var types = freeModule && freeModule.require && freeModule.require("util").types;
377
- if (types) {
378
- return types;
376
+ var types2 = freeModule && freeModule.require && freeModule.require("util").types;
377
+ if (types2) {
378
+ return types2;
379
379
  }
380
380
  return freeProcess && freeProcess.binding && freeProcess.binding("util");
381
381
  } catch (e) {}
@@ -738,7 +738,7 @@ var require_lodash = __commonJS((exports2, module2) => {
738
738
  var objectCtorString = funcToString.call(Object2);
739
739
  var oldDash = root._;
740
740
  var reIsNative = RegExp2("^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
741
- var Buffer2 = moduleExports ? context.Buffer : undefined2, Symbol2 = context.Symbol, Uint8Array2 = context.Uint8Array, allocUnsafe = Buffer2 ? Buffer2.allocUnsafe : undefined2, getPrototype = overArg(Object2.getPrototypeOf, Object2), objectCreate = Object2.create, propertyIsEnumerable = objectProto.propertyIsEnumerable, splice = arrayProto.splice, spreadableSymbol = Symbol2 ? Symbol2.isConcatSpreadable : undefined2, symIterator = Symbol2 ? Symbol2.iterator : undefined2, symToStringTag = Symbol2 ? Symbol2.toStringTag : undefined2;
741
+ var Buffer2 = moduleExports ? context.Buffer : undefined2, Symbol2 = context.Symbol, Uint8Array = context.Uint8Array, allocUnsafe = Buffer2 ? Buffer2.allocUnsafe : undefined2, getPrototype = overArg(Object2.getPrototypeOf, Object2), objectCreate = Object2.create, propertyIsEnumerable = objectProto.propertyIsEnumerable, splice = arrayProto.splice, spreadableSymbol = Symbol2 ? Symbol2.isConcatSpreadable : undefined2, symIterator = Symbol2 ? Symbol2.iterator : undefined2, symToStringTag = Symbol2 ? Symbol2.toStringTag : undefined2;
742
742
  var defineProperty = function() {
743
743
  try {
744
744
  var func = getNative(Object2, "defineProperty");
@@ -1996,7 +1996,7 @@ var require_lodash = __commonJS((exports2, module2) => {
1996
1996
  }
1997
1997
  function cloneArrayBuffer(arrayBuffer) {
1998
1998
  var result2 = new arrayBuffer.constructor(arrayBuffer.byteLength);
1999
- new Uint8Array2(result2).set(new Uint8Array2(arrayBuffer));
1999
+ new Uint8Array(result2).set(new Uint8Array(arrayBuffer));
2000
2000
  return result2;
2001
2001
  }
2002
2002
  function cloneDataView(dataView, isDeep) {
@@ -2578,7 +2578,7 @@ var require_lodash = __commonJS((exports2, module2) => {
2578
2578
  object = object.buffer;
2579
2579
  other = other.buffer;
2580
2580
  case arrayBufferTag:
2581
- if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array2(object), new Uint8Array2(other))) {
2581
+ if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
2582
2582
  return false;
2583
2583
  }
2584
2584
  return true;
@@ -5475,6 +5475,7 @@ __export(exports_node, {
5475
5475
  strictObject: () => strictObjectType,
5476
5476
  shuffleArray: () => shuffleArray,
5477
5477
  setErrorMap: () => setErrorMap,
5478
+ setCookie: () => setCookie,
5478
5479
  set: () => setType,
5479
5480
  sendMail: () => sendMail,
5480
5481
  schedule: () => schedule,
@@ -5512,7 +5513,6 @@ __export(exports_node, {
5512
5513
  levenshteinDistance: () => levenshteinDistance,
5513
5514
  lazy: () => lazyType,
5514
5515
  late: () => late,
5515
- keling: () => exports_keling,
5516
5516
  jsonParse: () => jsonParse,
5517
5517
  json5: () => import_json52.default,
5518
5518
  isValidNumber: () => isValidNumber,
@@ -5526,6 +5526,7 @@ __export(exports_node, {
5526
5526
  instanceof: () => instanceOfType,
5527
5527
  initChinaDayjs: () => initChinaDayjs,
5528
5528
  imageToBase64: () => imageToBase64,
5529
+ getVideoStatus: () => getVideoStatus,
5529
5530
  getType: () => getType,
5530
5531
  getTotal: () => getTotal,
5531
5532
  getStrLength: () => getStrLength,
@@ -5541,6 +5542,7 @@ __export(exports_node, {
5541
5542
  getCookie: () => getCookie,
5542
5543
  getChineseByStr: () => getChineseByStr,
5543
5544
  getChinese: () => getChinese,
5545
+ generateVideo: () => generateVideo,
5544
5546
  generateUniqueFileName: () => generateUniqueFileName,
5545
5547
  generateAlphabetArray: () => generateAlphabetArray,
5546
5548
  function: () => functionType,
@@ -5550,7 +5552,6 @@ __export(exports_node, {
5550
5552
  enum: () => enumType,
5551
5553
  effect: () => effectsType,
5552
5554
  downloadFile: () => downloadFile,
5553
- doubao: () => exports_doubao2,
5554
5555
  discriminatedUnion: () => discriminatedUnionType,
5555
5556
  delay: () => delay,
5556
5557
  defaultErrorMap: () => en_default,
@@ -5562,14 +5563,14 @@ __export(exports_node, {
5562
5563
  coerce: () => coerce,
5563
5564
  chinaDayjs: () => chinaDayjs,
5564
5565
  cheerio: () => cheerio,
5566
+ chat: () => chat,
5565
5567
  calcJsText: () => calcJsText,
5566
5568
  boolean: () => booleanType,
5567
5569
  bigint: () => bigIntType,
5568
- axios: () => import_axios15.default,
5570
+ axios: () => import_axios9.default,
5569
5571
  array: () => arrayType,
5570
5572
  any: () => anyType,
5571
5573
  amount: () => amount,
5572
- ai302: () => exports_302,
5573
5574
  addIssueToContext: () => addIssueToContext,
5574
5575
  _: () => import_lodash.default,
5575
5576
  ZodVoid: () => ZodVoid,
@@ -5630,12 +5631,6 @@ __export(exports_node, {
5630
5631
  BRAND: () => BRAND
5631
5632
  });
5632
5633
  module.exports = __toCommonJS(exports_node);
5633
- var import_nedb = __toESM(require("nedb"));
5634
- var cheerio = __toESM(require("cheerio"));
5635
- var import_lodash = __toESM(require_lodash());
5636
- var import_axios15 = __toESM(require("axios"));
5637
- var import_json52 = __toESM(require("json5"));
5638
- var import_consola = __toESM(require("consola"));
5639
5634
 
5640
5635
  // ../../node_modules/zod/v3/external.js
5641
5636
  var exports_external = {};
@@ -9610,13 +9605,13 @@ var coerce = {
9610
9605
  date: (arg) => ZodDate.create({ ...arg, coerce: true })
9611
9606
  };
9612
9607
  var NEVER = INVALID;
9613
- // src/common/ai/302/index.ts
9614
- var exports_302 = {};
9615
- __export(exports_302, {
9616
- image: () => exports_image,
9617
- chat: () => chat,
9618
- audio: () => exports_audio
9619
- });
9608
+ // src/node.ts
9609
+ var cheerio = __toESM(require("cheerio"));
9610
+ var import_lodash = __toESM(require_lodash());
9611
+ var import_axios9 = __toESM(require("axios"));
9612
+ var import_json52 = __toESM(require("json5"));
9613
+ var import_consola = __toESM(require("consola"));
9614
+ var import_nedb = __toESM(require("nedb"));
9620
9615
 
9621
9616
  // src/common/ai/302/axios.ts
9622
9617
  var import_axios = __toESM(require("axios"));
@@ -9641,7 +9636,7 @@ var chat = async (message, model = "gpt-4.1", isParse = true) => {
9641
9636
  message
9642
9637
  }
9643
9638
  });
9644
- console.log(666, "302 chat res", typeof data, data);
9639
+ console.log(666, typeof data, data);
9645
9640
  const output = typeof data === "string" ? import_json5.default.parse(data)?.output : data?.output;
9646
9641
  if (isParse) {
9647
9642
  const match = /```(json)?(.*)```/s.exec(output);
@@ -9653,423 +9648,17 @@ var chat = async (message, model = "gpt-4.1", isParse = true) => {
9653
9648
  }
9654
9649
  return output;
9655
9650
  } catch (error) {
9656
- const responseData = error?.response?.data;
9657
- const message2 = responseData?.error?.message_cn || responseData?.error?.message || responseData?.message || error?.response?.statusText || error?.message || "未知原因";
9658
- throw new Error(message2);
9659
- }
9660
- };
9661
- // src/common/ai/302/audio/index.ts
9662
- var exports_audio = {};
9663
- __export(exports_audio, {
9664
- tts: () => exports_tts,
9665
- doubao: () => exports_doubao
9666
- });
9667
-
9668
- // src/common/ai/302/audio/tts.ts
9669
- var exports_tts = {};
9670
- __export(exports_tts, {
9671
- textToSpeech: () => textToSpeech,
9672
- fetchTask: () => fetchTask,
9673
- fetchProviders: () => fetchProviders
9674
- });
9675
- var fetchProviders = async () => {
9676
- try {
9677
- const { data } = await axios({
9678
- url: "/302/tts/provider",
9679
- method: "get"
9680
- });
9681
- return data;
9682
- } catch (error) {
9683
- throw error;
9684
- }
9685
- };
9686
- var textToSpeech = async (request) => {
9687
- try {
9688
- const { webhook, run_async, ...body } = request;
9689
- const { data } = await axios({
9690
- url: "/302/v2/audio/tts",
9691
- method: "post",
9692
- params: {
9693
- webhook,
9694
- run_async
9695
- },
9696
- data: {
9697
- ...body,
9698
- speed: body.speed ?? 1,
9699
- volume: body.volume ?? 1,
9700
- timeout: body.timeout ?? 180
9701
- }
9702
- });
9703
- return data;
9704
- } catch (error) {
9705
- throw error;
9706
- }
9707
- };
9708
- var fetchTask = async (taskId) => {
9709
- if (!taskId) {
9710
- throw new Error("taskId 不能为空");
9711
- }
9712
- try {
9713
- const { data } = await axios({
9714
- url: `/302/v2/audio/fetch/${encodeURIComponent(taskId)}`,
9715
- method: "get"
9716
- });
9717
- return data;
9718
- } catch (error) {
9719
- throw error;
9720
- }
9721
- };
9722
- // src/common/ai/302/audio/doubao.ts
9723
- var exports_doubao = {};
9724
- __export(exports_doubao, {
9725
- ttsHd: () => ttsHd
9726
- });
9727
- var createReqid = () => {
9728
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
9729
- return crypto.randomUUID();
9730
- }
9731
- return `${Date.now()}-${Math.random().toString(16).slice(2)}`;
9732
- };
9733
- var getUtf8ByteLength = (value) => {
9734
- return new TextEncoder().encode(value).length;
9735
- };
9736
- var assertNonEmptyString = (value, label) => {
9737
- if (typeof value !== "string" || !value.trim()) {
9738
- throw new Error(`${label} 不能为空`);
9651
+ throw new Error(error?.response?.statusText || error?.message || "未知原因");
9739
9652
  }
9740
9653
  };
9741
- var assertSpeedRatio = (value) => {
9742
- if (value === undefined)
9743
- return;
9744
- if (typeof value !== "number" || !Number.isFinite(value)) {
9745
- throw new Error("speed_ratio 必须为数字");
9746
- }
9747
- if (value < 0.8 || value > 2) {
9748
- throw new Error("speed_ratio 取值范围为 [0.8, 2]");
9749
- }
9750
- };
9751
- var ttsHd = async (payload) => {
9752
- const { audio, request } = payload;
9753
- const { voice_type, encoding, speed_ratio } = audio;
9754
- const { text, reqid: rawReqid, operation } = request;
9755
- assertNonEmptyString(voice_type, "voice_type");
9756
- assertNonEmptyString(text, "text");
9757
- assertSpeedRatio(speed_ratio);
9758
- const textByteLength = getUtf8ByteLength(text);
9759
- if (textByteLength > 1024) {
9760
- throw new Error(`text 超出长度限制:${textByteLength}/1024 字节`);
9761
- }
9762
- const reqid = rawReqid?.trim() || createReqid();
9763
- const { data } = await axios({
9764
- url: "/doubao/tts_hd",
9765
- method: "post",
9766
- data: {
9767
- audio: {
9768
- voice_type,
9769
- encoding: encoding ?? "pcm",
9770
- speed_ratio: speed_ratio ?? 1
9771
- },
9772
- request: {
9773
- reqid,
9774
- text,
9775
- operation: operation ?? "query"
9776
- }
9777
- }
9778
- });
9779
- return data;
9780
- };
9781
- // src/common/ai/302/image/index.ts
9782
- var exports_image = {};
9783
- __export(exports_image, {
9784
- midjourney: () => exports_midjourney,
9785
- gpt: () => exports_gpt
9786
- });
9787
-
9788
- // src/common/ai/302/image/midjourney.ts
9789
- var exports_midjourney = {};
9790
- __export(exports_midjourney, {
9791
- getImageStatus: () => getImageStatus,
9792
- generateImage: () => generateImage
9793
- });
9794
- var generateImage = async (prompt, base64Array) => {
9795
- try {
9796
- const { data } = await axios({
9797
- url: "/mj/submit/imagine",
9798
- method: "post",
9799
- data: {
9800
- prompt,
9801
- base64Array,
9802
- botType: "MID_JOURNEY",
9803
- notifyHook: "",
9804
- state: ""
9805
- }
9806
- });
9807
- return data;
9808
- } catch (error) {
9809
- throw error;
9810
- }
9811
- };
9812
- var getImageStatus = async (taskId) => {
9813
- try {
9814
- const { data } = await axios({
9815
- url: `/mj/task/${taskId}/fetch`,
9816
- method: "get"
9817
- });
9818
- return data;
9819
- } catch (error) {
9820
- throw error;
9821
- }
9822
- };
9823
- // src/common/ai/302/image/gpt.ts
9824
- var exports_gpt = {};
9825
- __export(exports_gpt, {
9826
- generateImage: () => generateImage2
9827
- });
9828
- var generateImage2 = async (params) => {
9829
- if (params.model === "gpt-4o-plus") {
9830
- const { data: data2 } = await axios.post("/v1/chat/completions", {
9831
- model: params.model,
9832
- messages: [{ role: "user", content: params.prompt }]
9833
- });
9834
- const content = data2?.choices?.[0]?.message?.content || "";
9835
- const urlMatch = content.match(/!\[.*?\]\((.*?)\)/) || content.match(/(https?:\/\/[^\s]+)/);
9836
- const url = urlMatch ? urlMatch[1] : content;
9837
- return {
9838
- background: "",
9839
- created: data2.created,
9840
- data: [{ url }],
9841
- output_format: "",
9842
- quality: "",
9843
- size: "",
9844
- usage: {
9845
- input_tokens: data2.usage?.prompt_tokens || 0,
9846
- input_tokens_details: {
9847
- image_tokens: data2.usage?.prompt_tokens_details?.image_tokens || 0,
9848
- text_tokens: data2.usage?.prompt_tokens_details?.text_tokens || 0
9849
- },
9850
- output_tokens: data2.usage?.completion_tokens || 0,
9851
- output_tokens_details: {
9852
- image_tokens: data2.usage?.completion_tokens_details?.image_tokens || 0,
9853
- text_tokens: data2.usage?.completion_tokens_details?.content_tokens || 0
9854
- },
9855
- total_tokens: data2.usage?.total_tokens || 0
9856
- }
9857
- };
9858
- }
9859
- const { data } = await axios.post("/v1/images/generations", params);
9860
- return data;
9861
- };
9862
- // src/common/ai/doubao/index.ts
9863
- var exports_doubao2 = {};
9864
- __export(exports_doubao2, {
9865
- vc: () => vc,
9866
- tts: () => tts
9867
- });
9868
-
9869
- // src/common/ai/doubao/tts.ts
9870
- var import_axios7 = __toESM(require("axios"));
9871
- var createReqid2 = () => {
9872
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
9873
- return crypto.randomUUID();
9874
- }
9875
- return `${Date.now()}-${Math.random().toString(16).slice(2)}`;
9876
- };
9877
- var decodeBase64ToArrayBuffer = (value) => {
9878
- if (typeof window !== "undefined" && typeof window.atob === "function") {
9879
- const binary = window.atob(value);
9880
- const bytes = new Uint8Array(binary.length);
9881
- for (let i = 0;i < binary.length; i++) {
9882
- bytes[i] = binary.charCodeAt(i);
9883
- }
9884
- return bytes.buffer;
9885
- }
9886
- const buf = Buffer.from(value, "base64");
9887
- return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
9888
- };
9889
- var tts = async (params) => {
9890
- const { app, user, audio, request } = params;
9891
- const url = "https://openspeech.bytedance.com/api/v3/tts/unidirectional";
9892
- const reqid = request.reqid || createReqid2();
9893
- const speechRate = audio.speed_ratio ? Math.round((audio.speed_ratio - 1) * 100) : 0;
9894
- const loudnessRate = audio.volume_ratio ? Math.round((audio.volume_ratio - 1) * 100) : 0;
9895
- const headers = {
9896
- "X-Api-App-Id": app.appid || "",
9897
- "X-Api-Access-Key": app.accessToken || "",
9898
- "Content-Type": "application/json",
9899
- "X-Api-Resource-Id": app.resourceId || "seed-tts-2.0",
9900
- "X-Api-Request-Id": reqid
9901
- };
9902
- const payload = {
9903
- user: {
9904
- uid: user?.uid || "uid"
9905
- },
9906
- req_params: {
9907
- text: request.text,
9908
- speaker: audio.voice_type,
9909
- audio_params: {
9910
- format: audio.encoding || "pcm",
9911
- sample_rate: 24000,
9912
- speech_rate: speechRate,
9913
- loudness_rate: loudnessRate,
9914
- emotion: audio.emotion,
9915
- emotion_scale: audio.emotion_scale
9916
- }
9917
- }
9918
- };
9919
- if (audio.context_texts) {
9920
- payload.req_params.additions = JSON.stringify({
9921
- context_texts: audio.context_texts
9922
- });
9923
- }
9924
- try {
9925
- const response = await import_axios7.default.post(url, payload, {
9926
- headers,
9927
- responseType: "arraybuffer"
9928
- });
9929
- const responseText = new TextDecoder().decode(response.data);
9930
- const jsonObjects = [];
9931
- let depth = 0;
9932
- let start = 0;
9933
- for (let i = 0;i < responseText.length; i++) {
9934
- if (responseText[i] === "{") {
9935
- if (depth === 0)
9936
- start = i;
9937
- depth++;
9938
- } else if (responseText[i] === "}") {
9939
- depth--;
9940
- if (depth === 0) {
9941
- try {
9942
- const jsonStr = responseText.substring(start, i + 1);
9943
- const jsonObj = JSON.parse(jsonStr);
9944
- jsonObjects.push(jsonObj);
9945
- } catch (e) {
9946
- console.warn("Failed to parse JSON chunk", e);
9947
- }
9948
- }
9949
- }
9950
- }
9951
- if (jsonObjects.length === 0) {
9952
- try {
9953
- jsonObjects.push(JSON.parse(responseText));
9954
- } catch (e) {
9955
- console.error("Doubao TTS Response Parse Error:", responseText);
9956
- throw new Error("Invalid response format");
9957
- }
9958
- }
9959
- const audioChunks = [];
9960
- let totalLength = 0;
9961
- for (const data of jsonObjects) {
9962
- const code = data.code;
9963
- const message = data.message;
9964
- if (typeof code === "number" && code !== 0 && code !== 20000000) {
9965
- console.error("Doubao TTS Error Response:", JSON.stringify(data, null, 2));
9966
- const err = new Error(`豆包语音合成失败: ${message} (code: ${code})`);
9967
- err.code = code;
9968
- err.reqid = data.reqid;
9969
- throw err;
9970
- }
9971
- if (data.data) {
9972
- const chunkBuffer = decodeBase64ToArrayBuffer(data.data);
9973
- audioChunks.push(chunkBuffer);
9974
- totalLength += chunkBuffer.byteLength;
9975
- }
9976
- }
9977
- if (totalLength === 0) {
9978
- throw new Error("豆包语音合成失败:未返回音频数据");
9979
- }
9980
- const resultBuffer = new Uint8Array(totalLength);
9981
- let offset = 0;
9982
- for (const chunk of audioChunks) {
9983
- resultBuffer.set(new Uint8Array(chunk), offset);
9984
- offset += chunk.byteLength;
9985
- }
9986
- return resultBuffer.buffer;
9987
- } catch (error) {
9988
- if (error.response) {
9989
- try {
9990
- let errorData = error.response.data;
9991
- if (errorData instanceof ArrayBuffer || typeof Buffer !== "undefined" && Buffer.isBuffer(errorData)) {
9992
- errorData = new TextDecoder().decode(errorData);
9993
- } else if (typeof errorData === "object") {
9994
- errorData = JSON.stringify(errorData);
9995
- }
9996
- throw new Error(`Doubao TTS Error: ${error.response.status} - ${errorData}`);
9997
- } catch (e) {
9998
- if (e.message && e.message.startsWith("Doubao TTS Error")) {
9999
- throw e;
10000
- }
10001
- throw new Error(`Doubao TTS Error: ${error.response.status} ${error.message}`);
10002
- }
10003
- }
10004
- throw error;
10005
- }
10006
- };
10007
- // src/common/ai/doubao/vc.ts
10008
- var import_axios8 = __toESM(require("axios"));
10009
- var getHeaders = (accessToken, contentType) => {
10010
- const headers = {
10011
- Authorization: `Bearer; ${accessToken}`
10012
- };
10013
- if (contentType) {
10014
- headers["content-type"] = contentType;
10015
- }
10016
- return headers;
10017
- };
10018
- var handleResponse = (data) => {
10019
- if (data instanceof ArrayBuffer) {
10020
- return data;
10021
- }
10022
- if (typeof Buffer !== "undefined" && Buffer.isBuffer(data)) {
10023
- return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
10024
- }
10025
- return data;
10026
- };
10027
- var vc = {
10028
- submit: async (params) => {
10029
- const { app, audio, options = {} } = params;
10030
- const url = new URL("https://openspeech.bytedance.com/api/v1/vc/submit");
10031
- url.searchParams.set("appid", app.appid);
10032
- Object.entries(options).forEach(([key2, value]) => {
10033
- if (value !== undefined && value !== null) {
10034
- url.searchParams.set(key2, String(value));
10035
- }
10036
- });
10037
- const response = await import_axios8.default.post(url.toString(), audio.data, {
10038
- headers: getHeaders(app.accessToken, audio.contentType || "audio/wav"),
10039
- responseType: "arraybuffer"
10040
- });
10041
- return handleResponse(response.data);
10042
- },
10043
- query: async (params) => {
10044
- const { app, id, blocking } = params;
10045
- const url = new URL("https://openspeech.bytedance.com/api/v1/vc/query");
10046
- url.searchParams.set("appid", app.appid);
10047
- url.searchParams.set("id", id);
10048
- if (blocking !== undefined) {
10049
- url.searchParams.set("blocking", String(blocking));
10050
- }
10051
- const response = await import_axios8.default.get(url.toString(), {
10052
- headers: getHeaders(app.accessToken),
10053
- responseType: "arraybuffer"
10054
- });
10055
- return handleResponse(response.data);
10056
- }
10057
- };
10058
- // src/common/ai/keling/index.ts
10059
- var exports_keling = {};
10060
- __export(exports_keling, {
10061
- setCookie: () => setCookie,
10062
- getVideoStatus: () => getVideoStatus,
10063
- generateVideo: () => generateVideo
10064
- });
10065
9654
 
10066
9655
  // src/common/ai/keling/utils.ts
10067
9656
  var url = __toESM(require("url"));
10068
9657
  var path = __toESM(require("path"));
10069
9658
 
10070
9659
  // src/common/ai/keling/axios.ts
10071
- var import_axios9 = __toESM(require("axios"));
10072
- var axios4 = import_axios9.default.create({
9660
+ var import_axios3 = __toESM(require("axios"));
9661
+ var axios2 = import_axios3.default.create({
10073
9662
  headers: {
10074
9663
  "Content-Type": "application/json",
10075
9664
  Cookie: "weblogger_did=web_52354269549862D; did=web_d22eeae73f6e4c74a76a4cc98e3a1188a5b0; anonymous-message-release-notice-1=true; anonymous-message-release-notice-2=true; dev-center-view-welcome-dialog-key=true; userId=2904283585; welcome-future-partner-key=true; old-user-time=1731936878621; kuaishou.ai.portal_st=ChVrdWFpc2hvdS5haS5wb3J0YWwuc3QSoAFuUNTARKNKXARahOJhWZ4iVBl2mIANSUfk2nCSr85bxCg2lrpE3PHj2Kn_kjPW0_KV8DfZS6UnNam4i6gaYeBmxRwOVAldYysCz7YtlsosEZRuiTe2iY7Ziq5SZeAP7jhTg8lxk7gvC-bEELmAc8HSrqN5HLWeU4GUFcEq-ChV7qsodJ8m42oBuvkFgX1qytVTIROpSS4cMmEiBhB3h99EGhLGi0v_iyPMOr2JVXM8LPzBvxQiIJrnuzAheyLtkeb55iZOUgZoAzXjYj0U1e4mLSonbXBGKAUwAQ; kuaishou.ai.portal_ph=2669d9adaa5c0629ac1053ab87e6c123880a"
@@ -10079,7 +9668,7 @@ var axios4 = import_axios9.default.create({
10079
9668
  // src/common/ai/keling/utils.ts
10080
9669
  var getToken = async (filename) => {
10081
9670
  try {
10082
- const response = await axios4.get("https://klingai.kuaishou.com/api/upload/issue/token", {
9671
+ const response = await axios2.get("https://klingai.kuaishou.com/api/upload/issue/token", {
10083
9672
  params: { filename }
10084
9673
  });
10085
9674
  return response.data.data.token;
@@ -10090,7 +9679,7 @@ var getToken = async (filename) => {
10090
9679
  };
10091
9680
  var uploadFragment = async (uploadToken, imageBuffer) => {
10092
9681
  try {
10093
- const response = await axios4.post("https://upload.kuaishouzt.com/api/upload/fragment", imageBuffer, {
9682
+ const response = await axios2.post("https://upload.kuaishouzt.com/api/upload/fragment", imageBuffer, {
10094
9683
  params: {
10095
9684
  upload_token: uploadToken,
10096
9685
  fragment_id: 0
@@ -10107,7 +9696,7 @@ var uploadFragment = async (uploadToken, imageBuffer) => {
10107
9696
  };
10108
9697
  var completeUpload = async (uploadToken) => {
10109
9698
  try {
10110
- const response = await axios4.post("https://upload.kuaishouzt.com/api/upload/complete", null, {
9699
+ const response = await axios2.post("https://upload.kuaishouzt.com/api/upload/complete", null, {
10111
9700
  params: {
10112
9701
  upload_token: uploadToken,
10113
9702
  fragment_count: 1
@@ -10121,7 +9710,7 @@ var completeUpload = async (uploadToken) => {
10121
9710
  };
10122
9711
  var verifyUpload = async (token) => {
10123
9712
  try {
10124
- const response = await axios4.get("https://klingai.kuaishou.com/api/upload/verify/token", {
9713
+ const response = await axios2.get("https://klingai.kuaishou.com/api/upload/verify/token", {
10125
9714
  params: { token }
10126
9715
  });
10127
9716
  if (response.data?.result === 1 && response.data?.data?.status === 3) {
@@ -10136,7 +9725,7 @@ var verifyUpload = async (token) => {
10136
9725
  };
10137
9726
  var downloadImage = async (imageUrl) => {
10138
9727
  try {
10139
- const response = await axios4.get(imageUrl, {
9728
+ const response = await axios2.get(imageUrl, {
10140
9729
  responseType: "arraybuffer"
10141
9730
  });
10142
9731
  return Buffer.from(response.data, "binary");
@@ -10216,7 +9805,7 @@ var sbumit = async (imageUrl, prompt) => {
10216
9805
  ],
10217
9806
  type: "m2v_img2video_hq"
10218
9807
  });
10219
- const response = await axios4({
9808
+ const response = await axios2({
10220
9809
  method: "POST",
10221
9810
  url: "https://klingai.kuaishou.com/api/task/submit",
10222
9811
  data
@@ -10246,7 +9835,7 @@ var calculateProgress = (taskData) => {
10246
9835
  return progressRatio;
10247
9836
  };
10248
9837
  var setCookie = (newCookieValue) => {
10249
- axios4.defaults.headers.Cookie = newCookieValue;
9838
+ axios2.defaults.headers.Cookie = newCookieValue;
10250
9839
  };
10251
9840
 
10252
9841
  // src/common/ai/keling/index.ts
@@ -10255,7 +9844,7 @@ var getVideoStatus = async (taskId) => {
10255
9844
  return;
10256
9845
  }
10257
9846
  try {
10258
- const response = await axios4.get("https://klingai.kuaishou.com/api/task/status", {
9847
+ const response = await axios2.get("https://klingai.kuaishou.com/api/task/status", {
10259
9848
  params: { taskId }
10260
9849
  });
10261
9850
  return {
@@ -12955,7 +12544,7 @@ var retryPromise = async (promiseFn, retryInterval = 1000, retryCount = 3) => {
12955
12544
  return retryPromise(promiseFn, retryCount - 1, retryInterval);
12956
12545
  }
12957
12546
  };
12958
- // src/common/enum.ts
12547
+ // src/common/enum/index.ts
12959
12548
  class EnumItem {
12960
12549
  label;
12961
12550
  value;
@@ -13002,11 +12591,11 @@ var Enum = {
13002
12591
  return enumObj;
13003
12592
  }
13004
12593
  };
13005
- // src/common/image.ts
13006
- var import_axios12 = __toESM(require("axios"));
12594
+ // src/common/image/index.ts
12595
+ var import_axios6 = __toESM(require("axios"));
13007
12596
  async function imageToBase64(url2) {
13008
12597
  try {
13009
- const response = await import_axios12.default.get(url2, {
12598
+ const response = await import_axios6.default.get(url2, {
13010
12599
  responseType: "arraybuffer"
13011
12600
  });
13012
12601
  const base64String = Buffer.from(response.data).toString("base64");
@@ -13016,7 +12605,7 @@ async function imageToBase64(url2) {
13016
12605
  throw error;
13017
12606
  }
13018
12607
  }
13019
- // src/common/dayjs.ts
12608
+ // src/common/dayjs/index.ts
13020
12609
  var import_dayjs = __toESM(require("dayjs"));
13021
12610
  var import_isBetween = __toESM(require("dayjs/plugin/isBetween"));
13022
12611
  var import_weekday = __toESM(require("dayjs/plugin/weekday"));
@@ -13082,7 +12671,7 @@ var sendMail = (config2) => {
13082
12671
  };
13083
12672
  // src/node/file.ts
13084
12673
  var import_fs_extra = __toESM(require("fs-extra"));
13085
- var import_axios13 = __toESM(require("axios"));
12674
+ var import_axios7 = __toESM(require("axios"));
13086
12675
  var import_url = __toESM(require("url"));
13087
12676
  var path2 = __toESM(require("path"));
13088
12677
  var replaceContentInFile = async (filePath, targetContent, replacement) => {
@@ -13114,7 +12703,7 @@ var downloadFile = async (httpUrl, outputPath) => {
13114
12703
  }
13115
12704
  outputPath = ".tmp/" + decodeURIComponent(fileName);
13116
12705
  }
13117
- const response = await import_axios13.default({
12706
+ const response = await import_axios7.default({
13118
12707
  url: httpUrl,
13119
12708
  method: "get",
13120
12709
  responseType: "stream"
@@ -13133,7 +12722,7 @@ var downloadFile = async (httpUrl, outputPath) => {
13133
12722
  };
13134
12723
  // src/node/oss.ts
13135
12724
  var import_ali_oss = __toESM(require("ali-oss"));
13136
- var import_axios14 = __toESM(require("axios"));
12725
+ var import_axios8 = __toESM(require("axios"));
13137
12726
  var import_fs_extra2 = __toESM(require("fs-extra"));
13138
12727
  var path3 = __toESM(require("path"));
13139
12728
  var oss = new import_ali_oss.default({
@@ -13148,7 +12737,7 @@ async function uploadFile(file, filename) {
13148
12737
  if (typeof file === "string") {
13149
12738
  if (/^https?:\/\//.test(file)) {
13150
12739
  try {
13151
- const response = await import_axios14.default.get(file, { responseType: "arraybuffer" });
12740
+ const response = await import_axios8.default.get(file, { responseType: "arraybuffer" });
13152
12741
  buffer = Buffer.from(response.data);
13153
12742
  } catch (error) {
13154
12743
  throw new Error(`无法从 URL 下载文件: ${error}`);