node-karin 1.15.5 → 1.16.1

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.
Files changed (89) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/adapter-BqlH3u3X.mjs +218 -0
  3. package/dist/app-DdMQbBEY.mjs +4109 -0
  4. package/dist/cache-CPcPeo6N.mjs +163 -0
  5. package/dist/chunk-NzVPYdc1.mjs +21 -0
  6. package/dist/cli/index.cjs +10900 -1
  7. package/dist/cli/index.d.ts +1 -1
  8. package/dist/cli/index.mjs +10770 -10224
  9. package/dist/file-ZGuqNDd-.mjs +15987 -0
  10. package/dist/file-dGy9of8-.mjs +268 -0
  11. package/dist/fsSync-Cf5MWILk.mjs +65 -0
  12. package/dist/index.d.ts +12235 -12738
  13. package/dist/index.mjs +2054 -25247
  14. package/dist/internal-DupfycKE.mjs +597 -0
  15. package/dist/kv-DZp4UIxg.mjs +192 -0
  16. package/dist/module/art-template.d.ts +2 -13
  17. package/dist/module/art-template.mjs +3 -1
  18. package/dist/module/axios.d.ts +3 -2
  19. package/dist/module/axios.mjs +5 -2
  20. package/dist/module/chalk.d.ts +3 -2
  21. package/dist/module/chalk.mjs +5 -2
  22. package/dist/module/chokidar.d.ts +3 -2
  23. package/dist/module/chokidar.mjs +5 -2
  24. package/dist/module/express.d.ts +2 -1
  25. package/dist/module/express.mjs +3 -1
  26. package/dist/module/lodash.d.ts +2 -1
  27. package/dist/module/lodash.mjs +3 -1
  28. package/dist/module/log4js.d.ts +3 -2
  29. package/dist/module/log4js.mjs +5 -2
  30. package/dist/module/moment.d.ts +2 -1
  31. package/dist/module/moment.mjs +3 -1
  32. package/dist/module/node-schedule.d.ts +3 -2
  33. package/dist/module/node-schedule.mjs +5 -2
  34. package/dist/module/redis.d.ts +3 -2
  35. package/dist/module/redis.mjs +5 -2
  36. package/dist/module/sqlite3.d.ts +3 -2
  37. package/dist/module/sqlite3.mjs +5 -2
  38. package/dist/module/ws.d.ts +3 -2
  39. package/dist/module/ws.mjs +5 -2
  40. package/dist/module/yaml.d.ts +3 -2
  41. package/dist/module/yaml.mjs +5 -2
  42. package/dist/queue-CnKedaZA.mjs +70 -0
  43. package/dist/redis-aLJ7wbJH.mjs +1556 -0
  44. package/dist/render-DPqueDZr.mjs +170 -0
  45. package/dist/root.d.ts +46 -46
  46. package/dist/root.mjs +136 -93
  47. package/dist/router-zPSN9-tY.mjs +124 -0
  48. package/dist/server-DT64D-m-.mjs +38 -0
  49. package/dist/snapka-BTlnZOyI.mjs +450 -0
  50. package/dist/sqlite-Dcj9jlW9.mjs +307 -0
  51. package/dist/start/app.d.ts +1 -1
  52. package/dist/start/app.mjs +14 -7
  53. package/dist/start/index.d.ts +1 -1
  54. package/dist/start/index.mjs +325 -656
  55. package/dist/template-Djk6y0uC.mjs +133 -0
  56. package/dist/terminalManager-Lxa8Sm06.mjs +783 -0
  57. package/dist/uptime-C121X_rq.mjs +210 -0
  58. package/dist/web/{CompressaPRO-GX.woff2.br → CompressaPRO-GX.woff2} +0 -0
  59. package/dist/web/assets/css/style-CBB8wM_W.css +14880 -0
  60. package/dist/web/assets/js/entry-Blf4Trpx.js +258540 -0
  61. package/dist/web/{googleapis.woff2.br → googleapis.woff2} +0 -0
  62. package/dist/web/index.html +2 -15
  63. package/dist/web/karin.png +0 -0
  64. package/dist/web/sha256.min.js +9 -0
  65. package/dist/ws-BLDoC2gV.mjs +80 -0
  66. package/dist/ws-CcoWd3Ar.mjs +106 -0
  67. package/package.json +7 -7
  68. package/dist/global.d.d.ts +0 -68
  69. package/dist/types-hAhbXJDZ.d.ts +0 -109
  70. package/dist/web/assets/css/components-ep7vm38G.css +0 -1
  71. package/dist/web/assets/css/index-Dadvd9mn.css.br +0 -0
  72. package/dist/web/assets/css/vendor-editor-CFbL2ovg.css.br +0 -0
  73. package/dist/web/assets/css/vendor-others-ZgkIHsf0.css +0 -1
  74. package/dist/web/assets/js/components-CU2xw4lY.js.br +0 -0
  75. package/dist/web/assets/js/entry-Dvb7eYLE.js.br +0 -0
  76. package/dist/web/assets/js/hooks-CRfhs4ON.js.br +0 -0
  77. package/dist/web/assets/js/page-404.tsx-DYMd_RI_.js +0 -1
  78. package/dist/web/assets/js/page-dashboard-CG60V_Z-.js.br +0 -0
  79. package/dist/web/assets/js/page-loading.tsx-wY8a9me3.js.br +0 -0
  80. package/dist/web/assets/js/page-login.tsx-B54ZOEZB.js.br +0 -0
  81. package/dist/web/assets/js/utils-C9nWTSuo.js +0 -2
  82. package/dist/web/assets/js/vendor-editor-BmqYP7lh.js.br +0 -0
  83. package/dist/web/assets/js/vendor-heroui-ClBCy2zk.js.br +0 -0
  84. package/dist/web/assets/js/vendor-others-6GiMrjd4.js.br +0 -0
  85. package/dist/web/assets/js/vendor-react-Dc9jdQiK.js.br +0 -0
  86. package/dist/web/assets/js/vendor-ui-utils-D0xkboLL.js.br +0 -0
  87. package/dist/web/assets/js/vendor-visual-saF8KLH_.js.br +0 -0
  88. package/dist/web/karin.png.br +0 -0
  89. package/dist/web/sha256.min.js.br +0 -0
@@ -14,21 +14,8 @@
14
14
  content="viewport-fit=cover, width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
15
15
  name="viewport" />
16
16
  <link href="/web/assets/ico/favicon-BoqZd694.ico" rel="icon" />
17
- <script type="module" crossorigin src="/web/assets/js/entry-Dvb7eYLE.js"></script>
18
- <link rel="modulepreload" crossorigin href="/web/assets/js/vendor-editor-BmqYP7lh.js">
19
- <link rel="modulepreload" crossorigin href="/web/assets/js/vendor-others-6GiMrjd4.js">
20
- <link rel="modulepreload" crossorigin href="/web/assets/js/vendor-ui-utils-D0xkboLL.js">
21
- <link rel="modulepreload" crossorigin href="/web/assets/js/vendor-react-Dc9jdQiK.js">
22
- <link rel="modulepreload" crossorigin href="/web/assets/js/vendor-heroui-ClBCy2zk.js">
23
- <link rel="modulepreload" crossorigin href="/web/assets/js/hooks-CRfhs4ON.js">
24
- <link rel="modulepreload" crossorigin href="/web/assets/js/vendor-visual-saF8KLH_.js">
25
- <link rel="modulepreload" crossorigin href="/web/assets/js/components-CU2xw4lY.js">
26
- <link rel="modulepreload" crossorigin href="/web/assets/js/utils-C9nWTSuo.js">
27
- <link rel="modulepreload" crossorigin href="/web/assets/js/page-dashboard-CG60V_Z-.js">
28
- <link rel="stylesheet" crossorigin href="/web/assets/css/vendor-editor-CFbL2ovg.css">
29
- <link rel="stylesheet" crossorigin href="/web/assets/css/vendor-others-ZgkIHsf0.css">
30
- <link rel="stylesheet" crossorigin href="/web/assets/css/components-ep7vm38G.css">
31
- <link rel="stylesheet" crossorigin href="/web/assets/css/index-Dadvd9mn.css">
17
+ <script type="module" crossorigin src="/web/assets/js/entry-Blf4Trpx.js"></script>
18
+ <link rel="stylesheet" crossorigin href="/web/assets/css/style-CBB8wM_W.css">
32
19
  </head>
33
20
 
34
21
  <body>
Binary file
@@ -0,0 +1,9 @@
1
+ /**
2
+ * [js-sha256]{@link https://github.com/emn178/js-sha256}
3
+ *
4
+ * @version 0.11.0
5
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
6
+ * @copyright Chen, Yi-Cyuan 2014-2024
7
+ * @license MIT
8
+ */
9
+ !function(){"use strict";function t(t,i){i?(d[0]=d[16]=d[1]=d[2]=d[3]=d[4]=d[5]=d[6]=d[7]=d[8]=d[9]=d[10]=d[11]=d[12]=d[13]=d[14]=d[15]=0,this.blocks=d):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=t}function i(i,r,s){var e,n=typeof i;if("string"===n){var o,a=[],u=i.length,c=0;for(e=0;e<u;++e)(o=i.charCodeAt(e))<128?a[c++]=o:o<2048?(a[c++]=192|o>>>6,a[c++]=128|63&o):o<55296||o>=57344?(a[c++]=224|o>>>12,a[c++]=128|o>>>6&63,a[c++]=128|63&o):(o=65536+((1023&o)<<10|1023&i.charCodeAt(++e)),a[c++]=240|o>>>18,a[c++]=128|o>>>12&63,a[c++]=128|o>>>6&63,a[c++]=128|63&o);i=a}else{if("object"!==n)throw new Error(h);if(null===i)throw new Error(h);if(f&&i.constructor===ArrayBuffer)i=new Uint8Array(i);else if(!(Array.isArray(i)||f&&ArrayBuffer.isView(i)))throw new Error(h)}i.length>64&&(i=new t(r,!0).update(i).array());var y=[],p=[];for(e=0;e<64;++e){var l=i[e]||0;y[e]=92^l,p[e]=54^l}t.call(this,r,s),this.update(p),this.oKeyPad=y,this.inner=!0,this.sharedMemory=s}var h="input is invalid type",r="object"==typeof window,s=r?window:{};s.JS_SHA256_NO_WINDOW&&(r=!1);var e=!r&&"object"==typeof self,n=!s.JS_SHA256_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;n?s=global:e&&(s=self);var o=!s.JS_SHA256_NO_COMMON_JS&&"object"==typeof module&&module.exports,a="function"==typeof define&&define.amd,f=!s.JS_SHA256_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,u="0123456789abcdef".split(""),c=[-2147483648,8388608,32768,128],y=[24,16,8,0],p=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],l=["hex","array","digest","arrayBuffer"],d=[];!s.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!f||!s.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});var A=function(i,h){return function(r){return new t(h,!0).update(r)[i]()}},w=function(i){var h=A("hex",i);n&&(h=b(h,i)),h.create=function(){return new t(i)},h.update=function(t){return h.create().update(t)};for(var r=0;r<l.length;++r){var s=l[r];h[s]=A(s,i)}return h},b=function(t,i){var r,e=require("crypto"),n=require("buffer").Buffer,o=i?"sha224":"sha256";r=n.from&&!s.JS_SHA256_NO_BUFFER_FROM?n.from:function(t){return new n(t)};return function(i){if("string"==typeof i)return e.createHash(o).update(i,"utf8").digest("hex");if(null===i||void 0===i)throw new Error(h);return i.constructor===ArrayBuffer&&(i=new Uint8Array(i)),Array.isArray(i)||ArrayBuffer.isView(i)||i.constructor===n?e.createHash(o).update(r(i)).digest("hex"):t(i)}},_=function(t,h){return function(r,s){return new i(r,h,!0).update(s)[t]()}},v=function(t){var h=_("hex",t);h.create=function(h){return new i(h,t)},h.update=function(t,i){return h.create(t).update(i)};for(var r=0;r<l.length;++r){var s=l[r];h[s]=_(s,t)}return h};t.prototype.update=function(t){if(!this.finalized){var i,r=typeof t;if("string"!==r){if("object"!==r)throw new Error(h);if(null===t)throw new Error(h);if(f&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||f&&ArrayBuffer.isView(t)))throw new Error(h);i=!0}for(var s,e,n=0,o=t.length,a=this.blocks;n<o;){if(this.hashed&&(this.hashed=!1,a[0]=this.block,this.block=a[16]=a[1]=a[2]=a[3]=a[4]=a[5]=a[6]=a[7]=a[8]=a[9]=a[10]=a[11]=a[12]=a[13]=a[14]=a[15]=0),i)for(e=this.start;n<o&&e<64;++n)a[e>>>2]|=t[n]<<y[3&e++];else for(e=this.start;n<o&&e<64;++n)(s=t.charCodeAt(n))<128?a[e>>>2]|=s<<y[3&e++]:s<2048?(a[e>>>2]|=(192|s>>>6)<<y[3&e++],a[e>>>2]|=(128|63&s)<<y[3&e++]):s<55296||s>=57344?(a[e>>>2]|=(224|s>>>12)<<y[3&e++],a[e>>>2]|=(128|s>>>6&63)<<y[3&e++],a[e>>>2]|=(128|63&s)<<y[3&e++]):(s=65536+((1023&s)<<10|1023&t.charCodeAt(++n)),a[e>>>2]|=(240|s>>>18)<<y[3&e++],a[e>>>2]|=(128|s>>>12&63)<<y[3&e++],a[e>>>2]|=(128|s>>>6&63)<<y[3&e++],a[e>>>2]|=(128|63&s)<<y[3&e++]);this.lastByteIndex=e,this.bytes+=e-this.start,e>=64?(this.block=a[16],this.start=e-64,this.hash(),this.hashed=!0):this.start=e}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},t.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,i=this.lastByteIndex;t[16]=this.block,t[i>>>2]|=c[3&i],this.block=t[16],i>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}},t.prototype.hash=function(){var t,i,h,r,s,e,n,o,a,f=this.h0,u=this.h1,c=this.h2,y=this.h3,l=this.h4,d=this.h5,A=this.h6,w=this.h7,b=this.blocks;for(t=16;t<64;++t)i=((s=b[t-15])>>>7|s<<25)^(s>>>18|s<<14)^s>>>3,h=((s=b[t-2])>>>17|s<<15)^(s>>>19|s<<13)^s>>>10,b[t]=b[t-16]+i+b[t-7]+h<<0;for(a=u&c,t=0;t<64;t+=4)this.first?(this.is224?(e=300032,w=(s=b[0]-1413257819)-150054599<<0,y=s+24177077<<0):(e=704751109,w=(s=b[0]-210244248)-1521486534<<0,y=s+143694565<<0),this.first=!1):(i=(f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10),r=(e=f&u)^f&c^a,w=y+(s=w+(h=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7))+(l&d^~l&A)+p[t]+b[t])<<0,y=s+(i+r)<<0),i=(y>>>2|y<<30)^(y>>>13|y<<19)^(y>>>22|y<<10),r=(n=y&f)^y&u^e,A=c+(s=A+(h=(w>>>6|w<<26)^(w>>>11|w<<21)^(w>>>25|w<<7))+(w&l^~w&d)+p[t+1]+b[t+1])<<0,i=((c=s+(i+r)<<0)>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),r=(o=c&y)^c&f^n,d=u+(s=d+(h=(A>>>6|A<<26)^(A>>>11|A<<21)^(A>>>25|A<<7))+(A&w^~A&l)+p[t+2]+b[t+2])<<0,i=((u=s+(i+r)<<0)>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),r=(a=u&c)^u&y^o,l=f+(s=l+(h=(d>>>6|d<<26)^(d>>>11|d<<21)^(d>>>25|d<<7))+(d&A^~d&w)+p[t+3]+b[t+3])<<0,f=s+(i+r)<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+f<<0,this.h1=this.h1+u<<0,this.h2=this.h2+c<<0,this.h3=this.h3+y<<0,this.h4=this.h4+l<<0,this.h5=this.h5+d<<0,this.h6=this.h6+A<<0,this.h7=this.h7+w<<0},t.prototype.hex=function(){this.finalize();var t=this.h0,i=this.h1,h=this.h2,r=this.h3,s=this.h4,e=this.h5,n=this.h6,o=this.h7,a=u[t>>>28&15]+u[t>>>24&15]+u[t>>>20&15]+u[t>>>16&15]+u[t>>>12&15]+u[t>>>8&15]+u[t>>>4&15]+u[15&t]+u[i>>>28&15]+u[i>>>24&15]+u[i>>>20&15]+u[i>>>16&15]+u[i>>>12&15]+u[i>>>8&15]+u[i>>>4&15]+u[15&i]+u[h>>>28&15]+u[h>>>24&15]+u[h>>>20&15]+u[h>>>16&15]+u[h>>>12&15]+u[h>>>8&15]+u[h>>>4&15]+u[15&h]+u[r>>>28&15]+u[r>>>24&15]+u[r>>>20&15]+u[r>>>16&15]+u[r>>>12&15]+u[r>>>8&15]+u[r>>>4&15]+u[15&r]+u[s>>>28&15]+u[s>>>24&15]+u[s>>>20&15]+u[s>>>16&15]+u[s>>>12&15]+u[s>>>8&15]+u[s>>>4&15]+u[15&s]+u[e>>>28&15]+u[e>>>24&15]+u[e>>>20&15]+u[e>>>16&15]+u[e>>>12&15]+u[e>>>8&15]+u[e>>>4&15]+u[15&e]+u[n>>>28&15]+u[n>>>24&15]+u[n>>>20&15]+u[n>>>16&15]+u[n>>>12&15]+u[n>>>8&15]+u[n>>>4&15]+u[15&n];return this.is224||(a+=u[o>>>28&15]+u[o>>>24&15]+u[o>>>20&15]+u[o>>>16&15]+u[o>>>12&15]+u[o>>>8&15]+u[o>>>4&15]+u[15&o]),a},t.prototype.toString=t.prototype.hex,t.prototype.digest=function(){this.finalize();var t=this.h0,i=this.h1,h=this.h2,r=this.h3,s=this.h4,e=this.h5,n=this.h6,o=this.h7,a=[t>>>24&255,t>>>16&255,t>>>8&255,255&t,i>>>24&255,i>>>16&255,i>>>8&255,255&i,h>>>24&255,h>>>16&255,h>>>8&255,255&h,r>>>24&255,r>>>16&255,r>>>8&255,255&r,s>>>24&255,s>>>16&255,s>>>8&255,255&s,e>>>24&255,e>>>16&255,e>>>8&255,255&e,n>>>24&255,n>>>16&255,n>>>8&255,255&n];return this.is224||a.push(o>>>24&255,o>>>16&255,o>>>8&255,255&o),a},t.prototype.array=t.prototype.digest,t.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),i=new DataView(t);return i.setUint32(0,this.h0),i.setUint32(4,this.h1),i.setUint32(8,this.h2),i.setUint32(12,this.h3),i.setUint32(16,this.h4),i.setUint32(20,this.h5),i.setUint32(24,this.h6),this.is224||i.setUint32(28,this.h7),t},(i.prototype=new t).finalize=function(){if(t.prototype.finalize.call(this),this.inner){this.inner=!1;var i=this.array();t.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(i),t.prototype.finalize.call(this)}};var B=w();B.sha256=B,B.sha224=w(!0),B.sha256.hmac=v(),B.sha224.hmac=v(!0),o?module.exports=B:(s.sha256=B.sha256,s.sha224=B.sha224,a&&define(function(){return B}))}();
@@ -0,0 +1,80 @@
1
+ import { i as getRenderCfg } from "./file-ZGuqNDd-.mjs";
2
+ import { r as server } from "./app-DdMQbBEY.mjs";
3
+ import { _ as WS_CONNECTION_SANDBOX, d as WS_CLOSE_ONEBOT, f as WS_CLOSE_PUPPETEER, g as WS_CONNECTION_PUPPETEER, h as WS_CONNECTION_ONEBOT, m as WS_CONNECTION, r as listeners, u as WS_CLOSE, v as WS_CONNECTION_TERMINAL, y as WS_SNAPKA } from "./internal-DupfycKE.mjs";
4
+ import { WebSocketServer } from "ws";
5
+
6
+ //#region src/server/app/ws.ts
7
+ /** ws 服务 */
8
+ const wss = new WebSocketServer({ server });
9
+ /**
10
+ * 发送ws连接 如果5秒内无函数影响 则主动断开连接
11
+ * @param key 事件名
12
+ * @param socket 连接
13
+ * @param request 请求
14
+ */
15
+ const emitEvent = (key, socket, request) => {
16
+ /** 是否关闭 */
17
+ let isClose = true;
18
+ /** 回调 调用后代表有函数接管 */
19
+ const call = () => {
20
+ isClose = false;
21
+ timer && clearTimeout(timer);
22
+ };
23
+ /** 定时器 3秒后自动断开连接 */
24
+ const timer = setTimeout(() => {
25
+ if (!isClose) return;
26
+ socket.close();
27
+ logger.warn(`[WebSocket] 链接无函数接管 已自动断开ip: ${request.socket.remoteAddress}\nhost: ${request.headers.host}${request.url}\nheaders: ${JSON.stringify(request.headers, null, 2)}`);
28
+ }, 3e3);
29
+ listeners.emit(key, socket, request, call);
30
+ };
31
+ wss.on("error", (error) => {
32
+ if (error.code === "EADDRINUSE") logger.fatal(`[server] 端口 ${process.env.HTTP_PORT} 已被占用,无法启动 http WebSocket 服务`);
33
+ else logger.fatal(`[server] http服务启动失败: ${error.message}`);
34
+ throw error;
35
+ });
36
+ /** 监听 ws 连接 */
37
+ wss.on("connection", (socket, request) => {
38
+ /** 对url进行处理 去除url中的敏感信息打印在控制台 */
39
+ const url = (request.url || "").replace(/token=[^&]+/, "token=******").replace(/user_id=[^&]+/, "user_id=******").replace(/access_token=[^&]+/, "access_token=******");
40
+ logger.mark(`[WebSocket] ${logger.green("connection")}:\nip: ${request.socket.remoteAddress}\nhost: ${request.headers.host}${url}\nheaders: ${JSON.stringify(request.headers, null, 2)}`);
41
+ if (request.url === "/" || request.url === "/onebot/v11/ws" || request.url === "/onebot/v11/ws/") {
42
+ emitEvent(WS_CONNECTION_ONEBOT, socket, request);
43
+ socket.on("close", (code, reason) => {
44
+ listeners.emit(WS_CLOSE_ONEBOT, socket, request, code, reason);
45
+ });
46
+ return;
47
+ }
48
+ if (request.url === "/puppeteer" || request.url === "/snapka") {
49
+ if (!getRenderCfg().ws_server.enable) {
50
+ logger.warn("[WebSocket] snapkaServer 未启用");
51
+ socket.close();
52
+ return;
53
+ }
54
+ /**
55
+ * Snapka
56
+ * x-client-id: snapka 作为识别
57
+ */
58
+ if (request.headers["x-client-id"] === "snapka") emitEvent(WS_SNAPKA, socket, request);
59
+ else emitEvent(WS_CONNECTION_PUPPETEER, socket, request);
60
+ socket.once("close", (code, reason) => {
61
+ listeners.emit(WS_CLOSE_PUPPETEER, socket, request, code, reason);
62
+ });
63
+ return;
64
+ }
65
+ if (request.url?.startsWith("/terminal/create")) {
66
+ emitEvent(WS_CONNECTION_TERMINAL, socket, request);
67
+ return;
68
+ }
69
+ if (request.url?.startsWith("/sandbox")) {
70
+ emitEvent(WS_CONNECTION_SANDBOX, socket, request);
71
+ return;
72
+ }
73
+ emitEvent(WS_CONNECTION, socket, request);
74
+ socket.on("close", (code, reason) => {
75
+ listeners.emit(WS_CLOSE, socket, request, code, reason);
76
+ });
77
+ });
78
+
79
+ //#endregion
80
+ export { };
@@ -0,0 +1,106 @@
1
+ import { x as isPublic } from "./internal-DupfycKE.mjs";
2
+ import { o as registerRender, u as unregisterRender } from "./cache-CPcPeo6N.mjs";
3
+ import { n as renderTpl } from "./template-Djk6y0uC.mjs";
4
+ import fs from "node:fs";
5
+ import crypto from "node:crypto";
6
+
7
+ //#region src/adapter/render/connect/ws.ts
8
+ var WebSocketRender = class {
9
+ /** websocket实例 */
10
+ socket;
11
+ /** 唯一标识符 */
12
+ echo = 0;
13
+ /** 索引 */
14
+ index;
15
+ constructor(socket) {
16
+ this.socket = socket;
17
+ this.index = -1;
18
+ }
19
+ async init() {
20
+ this.socket.on("close", () => {
21
+ unregisterRender(this.index);
22
+ this.socket.removeAllListeners();
23
+ this.socket.close();
24
+ });
25
+ this.socket.on("message", (event) => {
26
+ const raw = event.toString();
27
+ const { echo, action, status, data } = JSON.parse(raw);
28
+ logger.debug(`[WebSocket] ${echo} ${action} ${status}`);
29
+ logger.trace(`[WebSocket] ${echo} ${raw}`);
30
+ if (action === "response") this.socket.emit(echo, {
31
+ action,
32
+ status,
33
+ data
34
+ });
35
+ else if (action === "close") {
36
+ logger.error(`[WebSocket] 收到断开连接请求: ${raw}`);
37
+ this.socket.close();
38
+ } else if (action === "static") return this.static(echo, data);
39
+ else logger.error(`[WebSocket] 未知的请求: ${raw}`);
40
+ });
41
+ this.index = registerRender("puppeteer", this.render.bind(this));
42
+ }
43
+ /**
44
+ * @description 鉴权
45
+ * @param token
46
+ * @param targetToken 目标的token
47
+ * @returns 是否鉴权成功
48
+ */
49
+ auth(token, targetToken) {
50
+ if (token !== targetToken) {
51
+ /** 再次检查长度 非md5转md5 */
52
+ if (token.length !== 32) token = crypto.createHash("md5").update(`Bearer ${token}`).digest("hex");
53
+ if (targetToken.length !== 32) targetToken = crypto.createHash("md5").update(`Bearer ${targetToken}`).digest("hex");
54
+ if (token !== targetToken) return false;
55
+ }
56
+ return true;
57
+ }
58
+ /**
59
+ * @description 处理静态资源请求
60
+ * @param echo 唯一标识符
61
+ * @param data 数据
62
+ */
63
+ async static(echo, data) {
64
+ if (!isPublic(data.file)) {
65
+ logger.warn(`[WebSocket] 访问的路径非法: echo: ${echo} data: ${JSON.stringify(data)}`);
66
+ return this.socket.send(JSON.stringify({
67
+ echo,
68
+ status: "error",
69
+ data: "非法的访问路径"
70
+ }));
71
+ }
72
+ const fileData = fs.readFileSync(data.file);
73
+ return this.socket.send(JSON.stringify({
74
+ echo,
75
+ status: "ok",
76
+ data: fileData
77
+ }));
78
+ }
79
+ render(data) {
80
+ const options = renderTpl(data);
81
+ return this.sendApi("render", options);
82
+ }
83
+ async sendApi(action, data) {
84
+ const echo = ++this.echo;
85
+ const str = JSON.stringify({
86
+ echo,
87
+ action,
88
+ data
89
+ });
90
+ logger.debug(`[sendApi][WebSocket] ${echo} ${action} ${str}`);
91
+ this.socket.send(str);
92
+ return new Promise((resolve, reject) => {
93
+ const timeoutId = setTimeout(() => {
94
+ reject(/* @__PURE__ */ new Error(`[sendApi] 请求错误:\n action: ${action}\n params: ${str}\n error: 请求超时}`));
95
+ }, 120 * 1e3);
96
+ this.socket.once(echo + "", ({ status, data }) => {
97
+ clearTimeout(timeoutId);
98
+ if (status === "ok") return resolve(data);
99
+ reject(new Error(`[sendApi] 请求错误:\n action: ${action}\n params: ${str}`, { cause: data }));
100
+ });
101
+ });
102
+ }
103
+ };
104
+
105
+ //#endregion
106
+ export { WebSocketRender as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-karin",
3
- "version": "1.15.5",
3
+ "version": "1.16.1",
4
4
  "description": "Lightweight, efficient, concise, and stable robot framework.",
5
5
  "keywords": [
6
6
  "node",
@@ -148,6 +148,7 @@
148
148
  "axios": "npm:@karinjs/axios@1.13.2",
149
149
  "chalk": "5.6.2",
150
150
  "chokidar": "4.0.3",
151
+ "dotenv": "npm:@karinjs/dotenv@^1.1.2",
151
152
  "express": "npm:@karinjs/express@1.0.3",
152
153
  "lodash": "npm:@karinjs/lodash@1.1.1",
153
154
  "log4js": "npm:@karinjs/log4js@1.5.6",
@@ -167,7 +168,6 @@
167
168
  "@types/jsonwebtoken": "^9.0.10",
168
169
  "@types/lodash": "^4.17.16",
169
170
  "cross-env": "^7.0.3",
170
- "dotenv": "npm:@karinjs/dotenv@^1.1.2",
171
171
  "@karinjs/onebot": "0.0.1"
172
172
  },
173
173
  "engines": {
@@ -177,17 +177,17 @@
177
177
  "access": "public",
178
178
  "registry": "https://registry.npmjs.org"
179
179
  },
180
- "time": "2025-10-08T06:35:20.005Z",
180
+ "time": "2026-06-11T07:00:35.219Z",
181
181
  "scripts": {
182
182
  ".": "pnpm app",
183
183
  "app": "node dist/start/index.mjs",
184
184
  "app:bun": "bun dist/start/index.mjs",
185
- "build": "pnpm build:main && pnpm build:module",
185
+ "build": "pnpm build:main && pnpm --filter node-karin-cli run build:core && pnpm build:locale",
186
186
  "build:dev": "pnpm build:main",
187
187
  "build:locale": "node cli/locale.js",
188
- "build:main": "tsc && tsup",
189
- "build:module": "tsc && tsup --config tsup.config.module.ts && pnpm build:locale",
190
- "build:types": "tsc && tsup --config tsup.config.types.ts",
188
+ "build:main": "tsc && tsdown",
189
+ "build:module": "pnpm build:main && pnpm build:locale",
190
+ "build:types": "pnpm build:main",
191
191
  "cli": "node dist/cli/index.mjs",
192
192
  "cli:dev": "tsx exports/cli/index.ts",
193
193
  "dev": "cross-env EBV_FILE=\"development.env\" node --conditions=development --import tsx src/start/index.ts",
@@ -1,68 +0,0 @@
1
- import EventEmitter from 'events';
2
- import * as events from 'events';
3
- import chalk__default from 'chalk';
4
- import { L as Logger } from './types-hAhbXJDZ.js';
5
- import 'log4js';
6
-
7
- /**
8
- * 创建调试函数
9
- * @param prefix 前缀
10
- */
11
- declare const createDebug: (prefix: string) => {
12
- /** 颜色库 */
13
- chalk: typeof chalk__default;
14
- /** 设置前缀、时间颜色 */
15
- setColor: (fnc: (text: string) => string) => void;
16
- /** 修改debug模式 */
17
- enable: (bool: boolean) => void;
18
- } & ((...args: any[]) => void);
19
-
20
- /* eslint-disable no-var */
21
- declare global {
22
- var logger: Logger
23
- var debug: ReturnType<typeof createDebug>
24
- type EventEmitter = events.EventEmitter
25
- }
26
-
27
- declare global {
28
- namespace NodeJS {
29
- interface ProcessEnv {
30
- /** 是否启用HTTP */
31
- HTTP_ENABLE: string
32
- /** HTTP监听端口 */
33
- HTTP_PORT: string
34
- /** HTTP监听地址 */
35
- HTTP_HOST: string
36
- /** HTTP鉴权秘钥 仅用于karin自身Api */
37
- HTTP_AUTH_KEY: string
38
- /** ws_server鉴权秘钥 */
39
- WS_SERVER_AUTH_KEY: string
40
- /** 是否启用Redis 关闭后将使用内部虚拟Redis */
41
- REDIS_ENABLE: string
42
- /** 重启是否调用pm2 如果不调用则会直接关机 此配置适合有进程守护的程序 */
43
- PM2_RESTART: string
44
- /** 日志等级 */
45
- LOG_LEVEL: string
46
- /** 日志保留天数 */
47
- LOG_DAYS_TO_KEEP: string
48
- /** 日志文件最大大小 如果此项大于0则启用日志分割 */
49
- LOG_MAX_LOG_SIZE: string
50
- /** logger.fnc颜色 */
51
- LOG_FNC_COLOR: string
52
- /** 运行器 "node" | "pm2" | "tsx" */
53
- RUNTIME: 'node' | 'pm2' | 'tsx'
54
- /** ffmpeg路径 */
55
- FFMPEG_PATH: string
56
- /** ffprobe路径 */
57
- FFPROBE_PATH: string
58
- /** ffplay路径 */
59
- FFPLAY_PATH: string
60
- /** node-karin版本 */
61
- KARIN_VERSION: string
62
- /** tsx监察者模式 */
63
- TSX_WATCH: string
64
- /** 日志实时Api最多支持同时连接数 */
65
- LOG_MAX_CONNECTIONS: string
66
- }
67
- }
68
- }
@@ -1,109 +0,0 @@
1
- import EventEmitter from 'events';
2
- import chalk__default from 'chalk';
3
- import { Logger as Logger$1 } from 'log4js';
4
-
5
- /**
6
- * @description 所有日志等级
7
- * @description 请使用`LogMethodNames`类型来获取日志方法名称
8
- */
9
- type LoggerLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal' | 'mark' | 'off';
10
- /** 日志方法名称 */
11
- type LogMethodNames = Exclude<LoggerLevel, 'off'>;
12
- /** 仅包含日志方法的Logger类型 */
13
- type LogMethodsOnly = Pick<Logger, LogMethodNames>;
14
- /**
15
- * @description 日志接口
16
- */
17
- interface Logger extends Logger$1 {
18
- /** @description chalk模块 */
19
- chalk: typeof chalk__default;
20
- /** @description 将文本设置为红色 */
21
- red: typeof chalk__default.red;
22
- /** @description 将文本设置为绿色 */
23
- green: typeof chalk__default.green;
24
- /** @description 将文本设置为黄色 */
25
- yellow: typeof chalk__default.yellow;
26
- /** @description 将文本设置为蓝色 */
27
- blue: typeof chalk__default.blue;
28
- /** @description 将文本设置为品红色 */
29
- magenta: typeof chalk__default.magenta;
30
- /** @description 将文本设置为青色 */
31
- cyan: typeof chalk__default.cyan;
32
- /** @description 将文本设置为白色 */
33
- white: typeof chalk__default.white;
34
- /** @description 将文本设置为灰色 */
35
- gray: typeof chalk__default.gray;
36
- /** @description 将文本设置为紫色 */
37
- violet: ReturnType<typeof chalk__default.hex>;
38
- /** @description 将文本设置为触发函数的颜色 */
39
- fnc: ReturnType<typeof chalk__default.hex>;
40
- /**
41
- * @description 打印Bot前缀日志
42
- * @param level - 日志等级
43
- * @param id - Bot ID
44
- * @param args - 日志内容
45
- */
46
- bot: (level: LogMethodNames, id: string, ...args: any[]) => void;
47
- /** @description 打印追踪日志 */
48
- trace(...args: any[]): void;
49
- /** @description 打印调试日志 */
50
- debug(...args: any[]): void;
51
- /** @description 打印信息日志 */
52
- info(...args: any[]): void;
53
- /** @description 打印警告日志 */
54
- warn(...args: any[]): void;
55
- /** @description 打印错误日志 */
56
- error(...args: any[]): void;
57
- /** @description 打印致命日志 */
58
- fatal(...args: any[]): void;
59
- /** @description 打印标记日志 */
60
- mark(...args: any[]): void;
61
- /** @description 关闭日志 */
62
- off(): void;
63
- /** @description 打印日志 跟`info`日志相同 */
64
- log(...args: any[]): void;
65
- }
66
- /**
67
- * @description 文件日志配置
68
- */
69
- interface FileLogConfig {
70
- /** @description 是否启用文件日志 @default false */
71
- enabled: boolean;
72
- /** @description 日志文件目录 @default 'logs' */
73
- dir: string;
74
- /** @description 文件日志级别(默认与控制台相同) */
75
- level?: LoggerLevel;
76
- /** @description 日志文件保留天数 @default 14 */
77
- daysToKeep: number;
78
- /**
79
- * @description 是否启用整体化模式(按日期每天一个日志文件)
80
- * @default true
81
- */
82
- enableWholeMode: boolean;
83
- /**
84
- * @description 是否启用碎片化模式(按大小分片)
85
- * @default false
86
- */
87
- enableFragmentMode: boolean;
88
- /** @description 碎片化模式下,单个日志文件的最大大小(MB) @default 10 */
89
- maxFileSize: number;
90
- /** @description 是否单独保存错误和致命日志 @default true */
91
- separateErrorLog: boolean;
92
- }
93
- /**
94
- * @description 日志配置
95
- */
96
- interface LoggerConfig {
97
- /** @description 日志级别 @default 'info' */
98
- level: LoggerLevel;
99
- /** @description `logger.fnc`自定义颜色 @default '#FFFF00' */
100
- color?: string;
101
- /** @description 文件日志配置 */
102
- file: FileLogConfig;
103
- }
104
- /**
105
- * @description 默认配置
106
- */
107
- declare const DEFAULT_LOGGER_CONFIG: LoggerConfig;
108
-
109
- export { DEFAULT_LOGGER_CONFIG as D, type FileLogConfig as F, type Logger as L, type LoggerLevel as a, type LogMethodNames as b, type LogMethodsOnly as c, type LoggerConfig as d };
@@ -1 +0,0 @@
1
- @font-face{font-family:HarmonyOS;src:url(https://s1.hdslb.com/bfs/static/jinkela/long/font/HarmonyOS_Medium.as.woff2) format("woff2");font-weight:400;font-style:normal;font-display:swap}.xterm-rows{line-height:.8!important;letter-spacing:-.05em!important;word-spacing:-.1em!important;font-kerning:none!important}.xterm-rows>div{height:auto!important;transform:translateY(-2px);margin-bottom:-2px!important}.xterm-rows span:not(:empty){letter-spacing:-.1em!important;display:inline-block}.xterm .xterm-viewport{line-height:.8!important}.xterm-screen{margin:0!important;padding:0!important}.xterm .terminal-cursor{margin-top:-2px;height:105%!important;transform:scaleX(.5)!important;opacity:.8!important}.xterm .xterm-cursor-block{width:.5em!important;transform-origin:left center}.xterm-rows span:empty{display:inline-block;width:.7em!important}
@@ -1 +0,0 @@
1
- pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#abb2bf;background:#282c34}.hljs-comment,.hljs-quote{color:#5c6370;font-style:italic}.hljs-doctag,.hljs-keyword,.hljs-formula{color:#c678dd}.hljs-section,.hljs-name,.hljs-selector-tag,.hljs-deletion,.hljs-subst{color:#e06c75}.hljs-literal{color:#56b6c2}.hljs-string,.hljs-regexp,.hljs-addition,.hljs-attribute,.hljs-meta .hljs-string{color:#98c379}.hljs-attr,.hljs-variable,.hljs-template-variable,.hljs-type,.hljs-selector-class,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-number{color:#d19a66}.hljs-symbol,.hljs-bullet,.hljs-link,.hljs-meta,.hljs-selector-id,.hljs-title{color:#61aeee}.hljs-built_in,.hljs-title.class_,.hljs-class .hljs-title{color:#e6c07b}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}.hljs-link{text-decoration:underline}
@@ -1 +0,0 @@
1
- import{j as t}from"./vendor-react-Dc9jdQiK.js";import{P as r}from"./components-CU2xw4lY.js";import"./vendor-others-6GiMrjd4.js";import"./vendor-editor-BmqYP7lh.js";import"./vendor-ui-utils-D0xkboLL.js";import"./vendor-heroui-ClBCy2zk.js";import"./page-dashboard-CG60V_Z-.js";import"./utils-C9nWTSuo.js";import"./hooks-CRfhs4ON.js";import"./vendor-visual-saF8KLH_.js";const x=()=>t.jsx("div",{className:"min-h-screen flex items-center justify-center",children:t.jsx(r,{})});export{x as default};
@@ -1,2 +0,0 @@
1
- import{V as p}from"./vendor-react-Dc9jdQiK.js";import{a5 as g}from"./components-CU2xw4lY.js";const u=async(e,a,n,t)=>{const{setIsLogModalOpen:c,setTaskId:i,setTaskLogs:o,setTaskName:f}=a;f("更新插件");const r=["开始创建更新任务...",`options: ${JSON.stringify(e)}`];o(r);try{const s=await g(e);if(s.success&&s.taskId)i(s.taskId),o([...r,`
2
- 任务创建成功!`,`任务ID: ${s.taskId}`,"正在连接任务执行日志..."]),c(!0),typeof t=="function"&&t();else throw new Error(s.message||"未知错误")}catch(s){console.error("更新失败:",s),p.error(`更新失败: ${s.message}`)}};export{u as c};
Binary file
Binary file